diff --git a/.gitignore b/.gitignore index 9946397765..2ea58c3f97 100644 --- a/.gitignore +++ b/.gitignore @@ -31,11 +31,11 @@ linux2/ garnet.gnu/ Cygwin proteus.egg-info/ -proteus/ADR.cpp proteus/subsurfaceTransportFunctions.c cygwin_bootstrap.done matlab_setup.done dist/ +tmp/ # Generated files @@ -58,14 +58,12 @@ proteus/csparsity.cpp proteus/csubgridError.c proteus/ctimeIntegration.c proteus/ctransportCoefficients.c -proteus/elastoplastic/cElastoPlastic.cpp proteus/equivalent_polynomials.cpp proteus/fenton/Fenton.cpp proteus/flcbdfWrappers.cpp proteus/mbd/CouplingFSI.cpp proteus/mprans/BoundaryConditions.cpp proteus/mprans/MeshSmoothing.cpp -proteus/mprans/SedClosure.cpp proteus/mprans/cAddedMass.cpp proteus/mprans/cCLSVOF.cpp proteus/mprans/cGN_SW2DCV.cpp @@ -79,5 +77,4 @@ proteus/mprans/cRANS3PF.cpp proteus/mprans/cRANS3PSed.cpp proteus/mprans/cVOF3P.cpp proteus/mprans/cVOS3P.cpp -proteus/richards/cRichards.cpp proteus/superluWrappers.c diff --git a/.travis.yml b/.travis.yml index ca52559932..e8e36c0869 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ jobs: env: TEST_PROFILE="proteus-hashdist" install: - git lfs pull + - ./get_xtensor.sh - ./stack/hit/bin/hit init-home - ./stack/hit/bin/hit remote add http://levant.hrwallingford.com/hashdist_src --objects="source" - ./stack/hit/bin/hit remote add http://levant.hrwallingford.com/hashdist_ubuntu_16_04 --objects="build" @@ -51,7 +52,7 @@ jobs: - export PATHSAVE=$PATH - export PATH=$PWD/linux/bin:$PATH - export LD_LIBRARY_PATH=$PWD/linux/lib:$LD_LIBRARY_PATH - - PROTEUS_OPT="-w -O2 -UNDEBUG" FC=gfortran CC=mpicc CXX=mpicxx make develop N=2 + - PROTEUS_OPT="-w -O2 -UNDEBUG" FC=gfortran CC=mpicc CXX=mpicxx make develop N=1 - export SSL_CERT_DIR=/etc/ssl/certs - #./linux/bin/pip3 install matplotlib script: @@ -76,7 +77,7 @@ jobs: - conda info -a - conda env create -f environment-dev.yml - conda activate proteus-dev - - pip install -v -e . + - make develop-conda N=1 script: - export MPLBACKEND="AGG" - py.test -n 1 --dist=loadfile --forked -v proteus/tests --ignore proteus/tests/POD --ignore proteus/tests/MeshAdaptPUMI --cov=proteus @@ -108,4 +109,4 @@ jobs: - git lfs pull - cd proteus/tests/ci - parun poisson_3d_tetgen_p.py poisson_3d_tetgen_c0p1_n.py -l 5 -v -# - py.test -n 1 --dist=no --forked -v proteus/tests --ignore proteus/tests/POD --ignore proteus/tests/MeshAdaptPUMI --cov=proteus \ No newline at end of file +# - py.test -n 1 --dist=no --forked -v proteus/tests --ignore proteus/tests/POD --ignore proteus/tests/MeshAdaptPUMI --cov=proteus diff --git a/environment-dev.yml b/environment-dev.yml index cd287c7395..48504f1027 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -41,4 +41,5 @@ dependencies: - ipyparallel - pillow - recordtype + - xtensor-python - git-lfs diff --git a/environment.yml b/environment.yml index 4c9958d0af..076dfe954d 100644 --- a/environment.yml +++ b/environment.yml @@ -11,5 +11,6 @@ dependencies: - cython - pillow - pip + - xtensor-python - pip: - recordtype diff --git a/get_xtensor.sh b/get_xtensor.sh new file mode 100755 index 0000000000..26be5deb94 --- /dev/null +++ b/get_xtensor.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +rm -rf proteus/xtensor +mkdir -p proteus/xtensor +cd proteus/xtensor +mkdir xtl xtensor-python xtensor pybind11 +wget https://github.com/QuantStack/xtl/archive/0.6.11.tar.gz -O xtl.tar.gz +wget https://github.com/QuantStack/xtensor-python/archive/0.24.1.tar.gz -O xtensor-python.tar.gz +wget https://github.com/xtensor-stack/xtensor/archive/0.21.2.tar.gz -O xtensor.tar.gz +wget https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz -O pybind11.tar.gz +tar zxf xtl.tar.gz --strip-components=1 -C xtl +tar zxf xtensor-python.tar.gz --strip-components=1 -C xtensor-python +tar zxf xtensor.tar.gz --strip-components=1 -C xtensor +tar zxf pybind11.tar.gz --strip-components=1 -C pybind11 +rm *.gz diff --git a/proteus/ADR.cpp b/proteus/ADR.cpp new file mode 100644 index 0000000000..8043f943d3 --- /dev/null +++ b/proteus/ADR.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "ADR.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppADR_base; + +PYBIND11_MODULE(ADR, m) +{ + xt::import_numpy(); + + py::class_(m, "ADR") + .def(py::init(&proteus::newADR)) + .def("calculateResidual", &cppADR_base::calculateResidual) + .def("calculateJacobian", &cppADR_base::calculateJacobian); +} diff --git a/proteus/ADR.h b/proteus/ADR.h index 8215797e8b..34ecee31f0 100644 --- a/proteus/ADR.h +++ b/proteus/ADR.h @@ -4,605 +4,627 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { - class cppADR_base - { - public: - virtual ~cppADR_base(){} - virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* elementDiameter, - double* cfl, - double Ct_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - //physics - int nElements_global, - int* u_l2g, - double* u_dof, - int* sd_rptr, - int* sd_colind, - double* q_a, - double* q_v, - double* q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - double* q_numDiff_u, - double* q_numDiff_u_last, - int offset_u, int stride_u, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_a, - double* ebqe_v, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isDiffusiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_bc_advectiveFlux_u_ext, - double* ebqe_penalty_ext, - const double eb_adjoint_sigma)=0; - virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* elementDiameter, - double* cfl, - double Ct_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - //physics - int nElements_global, - int* u_l2g, - double* u_dof, - int* sd_rowptr, - int* sd_colind, - double* q_a, - double* q_v, - double* q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_a, - double* ebqe_v, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isDiffusiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_bc_advectiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_penalty_ext, - const double eb_adjoint_sigma)=0; - }; - - template - class cppADR : public cppADR_base + class cppADR_base { - public: - const int nDOF_test_X_trial_element; - CompKernelType ck; - cppADR(): - nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element), - ck() - {} - /* inline - void evaluateCoefficients() - { - - } - */ - - inline - void exteriorNumericalDiffusiveFlux(int* rowptr, - int* colind, - const int& isDOFBoundary, - const int& isDiffusiveFluxBoundary, - const double n[nSpace], - double* bc_a, - const double& bc_u, - const double& bc_flux, - double* a, - const double grad_potential[nSpace], - const double& u, - const double& penalty, - double& flux) + public: + virtual ~cppADR_base(){} + virtual void calculateResidual(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturing, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + int offset_u, + int stride_u, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_a, + xt::pyarray& ebqe_v, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& ebqe_penalty_ext, + const double eb_adjoint_sigma + ) = 0; + virtual void calculateJacobian(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rowptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturing, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_a, + xt::pyarray& ebqe_v, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_penalty_ext, + const double eb_adjoint_sigma + ) = 0; + }; + + template + class cppADR: public cppADR_base { - double diffusiveVelocityComponent_I,penaltyFlux,max_a; - if(isDiffusiveFluxBoundary == 1) - { - flux = bc_flux; - } - else if(isDOFBoundary == 1) - { - flux = 0.0; - max_a=0.0; - for(int I=0;I= 0.0) - { - flux = u*flow; - //flux = flow; - } - else - { - flux = bc_u*flow; - //flux = flow; - } - } - else if (isFluxBoundary_u == 1) - { - flux = bc_flux_u; - } - else - { - if (flow >= 0.0) - { - flux = u*flow; - } - else - { - flux = 0.0; - } + inline + void exteriorNumericalAdvectiveFlux(const int& isDOFBoundary_u, + const int& isFluxBoundary_u, + const double n[nSpace], + const double& bc_u, + const double& bc_flux_u, + const double& u, + const double velocity[nSpace], + double& flux) + { - } - //flux = flow; - } + double flow = 0.0; + for (int I = 0; I < nSpace; I++) + flow += n[I] * velocity[I]; + if (isDOFBoundary_u == 1) + { + if (flow >= 0.0) + { + flux = u * flow; + //flux = flow; + } + else + { + flux = bc_u * flow; + //flux = flow; + } + } + else if (isFluxBoundary_u == 1) + { + flux = bc_flux_u; + } + else + { + if (flow >= 0.0) + { + flux = u * flow; + } + else + { + flux = 0.0; + } - inline - void exteriorNumericalAdvectiveFluxDerivative(const int& isDOFBoundary_u, - const int& isFluxBoundary_u, - const double n[nSpace], - const double velocity[nSpace], - double& dflux) - { - double flow=0.0; - for (int I=0; I < nSpace; I++) - { - flow += n[I]*velocity[I]; - } - //double flow=n[0]*velocity[0]+n[1]*velocity[1]+n[2]*velocity[2]; - dflux=0.0;//default to no flux - if (isDOFBoundary_u == 1) - { - if (flow >= 0.0) - { - dflux = flow; - } - else - { - dflux = 0.0; - } - } - else if (isFluxBoundary_u == 1) - { - dflux = 0.0; - } - else - { - if (flow >= 0.0) - { - dflux = flow; - } - } - } + } + //flux = flow; + } - inline void calculateElementResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* elementDiameter, - double* cfl, - double Ct_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - //physics - int nElements_global, - int* u_l2g, - double* u_dof, - int* sd_rowptr, - int* sd_colind, - double* q_a, - double* q_v, - double* q_r, - int lag_shockCapturingDiffusion, - double shockCapturingDiffusion, - double* q_numDiff_u, - double* q_numDiff_u_last, - int offset_u, int stride_u, - double* elementResidual_u, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* element_u, - int eN) - { - for (int i=0;i= 0.0) + { + dflux = flow; + } + else + { + dflux = 0.0; + } + } + else if (isFluxBoundary_u == 1) + { + dflux = 0.0; + } + else + { + if (flow >= 0.0) + { + dflux = flow; + } + } + } + + inline void calculateElementResidual(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rowptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturingDiffusion, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + int offset_u, + int stride_u, + xt::pyarray& elementResidual_u, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& element_u, + int eN) + { + for (int i = 0; i < nDOF_test_element; i++) + { + elementResidual_u.data()[i] = 0.0; + } + //loop over quadrature points and compute integrands + for (int k = 0; k < nQuadraturePoints_element; k++) + { + //compute indeces and declare local storage + int eN_k = eN * nQuadraturePoints_element + k; + double u = 0.0; + double grad_u[nSpace]; + double m = 0.0; + double dm=0.0; + double f[nSpace]; + double df[nSpace]; + double m_t = 0.0; + double dm_t = 0.0; + double pdeResidual_u = 0.0; + double Lstar_u[nDOF_test_element]; + double subgridError_u = 0.0; + double tau = 0.0; + double tau0 = 0.0; + double tau1 = 0.0; + double numDiff0 = 0.0; + double numDiff1 = 0.0; + double *a = NULL; + double r = 0.0; + double jac[nSpace*nSpace]; + double jacDet; + double jacInv[nSpace*nSpace]; + double u_grad_trial[nDOF_trial_element * nSpace]; + double u_test_dV[nDOF_trial_element]; + double u_grad_test_dV[nDOF_test_element * nSpace]; + double dV; + double x; + double y; + double z; + double G[nSpace * nSpace]; + double G_dd_G; + double tr_G; + // + //compute solution and gradients at quadrature points + // + ck.calculateMapping_element(eN, + k, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + jac, + jacDet, + jacInv, + x, + y, + z); + //get the physical integration weight + dV = fabs(jacDet) * dV_ref[k]; + //get the metric tensor and friends + ck.calculateG(jacInv, G, G_dd_G, tr_G); + //get the trial function gradients + ck.gradTrialFromRef(&u_grad_trial_ref[k * nDOF_trial_element * nSpace], jacInv, u_grad_trial); + //get the solution + ck.valFromElementDOF(element_u.data(), &u_trial_ref[k * nDOF_trial_element], u); + //get the solution gradients + ck.gradFromElementDOF(element_u.data(), u_grad_trial, grad_u); + //precalculate test function products with integration weights + for (int j = 0; j < nDOF_trial_element; j++) + { + u_test_dV[j] = u_test_ref[k * nDOF_trial_element + j] * dV; + for (int I = 0; I < nSpace; I++) + { + u_grad_test_dV[j * nSpace + I] = u_grad_trial[j * nSpace + I] *dV; //cek warning won't work for Petrov-Galerkin + } + } + + // + //calculate pde coefficients at quadrature points + // + //evaluateCoefficients(); + //just set from pre-evaluated quadrature point values for now + a = &q_a[eN_k * sd_rowptr.data()[nSpace]]; + r = q_r[eN_k]; + for (int I = 0; I < nSpace; I++) + { + f[I] = q_v[eN_k * nSpace + I] * u; + df[I] = q_v[eN_k * nSpace + I]; + } + // + //moving mesh + // + /* double mesh_velocity[3]; */ + /* mesh_velocity[0] = xt; */ + /* mesh_velocity[1] = yt; */ + /* mesh_velocity[2] = zt; */ + /* for (int I=0;I& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rowptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturing, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_a, + xt::pyarray& ebqe_v, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& ebqe_penalty_ext, + const double eb_adjoint_sigma) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -615,68 +637,70 @@ namespace proteus //eN_k_j is the quadrature point index for a trial function //eN_k_i is the quadrature point index for a trial function for(int eN=0;eN::from_shape({nDOF_test_element}); + auto element_u = xt::pyarray::from_shape({nDOF_trial_element}); + for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rowptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturing, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& elementJacobian_u_u, + xt::pyarray& element_u, + int eN) { for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& cfl, + double Ct_sge, + double sc_uref, + double sc_alpha, + double useMetrics, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& sd_rowptr, + xt::pyarray& sd_colind, + xt::pyarray& q_a, + xt::pyarray& q_v, + xt::pyarray& q_r, + int lag_shockCapturing, + double shockCapturingDiffusion, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_a, + xt::pyarray& ebqe_v, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_penalty_ext, + const double eb_adjoint_sigma) + { + // + //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian + // + for(int eN=0;eN::from_shape({nDOF_test_element*nDOF_trial_element}); + auto element_u = xt::pyarray::from_shape({nDOF_trial_element}); + for (int j=0;j(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); else return proteus::chooseAndAllocateDiscretization(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); } }//proteus #endif diff --git a/proteus/ADR.pyx b/proteus/ADR.py similarity index 67% rename from proteus/ADR.pyx rename to proteus/ADR.py index 9f405603f4..c89a1aa61c 100644 --- a/proteus/ADR.pyx +++ b/proteus/ADR.py @@ -1,10 +1,8 @@ -# A type of -*- python -*- file """ An optimized Advection-Diffusion-Reaction module """ import numpy -cimport numpy from math import fabs import proteus from proteus import cfemIntegrals, Quadrature @@ -20,369 +18,6 @@ from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base -cdef extern from "ADR.h" namespace "proteus": - cdef cppclass cppADR_base: - void calculateResidual(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* elementDiameter, - double* cfl, - double CT_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - int* u_l2g, - double* u_dof, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - double* q_a, - double* q_v, - double* q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - double* q_numDiff_u, - double* q_numDiff_u_last, - int offset_u, int stride_u, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_a, - double* ebqe_v, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_bc_advectiveFlux_u_ext, - double* ebqe_penalty, - double adjoint_sigma) - void calculateJacobian(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* elementDiameter, - double* cfl, - double CT_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - int* u_l2g, - double* u_dof, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - double* q_a, - double* q_v, - double* q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_a, - double* ebqe_v, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_bc_advectiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_penalty, - double adjoint_sigma) - cppADR_base* newADR(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - - -cdef class ADR: - """ - Optimized ADR member functions - """ - - cdef cppADR_base* thisptr - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newADR(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - def __dealloc__(self): - del self.thisptr - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray elementDiameter, - numpy.ndarray cfl, - double CT_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray q_a, - numpy.ndarray q_v, - numpy.ndarray q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_a, - numpy.ndarray ebqe_v, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray ebqe_penalty, - double adjoint_sigma): - self.thisptr.calculateResidual( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - elementDiameter.data, - cfl.data, - CT_sge, - sc_uref, - sc_alpha, - useMetrics, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - u_l2g.data, - u_dof.data, - sdInfo_u_u_rowptr.data, - sdInfo_u_u_colind.data, - q_a.data, - q_v.data, - q_r.data, - lag_shockCapturing, - shockCapturingDiffusion, - q_numDiff_u.data, - q_numDiff_u_last.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_a.data, - ebqe_v.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - isAdvectiveFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - ebqe_bc_advectiveFlux_u_ext.data, - ebqe_penalty.data, - adjoint_sigma) - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray elementDiameter, - numpy.ndarray cfl, - double CT_sge, - double sc_uref, - double sc_alpha, - double useMetrics, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray q_a, - numpy.ndarray q_v, - numpy.ndarray q_r, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_a, - numpy.ndarray ebqe_v, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray ebqe_penalty, - double adjoint_sigma): - """ - Optimized jacobian calculation - """ - cdef numpy.ndarray rowptr,colind,globalJacobian_a - (rowptr,colind,globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - elementDiameter.data, - cfl.data, - CT_sge, - sc_uref, - sc_alpha, - useMetrics, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - u_l2g.data, - u_dof.data, - sdInfo_u_u_rowptr.data, - sdInfo_u_u_colind.data, - q_a.data, - q_v.data, - q_r.data, - lag_shockCapturing, - shockCapturingDiffusion, - q_numDiff_u.data, - q_numDiff_u_last.data, - csrRowIndeces_u_u.data, - csrColumnOffsets_u_u.data, - globalJacobian_a.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_a.data, - ebqe_v.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - isAdvectiveFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - ebqe_bc_advectiveFlux_u_ext.data, - csrColumnOffsets_eb_u_u.data, - ebqe_penalty.data, - adjoint_sigma) - - class SubgridError(SGE_base): """ SubgridError approximation for ADR equations @@ -1050,7 +685,7 @@ def getJacobian(self,jacobian): self.shockCapturing.numDiff_last[0], self.csrRowIndeces[(0,0)], self.csrColumnOffsets[(0,0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/CompKernel.h b/proteus/CompKernel.h index 9787b448ee..ba97e92324 100644 --- a/proteus/CompKernel.h +++ b/proteus/CompKernel.h @@ -1,6 +1,8 @@ #ifndef COMPKERNEL_H #define COMPKERNEL_H #include +//#include "xtensor-python/pyarray.hpp" +//#include "xtensor-python/pyvectorize.hpp" /** * A class to provide indexing into Euclidean vectors and tensors. */ @@ -80,6 +82,7 @@ class CompKernelSpaceMapping const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -92,12 +95,14 @@ class CompKernelSpaceMapping const int k, double* h_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& h); inline void calculateMappingVelocity_element(const int eN, const int k, double* mesh_velocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt, @@ -205,6 +210,7 @@ class CompKernelSpaceMapping<3,NDOF_MESH_TRIAL_ELEMENT> const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -227,9 +233,12 @@ class CompKernelSpaceMapping<3,NDOF_MESH_TRIAL_ELEMENT> for (int j=0;j const int k, double* h_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& h) { @@ -273,7 +283,8 @@ class CompKernelSpaceMapping<3,NDOF_MESH_TRIAL_ELEMENT> for (int j=0;j const int k, double* mesh_velocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt, @@ -293,9 +305,12 @@ class CompKernelSpaceMapping<3,NDOF_MESH_TRIAL_ELEMENT> for (int j=0;j const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -513,6 +529,7 @@ class CompKernelSpaceMapping<3,NDOF_MESH_TRIAL_ELEMENT> const int k, double* mesh_velocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt) @@ -629,6 +646,7 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -657,7 +675,9 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> /* Grad_x[I] += mesh_dof[mesh_l2g[eN_j]*2+0]*mesh_grad_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT*2+j*2+I]; */ /* Grad_y[I] += mesh_dof[mesh_l2g[eN_j]*2+1]*mesh_grad_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT*2+j*2+I]; */ /* } */ - x += mesh_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; + //x += mesh_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref(k, j); + //y += mesh_dof[mesh_l2g[eN_j]*3+1]*mesh_trial_ref(k, j); + x += mesh_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; y += mesh_dof[mesh_l2g[eN_j]*3+1]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; for (int I=0;I<2;I++) { @@ -681,6 +701,7 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> const int k, double* h_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& h) { @@ -688,7 +709,8 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> for (int j=0;j const int k, double* mesh_velocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt) @@ -709,7 +732,9 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j; /* xt += mesh_velocity_dof[mesh_l2g[eN_j]*2+0]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; */ /* yt += mesh_velocity_dof[mesh_l2g[eN_j]*2+1]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; */ - xt += mesh_velocity_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; + //xt += mesh_velocity_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref(k, j); + //yt += mesh_velocity_dof[mesh_l2g[eN_j]*3+1]*mesh_trial_ref(k, j); + xt += mesh_velocity_dof[mesh_l2g[eN_j]*3+0]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; yt += mesh_velocity_dof[mesh_l2g[eN_j]*3+1]*mesh_trial_ref[k*NDOF_MESH_TRIAL_ELEMENT+j]; } } @@ -875,6 +900,7 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -900,6 +926,7 @@ class CompKernelSpaceMapping<2,NDOF_MESH_TRIAL_ELEMENT> const int k, double* mesh_velocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt, @@ -1573,6 +1600,7 @@ class CompKernel const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -1589,6 +1617,7 @@ class CompKernel const int k, double* h_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& h) { @@ -1604,6 +1633,7 @@ class CompKernel const int k, double* meshVelocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt, @@ -2401,6 +2431,7 @@ class CompKernel<2,NDOF_MESH_TRIAL_ELEMENT,NDOF_TRIAL_ELEMENT,NDOF_TEST_ELEMENT> const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -2416,6 +2447,7 @@ class CompKernel<2,NDOF_MESH_TRIAL_ELEMENT,NDOF_TRIAL_ELEMENT,NDOF_TEST_ELEMENT> const int k, double* h_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& h) { @@ -2431,6 +2463,7 @@ class CompKernel<2,NDOF_MESH_TRIAL_ELEMENT,NDOF_TRIAL_ELEMENT,NDOF_TEST_ELEMENT> const int k, double* mesh_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double* mesh_grad_trial_ref, double* jac, @@ -2447,6 +2480,7 @@ class CompKernel<2,NDOF_MESH_TRIAL_ELEMENT,NDOF_TRIAL_ELEMENT,NDOF_TEST_ELEMENT> const int k, double* meshVelocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt) @@ -2458,6 +2492,7 @@ class CompKernel<2,NDOF_MESH_TRIAL_ELEMENT,NDOF_TRIAL_ELEMENT,NDOF_TEST_ELEMENT> const int k, double* meshVelocity_dof, int* mesh_l2g, + //xt::pyarray& mesh_trial_ref, double* mesh_trial_ref, double& xt, double& yt, diff --git a/proteus/LinearSolvers.py b/proteus/LinearSolvers.py index db5cb91b7d..5ee414a1df 100644 --- a/proteus/LinearSolvers.py +++ b/proteus/LinearSolvers.py @@ -3510,7 +3510,7 @@ def updateTPAdvectionOperator(self, self.model.csrRowIndeces[(1,1)],self.model.csrColumnOffsets[(1,1)], self.model.csrRowIndeces[(2,2)],self.model.csrColumnOffsets[(2,2)], self.model.csrRowIndeces[(3,3)],self.model.csrColumnOffsets[(3,3)], - self.TPScaledAdvectionOperator) + self.TPScaledAdvectionOperator.getCSRrepresentation()[2]) def updateTPInvScaledLaplaceOperator(self): """ Create a discrete two phase laplace operator matrix. """ @@ -3549,7 +3549,7 @@ def updateTPInvScaledLaplaceOperator(self): self.model.csrRowIndeces[(1,1)],self.model.csrColumnOffsets[(1,1)], self.model.csrRowIndeces[(2,2)],self.model.csrColumnOffsets[(2,2)], self.model.csrRowIndeces[(3,3)],self.model.csrColumnOffsets[(3,3)], - self.TPInvScaledLaplaceOperator) + self.TPInvScaledLaplaceOperator.getCSRrepresentation()[2]) def updateTwoPhaseMassOperator_rho(self, density_scaling = True, @@ -3609,7 +3609,7 @@ def updateTwoPhaseMassOperator_rho(self, self.model.csrRowIndeces[(1,1)],self.model.csrColumnOffsets[(1,1)], self.model.csrRowIndeces[(2,2)],self.model.csrColumnOffsets[(2,2)], self.model.csrRowIndeces[(3,3)],self.model.csrColumnOffsets[(3,3)], - self.TPScaledMassOperator) + self.TPScaledMassOperator.getCSRrepresentation()[2]) def updateTwoPhaseInvScaledMassOperator(self, numerical_viscosity = True, @@ -3660,7 +3660,7 @@ def updateTwoPhaseInvScaledMassOperator(self, self.model.csrRowIndeces[(1,1)],self.model.csrColumnOffsets[(1,1)], self.model.csrRowIndeces[(2,2)],self.model.csrColumnOffsets[(2,2)], self.model.csrRowIndeces[(3,3)],self.model.csrColumnOffsets[(3,3)], - self.TPInvScaledMassOperator) + self.TPInvScaledMassOperator.getCSRrepresentation()[2]) class OperatorConstructor_oneLevel(OperatorConstructor): """ diff --git a/proteus/PyEmbeddedFunctions.h b/proteus/PyEmbeddedFunctions.h index 87f5e8ec6f..6e1b813e97 100644 --- a/proteus/PyEmbeddedFunctions.h +++ b/proteus/PyEmbeddedFunctions.h @@ -28,7 +28,7 @@ int logEvent(char* logString,int logLevel) // pValue reference stolen here: PyTuple_SetItem(pArgs, 0, pValue); - pValue = PyInt_FromLong(logLevel); + pValue = PyLong_FromLong(logLevel); // pValue reference stolen here: PyTuple_SetItem(pArgs, 1, pValue); */ diff --git a/proteus/elastoplastic/ElastoPlastic.h b/proteus/elastoplastic/ElastoPlastic.h index 9066574946..20319387da 100644 --- a/proteus/elastoplastic/ElastoPlastic.h +++ b/proteus/elastoplastic/ElastoPlastic.h @@ -18,1924 +18,1928 @@ #include "tresca.h" #include "druckerPrager.h" #include "mcdp.h" +#include "xtensor-python/pyarray.hpp" +#include "pybind11/pybind11.h" + +namespace py = pybind11; namespace proteus { - class ElastoPlastic_base - { - public: - virtual ~ElastoPlastic_base(){} - virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - double* ebqe_penalty, - //physics - int gravityStep, - int nElements_global, - int* materialTypes, - int nMaterialProperties, - double* materialProperties, - double pore_fluid_unit_weight, - double* pore_pressure_head_dof, - double* q_strain, - double* q_strain0, - double* q_strain_last, - double* q_plasticStrain, - double* q_plasticStrain_last, - double* ebqe_strain, - double* ebqe_strain0, - double* ebqe_strain_last, - double* ebqe_plasticStrain, - double* ebqe_plasticStrain_last, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext)=0; - virtual void calculateJacobian(int usePicard, - //element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - double* ebqe_penalty, - //physics - int gravityStep, - int nElements_global, - int* materialTypes, - int nMaterialProperties, - double* materialProperties, - double pore_fluid_unit_weight, - double* pore_pressure_head_dof, - double* q_strain, - double* q_strain0, - double* q_strain_last, - double* q_plasticStrain, - double* q_plasticStrain_last, - double* ebqe_strain, - double* ebqe_strain0, - double* ebqe_strain_last, - double* ebqe_plasticStrain, - double* ebqe_plasticStrain_last, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w)=0; - }; - - template - class ElastoPlastic : public ElastoPlastic_base - { - public: - CompKernelType ck; - - const int nDOF_test_X_trial_element; - - EIndex ei; - - const int X,Y,Z, - XX,XY,XZ, - YX,YY,YZ, - ZX,ZY,ZZ, - sXX,sXY,sXZ, - sYX,sYY,sYZ, - sZX,sZY,sZZ, - nSymTen, - XHX,XHY, - YHX,YHY, - ZHX,ZHY, - HXHX,HXHY, - HYHX,HYHY; - - ElastoPlastic(): - ck(), - nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element), - X(ei.X), - Y(ei.Y), - Z(ei.Z), - XX(ei.XX),XY(ei.XY),XZ(ei.XZ), - YX(ei.YX),YY(ei.YY),YZ(ei.YZ), - ZX(ei.ZX),ZY(ei.ZY),ZZ(ei.ZZ), - sXX(ei.sXX),sXY(ei.sXY),sXZ(ei.sXZ), - sYX(ei.sYX),sYY(ei.sYY),sYZ(ei.sYZ), - sZX(ei.sZX),sZY(ei.sZY),sZZ(ei.sZZ), - nSymTen(ei.nSymTen), - XHX(ei.XHX),XHY(ei.XHY), - YHX(ei.YHX),YHY(ei.YHY), - ZHX(ei.ZHX),ZHY(ei.ZHY), - HXHX(ei.HXHX),HXHY(ei.HXHY), - HYHX(ei.HYHX),HYHY(ei.HYHY) - {} - - inline void calculateStrain(double* D, double* strain) - { - //Voigt notation from Belytschko, Liu, Moran - strain[sXX] = D[XX];//du/dx - strain[sYY] = D[YY];//dv/dy - strain[sZZ] = D[ZZ];//dw/dz - strain[sYZ] = D[YZ]+D[ZY];//(dv/dz + dz/dy) - strain[sXZ] = D[XZ]+D[ZX];//(du/dz + dw/dx) - strain[sXY] = D[XY]+D[YX];//(du/dy + dv/dx) - } - - inline void elasticStress(const double* C, const double* strain, double* stress) - { - stress[sXX] = C[0]*strain[sXX] + C[1]*(strain[sYY] +strain[sZZ]); - stress[sYY] = C[0]*strain[sYY] + C[1]*(strain[sXX] +strain[sZZ]); - stress[sZZ] = C[0]*strain[sZZ] + C[1]*(strain[sXX] +strain[sYY]); - stress[sYZ] = C[sYZ+sYZ*nSymTen]*strain[sYZ]; - stress[sXZ] = C[sYZ+sYZ*nSymTen]*strain[sXZ]; - stress[sXY] = C[sYZ+sYZ*nSymTen]*strain[sXY]; - } - - inline void elasticStrain(const double* Cinv, const double* stress, double* strain) - { - strain[sXX] = Cinv[0]*stress[sXX] + Cinv[1]*(stress[sYY] +stress[sZZ]); - strain[sYY] = Cinv[0]*stress[sYY] + Cinv[1]*(stress[sXX] +stress[sZZ]); - strain[sZZ] = Cinv[0]*stress[sZZ] + Cinv[1]*(stress[sXX] +stress[sYY]); - strain[sYZ] = Cinv[sYZ+sYZ*nSymTen]*stress[sYZ]; - strain[sXZ] = Cinv[sYZ+sYZ*nSymTen]*stress[sXZ]; - strain[sXY] = Cinv[sYZ+sYZ*nSymTen]*stress[sXY]; - } - - inline void elasticModuli(const double& E,const double& nu,double* C,double* Cinv) + class ElastoPlastic_base { - for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& ebqe_penalty, + //physics + int gravityStep, + int nElements_global, + xt::pyarray& materialTypes, + int nMaterialProperties, + xt::pyarray& materialProperties, + double pore_fluid_unit_weight, + xt::pyarray& pore_pressure_head_dof, + xt::pyarray& q_strain, + xt::pyarray& q_strain0, + xt::pyarray& q_strain_last, + xt::pyarray& q_plasticStrain, + xt::pyarray& q_plasticStrain_last, + xt::pyarray& ebqe_strain, + xt::pyarray& ebqe_strain0, + xt::pyarray& ebqe_strain_last, + xt::pyarray& ebqe_plasticStrain, + xt::pyarray& ebqe_plasticStrain_last, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, + int offset_u, int offset_v, int offset_w, + int stride_u, int stride_v, int stride_w, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext)=0; + virtual void calculateJacobian(int usePicard, + //element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& ebqe_penalty, + //physics + int gravityStep, + int nElements_global, + xt::pyarray& materialTypes, + int nMaterialProperties, + xt::pyarray& materialProperties, + double pore_fluid_unit_weight, + xt::pyarray& pore_pressure_head_dof, + xt::pyarray& q_strain, + xt::pyarray& q_strain0, + xt::pyarray& q_strain_last, + xt::pyarray& q_plasticStrain, + xt::pyarray& q_plasticStrain_last, + xt::pyarray& ebqe_strain, + xt::pyarray& ebqe_strain0, + xt::pyarray& ebqe_strain_last, + xt::pyarray& ebqe_plasticStrain, + xt::pyarray& ebqe_plasticStrain_last, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w)=0; + }; - Cinv[sXX+sXX*nSymTen] = 1.0/E; - Cinv[sXX+sYY*nSymTen] = -nu/E; - Cinv[sXX+sZZ*nSymTen] = -nu/E; - Cinv[sYY+sXX*nSymTen] = -nu/E; - Cinv[sYY+sYY*nSymTen] = 1.0/E; - Cinv[sYY+sZZ*nSymTen] = -nu/E; - Cinv[sZZ+sXX*nSymTen] = -nu/E; - Cinv[sZZ+sYY*nSymTen] = -nu/E; - Cinv[sZZ+sZZ*nSymTen] = 1.0/E; - Cinv[sYZ+sYZ*nSymTen] = ((1.0+nu)/E)*2.0; - Cinv[sXZ+sXZ*nSymTen] = ((1.0+nu)/E)*2.0; - Cinv[sXY+sXY*nSymTen] = ((1.0+nu)/E)*2.0; - //cek debug - double I[nSymTen*nSymTen]; - for (int i=0;i 1.0e-12) - std::cout<<"I["< 1.0e-12) - std::cout<<"I["< fhist,ahist; - //get modulus from initial strain - elasticModuli(E,nu,C,Cinv); - elasticStress(C,strain0,stress); - evaluateConstitutiveModel(materialProperties,stress,f,df,r,dr,stress_3_init);//cek hack, this is just to get stress_3_init - const double n_e = 0.6, - P_a = materialProperties[12], - K_i = 500.0; - if (P_a > 0.0)//cek hack, if not a soil then set P_a=0.0 - { - E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); - //std::cout<<"E "<= f_atol || aNorm >= a_atol) && its < maxIts) //since aNorm=0 this will be skipped if f < f_atol i.e. within the yield surface up to the tolerance) - { - //fhist.push_back(f); - //ahist.push_back(aNorm); - //std::cout<<"plastic it "< 0.99*f_last) && (linesearches < max_linesearches)) - { - std::cout<<"+"; - double ds = pow(0.5,linesearches+1); - Delta_lambda = Delta_lambda_old + ds*Delta_lambda_incr; - for(int i=0;i 0) - { - if (f > 0.99*f_last) - { - std::cout<<"f"< + class ElastoPlastic : public ElastoPlastic_base + { + public: + CompKernelType ck; - } - //calculate residuals and norm(f is already calculated) - f_last = f; - aNorm=0.0; - stressNorm=0.0; - elasticStrain(Cinv,Delta_stress,minusDelta_plasticStrain); - for (int i=0;i predictorPhaseIts) */ - /* predictorPhase = false; */ - /* // */ - /* //if we haven't converged then try switchign to semi-implicit integration */ - /* // */ - /* bool resetSolution = false; */ - /* if (its == maxIts && useSemiImplicit==true && useDifferenceJacobian==true */ - /* && useFullPivoting==true && useDumbNewton == true && useLineSearch == false) */ - /* { */ - /* its = 0; */ - /* useLineSearch=true; */ - /* resetSolution = true; */ - /* std::cout<<"linesearch failed"< 0)//non-zero plastic strain increment - { - //std::cout<<"plastic it "< 0.0)//cek hack, if not a soil then set P_a=0.0 - { - E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); - elasticModuli(E,nu,C,Cinv); - } - } - for (int i=0; i 0.0)//cek hack, if not a soil then set P_a=0.0 - { - E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); - elasticModuli(E,nu,C,Cinv); - } - } - for (int i=0; i ei; - globalResidual[offset_u+stride_u*disp_l2g[eN_i]]+=elementResidual_u[i]; - globalResidual[offset_v+stride_v*disp_l2g[eN_i]]+=elementResidual_v[i]; - globalResidual[offset_w+stride_w*disp_l2g[eN_i]]+=elementResidual_w[i]; - }//i - }//ebNE - } + const int X,Y,Z, + XX,XY,XZ, + YX,YY,YZ, + ZX,ZY,ZZ, + sXX,sXY,sXZ, + sYX,sYY,sYZ, + sZX,sZY,sZZ, + nSymTen, + XHX,XHY, + YHX,YHY, + ZHX,ZHY, + HXHX,HXHY, + HYHX,HYHY; - virtual void calculateJacobian(int usePicard, - //element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - double* ebqe_penalty, - //physics - int gravityStep, - int nElements_global, - int* materialTypes, - int nMaterialProperties, - double* materialProperties, - double pore_fluid_unit_weight, - double* pore_pressure_head_dof, - double* q_strain, - double* q_strain0, - double* q_strain_last, - double* q_plasticStrain, - double* q_plasticStrain_last, - double* ebqe_strain, - double* ebqe_strain0, - double* ebqe_strain_last, - double* ebqe_plasticStrain, - double* ebqe_plasticStrain_last, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w) - { - CompKernel ck; - const int nSymTen(ck.nSymTen); - // - //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian - // - for(int eN=0;eN 0.0)//cek hack, if not a soil then set P_a=0.0 - { - E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); - elasticModuli(E,nu,C,Cinv); - } - } - for (int i=0; i 1.0e-12) + std::cout<<"I["< 1.0e-12) + std::cout<<"I["< fhist,ahist; + //get modulus from initial strain + elasticModuli(E,nu,C,Cinv); + elasticStress(C,strain0,stress); + evaluateConstitutiveModel(materialProperties,stress,f,df,r,dr,stress_3_init);//cek hack, this is just to get stress_3_init + const double n_e = 0.6, + P_a = materialProperties[12], + K_i = 500.0; + if (P_a > 0.0)//cek hack, if not a soil then set P_a=0.0 + { + E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); + //std::cout<<"E "<= f_atol || aNorm >= a_atol) && its < maxIts) //since aNorm=0 this will be skipped if f < f_atol i.e. within the yield surface up to the tolerance) + { + //fhist.push_back(f); + //ahist.push_back(aNorm); + //std::cout<<"plastic it "< 0.99*f_last) && (linesearches < max_linesearches)) + { + std::cout<<"+"; + double ds = pow(0.5,linesearches+1); + Delta_lambda = Delta_lambda_old + ds*Delta_lambda_incr; + for(int i=0;i 0) + { + if (f > 0.99*f_last) + { + std::cout<<"f"< predictorPhaseIts) */ + /* predictorPhase = false; */ + /* // */ + /* //if we haven't converged then try switchign to semi-implicit integration */ + /* // */ + /* bool resetSolution = false; */ + /* if (its == maxIts && useSemiImplicit==true && useDifferenceJacobian==true */ + /* && useFullPivoting==true && useDumbNewton == true && useLineSearch == false) */ + /* { */ + /* its = 0; */ + /* useLineSearch=true; */ + /* resetSolution = true; */ + /* std::cout<<"linesearch failed"< 0)//non-zero plastic strain increment + { + //std::cout<<"plastic it "< 0.0)//cek hack, if not a soil then set P_a=0.0 - { - E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); - elasticModuli(E,nu,C,Cinv); - } - } - for (int i=0; i(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); - } + inline void exteriorNumericalStressFluxJacobian(const int& isDOFBoundary_u, + const int& isDOFBoundary_v, + const int& isDOFBoundary_w, + const double* normal, + const double* dstress, + const double& penalty, + const double& disp_trial, + const double* disp_grad_trial, + double& dstressFlux_u_u, + double& dstressFlux_u_v, + double& dstressFlux_u_w, + double& dstressFlux_v_u, + double& dstressFlux_v_v, + double& dstressFlux_v_w, + double& dstressFlux_w_u, + double& dstressFlux_w_v, + double& dstressFlux_w_w) + { + //here we use both the symmetry of the stress tensor and the fact that dstress is w.r.t. the strain in Voigt notation to go directly to derivatives w.r.t. displacement DOF + if (isDOFBoundary_u == 1) + { + //stressFlux_u = -(stress[sXX]*normal[X] + stress[sXY]*normal[Y] + stress[sXZ]*normal[Z] - h_penalty*(u - bc_u)); + dstressFlux_u_u = -( + (dstress[sXX*nSymTen+sXX]*disp_grad_trial[X] + dstress[sXX*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sXX*nSymTen+sXZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sXY*nSymTen+sXX]*disp_grad_trial[X] + dstress[sXY*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sXY*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sXZ*nSymTen+sXX]*disp_grad_trial[X] + dstress[sXZ*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sXZ*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Z] + - + penalty*disp_trial); + dstressFlux_u_v = -( + (dstress[sXX*nSymTen+sYX]*disp_grad_trial[X] + dstress[sXX*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sXX*nSymTen+sYZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sXY*nSymTen+sYX]*disp_grad_trial[X] + dstress[sXY*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sXY*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sXZ*nSymTen+sYX]*disp_grad_trial[X] + dstress[sXZ*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sXZ*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Z]); + dstressFlux_u_w = -( + (dstress[sXX*nSymTen+sZX]*disp_grad_trial[X] + dstress[sXX*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sXX*nSymTen+sZZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sXY*nSymTen+sZX]*disp_grad_trial[X] + dstress[sXY*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sXY*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sXZ*nSymTen+sZX]*disp_grad_trial[X] + dstress[sXZ*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sXZ*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Z]); + } + else + { + dstressFlux_u_u = 0.0; + dstressFlux_u_v = 0.0; + dstressFlux_u_w = 0.0; + } + + if (isDOFBoundary_v == 1) + { + //stressFlux_v = -(stress[sYX]*normal[X] + stress[sYY]*normal[Y] + stress[sYZ]*normal[Z] - h_penalty*(v - bc_v)); + dstressFlux_v_u = -( + (dstress[sYX*nSymTen+sXX]*disp_grad_trial[X] + dstress[sYX*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sYX*nSymTen+sXZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sYY*nSymTen+sXX]*disp_grad_trial[X] + dstress[sYY*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sYY*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sYZ*nSymTen+sXX]*disp_grad_trial[X] + dstress[sYZ*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sYZ*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Z]); + dstressFlux_v_v = -( + (dstress[sYX*nSymTen+sYX]*disp_grad_trial[X] + dstress[sYX*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sYX*nSymTen+sYZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sYY*nSymTen+sYX]*disp_grad_trial[X] + dstress[sYY*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sYY*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sYZ*nSymTen+sYX]*disp_grad_trial[X] + dstress[sYZ*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sYZ*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Z] + - + penalty*disp_trial); + dstressFlux_v_w = -( + (dstress[sYX*nSymTen+sZX]*disp_grad_trial[X] + dstress[sYX*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sYX*nSymTen+sZZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sYY*nSymTen+sZX]*disp_grad_trial[X] + dstress[sYY*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sYY*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sYZ*nSymTen+sZX]*disp_grad_trial[X] + dstress[sYZ*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sYZ*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Z]); + } + else + { + dstressFlux_v_u = 0.0; + dstressFlux_v_v = 0.0; + dstressFlux_v_w = 0.0; + } + + if (isDOFBoundary_w == 1) + { + //stressFlux_w = -(stress[sZX]*normal[X] + stress[sZY]*normal[Y] + stress[sZZ]*normal[Z] - h_penalty*(w - bc_w)); + dstressFlux_w_u = -( + (dstress[sZX*nSymTen+sXX]*disp_grad_trial[X] + dstress[sZX*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sZX*nSymTen+sXZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sZY*nSymTen+sXX]*disp_grad_trial[X] + dstress[sZY*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sZY*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sZZ*nSymTen+sXX]*disp_grad_trial[X] + dstress[sZZ*nSymTen+sXY]*disp_grad_trial[Y] + dstress[sZZ*nSymTen+sXZ]*disp_grad_trial[Z])*normal[Z]); + dstressFlux_w_v = -( + (dstress[sZX*nSymTen+sYX]*disp_grad_trial[X] + dstress[sZX*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sZX*nSymTen+sYZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sZY*nSymTen+sYX]*disp_grad_trial[X] + dstress[sZY*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sZY*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sZZ*nSymTen+sYX]*disp_grad_trial[X] + dstress[sZZ*nSymTen+sYY]*disp_grad_trial[Y] + dstress[sZZ*nSymTen+sYZ]*disp_grad_trial[Z])*normal[Z]); + dstressFlux_w_w = -( + (dstress[sZX*nSymTen+sZX]*disp_grad_trial[X] + dstress[sZX*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sZX*nSymTen+sZZ]*disp_grad_trial[Z])*normal[X]+ + (dstress[sZY*nSymTen+sZX]*disp_grad_trial[X] + dstress[sZY*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sZY*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Y]+ + (dstress[sZZ*nSymTen+sZX]*disp_grad_trial[X] + dstress[sZZ*nSymTen+sZY]*disp_grad_trial[Y] + dstress[sZZ*nSymTen+sZZ]*disp_grad_trial[Z])*normal[Z] + - + penalty*disp_trial); + } + else + { + dstressFlux_w_u = 0.0; + dstressFlux_w_v = 0.0; + dstressFlux_w_w = 0.0; + } + } + + virtual void calculateResidual(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& ebqe_penalty, + //physics + int gravityStep, + int nElements_global, + xt::pyarray& materialTypes, + int nMaterialProperties, + xt::pyarray& materialProperties, + double pore_fluid_unit_weight, + xt::pyarray& pore_pressure_head_dof, + xt::pyarray& q_strain, + xt::pyarray& q_strain0, + xt::pyarray& q_strain_last, + xt::pyarray& q_plasticStrain, + xt::pyarray& q_plasticStrain_last, + xt::pyarray& ebqe_strain, + xt::pyarray& ebqe_strain0, + xt::pyarray& ebqe_strain_last, + xt::pyarray& ebqe_plasticStrain, + xt::pyarray& ebqe_plasticStrain_last, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, + int offset_u, int offset_v, int offset_w, + int stride_u, int stride_v, int stride_w, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext) + { + // + //loop over elements to compute volume integrals and load them into element and global residual + // + //std::cout<<"nElements_global"< 0.0)//cek hack, if not a soil then set P_a=0.0 + { + E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); + elasticModuli(E,nu,C,Cinv); + } + } + for (int i=0; i 0.0)//cek hack, if not a soil then set P_a=0.0 + { + E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); + elasticModuli(E,nu,C,Cinv); + } + } + for (int i=0; i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& ebqe_penalty, + //physics + int gravityStep, + int nElements_global, + xt::pyarray& materialTypes, + int nMaterialProperties, + xt::pyarray& materialProperties, + double pore_fluid_unit_weight, + xt::pyarray& pore_pressure_head_dof, + xt::pyarray& q_strain, + xt::pyarray& q_strain0, + xt::pyarray& q_strain_last, + xt::pyarray& q_plasticStrain, + xt::pyarray& q_plasticStrain_last, + xt::pyarray& ebqe_strain, + xt::pyarray& ebqe_strain0, + xt::pyarray& ebqe_strain_last, + xt::pyarray& ebqe_plasticStrain, + xt::pyarray& ebqe_plasticStrain_last, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w) + { + CompKernel ck; + const int nSymTen(ck.nSymTen); + // + //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian + // + for(int eN=0;eN 0.0)//cek hack, if not a soil then set P_a=0.0 + { + E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); + elasticModuli(E,nu,C,Cinv); + } + } + for (int i=0; i 0.0)//cek hack, if not a soil then set P_a=0.0 + { + E =K_i*P_a*pow(fmax(stress_3_init,P_a)/P_a,n_e); + elasticModuli(E,nu,C,Cinv); + } + } + for (int i=0; i(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } }//proteus #endif diff --git a/proteus/elastoplastic/ElastoPlastic.py b/proteus/elastoplastic/ElastoPlastic.py index 879fef43ad..a06afaf1be 100644 --- a/proteus/elastoplastic/ElastoPlastic.py +++ b/proteus/elastoplastic/ElastoPlastic.py @@ -5,6 +5,10 @@ from past.utils import old_div import proteus from .cElastoPlastic import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class Coefficients(proteus.TransportCoefficients.TC_base): def __init__(self, @@ -794,7 +798,7 @@ def getJacobian(self,jacobian,usePicard=False): self.csrRowIndeces[(2,0)],self.csrColumnOffsets[(2,0)], self.csrRowIndeces[(2,1)],self.csrColumnOffsets[(2,1)], self.csrRowIndeces[(2,2)],self.csrColumnOffsets[(2,2)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/elastoplastic/cElastoPlastic.cpp b/proteus/elastoplastic/cElastoPlastic.cpp new file mode 100644 index 0000000000..393a198f4c --- /dev/null +++ b/proteus/elastoplastic/cElastoPlastic.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "ElastoPlastic.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::ElastoPlastic_base; + +PYBIND11_MODULE(cElastoPlastic, m) +{ + xt::import_numpy(); + + py::class_(m, "cElastoPlastic_base") + .def(py::init(&proteus::newElastoPlastic)) + .def("calculateResidual", &ElastoPlastic_base::calculateResidual) + .def("calculateJacobian", &ElastoPlastic_base::calculateJacobian); +} diff --git a/proteus/elastoplastic/cElastoPlastic.pyx b/proteus/elastoplastic/cElastoPlastic.pyx deleted file mode 100644 index 644f5f9e16..0000000000 --- a/proteus/elastoplastic/cElastoPlastic.pyx +++ /dev/null @@ -1,426 +0,0 @@ -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "ElastoPlastic.h" namespace "proteus": - cdef cppclass ElastoPlastic_base: - void calculateResidual(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - double* penalty, - int gravityStep, - int nElements_global, - int* materialTypes, - int nMaterialProperties, - double* materialProperties, - double pore_fluid_unit_weight, - double* pore_pressure_head_dof, - double* q_strain, - double* q_strain0, - double* q_strain_last, - double* q_plasticStrain, - double* q_plasticStrain_last, - double* ebeq_strain, - double* ebeq_strain0, - double* ebeq_strain_last, - double* ebqe_plasticStrain, - double* ebqe_plasticStrain_last, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext) - void calculateJacobian(int usePicard, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - double* penalty, - int gravityStep, - int nElements_global, - int* materialTypes, - int nMaterialProperties, - double* materialProperties, - double pore_fluid_unit_weight, - double* pore_pressure_head_dof, - double* q_strain, - double* q_strain0, - double* q_strain_last, - double* q_plasticStrain, - double* q_plasticStrain_last, - double* ebqe_strain, - double* ebqe_strain0, - double* ebqe_strain_last, - double* ebqe_plasticStrain, - double* ebqe_plasticStrain_last, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w) - ElastoPlastic_base* newElastoPlastic(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cElastoPlastic_base: - cdef ElastoPlastic_base* thisptr - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newElastoPlastic(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - def __dealloc__(self): - del self.thisptr - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray penalty, - int gravityStep, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - double pore_fluid_unit_weight, - numpy.ndarray pore_pressure_head_dof, - numpy.ndarray q_strain, - numpy.ndarray q_strain0, - numpy.ndarray q_strain_last, - numpy.ndarray q_plasticStrain, - numpy.ndarray q_plasticStrain_last, - numpy.ndarray ebqe_strain, - numpy.ndarray ebqe_strain0, - numpy.ndarray ebqe_strain_last, - numpy.ndarray ebqe_plasticStrain, - numpy.ndarray ebqe_plasticStrain_last, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_stressFlux_u_ext, - numpy.ndarray ebqe_bc_stressFlux_v_ext, - numpy.ndarray ebqe_bc_stressFlux_w_ext): - self.thisptr.calculateResidual(mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - disp_trial_ref.data, - disp_grad_trial_ref.data, - disp_test_ref.data, - disp_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - disp_trial_trace_ref.data, - disp_grad_trial_trace_ref.data, - disp_test_trace_ref.data, - disp_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - penalty.data, - gravityStep, - nElements_global, - materialTypes.data, - nMaterialProperties, - materialProperties.data, - pore_fluid_unit_weight, - pore_pressure_head_dof.data, - q_strain.data, - q_strain0.data, - q_strain_last.data, - q_plasticStrain.data, - q_plasticStrain_last.data, - ebqe_strain.data, - ebqe_strain0.data, - ebqe_strain_last.data, - ebqe_plasticStrain.data, - ebqe_plasticStrain_last.data, - disp_l2g.data, - u_dof.data, - v_dof.data, - w_dof.data, - bodyForce.data, - offset_u, offset_v, offset_w, - stride_u, stride_v, stride_w, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - isDOFBoundary_u.data, - isDOFBoundary_v.data, - isDOFBoundary_w.data, - isStressFluxBoundary_u.data, - isStressFluxBoundary_v.data, - isStressFluxBoundary_w.data, - ebqe_bc_u_ext.data, - ebqe_bc_v_ext.data, - ebqe_bc_w_ext.data, - ebqe_bc_stressFlux_u_ext.data, - ebqe_bc_stressFlux_v_ext.data, - ebqe_bc_stressFlux_w_ext.data) - def calculateJacobian(self, - int usePicard, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray penalty, - int gravityStep, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - double pore_fluid_unit_weight, - numpy.ndarray pore_pressure_head_dof, - numpy.ndarray q_strain, - numpy.ndarray q_strain0, - numpy.ndarray q_strain_last, - numpy.ndarray q_plasticStrain, - numpy.ndarray q_plasticStrain_last, - numpy.ndarray ebqe_strain, - numpy.ndarray ebqe_strain0, - numpy.ndarray ebqe_strain_last, - numpy.ndarray ebqe_plasticStrain, - numpy.ndarray ebqe_plasticStrain_last, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray bodyForce, - numpy.ndarray csrRowIndeces_u_u,numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v,numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w,numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_u,numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v,numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w,numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_u,numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v,numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w,numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w): - cdef numpy.ndarray rowptr,colind,globalJacobian_a - (rowptr,colind,globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(usePicard, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - disp_trial_ref.data, - disp_grad_trial_ref.data, - disp_test_ref.data, - disp_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - disp_trial_trace_ref.data, - disp_grad_trial_trace_ref.data, - disp_test_trace_ref.data, - disp_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - penalty.data, - gravityStep, - nElements_global, - materialTypes.data, - nMaterialProperties, - materialProperties.data, - pore_fluid_unit_weight, - pore_pressure_head_dof.data, - q_strain.data, - q_strain0.data, - q_strain_last.data, - q_plasticStrain.data, - q_plasticStrain_last.data, - ebqe_strain.data, - ebqe_strain0.data, - ebqe_strain_last.data, - ebqe_plasticStrain.data, - ebqe_plasticStrain_last.data, - disp_l2g.data, - u_dof.data, v_dof.data, w_dof.data, - bodyForce.data, - csrRowIndeces_u_u.data,csrColumnOffsets_u_u.data, - csrRowIndeces_u_v.data,csrColumnOffsets_u_v.data, - csrRowIndeces_u_w.data,csrColumnOffsets_u_w.data, - csrRowIndeces_v_u.data,csrColumnOffsets_v_u.data, - csrRowIndeces_v_v.data,csrColumnOffsets_v_v.data, - csrRowIndeces_v_w.data,csrColumnOffsets_v_w.data, - csrRowIndeces_w_u.data,csrColumnOffsets_w_u.data, - csrRowIndeces_w_v.data,csrColumnOffsets_w_v.data, - csrRowIndeces_w_w.data,csrColumnOffsets_w_w.data, - globalJacobian_a.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - isDOFBoundary_u.data, - isDOFBoundary_v.data, - isDOFBoundary_w.data, - isStressFluxBoundary_u.data, - isStressFluxBoundary_v.data, - isStressFluxBoundary_w.data, - csrColumnOffsets_eb_u_u.data, - csrColumnOffsets_eb_u_v.data, - csrColumnOffsets_eb_u_w.data, - csrColumnOffsets_eb_v_u.data, - csrColumnOffsets_eb_v_v.data, - csrColumnOffsets_eb_v_w.data, - csrColumnOffsets_eb_w_u.data, - csrColumnOffsets_eb_w_v.data, - csrColumnOffsets_eb_w_w.data) diff --git a/proteus/mprans/AddedMass.cpp b/proteus/mprans/AddedMass.cpp new file mode 100644 index 0000000000..c6bed476e2 --- /dev/null +++ b/proteus/mprans/AddedMass.cpp @@ -0,0 +1,32 @@ +#define FORCE_IMPORT_ARRAY +#include "AddedMass.h" + +namespace py = pybind11; + +namespace xt +{ +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void complex_allocator() + { + std::allocator ai; + std::allocator ad; + } + } +#endif +} + +PYBIND11_MODULE(cAddedMass, m) +{ + using proteus::cppAddedMass_base; + using proteus::newAddedMass; + + xt::import_numpy(); + + py::class_(m, "cppAddedMass_base") + .def("calculateResidual", &cppAddedMass_base::calculateResidual) + .def("calculateJacobian", &cppAddedMass_base::calculateJacobian); + + m.def("newAddedMass", newAddedMass); +} diff --git a/proteus/mprans/AddedMass.h b/proteus/mprans/AddedMass.h index cdbe240f24..d9a2643c5a 100644 --- a/proteus/mprans/AddedMass.h +++ b/proteus/mprans/AddedMass.h @@ -5,6 +5,8 @@ #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + using namespace std; namespace proteus @@ -14,76 +16,76 @@ namespace proteus public: virtual ~cppAddedMass_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, int nElementBoundaries_owned, - int* u_l2g, - double* u_dof, - double* q_rho, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_rho, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypesArray, - double* Aij, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypesArray, + xt::pyarray& Aij, int added_mass_i, - double* barycenters, - int* flags_rigidbody)=0; + xt::pyarray& barycenters, + xt::pyarray& flags_rigidbody)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* u_l2g, - double* u_dof, - double* q_rho, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_rho, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* csrColumnOffsets_eb_u_u)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& csrColumnOffsets_eb_u_u)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, int nElementBoundaries_owned, - int* u_l2g, - double* u_dof, - double* q_rho, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_rho, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypesArray, - double* Aij, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypesArray, + xt::pyarray& Aij, int added_mass_i, - double* barycenters, - int* flags_rigidbody) + xt::pyarray& barycenters, + xt::pyarray& flags_rigidbody) { for(int eN=0;eN& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* u_l2g, - double* u_dof, - double* q_rho, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_rho, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* csrColumnOffsets_eb_u_u) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& csrColumnOffsets_eb_u_u) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -653,28 +655,28 @@ namespace proteus register int eN_j = eN*nDOF_trial_element+j; element_u[j] = u_dof[u_l2g[eN_j]]; } - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, - u_l2g, - u_dof, - q_rho, + u_l2g.data(), + u_dof.data(), + q_rho.data(), elementJacobian_u_u, element_u, eN); diff --git a/proteus/mprans/AddedMass.py b/proteus/mprans/AddedMass.py index 14cf5e615c..2fe7315a6c 100644 --- a/proteus/mprans/AddedMass.py +++ b/proteus/mprans/AddedMass.py @@ -639,7 +639,7 @@ def __init__(self, self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() self.globalResidualDummy = None compKernelFlag = 0 - self.addedMass = cAddedMass.AddedMass( + self.addedMass = cAddedMass.newAddedMass( self.nSpace_global, self.nQuadraturePoints_element, self.u[0].femSpace.elementMaps.localFunctionSpace.dim, @@ -761,7 +761,7 @@ def getJacobian(self, jacobian): self.u[0].dof, self.coefficients.q_rho, self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/CLSVOF.cpp b/proteus/mprans/CLSVOF.cpp new file mode 100644 index 0000000000..2c0b5d7cdd --- /dev/null +++ b/proteus/mprans/CLSVOF.cpp @@ -0,0 +1,37 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "CLSVOF.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::CLSVOF_base; +using py::return_value_policy; + +PYBIND11_MODULE(cCLSVOF, m) +{ + xt::import_numpy(); + + py::class_(m, "cCLSVOF_base") + .def(py::init(&proteus::newCLSVOF)) + .def("calculateResidual" , &CLSVOF_base::calculateResidual ) + .def("calculateJacobian" , &CLSVOF_base::calculateJacobian ) + .def("calculateMetricsAtEOS" , &CLSVOF_base::calculateMetricsAtEOS , return_value_policy::take_ownership) + .def("calculateMetricsAtETS" , &CLSVOF_base::calculateMetricsAtETS , return_value_policy::take_ownership) + .def("normalReconstruction" , &CLSVOF_base::normalReconstruction ) + .def("calculateRhsL2Proj" , &CLSVOF_base::calculateRhsL2Proj ) + .def("calculateLumpedMassMatrix", &CLSVOF_base::calculateLumpedMassMatrix) + .def("assembleSpinUpSystem" , &CLSVOF_base::assembleSpinUpSystem ) + .def("FCTStep" , &CLSVOF_base::FCTStep ); +} diff --git a/proteus/mprans/CLSVOF.h b/proteus/mprans/CLSVOF.h index 7fec36f842..22edea306e 100644 --- a/proteus/mprans/CLSVOF.h +++ b/proteus/mprans/CLSVOF.h @@ -5,6 +5,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; #define USE_SIGN_FUNCTION 1 #define IMPLICIT_BCs 0 @@ -31,68 +34,68 @@ namespace proteus virtual ~CLSVOF_base(){} virtual void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, int nElements_owned, double useMetrics, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* velocity_old, - double* q_m, - double* q_u, - double* q_n, - double* q_H, - double* q_mH, - double* q_dV, - double* q_dV_last, - double* cfl, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& velocity_old, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_H, + xt::pyarray& q_mH, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_u, - double* ebqe_n, - double* ebqe_H, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& ebqe_H, + xt::pyarray& ebqe_flux, // FOR NONLINEAR CLSVOF; i.e., MCorr with VOF int timeOrder, int timeStage, @@ -101,79 +104,79 @@ namespace proteus double epsFactRedist, double lambdaFact, // normalization factor - double* min_distance, - double* max_distance, - double* mean_distance, - double* volume_domain, + xt::pyarray& min_distance, + xt::pyarray& max_distance, + xt::pyarray& mean_distance, + xt::pyarray& volume_domain, double norm_factor_lagged, double VelMax, // normal reconstruction - double* projected_qx_tn, - double* projected_qy_tn, - double* projected_qz_tn, - double* projected_qx_tStar, - double* projected_qy_tStar, - double* projected_qz_tStar, + xt::pyarray& projected_qx_tn, + xt::pyarray& projected_qy_tn, + xt::pyarray& projected_qz_tn, + xt::pyarray& projected_qx_tStar, + xt::pyarray& projected_qy_tStar, + xt::pyarray& projected_qz_tStar, // TO COMPUTE H int numDOFs, - double* lumped_mass_matrix, - double* H_dof, + xt::pyarray& lumped_mass_matrix, + xt::pyarray& H_dof, // PRE REDISTANCING int preRedistancingStage, - double* interface_locator, + xt::pyarray& interface_locator, double alpha)=0; virtual void calculateJacobian(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* cfl, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& cfl, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // FOR NONLINEAR CLSVOF; i.e., MCorr with VOF int timeOrder, int timeStage, @@ -185,148 +188,132 @@ namespace proteus int preRedistancingStage, double norm_factor_lagged, double alpha)=0; - virtual void calculateMetricsAtEOS( //EOS=End Of Simulation - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + virtual std::tuple calculateMetricsAtEOS( //EOS=End Of Simulation + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, int nElements_owned, int useMetrics, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFactHeaviside, - double* u_dof, - double* u0_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_sI_err, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err, - double* global_L2_err, - double* global_L2Banded_err, - double* global_area_band, - double* global_sH_L2_err)=0; - virtual void calculateMetricsAtETS( //ETS=Every Time Step + xt::pyarray& u_dof, + xt::pyarray& u0_dof, + xt::pyarray& u_exact, + int offset_u, int stride_u)=0; + virtual std::tuple calculateMetricsAtETS( //ETS=Every Time Step double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, int nElements_owned, int useMetrics, - double* q_vos, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFactHeaviside, - double* u_dof, - double* u_dof_old, - double* u0_dof, - double* velocity, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& u0_dof, + xt::pyarray& velocity, int offset_u, int stride_u, int numDOFs, - double* R_vector, - double* sR_vector, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err)=0; - virtual void normalReconstruction(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& R_vector, + xt::pyarray& sR_vector)=0; + virtual void normalReconstruction(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, int nElements_global, - int* u_l2g, - double* elementDiameter, - double* u_dof, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, int offset_u, int stride_u, int numDOFs, - double* weighted_lumped_mass_matrix, + xt::pyarray& weighted_lumped_mass_matrix, // normal reconstruction via consistent mass matrix - double* rhs_qx, - double* rhs_qy, - double* rhs_qz, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* weighted_mass_matrix)=0; - virtual void calculateRhsL2Proj(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& rhs_qx, + xt::pyarray& rhs_qy, + xt::pyarray& rhs_qz, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& weighted_mass_matrix)=0; + virtual void calculateRhsL2Proj(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, int nElements_global, - int* u_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, double he_for_disc_ICs, - double* u_dof, + xt::pyarray& u_dof, int offset_u, int stride_u, int numDOFs, - double* rhs_qx)=0; - virtual void calculateLumpedMassMatrix(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& rhs_qx)=0; + virtual void calculateLumpedMassMatrix(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, int nElements_global, - int* u_l2g, - double* elementDiameter, - double* lumped_mass_matrix, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& lumped_mass_matrix, int offset_u, int stride_u)=0; virtual void assembleSpinUpSystem(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* uInitial, + xt::pyarray& u_l2g, + xt::pyarray& uInitial, int offset_u, int stride_u, - double* globalResidual, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalMassMatrix)=0; + xt::pyarray& globalResidual, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalMassMatrix)=0; virtual void FCTStep(int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* lumped_mass_matrix, //lumped mass matrix (as vector) - double* soln, - double* solH, //DOFs of high order solution at tnp1 - double* solL, - double* limited_solution, - int* csrRowIndeces_DofLoops, //csr row indeces - int* csrColumnOffsets_DofLoops, //csr column offsets - double* MassMatrix //mass matrix + xt::pyarray& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& solL, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix //mass matrix )=0; }; @@ -530,68 +517,68 @@ namespace proteus void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, int nElements_owned, double useMetrics, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* velocity_old, - double* q_m, - double* q_u, - double* q_n, - double* q_H, - double* q_mH, - double* q_dV, - double* q_dV_last, - double* cfl, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& velocity_old, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_H, + xt::pyarray& q_mH, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_u, - double* ebqe_n, - double* ebqe_H, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& ebqe_H, + xt::pyarray& ebqe_flux, // FOR NONLINEAR CLSVOF; i.e., MCorr with VOF int timeOrder, int timeStage, @@ -600,32 +587,32 @@ namespace proteus double epsFactRedist, double lambdaFact, // normalization factor - double* min_distance, - double* max_distance, - double* mean_distance, - double* volume_domain, + xt::pyarray& min_distance, + xt::pyarray& max_distance, + xt::pyarray& mean_distance, + xt::pyarray& volume_domain, double norm_factor_lagged, double VelMax, // normal reconstruction - double* projected_qx_tn, - double* projected_qy_tn, - double* projected_qz_tn, - double* projected_qx_tStar, - double* projected_qy_tStar, - double* projected_qz_tStar, + xt::pyarray& projected_qx_tn, + xt::pyarray& projected_qy_tn, + xt::pyarray& projected_qz_tn, + xt::pyarray& projected_qx_tStar, + xt::pyarray& projected_qy_tStar, + xt::pyarray& projected_qz_tStar, // TO COMPUTE H int numDOFs, - double* lumped_mass_matrix, - double* H_dof, + xt::pyarray& lumped_mass_matrix, + xt::pyarray& H_dof, // PRE REDISTANCING int preRedistancingStage, - double* interface_locator, + xt::pyarray& interface_locator, double alpha) { - min_distance[0] = 1E10; - max_distance[0] = -1E10; - mean_distance[0] = 0.; - volume_domain[0] = 0.; + min_distance.data()[0] = 1E10; + max_distance.data()[0] = -1E10; + mean_distance.data()[0] = 0.; + volume_domain.data()[0] = 0.; for(int eN=0;eN& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* cfl, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& cfl, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // FOR NONLINEAR CLSVOF; i.e., MCorr with VOF int timeOrder, int timeStage, @@ -1256,60 +1243,60 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; //get the trial function gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace], + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace], jacInv, u_grad_trial); //get the solution - ck.valFromDOF(u_dof, - &u_l2g[eN_nDOF_trial_element], - &u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(u_dof.data(), + &u_l2g.data()[eN_nDOF_trial_element], + &u_trial_ref.data()[k*nDOF_trial_element], u); - ck.valFromDOF(u_dof_old, - &u_l2g[eN_nDOF_trial_element], - &u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(u_dof_old.data(), + &u_l2g.data()[eN_nDOF_trial_element], + &u_trial_ref.data()[k*nDOF_trial_element], un); //get the solution gradients - ck.gradFromDOF(u_dof, - &u_l2g[eN_nDOF_trial_element], + ck.gradFromDOF(u_dof.data(), + &u_l2g.data()[eN_nDOF_trial_element], u_grad_trial, grad_u); - ck.gradFromDOF(u_dof_old, - &u_l2g[eN_nDOF_trial_element], + ck.gradFromDOF(u_dof_old.data(), + &u_l2g.data()[eN_nDOF_trial_element], u_grad_trial, grad_un); //precalculate test function products with integration weights for (int j=0;j calculateMetricsAtEOS( //EOS=End Of Simulation + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, int nElements_owned, int useMetrics, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFactHeaviside, - double* u_dof, - double* u0_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_sI_err, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err, - double* global_L2_err, - double* global_L2Banded_err, - double* global_area_band, - double* global_sH_L2_err) + xt::pyarray& u_dof, + xt::pyarray& u0_dof, + xt::pyarray& u_exact, + int offset_u, int stride_u) { - *global_I_err = 0.0; - *global_sI_err = 0.0; - *global_V = 0.0; - *global_V0 = 0.0; - *global_sV = 0.0; - *global_sV0 = 0.0; - *global_D_err = 0.0; - *global_L2_err = 0.0; - *global_L2Banded_err = 0.0; - *global_area_band = 0.0; - *global_sH_L2_err = 0.0; + double global_I_err = 0.0; + double global_sI_err = 0.0; + double global_V = 0.0; + double global_V0 = 0.0; + double global_sV = 0.0; + double global_sV0 = 0.0; + double global_D_err = 0.0; + double global_L2_err = 0.0; + double global_L2Banded_err = 0.0; + double global_area_band = 0.0; + double global_sH_L2_err = 0.0; ////////////////////// // ** LOOP IN CELLS // ////////////////////// @@ -1673,30 +1649,30 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; // get functions at quad points - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],uh); - ck.valFromDOF(u0_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u0); - u = u_exact[eN_k]; + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],uh); + ck.valFromDOF(u0_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u0); + u = u_exact.data()[eN_k]; // get gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_uh); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_uh); - double epsHeaviside = epsFactHeaviside*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN])/degree_polynomial; + double epsHeaviside = epsFactHeaviside*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN])/degree_polynomial; // compute (smoothed) heaviside functions // double Hu0 = heaviside(u0); double Hu = heaviside(u); @@ -1730,62 +1706,59 @@ namespace proteus norm2_grad_uh += grad_uh[I]*grad_uh[I]; cell_D_err += std::pow(std::sqrt(norm2_grad_uh) - 1, 2.)*dV; } - *global_V += cell_V; - *global_V0 += cell_V0; - *global_sV += cell_sV; - *global_sV0 += cell_sV0; + global_V += cell_V; + global_V0 += cell_V0; + global_sV += cell_sV; + global_sV0 += cell_sV0; // metrics // - *global_I_err += cell_I_err; - *global_sI_err += cell_sI_err; - *global_D_err += cell_D_err; - *global_L2_err += cell_L2_err; - *global_L2Banded_err += cell_L2Banded_err; - *global_area_band += cell_area_band; - *global_sH_L2_err += cell_sH_L2_err; + global_I_err += cell_I_err; + global_sI_err += cell_sI_err; + global_D_err += cell_D_err; + global_L2_err += cell_L2_err; + global_L2Banded_err += cell_L2Banded_err; + global_area_band += cell_area_band; + global_sH_L2_err += cell_sH_L2_err; }//elements } - *global_D_err *= 0.5; + global_D_err *= 0.5; + + return std::tuple(global_I_err, global_sI_err, global_V, global_V0, global_sV, global_sV0, global_D_err, global_L2_err, global_L2Banded_err, global_area_band, global_sH_L2_err); } - void calculateMetricsAtETS( // ETS=Every Time Step + std::tuple calculateMetricsAtETS( // ETS=Every Time Step double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, int nElements_owned, int useMetrics, - double* q_vos, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFactHeaviside, - double* u_dof, - double* u_dof_old, - double* u0_dof, - double* velocity, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& u0_dof, + xt::pyarray& velocity, int offset_u, int stride_u, int numDOFs, - double* R_vector, - double* sR_vector, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err) + xt::pyarray& R_vector, + xt::pyarray& sR_vector) { - *global_V = 0.0; - *global_V0 = 0.0; - *global_sV = 0.0; - *global_sV0 = 0.0; - *global_D_err = 0.0; + double global_V = 0.0; + double global_V0 = 0.0; + double global_sV = 0.0; + double global_sV0 = 0.0; + double global_D_err = 0.0; ////////////////////////////////////////////// // ** LOOP IN CELLS FOR CELL BASED TERMS ** // ////////////////////////////////////////////// @@ -1821,39 +1794,39 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; // get functions at quad points - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],unp1); - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); - ck.valFromDOF(u0_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u0); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],unp1); + ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],un); + ck.valFromDOF(u0_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u0); // get gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_unp1); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_unp1); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j(global_V, global_V0, global_sV, global_sV0, global_D_err); } void normalReconstruction(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* elementDiameter, - double* u_dof, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, int offset_u, int stride_u, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, - double* weighted_lumped_mass_matrix, + xt::pyarray& weighted_lumped_mass_matrix, // normal reconstruction via consistent mass matrix - double* rhs_qx, - double* rhs_qy, - double* rhs_qz, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* weighted_mass_matrix) + xt::pyarray& rhs_qx, + xt::pyarray& rhs_qy, + xt::pyarray& rhs_qz, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& weighted_mass_matrix) { for (int i=0; i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, double he_for_disc_ICs, - double* u_dof, + xt::pyarray& u_dof, int offset_u, int stride_u, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, - double* rhs_l2_proj) + xt::pyarray& rhs_l2_proj) { for (int i=0; i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* elementDiameter, - double* lumped_mass_matrix, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& lumped_mass_matrix, int offset_u, int stride_u) { for(int eN=0;eN& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* uInitial, + xt::pyarray& u_l2g, + xt::pyarray& uInitial, int offset_u, int stride_u, - double* globalResidual, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalMassMatrix) + xt::pyarray& globalResidual, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalMassMatrix) { for(int eN=0;eN& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& solL, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix //mass matrix ) { Rpos.resize(numDOFs, 0.0); @@ -2282,22 +2257,22 @@ namespace proteus for (int i=0; i0) ? std::min(Rposi,Rneg[j]) : std::min(Rnegi,Rpos[j])) * FluxCorrectionMatrix[ij]; @@ -2340,7 +2315,7 @@ namespace proteus //update ij ij+=1; } - limited_solution[i] = solL[i] + 1./lumped_mass_matrix[i]*ith_Limiter_times_FluxCorrectionMatrix; + limited_solution.data()[i] = solL.data()[i] + 1./lumped_mass_matrix.data()[i]*ith_Limiter_times_FluxCorrectionMatrix; } } };//CLSVOF diff --git a/proteus/mprans/CLSVOF.py b/proteus/mprans/CLSVOF.py index d1a967e865..57ee450783 100644 --- a/proteus/mprans/CLSVOF.py +++ b/proteus/mprans/CLSVOF.py @@ -4,6 +4,10 @@ from past.utils import old_div import proteus from proteus.mprans.cCLSVOF import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class NumericalFlux(proteus.NumericalFlux.Advection_DiagonalUpwind_Diffusion_IIPG_exterior): def __init__(self,vt,getPointwiseBoundaryConditions, @@ -835,7 +839,7 @@ def assembleSpinUpSystem(self,residual,jacobian): self.offset[0],self.stride[0], residual, self.csrRowIndeces[(0,0)],self.csrColumnOffsets[(0,0)], - jacobian) + jacobian.getCSRrepresentation()[2]) def updateVelocityFieldAsFunction(self): X = {0:self.q[('x')][:,:,0], @@ -902,7 +906,7 @@ def getMetricsAtETS(self): #ETS=Every Time Step #physics self.mesh.nElements_global, self.mesh.nElements_owned, - self.coefficients.useMetrics, + int(self.coefficients.useMetrics), self.coefficients.q_vos, self.u[0].femSpace.dofMap.l2g, self.mesh.elementDiametersArray, @@ -1011,7 +1015,7 @@ def FCTStep(self, limited_solution, self.rowptr, # Row indices for Sparsity Pattern self.colind, # Column indices for Sparsity Pattern - MassMatrix) + MassMatrix.getCSRrepresentation()[2]) def getNormalReconstruction(self,weighted_mass_matrix): cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian,weighted_mass_matrix) @@ -1035,7 +1039,7 @@ def getNormalReconstruction(self,weighted_mass_matrix): self.rhs_qy, self.rhs_qz, self.csrRowIndeces[(0,0)],self.csrColumnOffsets[(0,0)], - weighted_mass_matrix) + weighted_mass_matrix.getCSRrepresentation()[2]) def getRhsL2Proj(self): self.clsvof.calculateRhsL2Proj( @@ -1289,7 +1293,7 @@ def getJacobian(self,jacobian): self.coefficients.q_v, self.q[('cfl',0)], self.csrRowIndeces[(0,0)],self.csrColumnOffsets[(0,0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/Dissipation.cpp b/proteus/mprans/Dissipation.cpp new file mode 100644 index 0000000000..b5dc1ff6eb --- /dev/null +++ b/proteus/mprans/Dissipation.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "Dissipation.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::Dissipation_base; + +PYBIND11_MODULE(cDissipation, m) +{ + xt::import_numpy(); + + py::class_(m, "cDissipation_base") + .def(py::init(&proteus::newDissipation)) + .def("calculateResidual", &Dissipation_base::calculateResidual) + .def("calculateJacobian", &Dissipation_base::calculateJacobian); +} diff --git a/proteus/mprans/Dissipation.h b/proteus/mprans/Dissipation.h index 7e1334e718..16fc638077 100644 --- a/proteus/mprans/Dissipation.h +++ b/proteus/mprans/Dissipation.h @@ -5,6 +5,9 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "SedClosure.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -31,27 +34,27 @@ namespace proteus double vos_limiter, double mu_fr_limiter){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -66,15 +69,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -83,67 +86,67 @@ namespace proteus int lag_shockCapturing, double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy variable - double* q_grad_kappa, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy variable + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_kappa, //kinetic energy variable on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa, //kinetic energy variable on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion @@ -162,52 +165,52 @@ namespace proteus double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy - double* q_grad_kappa, - double* q_porosity,//VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity,//VRANS // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_phi,double epsFact, - double* ebqe_kappa,//kinetic energy on boundary - double* ebqe_porosity)=0; //VRANS + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa,//kinetic energy on boundary + xt::pyarray& ebqe_porosity)=0; //VRANS }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -785,15 +788,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -802,45 +805,45 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy - double* q_grad_kappa, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_kappa, //kinetic energy on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa, //kinetic energy on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux) { //cek should this be read in? double Ct_sge = 4.0; @@ -903,51 +906,51 @@ namespace proteus // int eN_j=eN*nDOF_trial_element+j; // int eN_k_j=eN_k*nDOF_trial_element+j; // int eN_k_j_nSpace = eN_k_j*nSpace; - // u += valFromDOF_c(u_dof[u_l2g[eN_j]],u_trial[eN_k_j]); + // u += valFromDOF_c(u_dof.data()[u_l2g.data()[eN_j]],u_trial[eN_k_j]); // for (int I=0;I a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::Dissipation2D_base; + +PYBIND11_MODULE(cDissipation2D, m) +{ + xt::import_numpy(); + + py::class_(m, "cDissipation2D_base") + .def(py::init(&proteus::newDissipation2D)) + .def("calculateResidual", &Dissipation2D_base::calculateResidual) + .def("calculateJacobian", &Dissipation2D_base::calculateJacobian); +} diff --git a/proteus/mprans/Dissipation2D.h b/proteus/mprans/Dissipation2D.h index 521cc28819..9b44daa367 100644 --- a/proteus/mprans/Dissipation2D.h +++ b/proteus/mprans/Dissipation2D.h @@ -5,6 +5,9 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "SedClosure.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -31,27 +34,27 @@ namespace proteus double vos_limiter, double mu_fr_limiter){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -66,15 +69,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -83,67 +86,67 @@ namespace proteus int lag_shockCapturing, double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy variable - double* q_grad_kappa, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy variable + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_kappa, //kinetic energy variable on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa, //kinetic energy variable on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion @@ -162,52 +165,52 @@ namespace proteus double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy - double* q_grad_kappa, - double* q_porosity,//VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity,//VRANS // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_phi,double epsFact, - double* ebqe_kappa,//kinetic energy on boundary - double* ebqe_porosity)=0; //VRANS + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa,//kinetic energy on boundary + xt::pyarray& ebqe_porosity)=0; //VRANS }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -778,15 +781,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -795,45 +798,45 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_kappa, //kinetic energy - double* q_grad_kappa, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_kappa, //kinetic energy + xt::pyarray& q_grad_kappa, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_kappa, //kinetic energy on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_kappa, //kinetic energy on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux) { //cek should this be read in? double Ct_sge = 4.0; @@ -896,51 +899,51 @@ namespace proteus // int eN_j=eN*nDOF_trial_element+j; // int eN_k_j=eN_k*nDOF_trial_element+j; // int eN_k_j_nSpace = eN_k_j*nSpace; - // u += valFromDOF_c(u_dof[u_l2g[eN_j]],u_trial[eN_k_j]); + // u += valFromDOF_c(u_dof.data()[u_l2g.data()[eN_j]],u_trial[eN_k_j]); // for (int I=0;I a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::GN_SW2DCV_base; +using pybind11::return_value_policy; + +PYBIND11_MODULE(cGN_SW2DCV, m) +{ + xt::import_numpy(); + + py::class_(m, "cGN_SW2DCV_base") + .def(py::init(&proteus::newGN_SW2DCV)) + .def("FCTStep" , &GN_SW2DCV_base::FCTStep ) + .def("convexLimiting" , &GN_SW2DCV_base::convexLimiting ) + .def("calculateEdgeBasedCFL" , &GN_SW2DCV_base::calculateEdgeBasedCFL, return_value_policy::take_ownership) + .def("calculateResidual" , &GN_SW2DCV_base::calculateResidual ) + .def("calculateMassMatrix" , &GN_SW2DCV_base::calculateMassMatrix ) + .def("calculateLumpedMassMatrix", &GN_SW2DCV_base::calculateLumpedMassMatrix); +} diff --git a/proteus/mprans/GN_SW2DCV.h b/proteus/mprans/GN_SW2DCV.h index 656a1e721d..2fd3685114 100644 --- a/proteus/mprans/GN_SW2DCV.h +++ b/proteus/mprans/GN_SW2DCV.h @@ -6,7 +6,9 @@ #include #include #include -#include +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; // cek todo // 2. Get stabilization right @@ -167,273 +169,281 @@ class GN_SW2DCV_base { FCTStep(double dt, int NNZ, // number on non-zero entries on sparsity pattern int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *heta_old, double *hw_old, - double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *high_order_hetanp1, double *high_order_hwnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, - double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, - double *limited_hetanp1, double *limited_hwnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, xt::pyarray& limited_hvnp1, + xt::pyarray& limited_hetanp1, xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, xt::pyarray& hReg, int LUMPED_MASS_MATRIX, // LOCAL LIMITING - double *dLow, double *hBT, double *huBT, double *hvBT, double *hetaBT, - double *hwBT) = 0; - virtual void convexLimiting( - double dt, - int NNZ, // number on non-zero entries on sparsity pattern - int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *heta_old, double *hw_old, - double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *high_order_hetanp1, double *high_order_hwnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, - double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, - double *limited_hetanp1, double *limited_hwnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, - int LUMPED_MASS_MATRIX, - // LOCAL LIMITING - double *dLow, double *hBT, double *huBT, double *hvBT, double *hetaBT, - double *hwBT, double *new_SourceTerm_hu, double *new_SourceTerm_hv, - double *new_SourceTerm_heta, double *new_SourceTerm_hw) = 0; + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, + xt::pyarray& hwBT) = 0; + virtual void + convexLimiting(double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, + xt::pyarray& hw_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, xt::pyarray& limited_hetanp1, + xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, + // LOCAL LIMITING + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, + xt::pyarray& hetaBT, xt::pyarray& hwBT, + xt::pyarray& new_SourceTerm_hu, + xt::pyarray& new_SourceTerm_hv, + xt::pyarray& new_SourceTerm_heta, + xt::pyarray& new_SourceTerm_hw) = 0; virtual double calculateEdgeBasedCFL( double g, int numDOFsPerEqn, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *heta_old, double *b_dof, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double hEps, double *hReg, double *Cx, double *Cy, double *CTx, - double *CTy, double *dLow, double run_cfl, double *edge_based_cfl, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, int debug) = 0; virtual void calculateResidual( // last EDGE BASED version - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, // 0 or 1 - int *mesh_l2g, double *dV_ref, double *h_trial_ref, - double *h_grad_trial_ref, double *h_test_ref, double *h_grad_test_ref, - double *vel_trial_ref, double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_l2g, xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *h_dof_old, double *hu_dof_old, double *hv_dof_old, - double *heta_dof_old, double *hw_dof_old, double *b_dof, double *h_dof, - double *hu_dof, double *hv_dof, double *heta_dof, double *hw_dof, - double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *heta_dof_sge, double *hw_dof_sge, double *q_mass_acc, - double *q_mom_hu_acc, double *q_mom_hv_acc, double *q_mass_adv, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& heta_dof_old, xt::pyarray& hw_dof_old, xt::pyarray& b_dof, xt::pyarray& h_dof, + xt::pyarray& hu_dof, xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& heta_dof_sge, xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, int offset_heta, int offset_hw, int stride_h, int stride_hu, - int stride_hv, int stride_heta, int stride_hw, double *globalResidual, + int stride_hv, int stride_heta, int stride_hw, xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - double *q_velocity, double *ebqe_velocity, double *flux, - double *elementResidual_h, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h, // C matrices - double *Cx, double *Cy, double *CTx, double *CTy, + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, // PARAMETERS FOR EDGE BASED STABILIZATION - int numDOFsPerEqn, int NNZ, int *csrRowIndeces_DofLoops, - int *csrColumnOffsets_DofLoops, + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, // LUMPED MASS MATRIX - double *lumped_mass_matrix, double cfl_run, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, // SAVE SOLUTION (mql) - double *hnp1_at_quad_point, double *hunp1_at_quad_point, - double *hvnp1_at_quad_point, double *hetanp1_at_quad_point, - double *hwnp1_at_quad_point, + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, xt::pyarray& hetanp1_at_quad_point, + xt::pyarray& hwnp1_at_quad_point, // TO COMPUTE LOW ORDER - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, // FOR FCT - double *dH_minus_dL, double *muH_minus_muL, double cE, + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, // Quant of interests - double *quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, // NORMAL COMPONENTS - int COMPUTE_NORMALS, double *normalx, double *normaly, double *dLow, - double *hBT, double *huBT, double *hvBT, double *hetaBT, double *hwBT, - int lstage, double *new_SourceTerm_hu, double *new_SourceTerm_hv, - double *new_SourceTerm_heta, double *new_SourceTerm_hw) = 0; + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT, + int lstage, + xt::pyarray& new_SourceTerm_hu, + xt::pyarray& new_SourceTerm_hv, + xt::pyarray& new_SourceTerm_heta, + xt::pyarray& new_SourceTerm_hw + ) = 0; virtual void calculateMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *heta_dof, double *hw_dof, double *h_dof_sge, - double *hu_dof_sge, double *hv_dof_sge, double *heta_dof_sge, - double *hw_dof_sge, double *q_mass_acc_beta_bdf, - double *q_mom_hu_acc_beta_bdf, double *q_mom_hv_acc_beta_bdf, - double *q_cfl, int *sdInfo_hu_hu_rowptr, int *sdInfo_hu_hu_colind, - int *sdInfo_hu_hv_rowptr, int *sdInfo_hu_hv_colind, - int *sdInfo_hv_hv_rowptr, int *sdInfo_hv_hv_colind, - int *sdInfo_hv_hu_rowptr, int *sdInfo_hv_hu_colind, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, xt::pyarray& h_dof_sge, + xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, xt::pyarray& heta_dof_sge, + xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, // h - int *csrRowIndeces_h_h, int *csrColumnOffsets_h_h, - int *csrRowIndeces_h_hu, int *csrColumnOffsets_h_hu, - int *csrRowIndeces_h_hv, int *csrColumnOffsets_h_hv, - int *csrRowIndeces_h_heta, int *csrColumnOffsets_h_heta, - int *csrRowIndeces_h_hw, int *csrColumnOffsets_h_hw, + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, // hu - int *csrRowIndeces_hu_h, int *csrColumnOffsets_hu_h, - int *csrRowIndeces_hu_hu, int *csrColumnOffsets_hu_hu, - int *csrRowIndeces_hu_hv, int *csrColumnOffsets_hu_hv, - int *csrRowIndeces_hu_heta, int *csrColumnOffsets_hu_heta, - int *csrRowIndeces_hu_hw, int *csrColumnOffsets_hu_hw, + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, // hv - int *csrRowIndeces_hv_h, int *csrColumnOffsets_hv_h, - int *csrRowIndeces_hv_hu, int *csrColumnOffsets_hv_hu, - int *csrRowIndeces_hv_hv, int *csrColumnOffsets_hv_hv, - int *csrRowIndeces_hv_heta, int *csrColumnOffsets_hv_heta, - int *csrRowIndeces_hv_hw, int *csrColumnOffsets_hv_hw, + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, // heta - int *csrRowIndeces_heta_h, int *csrColumnOffsets_heta_h, - int *csrRowIndeces_heta_hu, int *csrColumnOffsets_heta_hu, - int *csrRowIndeces_heta_hv, int *csrColumnOffsets_heta_hv, - int *csrRowIndeces_heta_heta, int *csrColumnOffsets_heta_heta, - int *csrRowIndeces_heta_hw, int *csrColumnOffsets_heta_hw, + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, // hw - int *csrRowIndeces_hw_h, int *csrColumnOffsets_hw_h, - int *csrRowIndeces_hw_hu, int *csrColumnOffsets_hw_hu, - int *csrRowIndeces_hw_hv, int *csrColumnOffsets_hw_hv, - int *csrRowIndeces_hw_heta, int *csrColumnOffsets_hw_heta, - int *csrRowIndeces_hw_hw, int *csrColumnOffsets_hw_hw, + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, // - double *globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) = 0; + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; virtual void calculateLumpedMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, // h - int *csrRowIndeces_h_h, int *csrColumnOffsets_h_h, - int *csrRowIndeces_h_hu, int *csrColumnOffsets_h_hu, - int *csrRowIndeces_h_hv, int *csrColumnOffsets_h_hv, - int *csrRowIndeces_h_heta, int *csrColumnOffsets_h_heta, - int *csrRowIndeces_h_hw, int *csrColumnOffsets_h_hw, + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, // hu - int *csrRowIndeces_hu_h, int *csrColumnOffsets_hu_h, - int *csrRowIndeces_hu_hu, int *csrColumnOffsets_hu_hu, - int *csrRowIndeces_hu_hv, int *csrColumnOffsets_hu_hv, - int *csrRowIndeces_hu_heta, int *csrColumnOffsets_hu_heta, - int *csrRowIndeces_hu_hw, int *csrColumnOffsets_hu_hw, + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, // hv - int *csrRowIndeces_hv_h, int *csrColumnOffsets_hv_h, - int *csrRowIndeces_hv_hu, int *csrColumnOffsets_hv_hu, - int *csrRowIndeces_hv_hv, int *csrColumnOffsets_hv_hv, - int *csrRowIndeces_hv_heta, int *csrColumnOffsets_hv_heta, - int *csrRowIndeces_hv_hw, int *csrColumnOffsets_hv_hw, + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, // heta - int *csrRowIndeces_heta_h, int *csrColumnOffsets_heta_h, - int *csrRowIndeces_heta_hu, int *csrColumnOffsets_heta_hu, - int *csrRowIndeces_heta_hv, int *csrColumnOffsets_heta_hv, - int *csrRowIndeces_heta_heta, int *csrColumnOffsets_heta_heta, - int *csrRowIndeces_heta_hw, int *csrColumnOffsets_heta_hw, + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, // hw - int *csrRowIndeces_hw_h, int *csrColumnOffsets_hw_h, - int *csrRowIndeces_hw_hu, int *csrColumnOffsets_hw_hu, - int *csrRowIndeces_hw_hv, int *csrColumnOffsets_hw_hv, - int *csrRowIndeces_hw_heta, int *csrColumnOffsets_hw_heta, - int *csrRowIndeces_hw_hw, int *csrColumnOffsets_hw_hw, - double *globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) = 0; + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; }; template & lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, xt::pyarray& limited_hetanp1, + xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, xt::pyarray& dLow, xt::pyarray& hBT, + xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT) { Rneg.resize(numDOFs, 0.0); Rpos.resize(numDOFs, 0.0); Rneg_heta.resize(numDOFs, 0.0); @@ -1026,26 +1036,27 @@ class GN_SW2DCV : public GN_SW2DCV_base { double dt, int NNZ, // number on non-zero entries on sparsity pattern int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector)) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *heta_old, double *hw_old, - double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *high_order_hetanp1, double *high_order_hwnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, - double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, - double *limited_hetanp1, double *limited_hwnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, - int LUMPED_MASS_MATRIX, double *dLow, double *hBT, double *huBT, - double *hvBT, double *hetaBT, double *hwBT, double *new_SourceTerm_hu, - double *new_SourceTerm_hv, double *new_SourceTerm_heta, - double *new_SourceTerm_hw) { - + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, xt::pyarray& limited_hvnp1, + xt::pyarray& limited_hetanp1, xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, xt::pyarray& hReg, + int LUMPED_MASS_MATRIX, xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, + xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT, + xt::pyarray& new_SourceTerm_hu, + xt::pyarray& new_SourceTerm_hv, + xt::pyarray& new_SourceTerm_heta, + xt::pyarray& new_SourceTerm_hw) { Rneg.resize(numDOFs, 0.0); Rpos.resize(numDOFs, 0.0); Rneg_heta.resize(numDOFs, 0.0); @@ -1507,14 +1518,14 @@ class GN_SW2DCV : public GN_SW2DCV_base { double calculateEdgeBasedCFL( double g, int numDOFsPerEqn, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector)) - double *h_dof_old, // DOFs of solution at last stage - double *hu_dof_old, double *hv_dof_old, double *heta_dof_old, - double *b_dof, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double hEps, double *hReg, double *Cx, double *Cy, double *CTx, - double *CTy, double *dLow, double run_cfl, double *edge_based_cfl, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_dof_old, // DOFs of solution at last stage + xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, xt::pyarray& heta_dof_old, + xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, int debug) { /* note that for the CFL condition, we use only the values of dij and @@ -1580,75 +1591,77 @@ class GN_SW2DCV : public GN_SW2DCV_base { } // End calculateEdgeBasedCFL void calculateResidual( // last EDGE BASED version - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *h_dof_old, double *hu_dof_old, double *hv_dof_old, - double *heta_dof_old, double *hw_dof_old, double *b_dof, double *h_dof, - double *hu_dof, double *hv_dof, double *heta_dof, double *hw_dof, - double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *heta_dof_sge, double *hw_dof_sge, double *q_mass_acc, - double *q_mom_hu_acc, double *q_mom_hv_acc, double *q_mass_adv, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& heta_dof_old, xt::pyarray& hw_dof_old, xt::pyarray& b_dof, xt::pyarray& h_dof, + xt::pyarray& hu_dof, xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& heta_dof_sge, xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, int offset_heta, int offset_hw, int stride_h, int stride_hu, - int stride_hv, int stride_heta, int stride_hw, double *globalResidual, + int stride_hv, int stride_heta, int stride_hw, xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - double *q_velocity, double *ebqe_velocity, double *flux, - double *elementResidual_h_save, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h_save, // C matrices - double *Cx, double *Cy, double *CTx, double *CTy, + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, // PARAMETERS FOR EDGE BASED STABILIZATION - int numDOFsPerEqn, int NNZ, int *csrRowIndeces_DofLoops, - int *csrColumnOffsets_DofLoops, + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, // LUMPED MASS MATRIX - double *lumped_mass_matrix, double cfl_run, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, // SAVE SOLUTION (mql) - double *hnp1_at_quad_point, double *hunp1_at_quad_point, - double *hvnp1_at_quad_point, double *hetanp1_at_quad_point, - double *hwnp1_at_quad_point, + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, xt::pyarray& hetanp1_at_quad_point, + xt::pyarray& hwnp1_at_quad_point, // TO COMPUTE LOW ORDER - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, // FOR FCT - double *dH_minus_dL, double *muH_minus_muL, double cE, + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, // Quant of interests - double *quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, // NORMAL COMPONENTS - int COMPUTE_NORMALS, double *normalx, double *normaly, double *dLow, + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, // LOCAL LIMITING - double *hBT, double *huBT, double *hvBT, double *hetaBT, double *hwBT, - int lstage, double *new_SourceTerm_hu, double *new_SourceTerm_hv, - double *new_SourceTerm_heta, double *new_SourceTerm_hw) { - + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT, + int lstage, + xt::pyarray& new_SourceTerm_hu, + xt::pyarray& new_SourceTerm_hv, + xt::pyarray& new_SourceTerm_heta, + xt::pyarray& new_SourceTerm_hw) { // FOR FRICTION// double n2 = std::pow(mannings, 2.); double gamma = 4. / 3; @@ -1694,32 +1707,32 @@ class GN_SW2DCV : public GN_SW2DCV_base { jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace], h_test_dV[nDOF_trial_element], dV, x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; // get the solution at current time - ck.valFromDOF(h_dof, &h_l2g[eN_nDOF_trial_element], + ck.valFromDOF(h_dof.data(), &h_l2g[eN_nDOF_trial_element], &h_trial_ref[k * nDOF_trial_element], h); - ck.valFromDOF(hu_dof, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hu_dof.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hu); - ck.valFromDOF(hv_dof, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hv_dof.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hv); - ck.valFromDOF(heta_dof, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(heta_dof.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], heta); - ck.valFromDOF(hw_dof, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hw_dof.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hw); // get the solution at the lstage - ck.valFromDOF(h_dof_old, &h_l2g[eN_nDOF_trial_element], + ck.valFromDOF(h_dof_old.data(), &h_l2g[eN_nDOF_trial_element], &h_trial_ref[k * nDOF_trial_element], h_old); - ck.valFromDOF(hu_dof_old, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hu_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hu_old); - ck.valFromDOF(hv_dof_old, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hv_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hv_old); - ck.valFromDOF(heta_dof_old, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(heta_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], heta_old); - ck.valFromDOF(hw_dof_old, &vel_l2g[eN_nDOF_trial_element], + ck.valFromDOF(hw_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], &vel_trial_ref[k * nDOF_trial_element], hw_old); // calculate cell based CFL to keep a reference calculateCFL(elementDiameter[eN], g, h_old, hu_old, hv_old, hEps, @@ -2347,10 +2360,10 @@ class GN_SW2DCV : public GN_SW2DCV_base { /* compute information about mapping from reference element to * physical element */ ck.calculateMapping_elementBoundary( - eN, ebN_local, kb, ebN_local_kb, mesh_dof, mesh_l2g, - mesh_trial_trace_ref, mesh_grad_trial_trace_ref, boundaryJac_ref, + eN, ebN_local, kb, ebN_local_kb, mesh_dof.data(), mesh_l2g.data(), + mesh_trial_trace_ref.data(), mesh_grad_trial_trace_ref.data(), boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, - metricTensorDetSqrt, normal_ref, normal, x_ext, y_ext); + metricTensorDetSqrt, normal_ref.data(), normal, x_ext, y_ext); } // distribute the normal vectors for (int i = 0; i < nDOF_test_element; i++) { @@ -2374,78 +2387,78 @@ class GN_SW2DCV : public GN_SW2DCV_base { } // namespace proteus void calculateMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *heta_dof, double *hw_dof, double *h_dof_sge, - double *hu_dof_sge, double *hv_dof_sge, double *heta_dof_sge, - double *hw_dof_sge, double *q_mass_acc_beta_bdf, - double *q_mom_hu_acc_beta_bdf, double *q_mom_hv_acc_beta_bdf, - double *q_cfl, int *sdInfo_hu_hu_rowptr, int *sdInfo_hu_hu_colind, - int *sdInfo_hu_hv_rowptr, int *sdInfo_hu_hv_colind, - int *sdInfo_hv_hv_rowptr, int *sdInfo_hv_hv_colind, - int *sdInfo_hv_hu_rowptr, int *sdInfo_hv_hu_colind, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, xt::pyarray& h_dof_sge, + xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, xt::pyarray& heta_dof_sge, + xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, // h - int *csrRowIndeces_h_h, int *csrColumnOffsets_h_h, - int *csrRowIndeces_h_hu, int *csrColumnOffsets_h_hu, - int *csrRowIndeces_h_hv, int *csrColumnOffsets_h_hv, - int *csrRowIndeces_h_heta, int *csrColumnOffsets_h_heta, - int *csrRowIndeces_h_hw, int *csrColumnOffsets_h_hw, + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, // hu - int *csrRowIndeces_hu_h, int *csrColumnOffsets_hu_h, - int *csrRowIndeces_hu_hu, int *csrColumnOffsets_hu_hu, - int *csrRowIndeces_hu_hv, int *csrColumnOffsets_hu_hv, - int *csrRowIndeces_hu_heta, int *csrColumnOffsets_hu_heta, - int *csrRowIndeces_hu_hw, int *csrColumnOffsets_hu_hw, + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, // hv - int *csrRowIndeces_hv_h, int *csrColumnOffsets_hv_h, - int *csrRowIndeces_hv_hu, int *csrColumnOffsets_hv_hu, - int *csrRowIndeces_hv_hv, int *csrColumnOffsets_hv_hv, - int *csrRowIndeces_hv_heta, int *csrColumnOffsets_hv_heta, - int *csrRowIndeces_hv_hw, int *csrColumnOffsets_hv_hw, + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, // heta - int *csrRowIndeces_heta_h, int *csrColumnOffsets_heta_h, - int *csrRowIndeces_heta_hu, int *csrColumnOffsets_heta_hu, - int *csrRowIndeces_heta_hv, int *csrColumnOffsets_heta_hv, - int *csrRowIndeces_heta_heta, int *csrColumnOffsets_heta_heta, - int *csrRowIndeces_heta_hw, int *csrColumnOffsets_heta_hw, + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, // hw - int *csrRowIndeces_hw_h, int *csrColumnOffsets_hw_h, - int *csrRowIndeces_hw_hu, int *csrColumnOffsets_hw_hu, - int *csrRowIndeces_hw_hv, int *csrColumnOffsets_hw_hv, - int *csrRowIndeces_hw_heta, int *csrColumnOffsets_hw_heta, - int *csrRowIndeces_hw_hw, int *csrColumnOffsets_hw_hw, + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, // - double *globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) { + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { // // loop over elements to compute volume integrals and load them into the // element Jacobians and global Jacobian @@ -2478,8 +2491,8 @@ class GN_SW2DCV : public GN_SW2DCV_base { dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; @@ -2533,77 +2546,77 @@ class GN_SW2DCV : public GN_SW2DCV_base { } void calculateLumpedMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, // h - int *csrRowIndeces_h_h, int *csrColumnOffsets_h_h, - int *csrRowIndeces_h_hu, int *csrColumnOffsets_h_hu, - int *csrRowIndeces_h_hv, int *csrColumnOffsets_h_hv, - int *csrRowIndeces_h_heta, int *csrColumnOffsets_h_heta, - int *csrRowIndeces_h_hw, int *csrColumnOffsets_h_hw, + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, // hu - int *csrRowIndeces_hu_h, int *csrColumnOffsets_hu_h, - int *csrRowIndeces_hu_hu, int *csrColumnOffsets_hu_hu, - int *csrRowIndeces_hu_hv, int *csrColumnOffsets_hu_hv, - int *csrRowIndeces_hu_heta, int *csrColumnOffsets_hu_heta, - int *csrRowIndeces_hu_hw, int *csrColumnOffsets_hu_hw, + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, // hv - int *csrRowIndeces_hv_h, int *csrColumnOffsets_hv_h, - int *csrRowIndeces_hv_hu, int *csrColumnOffsets_hv_hu, - int *csrRowIndeces_hv_hv, int *csrColumnOffsets_hv_hv, - int *csrRowIndeces_hv_heta, int *csrColumnOffsets_hv_heta, - int *csrRowIndeces_hv_hw, int *csrColumnOffsets_hv_hw, + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, // heta - int *csrRowIndeces_heta_h, int *csrColumnOffsets_heta_h, - int *csrRowIndeces_heta_hu, int *csrColumnOffsets_heta_hu, - int *csrRowIndeces_heta_hv, int *csrColumnOffsets_heta_hv, - int *csrRowIndeces_heta_heta, int *csrColumnOffsets_heta_heta, - int *csrRowIndeces_heta_hw, int *csrColumnOffsets_heta_hw, + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, // hw - int *csrRowIndeces_hw_h, int *csrColumnOffsets_hw_h, - int *csrRowIndeces_hw_hu, int *csrColumnOffsets_hw_hu, - int *csrRowIndeces_hw_hv, int *csrColumnOffsets_hw_hv, - int *csrRowIndeces_hw_heta, int *csrColumnOffsets_hw_heta, - int *csrRowIndeces_hw_hw, int *csrColumnOffsets_hw_hw, + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, // - double *globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) { + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { // // loop over elements to compute volume integrals and load them into the // element Jacobians and global Jacobian @@ -2636,8 +2649,8 @@ class GN_SW2DCV : public GN_SW2DCV_base { dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; diff --git a/proteus/mprans/GN_SW2DCV.h.orig b/proteus/mprans/GN_SW2DCV.h.orig new file mode 100644 index 0000000000..21c8159b85 --- /dev/null +++ b/proteus/mprans/GN_SW2DCV.h.orig @@ -0,0 +1,2773 @@ +#ifndef GN_SW2DCV_H +#define GN_SW2DCV_H +#include "CompKernel.h" +#include "ModelFactory.h" +#include +#include +#include +#include +<<<<<<< HEAD +#include +======= +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; +>>>>>>> dceecb29d... GN_SW2DCV + +// cek todo +// 2. Get stabilization right +// 3. Add Riemann solvers for external flux +// 4. Add Riemann solvers for internal flux and DG terms +// 5. Try other choices of variables h,hu,hv, Bova-Carey symmetrization? + +#define GLOBAL_FCT 0 +#define POWER_SMOOTHNESS_INDICATOR 4 +#define VEL_FIX_POWER 2. +#define REESTIMATE_MAX_EDGE_BASED_CFL 0 +#define LAMBDA_MGN 1 +#define IF_BOTH_GAMMA_BRANCHES 0 + +namespace proteus { + +// for mGN stuff "max" wave speeds. See section 4.4 of first mGN paper by +// Guermond, Popov, Tovar, Kees for formulas +inline double GN_nu1(const double &g, const double &hL, const double &uL, + const double &etaL, const double &meshSizeL) { + + double augL = LAMBDA_MGN / (3. * meshSizeL) * (6. * hL + 12. * (hL - etaL)); + + if (etaL >= hL) { + augL = LAMBDA_MGN / (3. * meshSizeL) * (6. * hL); + } + augL = augL * std::pow(meshSizeL / fmax(meshSizeL, hL), 2); + + return uL - sqrt(g * hL) * sqrt(1. + augL); +} +inline double GN_nu3(const double &g, const double &hR, const double &uR, + const double &etaR, const double &meshSizeR) { + // See section 4.4 of first mGN paper by Guermond, Popov, Tovar, Kees for + // formulas + double augR = LAMBDA_MGN / (3. * meshSizeR) * (6. * hR + 12. * (hR - etaR)); + + if (etaR >= hR) { + augR = LAMBDA_MGN / (3. * meshSizeR) * (6. * hR); + } + augR = augR * std::pow(meshSizeR / fmax(meshSizeR, hR), 2); + return uR + sqrt(g * hR) * sqrt(1 + augR); +} + +// FOR CELL BASED ENTROPY VISCOSITY +inline double ENTROPY(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return 0.5 * + (g * h * h + one_over_hReg * (hu * hu + hv * hv) + 2. * g * h * z); +} +inline double DENTROPY_DH(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return g * h - 0.5 * (hu * hu + hv * hv) * std::pow(one_over_hReg, 2) + g * z; +} +inline double DENTROPY_DHU(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return hu * one_over_hReg; +} +inline double DENTROPY_DHV(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return hv * one_over_hReg; +} +inline double ENTROPY_FLUX1(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return (ENTROPY(g, h, hu, hv, z, one_over_hReg) + 0.5 * g * h * h + + g * h * z) * + hu * one_over_hReg; +} +inline double ENTROPY_FLUX2(const double &g, const double &h, const double &hu, + const double &hv, const double &z, + const double &one_over_hReg) { + return (ENTROPY(g, h, hu, hv, z, one_over_hReg) + 0.5 * g * h * h + + g * h * z) * + hv * one_over_hReg; +} +// FOR ESTIMATING MAX WAVE SPEEDS, GIVE REFERENCE +inline double f(const double &g, const double &h, const double &hZ) { + return ((h <= hZ) ? 2. * (sqrt(g * h) - sqrt(g * hZ)) + : (h - hZ) * sqrt(0.5 * g * (h + hZ) / h / hZ)); +} +inline double phi(const double &g, const double &h, const double &hL, + const double &hR, const double &uL, const double &uR) { + return (f(g, h, hL) + f(g, h, hR) + uR - uL); +} +inline double fp(const double &g, const double &h, const double &hZ) { + return ((h <= hZ) + ? sqrt(g / h) + : g * (2 * h * h + h * hZ + hZ * hZ) / + (2 * sqrt(2 * g) * h * h * hZ * sqrt(1 / h + 1 / hZ))); +} +inline double phip(const double &g, const double &h, const double &hL, + const double &hR) { + return (fp(g, h, hL) + fp(g, h, hR)); +} +inline double nu1(const double &g, const double &hStar, const double &hL, + const double &uL) { + return (uL - sqrt(g * hL) * sqrt((1 + fmax((hStar - hL) / 2 / hL, 0.0)) * + (1 + fmax((hStar - hL) / hL, 0.)))); +} +inline double nu3(const double &g, const double &hStar, const double &hR, + const double &uR) { + return (uR + sqrt(g * hR) * sqrt((1 + fmax((hStar - hR) / 2 / hR, 0.0)) * + (1 + fmax((hStar - hR) / hR, 0.)))); +} +inline double phiDiff(const double &g, const double &h1k, const double &h2k, + const double &hL, const double &hR, const double &uL, + const double &uR) { + return ((phi(g, h2k, hL, hR, uL, uR) - phi(g, h1k, hL, hR, uL, uR)) / + (h2k - h1k)); +} +inline double phiDDiff1(const double &g, const double &h1k, const double &h2k, + const double &hL, const double &hR, const double &uL, + const double &uR) { + return ((phiDiff(g, h1k, h2k, hL, hR, uL, uR) - phip(g, h1k, hL, hR)) / + (h2k - h1k)); +} +inline double phiDDiff2(const double &g, const double &h1k, const double &h2k, + const double &hL, const double &hR, const double &uL, + const double &uR) { + return ((phip(g, h2k, hL, hR) - phiDiff(g, h1k, h2k, hL, hR, uL, uR)) / + (h2k - h1k)); +} +inline double hStarLFromQuadPhiFromAbove(const double &g, const double &hStarL, + const double &hStarR, const double &hL, + const double &hR, const double &uL, + const double &uR) { + return (hStarL - + 2 * phi(g, hStarL, hL, hR, uL, uR) / + (phip(g, hStarL, hL, hR) + + sqrt(std::pow(phip(g, hStarL, hL, hR), 2) - + 4 * phi(g, hStarL, hL, hR, uL, uR) * + phiDDiff1(g, hStarL, hStarR, hL, hR, uL, uR)))); +} +inline double hStarRFromQuadPhiFromBelow(const double &g, const double &hStarL, + const double &hStarR, const double &hL, + const double &hR, const double &uL, + const double &uR) { + return (hStarR - + 2 * phi(g, hStarR, hL, hR, uL, uR) / + (phip(g, hStarR, hL, hR) + + sqrt(std::pow(phip(g, hStarR, hL, hR), 2) - + 4 * phi(g, hStarR, hL, hR, uL, uR) * + phiDDiff2(g, hStarL, hStarR, hL, hR, uL, uR)))); +} +} // namespace proteus + +namespace proteus { +class GN_SW2DCV_base { +public: + std::valarray Rneg, Rpos, Rneg_heta, Rpos_heta, hLow, huLow, hvLow, + hetaLow, hwLow, Kmax; + virtual ~GN_SW2DCV_base() {} + virtual void + FCTStep(double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, xt::pyarray& limited_hvnp1, + xt::pyarray& limited_hetanp1, xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, xt::pyarray& hReg, + int LUMPED_MASS_MATRIX, + // LOCAL LIMITING +<<<<<<< HEAD + double *dLow, double *hBT, double *huBT, double *hvBT, double *hetaBT, + double *hwBT) = 0; + virtual void convexLimiting( + double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs + double *lumped_mass_matrix, // lumped mass matrix (as vector) + double *h_old, // DOFs of solution at last stage + double *hu_old, double *hv_old, double *heta_old, double *hw_old, + double *b_dof, + double *high_order_hnp1, // DOFs of high order solution at tnp1 + double *high_order_hunp1, double *high_order_hvnp1, + double *high_order_hetanp1, double *high_order_hwnp1, + double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, + double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, + double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, + double *limited_hetanp1, double *limited_hwnp1, + int *csrRowIndeces_DofLoops, // csr row indeces + int *csrColumnOffsets_DofLoops, // csr column offsets + double *MassMatrix, // mass matrix + double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, + int LUMPED_MASS_MATRIX, + // LOCAL LIMITING + double *dLow, double *hBT, double *huBT, double *hvBT, double *hetaBT, + double *hwBT, double *new_SourceTerm_hu, double *new_SourceTerm_hv, + double *new_SourceTerm_heta, double *new_SourceTerm_hw) = 0; +======= + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, + xt::pyarray& hwBT) = 0; + virtual void + convexLimiting(double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, + xt::pyarray& hw_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, xt::pyarray& limited_hetanp1, + xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, + // LOCAL LIMITING + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, + xt::pyarray& hetaBT, xt::pyarray& hwBT) = 0; +>>>>>>> dceecb29d... GN_SW2DCV + virtual double calculateEdgeBasedCFL( + double g, + int numDOFsPerEqn, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, + int debug) = 0; + virtual void calculateResidual( // last EDGE BASED version + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, + double MOVING_DOMAIN, // 0 or 1 + xt::pyarray& mesh_l2g, xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& heta_dof_old, xt::pyarray& hw_dof_old, xt::pyarray& b_dof, xt::pyarray& h_dof, + xt::pyarray& hu_dof, xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& heta_dof_sge, xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, + int offset_heta, int offset_hw, int stride_h, int stride_hu, + int stride_hv, int stride_heta, int stride_hw, xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h, + // C matrices + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, + // PARAMETERS FOR EDGE BASED STABILIZATION + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + // LUMPED MASS MATRIX + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, + // SAVE SOLUTION (mql) + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, xt::pyarray& hetanp1_at_quad_point, + xt::pyarray& hwnp1_at_quad_point, + // TO COMPUTE LOW ORDER + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + // FOR FCT + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, + int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, + // Quant of interests + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + // NORMAL COMPONENTS +<<<<<<< HEAD + int COMPUTE_NORMALS, double *normalx, double *normaly, double *dLow, + double *hBT, double *huBT, double *hvBT, double *hetaBT, double *hwBT, + int lstage, double *new_SourceTerm_hu, double *new_SourceTerm_hv, + double *new_SourceTerm_heta, double *new_SourceTerm_hw) = 0; +======= + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT, + int lstage) = 0; +>>>>>>> dceecb29d... GN_SW2DCV + virtual void calculateMassMatrix( // element + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, xt::pyarray& h_dof_sge, + xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, xt::pyarray& heta_dof_sge, + xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, + // h + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, + // hu + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, + // hv + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, + // heta + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, + // hw + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, + // + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; + virtual void calculateLumpedMassMatrix( // element + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, + // h + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, + // hu + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, + // hv + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, + // heta + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, + // hw + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; +}; + +template +class GN_SW2DCV : public GN_SW2DCV_base { +public: + const int nDOF_test_X_trial_element; + CompKernelType ck; + GN_SW2DCV() + : nDOF_test_X_trial_element(nDOF_test_element * nDOF_trial_element), + ck() { + std::cout << "Constructing GN_SW2DCV());" << std::endl + << std::flush; + } + + inline double maxWaveSpeedSharpInitialGuess(double g, double nx, double ny, + double hL, double huL, double hvL, + double hetaL, double lumpedL, + double hR, double huR, double hvR, + double hetaR, double lumpedR, + double hEpsL, double hEpsR, + bool debugging) { + double lambda1, lambda3; + + double hVelL = nx * huL + ny * hvL; + double hVelR = nx * huR + ny * hvR; + double velL = 2.0 * hL / (hL * hL + std::pow(fmax(hL, hEpsL), 2)) * hVelL; + double velR = 2.0 * hR / (hR * hR + std::pow(fmax(hR, hEpsR), 2)) * hVelR; + double etaL = 2.0 * hL / (hL * hL + std::pow(fmax(hL, hEpsL), 2)) * hetaL; + double etaR = 2.0 * hR / (hR * hR + std::pow(fmax(hR, hEpsR), 2)) * hetaR; + double meshSizeL = sqrt(lumpedL); + double meshSizeR = sqrt(lumpedR); + + /* See equation 4.12 from mGN paper: + 1-eigenvalue: uL-sqrt(g*hL)*sqrt(1 + augL) + 3-eigenvalue: uR+sqrt(g*hR)*sqrt(1 + augR) + */ + lambda1 = GN_nu1(g, hL, velL, etaL, meshSizeL); + lambda3 = GN_nu3(g, hR, velR, etaR, meshSizeR); + + // if (debugging) { + // std::cout << "lambda 1 " << lambda1 << std::endl; + // std::cout << "lambda 3 " << lambda3 << std::endl; + // std::cout << "hL " << hL << " velL " << velL << " etaL " << etaL + // << " hetaL " << hetaL << std::endl; + // std::cout << "hR " << hR << " velR " << velR << " etaR " << etaR + // << " hetaR " << hetaR << std::endl; + // } + return fmax(fabs(lambda1), fabs(lambda3)); + } + +// Don't need this right now but keeping it just in case we need it later +#if 0 + inline double maxWaveSpeedIterativeProcess(double g, double nx, double ny, + double hL, double huL, double + hvL, double hR, double huR, + double hvR, double hEpsL, double + hEpsR, bool verbose) { + double tol = 1E-15; + // 1-eigenvalue: uL-sqrt(g*hL) + // 3-eigenvalue: uR+sqrt(g*hR) + + double hVelL = nx * huL + ny * hvL; + double hVelR = nx * huR + ny * hvR; + double velL = 2 * hL / (hL * hL + std::pow(fmax(hL, hEpsL), 2)) * hVelL; + double velR = 2 * hR / (hR * hR + std::pow(fmax(hR, hEpsR), 2)) * hVelR; + + double lambda1, lambda3; + + // CHECK IF BOTH STATES ARE DRY: + if (hL == 0 && hR == 0) { + lambda1 = 0.; + lambda3 = 0.; + return 0.; + } else if (hL == 0) // left dry state + { + lambda1 = velR - 2 * sqrt(g * hR); + lambda3 = velR + sqrt(g * hR); + return fmax(fabs(lambda1), fabs(lambda3)); + } else if (hR == 0) // right dry state + { + lambda1 = velL - sqrt(g * hL); + lambda3 = velL + 2 * sqrt(g * hL); + return fmax(fabs(lambda1), fabs(lambda3)); + } else { + //////////////////// + // ESTIMATE hStar // + //////////////////// + // Initial estimate of hStar0 from above. + // This is computed via phiR(h) >= phi(h) ---> hStar0 >= hStar + double hStar0 = 1; + double hStar = hStar0; + + ///////////////////////////////// + // ALGORITHM 1: Initialization // + ///////////////////////////////// + // Requires: tol + // Ensures: hStarL, hStarR + double hStarL, hStarR; + double hMin = fmin(hL, hR); + double hMax = fmin(hL, hR); + double phiMin = phi(g, hMin, hL, hR, velL, velR); + double phiMax = phi(g, hMax, hL, hR, velL, velR); + if (0 <= phiMin) { + // This is a 1- and 3-rarefactions situation. We know the solution in + // this case + lambda1 = velL - sqrt(g * hL); + lambda3 = velR + sqrt(g * hR); + + std::cout << "lambda Min, lambda Max: " << lambda1 << ", " << lambda3 + << std::endl; + + return fmax(fabs(lambda1), fabs(lambda3)); + } + if (phiMax == 0) // if hMax "hits" hStar (very unlikely) + { + hStar = hMax; + lambda1 = nu1(g, hStar, hL, velL); + lambda3 = nu3(g, hStar, hR, velR); + return fmax(fabs(lambda1), fabs(lambda3)); + } + double hStarTwoRarefactions = + std::pow(velL - velR + 2 * sqrt(g) * (sqrt(hL) + sqrt(hR)), 2) / 16 + / g; + if (phiMax < 0) // This is a 1- and 3-shock situation + { + hStarL = hMax; + hStarR = hStarTwoRarefactions; + } else // Here we have one shock and one rarefaction + { + hStarL = hMin; + hStarR = fmin(hMax, hStarTwoRarefactions); + } + + // improve estimate from below via one newton step (not required) + hStarL = fmax(hStarL, hStarR - phi(g, hStarR, hL, hR, velL, velR) / + phip(g, hStarR, hL, hR)); + // COMPUTE lambdaMin0 and lambdaMax0 + double nu11 = nu1(g, hStarR, hL, velL); + double nu12 = nu1(g, hStarL, hL, velL); + double nu31 = nu3(g, hStarL, hR, velR); + double nu32 = nu3(g, hStarR, hR, velR); + + double lambdaMin = fmax(fmax(nu31, 0), fmax(-nu12, 0)); + double lambdaMax = fmax(fmax(nu32, 0), fmax(-nu11, 0)); + + if (verbose) { + std::cout << "hStarL, hStarR: " << hStarL << ", " << hStarR << "\t" + << "lambda Min, lambda Max: " << lambdaMin << ", " + << lambdaMax << std::endl; + } + // CHECK IF TOL IS SATISFIED. O.W. GOT TO ALGORITHM 2 // + if (lambdaMin > 0 && lambdaMax / lambdaMin - 1 <= tol) + return lambdaMax; + else // Proceed to algorithm 2 + { + /////////////////////////////////////////// + // ALGORITHM 2: ESTIMATION OF LAMBDA MAX // + /////////////////////////////////////////// + // Requires: hStarL, hStarR + // Ensures: lambdaMax + int aux_counter = 0; + while (true) { + aux_counter++; + // Start having lambdaMin and lambdaMax + // Check if current lambdaMin and lambdaMax satisfy the tolerance + if (verbose) { + std::cout << lambdaMin << ", " << lambdaMax << std::endl; + } + if (lambdaMin > 0 && lambdaMax / lambdaMin - 1 <= tol) + return lambdaMax; + // Check for round off error + if (phi(g, hStarL, hL, hR, velL, velR) > 0 || + phi(g, hStarR, hL, hR, velL, velR) < 0) + return lambdaMax; + + // Save old estimates of hStar + double hStarL_old = hStarL; + double hStarR_old = hStarR; + // Compute new estimates on hStarL and hStarR + // NOTE (MQL): hStarL and hStarR must be computed using the old + values hStarL = hStarLFromQuadPhiFromAbove(g, hStarL_old, + hStarR_old, hL, hR, + velL, velR); + hStarR = hStarRFromQuadPhiFromBelow(g, hStarL_old, hStarR_old, hL, + hR, + velL, velR); + + // Compute lambdaMax and lambdaMin + nu11 = nu1(g, hStarR, hL, velL); + nu12 = nu1(g, hStarL, hL, velL); + nu31 = nu3(g, hStarL, hR, velR); + nu32 = nu3(g, hStarR, hR, velR); + + lambdaMin = fmax(fmax(nu31, 0), fmax(-nu12, 0)); + lambdaMax = fmax(fmax(nu32, 0), fmax(-nu11, 0)); + + if (aux_counter > 1000) // TMP + { + std::cout << "**** AUX COUNTER > 1000... aborting!" << std::endl; + std::cout << "**** Initial guess hStar: " << hStar0 << std::endl; + + hStar = hStar0; + lambda1 = nu1(g, hStar, hL, velL); + lambda3 = nu3(g, hStar, hR, velR); + std::cout << "**** Initial estimate of max wave speed: " + << fmax(fabs(lambda1), fabs(lambda3)) << std::endl; + + abort(); + } + // else + //{ + // std::cout << "*****... AUX COUNTER: " << aux_counter << + std::endl; + // //TMP + //} + } + } + } + } +#endif + + /* I don't think this does anything of importance. -EJT */ + inline void calculateCFL(const double &elementDiameter, const double &g, + const double &h, const double &hu, const double &hv, + const double hEps, double &cfl) { + double cflx, cfly, c = sqrt(fmax(g * hEps, g * h)); + double u = 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hu; + double v = 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hv; + + if (u > 0.0) + cflx = (u + c) / elementDiameter; + else + cflx = fabs(u - c) / elementDiameter; + + if (v > 0.0) + cfly = (v + c) / elementDiameter; + else + cfly = fabs(v - c) / elementDiameter; + cfl = sqrt(cflx * cflx + cfly * cfly); // hack, conservative estimate + } + + // Don't use FCTstep + void FCTStep(double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, xt::pyarray& limited_hetanp1, + xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, xt::pyarray& dLow, xt::pyarray& hBT, + xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT) { + Rneg.resize(numDOFs, 0.0); + Rpos.resize(numDOFs, 0.0); + Rneg_heta.resize(numDOFs, 0.0); + Rpos_heta.resize(numDOFs, 0.0); + hLow.resize(numDOFs, 0.0); + huLow.resize(numDOFs, 0.0); + hvLow.resize(numDOFs, 0.0); + hetaLow.resize(numDOFs, 0.0); + hwLow.resize(numDOFs, 0.0); + + /* For reference, see section 6.3 of friction shallow water paper + by Guermond, Quezada De Luna, Popov, Kees, Farthing */ + + //////////////////////// + // FIRST LOOP in DOFs // + //////////////////////// + int ij = 0; + for (int i = 0; i < numDOFs; i++) { + // read some vectors + double high_order_hnp1i = high_order_hnp1[i]; + double hi = h_old[i]; + double hui = hu_old[i]; + double hvi = hv_old[i]; + double high_order_hetanp1i = high_order_hetanp1[i]; + double hetai = heta_old[i]; + double hwi = hw_old[i]; + double Zi = b_dof[i]; + double mi = lumped_mass_matrix[i]; + + double hiMin = hi; + double hiMax = hi; + double Pnegi = 0., Pposi = 0.; + + /* Actually it's probably better to put this all + in a function with inputs to be able to limit any of the conserved + variables - EJT */ + + // For limiting heta + double hetai_Min = hetai; + double hetai_Max = hetai; + double Pnegi_heta = 0., Pposi_heta = 0.; + + // LOW ORDER SOLUTION without extended source term. Eqn 6.23 + hLow[i] = hi; + huLow[i] = hui; + hvLow[i] = hvi; + hetaLow[i] = hetai; + hwLow[i] = hwi; + + // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + + // read some vectors + double hj = h_old[j]; + double hetaj = heta_old[j]; + double Zj = b_dof[j]; + // COMPUTE STAR SOLUTION // hStar, huStar and hvStar + double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj)); + double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj)); + + // i-th row of flux correction matrix + double ML_minus_MC = (LUMPED_MASS_MATRIX == 1 + ? 0. + : (i == j ? 1. : 0.) * mi - MassMatrix[ij]); + double FluxCorrectionMatrix1 = + ML_minus_MC * (high_order_hnp1[j] - hj - (high_order_hnp1i - hi)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hStarji - hStarij) + + dt * muH_minus_muL[ij] * (hj - hi); + + double FluxCorrectionMatrix_heta = + ML_minus_MC * + (high_order_hetanp1[j] - hetaj - (high_order_hetanp1i - hi)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hStarji - hStarij) + + dt * muH_minus_muL[ij] * (hetaj - hetai); + + // COMPUTE P VECTORS // + Pnegi += + FluxCorrectionMatrix1 * ((FluxCorrectionMatrix1 < 0) ? 1. : 0.); + Pposi += + FluxCorrectionMatrix1 * ((FluxCorrectionMatrix1 > 0) ? 1. : 0.); + + Pnegi_heta += FluxCorrectionMatrix_heta * + ((FluxCorrectionMatrix_heta < 0) ? 1. : 0.); + Pposi_heta += FluxCorrectionMatrix_heta * + ((FluxCorrectionMatrix_heta > 0) ? 1. : 0.); + + // COMPUTE LOCAL BOUNDS // + hiMin = std::min(hiMin, hBT[ij]); + hiMax = std::max(hiMax, hBT[ij]); + hetai_Min = std::min(hetai_Min, hetaBT[ij]); + hetai_Max = std::max(hetai_Max, hetaBT[ij]); + + // COMPUTE LOW ORDER SOLUTION (WITHOUT EXTENDED SOURCE) // + // SEE EQUATION 6.23 FROM SW FRICTION PAPER -EJT // + if (i != j) { + hLow[i] += hi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hBT[ij]); + huLow[i] += hui * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * huBT[ij]); + hvLow[i] += hvi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hvBT[ij]); + hetaLow[i] += hetai * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hetaBT[ij]); + hwLow[i] += hwi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hwBT[ij]); + } + // update ij + ij += 1; + } + // clean up hLow from round off error + if (hLow[i] < hEps) + hLow[i] = 0; + /////////////////////// + // COMPUTE Q VECTORS // + /////////////////////// + if (GLOBAL_FCT == 1) + hiMin = 0; + + double Qnegi = mi * (hiMin - hLow[i]); + double Qposi = mi * (hiMax - hLow[i]); + + double Qnegi_heta = + mi * (hetai_Min - (hetaLow[i] - extendedSourceTerm_heta[i])); + double Qposi_heta = + mi * (hetai_Max - (hetaLow[i] - extendedSourceTerm_heta[i])); + + /////////////////////// + // COMPUTE R VECTORS // + /////////////////////// + if (high_order_hnp1[i] <= hReg[i]) // hEps + { + Rneg[i] = 0.; + Rpos[i] = 0.; + // for heta - EJT + Rneg_heta[i] = 0.; + Rpos_heta[i] = 0.; + } else { + Rneg[i] = ((Pnegi == 0) ? 1. : std::min(1.0, Qnegi / Pnegi)); + Rpos[i] = ((Pposi == 0) ? 1. : std::min(1.0, Qposi / Pposi)); + // for heta + Rneg_heta[i] = + ((Pnegi_heta == 0) ? 1. : std::min(1.0, Qnegi_heta / Pnegi_heta)); + Rpos_heta[i] = + ((Pposi_heta == 0) ? 1. : std::min(1.0, Qposi_heta / Pposi_heta)); + } + } // i DOFs + + ////////////////////// + // COMPUTE LIMITERS // + ////////////////////// + ij = 0; + for (int i = 0; i < numDOFs; i++) { + /* read some vectors */ + // high order + double high_order_hnp1i = high_order_hnp1[i]; + double high_order_hunp1i = high_order_hunp1[i]; + double high_order_hvnp1i = high_order_hvnp1[i]; + double high_order_hetanp1i = high_order_hetanp1[i]; + double high_order_hwnp1i = high_order_hwnp1[i]; + // old + double hi = h_old[i]; + double huni = hu_old[i]; + double hvni = hv_old[i]; + double hetani = heta_old[i]; + double hwni = hw_old[i]; + double Zi = b_dof[i]; + double mi = lumped_mass_matrix[i]; + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); // hEps + + double ith_Limiter_times_FluxCorrectionMatrix1 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix2 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix3 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix4 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix5 = 0.; + + // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + // read some vectors + double hj = h_old[j]; + double hunj = hu_old[j]; + double hvnj = hv_old[j]; + double hetanj = heta_old[j]; + double hwnj = hw_old[j]; + double Zj = b_dof[j]; + double one_over_hjReg = + 2 * hj / (hj * hj + std::pow(fmax(hj, hEps), 2)); // hEps + + /* COMPUTE STAR SOLUTIONS: + hStar, huStar, hvStar, hetaStar, and hwStar + */ + double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj)); + double huStarij = huni * hStarij * one_over_hiReg; + double hvStarij = hvni * hStarij * one_over_hiReg; + double hetaStarij = hetani * std::pow(hStarij * one_over_hiReg, 2); + double hwStarij = hwni * hStarij * one_over_hiReg; + + double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj)); + double huStarji = hunj * hStarji * one_over_hjReg; + double hvStarji = hvnj * hStarji * one_over_hjReg; + double hetaStarji = hetanj * std::pow(hStarji * one_over_hjReg, 2); + double hwStarji = hwnj * hStarji * one_over_hjReg; + + // COMPUTE FLUX CORRECTION MATRICES + double ML_minus_MC = (LUMPED_MASS_MATRIX == 1 + ? 0. + : (i == j ? 1. : 0.) * mi - MassMatrix[ij]); + double FluxCorrectionMatrix1 = + ML_minus_MC * (high_order_hnp1[j] - hj - (high_order_hnp1i - hi)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hStarji - hStarij) + + dt * muH_minus_muL[ij] * (hj - hi); + + double FluxCorrectionMatrix2 = + ML_minus_MC * + (high_order_hunp1[j] - hunj - (high_order_hunp1i - huni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (huStarji - huStarij) + + dt * muH_minus_muL[ij] * (hunj - huni); + + double FluxCorrectionMatrix3 = + ML_minus_MC * + (high_order_hvnp1[j] - hvnj - (high_order_hvnp1i - hvni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hvStarji - hvStarij) + + dt * muH_minus_muL[ij] * (hvnj - hvni); + + double FluxCorrectionMatrix4 = + ML_minus_MC * (high_order_hetanp1[j] - hetanj - + (high_order_hetanp1i - hetani)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * + (hetaStarji - hetaStarij) + + dt * muH_minus_muL[ij] * (hetanj - hetani); + + double FluxCorrectionMatrix5 = + ML_minus_MC * + (high_order_hwnp1[j] - hwnj - (high_order_hwnp1i - hwni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hwStarji - hwStarij) + + dt * muH_minus_muL[ij] * (hwnj - hwni); + + // COMPUTE LIMITER based on water height + double Lij = 0.; + if (FluxCorrectionMatrix1 >= 0) + Lij = std::min(Rpos[i], Rneg[j]); + else + Lij = std::min(Rneg[i], Rpos[j]); + + // COMPUTE LIMITER based on heta -EJT + // Note that we set lij = min(lij_h,lij_heta) + if (FluxCorrectionMatrix4 >= 0) + Lij = std::min(Lij, std::min(Rpos_heta[i], Rneg_heta[j])); + else + Lij = std::min(Lij, std::min(Rneg_heta[i], Rpos_heta[j])); + + // take off all instances of GLOBAL_FCT -EJT + if (GLOBAL_FCT == 1) + Lij = (FluxCorrectionMatrix1 >= 0. ? std::min(1., Rneg[j]) + : std::min(Rneg[i], 1.)); + + // COMPUTE LIMITED FLUX // + ith_Limiter_times_FluxCorrectionMatrix1 += Lij * FluxCorrectionMatrix1; + ith_Limiter_times_FluxCorrectionMatrix2 += Lij * FluxCorrectionMatrix2; + ith_Limiter_times_FluxCorrectionMatrix3 += Lij * FluxCorrectionMatrix3; + ith_Limiter_times_FluxCorrectionMatrix4 += Lij * FluxCorrectionMatrix4; + ith_Limiter_times_FluxCorrectionMatrix5 += Lij * FluxCorrectionMatrix5; + + // update ij + ij += 1; + } + + double one_over_mi = 1.0 / lumped_mass_matrix[i]; + limited_hnp1[i] = + hLow[i] + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix1; + limited_hunp1[i] = + ((huLow[i] - + dt / mi * extendedSourceTerm_hu[i]) // low_order_hunp1+... + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix2); + limited_hvnp1[i] = + ((hvLow[i] - + dt / mi * extendedSourceTerm_hv[i]) // low_order_hvnp1+... + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix3); + limited_hetanp1[i] = + ((hetaLow[i] - + dt / mi * extendedSourceTerm_heta[i]) // low_order_hetanp1+... + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix4); + limited_hwnp1[i] = + ((hwLow[i] - + dt / mi * extendedSourceTerm_hw[i]) // low_order_hwnp1+... + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix5); + + if (limited_hnp1[i] < -hEps && dt < 1.0) { + std::cout << "Limited water height is negative: " + << "hLow: " << hLow[i] << "\t" + << "hHigh: " << limited_hnp1[i] << "\t" + << " ... aborting!" << std::endl; + abort(); + } else { + // clean up uHigh from round off error + // if (limited_hnp1[i] < hEps) + // limited_hnp1[i] = 0; + // double aux = fmax(limited_hnp1[i],hEps); // hEps + double aux = + fmax(limited_hnp1[i], hReg[i]); // hReg makes the code more robust + limited_hunp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hvnp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hetanp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hwnp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + } + } + } + + void convexLimiting( + double dt, + int NNZ, // number on non-zero entries on sparsity pattern + int numDOFs, // number of DOFs +<<<<<<< HEAD + double *lumped_mass_matrix, // lumped mass matrix (as vector)) + double *h_old, // DOFs of solution at last stage + double *hu_old, double *hv_old, double *heta_old, double *hw_old, + double *b_dof, + double *high_order_hnp1, // DOFs of high order solution at tnp1 + double *high_order_hunp1, double *high_order_hvnp1, + double *high_order_hetanp1, double *high_order_hwnp1, + double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, + double *extendedSourceTerm_heta, double *extendedSourceTerm_hw, + double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, + double *limited_hetanp1, double *limited_hwnp1, + int *csrRowIndeces_DofLoops, // csr row indeces + int *csrColumnOffsets_DofLoops, // csr column offsets + double *MassMatrix, // mass matrix + double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, + int LUMPED_MASS_MATRIX, double *dLow, double *hBT, double *huBT, + double *hvBT, double *hetaBT, double *hwBT, double *new_SourceTerm_hu, + double *new_SourceTerm_hv, double *new_SourceTerm_heta, + double *new_SourceTerm_hw) { + +======= + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& heta_old, xt::pyarray& hw_old, + xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& high_order_hetanp1, xt::pyarray& high_order_hwnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, xt::pyarray& limited_hvnp1, + xt::pyarray& limited_hetanp1, xt::pyarray& limited_hwnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, xt::pyarray& hReg, + int LUMPED_MASS_MATRIX, xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, + xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT) { +>>>>>>> dceecb29d... GN_SW2DCV + Rneg.resize(numDOFs, 0.0); + Rpos.resize(numDOFs, 0.0); + Rneg_heta.resize(numDOFs, 0.0); + Rpos_heta.resize(numDOFs, 0.0); + hLow.resize(numDOFs, 0.0); + huLow.resize(numDOFs, 0.0); + hvLow.resize(numDOFs, 0.0); + hetaLow.resize(numDOFs, 0.0); + hwLow.resize(numDOFs, 0.0); + Kmax.resize(numDOFs, 0.0); + + ////////////////////////////// + // For relaxation of bounds // + ////////////////////////////// + + std::valarray urelax; + urelax.resize(numDOFs, 0.0); + std::valarray drelax; + drelax.resize(numDOFs, 0.0); + + // for h + std::valarray delta_Sqd_h; + delta_Sqd_h.resize(numDOFs, 0.0); + std::valarray bar_deltaSqd_h; + bar_deltaSqd_h.resize(numDOFs, 0.0); + // for heta + std::valarray delta_Sqd_heta; + delta_Sqd_heta.resize(numDOFs, 0.0); + std::valarray bar_deltaSqd_heta; + bar_deltaSqd_heta.resize(numDOFs, 0.0); + // for kinetic energy + std::valarray kin; + kin.resize(numDOFs, 0.0); + std::valarray delta_Sqd_kin; + delta_Sqd_kin.resize(numDOFs, 0.0); + std::valarray bar_deltaSqd_kin; + bar_deltaSqd_kin.resize(numDOFs, 0.0); + + double size_of_domain = 0.0; + + // loop to define size of domain and kinetic energy + for (int i = 0; i < numDOFs; i++) { + size_of_domain += lumped_mass_matrix[i]; + kin[i] = 0.5 * (hu_old[i] * hu_old[i] + hv_old[i] * hv_old[i]); + kin[i] *= 2.0 * h_old[i] / + (h_old[i] * h_old[i] + std::pow(fmax(h_old[i], hEps), 2)); + } + + // First loop + for (int i = 0; i < numDOFs; i++) { + urelax[i] = + 1.0 + + 2.0 * std::pow(sqrt(sqrt(lumped_mass_matrix[i] / size_of_domain)), 3); + drelax[i] = + 1.0 - + 2.0 * std::pow(sqrt(sqrt(lumped_mass_matrix[i] / size_of_domain)), 3); + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + if (i != j) { + delta_Sqd_h[i] += h_old[i] - h_old[j]; + delta_Sqd_heta[i] += heta_old[i] - heta_old[j]; + delta_Sqd_kin[i] += kin[i] - kin[j]; + } + } // j loop ends here + } // i loops ends here + + // Second loop + for (int i = 0; i < numDOFs; i++) { + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + if (i != j) { + bar_deltaSqd_h[i] += delta_Sqd_h[j] + delta_Sqd_h[i]; + bar_deltaSqd_heta[i] += delta_Sqd_heta[j] + delta_Sqd_heta[i]; + bar_deltaSqd_kin[i] += delta_Sqd_kin[j] + delta_Sqd_kin[i]; + } + } // j loop ends here + } // i loops ends here + + for (int i = 0; i < numDOFs; i++) { + bar_deltaSqd_h[i] = + bar_deltaSqd_h[i] / + (csrRowIndeces_DofLoops[i + 1] - csrRowIndeces_DofLoops[i]) / 2.0; + bar_deltaSqd_heta[i] = + bar_deltaSqd_heta[i] / + (csrRowIndeces_DofLoops[i + 1] - csrRowIndeces_DofLoops[i]) / 2.0; + bar_deltaSqd_kin[i] = + bar_deltaSqd_kin[i] / + (csrRowIndeces_DofLoops[i + 1] - csrRowIndeces_DofLoops[i]) / 2.0; + } + + ///////////////////////////// + // FIRST Main LOOP in DOFs // + ///////////////////////////// + int ij = 0; + for (int i = 0; i < numDOFs; i++) { + // read some vectors + double high_order_hnp1i = high_order_hnp1[i]; + double hi = h_old[i]; + double hui = hu_old[i]; + double hvi = hv_old[i]; + double high_order_hetanp1i = high_order_hetanp1[i]; + double hetai = heta_old[i]; + double hwi = hw_old[i]; + double Zi = b_dof[i]; + double mi = lumped_mass_matrix[i]; + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); // hEps + + // For limiting h, initializing hMin and hMax + double hiMin = hi; + double hiMax = hi; + double Pnegi = 0., Pposi = 0.; + + // For limiting heta, initializing heta_Min, heta_max + double hetai_Min = hetai; + double hetai_Max = hetai; + double Pnegi_heta = 0., Pposi_heta = 0.; + + /* LOW ORDER SOLUTION */ + hLow[i] = hi; + huLow[i] = hui; + hvLow[i] = hvi; + hetaLow[i] = hetai; + hwLow[i] = hwi; + Kmax[i] = 0; + + // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + double psi_ij = 0; + double one_over_hBT = + 2.0 * hBT[ij] / + (hBT[ij] * hBT[ij] + std::pow(fmax(hBT[ij], hEps), 2)); + psi_ij = one_over_hBT * (huBT[ij] * huBT[ij] + hvBT[ij] * hvBT[ij]) / + 2.0; // Eqn (6.31) + Kmax[i] = fmax(psi_ij, Kmax[i]); + + // read some vectors + double hj = h_old[j]; + double one_over_hjReg = + 2 * hj / (hj * hj + std::pow(fmax(hj, hEps), 2)); // hEps + double hetaj = heta_old[j]; + double Zj = b_dof[j]; + + // COMPUTE STAR SOLUTION // hStar, huStar and hvStar + double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj)); + double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj)); + double hetaStarji = hetaj * std::pow(hStarji * one_over_hjReg, 2); + double hetaStarij = hetai * std::pow(hStarij * one_over_hiReg, 2); + + // i-th row of flux correction matrix + double ML_minus_MC = (LUMPED_MASS_MATRIX == 1 + ? 0. + : (i == j ? 1. : 0.) * mi - MassMatrix[ij]); + double FluxCorrectionMatrix1 = + ML_minus_MC * (high_order_hnp1[j] - hj - (high_order_hnp1i - hi)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hStarji - hStarij) + + dt * muH_minus_muL[ij] * (hj - hi); + + double FluxCorrectionMatrix_heta = + ML_minus_MC * (high_order_hetanp1[j] - hetaj - + (high_order_hetanp1i - hetai)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * + (hetaStarji - hetaStarij) + + dt * muH_minus_muL[ij] * (hetaj - hetai); + + // COMPUTE P VECTORS // + Pnegi += + FluxCorrectionMatrix1 * ((FluxCorrectionMatrix1 < 0) ? 1. : 0.); + Pposi += + FluxCorrectionMatrix1 * ((FluxCorrectionMatrix1 > 0) ? 1. : 0.); + + Pnegi_heta += FluxCorrectionMatrix_heta * + ((FluxCorrectionMatrix_heta < 0) ? 1. : 0.); + Pposi_heta += FluxCorrectionMatrix_heta * + ((FluxCorrectionMatrix_heta > 0) ? 1. : 0.); + + // COMPUTE LOCAL BOUNDS // + hiMin = std::min(hiMin, hBT[ij]); + hiMax = std::max(hiMax, hBT[ij]); + + hetai_Min = std::min(hetai_Min, hetaBT[ij]); + hetai_Max = std::max(hetai_Max, hetaBT[ij]); + + // Then do relaxation of bounds here. If confused, see (4.12) of Euler + // convex limiting paper. Turn this off for now + hiMin = std::max(drelax[i] * hiMin, + hiMin - std::abs(bar_deltaSqd_h[i]) / 2.0); + hetai_Min = std::max(drelax[i] * hetai_Min, + hetai_Min - std::abs(bar_deltaSqd_heta[i]) / 2.0); + + hiMax = std::min(urelax[i] * hiMax, + hiMax + std::abs(bar_deltaSqd_h[i]) / 2.0); + hetai_Max = std::min(urelax[i] * hetai_Max, + hetai_Max + std::abs(bar_deltaSqd_heta[i]) / 2.0); + Kmax[i] = std::min(urelax[i] * Kmax[i], + Kmax[i] + std::abs(bar_deltaSqd_kin[i]) / 2.0); + + /* COMPUTE LOW ORDER SOLUTION. See EQN 6.23 in + * SW friction paper */ + if (i != j) { + hLow[i] += hi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hBT[ij]); + huLow[i] += hui * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * huBT[ij]); + hvLow[i] += hvi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hvBT[ij]); + hetaLow[i] += hetai * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hetaBT[ij]); + hwLow[i] += hwi * (-dt / mi * 2 * dLow[ij]) + + dt / mi * (2 * dLow[ij] * hwBT[ij]); + } + // UPDATE ij // + ij += 1; + } // j loop ends here + + // clean up hLow from round off error + if (hLow[i] < hEps) + hLow[i] = 0.0; + + /////////////////////// + // COMPUTE Q VECTORS // + /////////////////////// + double Qnegi = std::min(mi * (hiMin - hLow[i]), 0.0); + double Qposi = std::max(mi * (hiMax - hLow[i]), 0.0); + double Qnegi_heta = std::min(mi * (hetai_Min - hetaLow[i]), 0.0); + double Qposi_heta = std::max(mi * (hetai_Max - hetaLow[i]), 0.0); + + /////////////////////// + // COMPUTE R VECTORS // + /////////////////////// + if (high_order_hnp1[i] <= hEps) // hEps + { + Rneg[i] = 0.; + Rpos[i] = 0.; + Rneg_heta[i] = 0.; + Rpos_heta[i] = 0.; + } else { + Rneg[i] = ((Pnegi == 0) ? 1. : std::min(1.0, Qnegi / Pnegi)); + Rpos[i] = ((Pposi == 0) ? 1. : std::min(1.0, Qposi / Pposi)); + Rneg_heta[i] = + ((Pnegi_heta == 0) ? 1. : std::min(1.0, Qnegi_heta / Pnegi_heta)); + Rpos_heta[i] = + ((Pposi_heta == 0) ? 1. : std::min(1.0, Qposi_heta / Pposi_heta)); + } + } // i DOFs + + ////////////////////// + // COMPUTE LIMITERS // + ////////////////////// + ij = 0; + for (int i = 0; i < numDOFs; i++) { + // read some vectors + double high_order_hnp1i = high_order_hnp1[i]; + double high_order_hunp1i = high_order_hunp1[i]; + double high_order_hvnp1i = high_order_hvnp1[i]; + double high_order_hetanp1i = high_order_hetanp1[i]; + double high_order_hwnp1i = high_order_hwnp1[i]; + double hi = h_old[i]; + double huni = hu_old[i]; + double hvni = hv_old[i]; + double hetani = heta_old[i]; + double hwni = hw_old[i]; + double Zi = b_dof[i]; + double mi = lumped_mass_matrix[i]; + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); // hEps + + double ith_Limiter_times_FluxCorrectionMatrix1 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix2 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix3 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix4 = 0.; + double ith_Limiter_times_FluxCorrectionMatrix5 = 0.; + + double ci = + Kmax[i] * hLow[i] - + 0.5 * (huLow[i] * huLow[i] + hvLow[i] * hvLow[i]); // for KE lim. + + // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + int j = csrColumnOffsets_DofLoops[offset]; + // read some vectors + double hj = h_old[j]; + double hunj = hu_old[j]; + double hvnj = hv_old[j]; + double hetanj = heta_old[j]; + double hwnj = hw_old[j]; + double Zj = b_dof[j]; + double one_over_hjReg = + 2 * hj / (hj * hj + std::pow(fmax(hj, hEps), 2)); // hEps + + // COMPUTE STAR SOLUTION // hStar, huStar, hvStar, hetaStar, and + // hwStar + double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj)); + double huStarij = huni * hStarij * one_over_hiReg; + double hvStarij = hvni * hStarij * one_over_hiReg; + double hetaStarij = hetani * std::pow(hStarij * one_over_hiReg, 2); + double hwStarij = hwni * std::pow(hStarij * one_over_hiReg, 2); + + double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj)); + double huStarji = hunj * hStarji * one_over_hjReg; + double hvStarji = hvnj * hStarji * one_over_hjReg; + double hetaStarji = hetanj * std::pow(hStarji * one_over_hjReg, 2); + double hwStarji = hwnj * std::pow(hStarij * one_over_hjReg, 2); + + // COMPUTE FLUX CORRECTION MATRICES + double ML_minus_MC = (LUMPED_MASS_MATRIX == 1 + ? 0. + : (i == j ? 1. : 0.) * mi - MassMatrix[ij]); + double FluxCorrectionMatrix1 = + ML_minus_MC * (high_order_hnp1[j] - hj - (high_order_hnp1i - hi)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hStarji - hStarij) + + dt * muH_minus_muL[ij] * (hj - hi); + + double FluxCorrectionMatrix2 = + ML_minus_MC * + (high_order_hunp1[j] - hunj - (high_order_hunp1i - huni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (huStarji - huStarij) + + dt * muH_minus_muL[ij] * (hunj - huni); + + double FluxCorrectionMatrix3 = + ML_minus_MC * + (high_order_hvnp1[j] - hvnj - (high_order_hvnp1i - hvni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hvStarji - hvStarij) + + dt * muH_minus_muL[ij] * (hvnj - hvni); + double FluxCorrectionMatrix4 = + ML_minus_MC * (high_order_hetanp1[j] - hetanj - + (high_order_hetanp1i - hetani)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * + (hetaStarji - hetaStarij) + + dt * muH_minus_muL[ij] * (hetanj - hetani); + + double FluxCorrectionMatrix5 = + ML_minus_MC * + (high_order_hwnp1[j] - hwnj - (high_order_hwnp1i - hwni)) + + dt * (dH_minus_dL[ij] - muH_minus_muL[ij]) * (hwStarji - hwStarij) + + dt * muH_minus_muL[ij] * (hwnj - hwni); + + // compute limiter based on water height + double Lij = 1.; + if (FluxCorrectionMatrix1 >= 0) + Lij = fmin(Lij, std::min(Rneg[j], Rpos[i])); + else + Lij = fmin(Lij, std::min(Rneg[i], Rpos[j])); + + // COMPUTE LIMITER based on heta -EJT + // Note that we set lij = min(lij_h,lij_heta) + if (FluxCorrectionMatrix4 >= 0) + Lij = fmin(Lij, std::min(Rneg_heta[j], Rpos_heta[i])); + else + Lij = fmin(Lij, std::min(Rneg_heta[i], Rpos_heta[j])); + + double lambdaj = + csrRowIndeces_DofLoops[i + 1] - csrRowIndeces_DofLoops[i] - 1; + double Ph_ij = FluxCorrectionMatrix1 / mi / lambdaj; + double Phu_ij = FluxCorrectionMatrix2 / mi / lambdaj; + double Phv_ij = FluxCorrectionMatrix3 / mi / lambdaj; + + double ai = -0.5 * (Phu_ij * Phu_ij + Phv_ij * Phv_ij); + double bi = Kmax[i] * Ph_ij - (huLow[i] * Phu_ij + hvLow[i] * Phv_ij); + + double r1 = ai == 0 + ? (bi == 0 ? 1. : -ci / bi) + : (-bi + std::sqrt(bi * bi - 4 * ai * ci)) / 2. / ai; + double r2 = ai == 0 + ? (bi == 0 ? 1. : -ci / bi) + : (-bi - std::sqrt(bi * bi - 4 * ai * ci)) / 2. / ai; + if (r1 < 0 && r2 < 0) { + r1 = 1.; + r2 = 1.; + } + double ri = fabs(fmax(r1, r2)); + + // root of jth-DOF (To compute transpose component) + double lambdai = + csrRowIndeces_DofLoops[j + 1] - csrRowIndeces_DofLoops[j] - 1; + double mj = lumped_mass_matrix[j]; + double cj = Kmax[j] * hLow[j] - + 0.5 * (huLow[j] * huLow[j] + hvLow[j] * hvLow[j]); + double Ph_ji = -FluxCorrectionMatrix1 / mj / lambdai; // Aij=-Aji + double Phu_ji = -FluxCorrectionMatrix2 / mj / lambdai; + double Phv_ji = -FluxCorrectionMatrix3 / mj / lambdai; + double aj = -0.5 * (Phu_ji * Phu_ji + Phv_ji * Phv_ji); + double bj = Kmax[j] * Ph_ji - (huLow[j] * Phu_ji + hvLow[j] * Phv_ji); + + r1 = aj == 0 ? (bj == 0 ? 1. : -cj / bj) + : (-bj + std::sqrt(bj * bj - 4 * aj * cj)) / 2. / aj; + r2 = aj == 0 ? (bj == 0 ? 1. : -cj / bj) + : (-bj - std::sqrt(bj * bj - 4 * aj * cj)) / 2. / aj; + if (r1 < 0 && r2 < 0) { + r1 = 1.; + r2 = 1.; + } + double rj = fabs(fmax(r1, r2)); + + // COMPUTE LIMITER // + Lij = fmin(fmin(ri, Lij), fmin(rj, Lij)); // Lij=Lji + + // COMPUTE LIMITED FLUX // + ith_Limiter_times_FluxCorrectionMatrix1 += Lij * FluxCorrectionMatrix1; + ith_Limiter_times_FluxCorrectionMatrix2 += Lij * FluxCorrectionMatrix2; + ith_Limiter_times_FluxCorrectionMatrix3 += Lij * FluxCorrectionMatrix3; + ith_Limiter_times_FluxCorrectionMatrix4 += Lij * FluxCorrectionMatrix4; + ith_Limiter_times_FluxCorrectionMatrix5 += Lij * FluxCorrectionMatrix5; + + // update ij + ij += 1; + } + double one_over_mi = 1.0 / lumped_mass_matrix[i]; + limited_hnp1[i] = + hLow[i] + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix1; + limited_hunp1[i] = + ((huLow[i] + dt / mi * new_SourceTerm_hu[i]) + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix2); + limited_hvnp1[i] = + ((hvLow[i] + dt / mi * new_SourceTerm_hv[i]) + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix3); + limited_hetanp1[i] = + ((hetaLow[i] - dt / mi * extendedSourceTerm_heta[i]) + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix4); + limited_hwnp1[i] = + ((hwLow[i] - dt / mi * extendedSourceTerm_hw[i]) + + one_over_mi * ith_Limiter_times_FluxCorrectionMatrix5); + + if (limited_hnp1[i] < -hEps && dt < 1.0) { + std::cout << "Limited water height is negative: " + << "hLow: " << hLow[i] << "\t" + << "hHigh: " << limited_hnp1[i] << "\t" + << "hEps: " << hEps << "\t" + << " ... aborting!" << std::endl; + abort(); + } else { + // clean up uHigh from round off error + if (limited_hnp1[i] < hEps) + limited_hnp1[i] = 0.0; + // // double aux = fmax(limited_hnp1[i], hEps); // hEps + double aux = + fmax(limited_hnp1[i], hEps); // hReg makes the code more robust + limited_hunp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hvnp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hetanp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + limited_hwnp1[i] *= 2 * std::pow(limited_hnp1[i], VEL_FIX_POWER) / + (std::pow(limited_hnp1[i], VEL_FIX_POWER) + + std::pow(aux, VEL_FIX_POWER)); + } + } + } + + double calculateEdgeBasedCFL( + double g, + int numDOFsPerEqn, // number of DOFs + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_dof_old, // DOFs of solution at last stage + xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, xt::pyarray& heta_dof_old, + xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, + int debug) { + + /* note that for the CFL condition, we use only the values of dij and + * don't do the dij = Max(dij,muij) thing */ + + std::valarray psi(numDOFsPerEqn); + double max_edge_based_cfl = 0.; + int ij = 0; + for (int i = 0; i < numDOFsPerEqn; i++) { + // solution at time tn for the ith DOF + double hi = h_dof_old[i]; + double hui = hu_dof_old[i]; + double hvi = hv_dof_old[i]; + double hetai = heta_dof_old[i]; + double mi = lumped_mass_matrix[i]; + double dLowii = 0.; + + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + // loop in j (sparsity pattern) + // solution at time tn for the jth DOF + int j = csrColumnOffsets_DofLoops[offset]; + double hj = h_dof_old[j]; + double huj = hu_dof_old[j]; + double hvj = hv_dof_old[j]; + double hetaj = heta_dof_old[j]; + double mj = lumped_mass_matrix[j]; + + if (i != j) { + //////////////////////// + // DISSIPATIVE MATRIX // + //////////////////////// + double cij_norm = sqrt(Cx[ij] * Cx[ij] + Cy[ij] * Cy[ij]); + double cji_norm = sqrt(CTx[ij] * CTx[ij] + CTy[ij] * CTy[ij]); + double nxij = Cx[ij] / cij_norm, nyij = Cy[ij] / cij_norm; + double nxji = CTx[ij] / cji_norm, nyji = CTy[ij] / cji_norm; + + dLow[ij] = + fmax(maxWaveSpeedSharpInitialGuess(g, nxij, nyij, hi, hui, hvi, + hetai, mi, hj, huj, hvj, hetaj, + mj, hEps, hEps, debug) * + cij_norm, // hEps + maxWaveSpeedSharpInitialGuess(g, nxji, nyji, hj, huj, hvj, + hetaj, mj, hi, hui, hvi, hetai, + mi, hEps, hEps, debug) * + cji_norm); // hEps + dLowii -= dLow[ij]; + + } else + dLow[ij] = 0.; + // update ij + ij += 1; + } + ////////////////////////////// + // CALCULATE EDGE BASED CFL // + ////////////////////////////// + // mi = lumped_mass_matrix[i]; + edge_based_cfl[i] = 1.0 * fabs(dLowii) / mi; + max_edge_based_cfl = fmax(max_edge_based_cfl, edge_based_cfl[i]); + } + + return max_edge_based_cfl; + } // End calculateEdgeBasedCFL + + void calculateResidual( // last EDGE BASED version + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& heta_dof_old, xt::pyarray& hw_dof_old, xt::pyarray& b_dof, xt::pyarray& h_dof, + xt::pyarray& hu_dof, xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& heta_dof_sge, xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, + int offset_heta, int offset_hw, int stride_h, int stride_hu, + int stride_hv, int stride_heta, int stride_hw, xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h_save, + // C matrices + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, + // PARAMETERS FOR EDGE BASED STABILIZATION + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + // LUMPED MASS MATRIX + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, + // SAVE SOLUTION (mql) + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, xt::pyarray& hetanp1_at_quad_point, + xt::pyarray& hwnp1_at_quad_point, + // TO COMPUTE LOW ORDER + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_heta, xt::pyarray& extendedSourceTerm_hw, + // FOR FCT + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, + int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, + // Quant of interests + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + // NORMAL COMPONENTS + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, + // LOCAL LIMITING +<<<<<<< HEAD + double *hBT, double *huBT, double *hvBT, double *hetaBT, double *hwBT, + int lstage, double *new_SourceTerm_hu, double *new_SourceTerm_hv, + double *new_SourceTerm_heta, double *new_SourceTerm_hw) { + +======= + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, xt::pyarray& hetaBT, xt::pyarray& hwBT, + int lstage) { +>>>>>>> dceecb29d... GN_SW2DCV + // FOR FRICTION// + double n2 = std::pow(mannings, 2.); + double gamma = 4. / 3; + // mql. This parameter relaxes the cfl restriction. + // It is now conservative. I might change it after the local bounds are + // implemented + double xi = 10.; + + ////////////////////////////////////// + // ********** CELL LOOPS ********** // + ////////////////////////////////////// + // To compute: + // * Time derivative term + // * Cell based CFL + // * Velocity and soln at quad points (for other models) + for (int eN = 0; eN < nElements_global; eN++) { + // declare local storage for element residual and initialize + register double elementResidual_h[nDOF_test_element], + elementResidual_hu[nDOF_test_element], + elementResidual_hv[nDOF_test_element], + elementResidual_heta[nDOF_test_element], + elementResidual_hw[nDOF_test_element]; + + for (int i = 0; i < nDOF_test_element; i++) { + elementResidual_h[i] = 0.0; + elementResidual_hu[i] = 0.0; + elementResidual_hv[i] = 0.0; + elementResidual_heta[i] = 0.0; + elementResidual_hw[i] = 0.0; + } + // + // loop over quadrature points and compute integrands + // + for (int k = 0; k < nQuadraturePoints_element; k++) { + // compute indices and declare local storage + register int eN_k = eN * nQuadraturePoints_element + k, + eN_k_nSpace = eN_k * nSpace, + eN_nDOF_trial_element = eN * nDOF_trial_element; + register double h = 0.0, hu = 0.0, hv = 0.0, heta = 0.0, + hw = 0.0, // solution at current time + h_old = 0.0, hu_old = 0.0, hv_old = 0.0, heta_old = 0.0, + hw_old = 0.0, // solution at lstage + jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace], + h_test_dV[nDOF_trial_element], dV, x, y, xt, yt; + // get jacobian, etc for mapping reference element + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, + y); + // get the physical integration weight + dV = fabs(jacDet) * dV_ref[k]; + // get the solution at current time + ck.valFromDOF(h_dof.data(), &h_l2g[eN_nDOF_trial_element], + &h_trial_ref[k * nDOF_trial_element], h); + ck.valFromDOF(hu_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hu); + ck.valFromDOF(hv_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hv); + ck.valFromDOF(heta_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], heta); + ck.valFromDOF(hw_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hw); + // get the solution at the lstage + ck.valFromDOF(h_dof_old.data(), &h_l2g[eN_nDOF_trial_element], + &h_trial_ref[k * nDOF_trial_element], h_old); + ck.valFromDOF(hu_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hu_old); + ck.valFromDOF(hv_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hv_old); + ck.valFromDOF(heta_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], heta_old); + ck.valFromDOF(hw_dof_old.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref[k * nDOF_trial_element], hw_old); + // calculate cell based CFL to keep a reference + calculateCFL(elementDiameter[eN], g, h_old, hu_old, hv_old, hEps, + q_cfl[eN_k]); + // precalculate test function products with integration weights + for (int j = 0; j < nDOF_trial_element; j++) + h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV; + + // SAVE VELOCITY // at quadrature points for other models to use + q_velocity[eN_k_nSpace + 0] = + 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hu; + q_velocity[eN_k_nSpace + 1] = + 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hv; + hnp1_at_quad_point[eN_k] = h; + hunp1_at_quad_point[eN_k] = hu; + hvnp1_at_quad_point[eN_k] = hv; + hetanp1_at_quad_point[eN_k] = heta; + hwnp1_at_quad_point[eN_k] = hw; + + for (int i = 0; i < nDOF_test_element; i++) { + // compute time derivative part of global residual. NOTE: no lumping + elementResidual_h[i] += (h - h_old) * h_test_dV[i]; + elementResidual_hu[i] += (hu - hu_old) * h_test_dV[i]; + elementResidual_hv[i] += (hv - hv_old) * h_test_dV[i]; + elementResidual_heta[i] += (heta - heta_old) * h_test_dV[i]; + elementResidual_hw[i] += (hw - hw_old) * h_test_dV[i]; + } + } + // distribute + for (int i = 0; i < nDOF_test_element; i++) { + register int eN_i = eN * nDOF_test_element + i; + int h_gi = h_l2g[eN_i]; // global i-th index for h + int vel_gi = vel_l2g[eN_i]; // global i-th index for velocities + + // distribute time derivative to global residual + globalResidual[offset_h + stride_h * h_gi] += elementResidual_h[i]; + globalResidual[offset_hu + stride_hu * vel_gi] += elementResidual_hu[i]; + globalResidual[offset_hv + stride_hv * vel_gi] += elementResidual_hv[i]; + globalResidual[offset_heta + stride_heta * vel_gi] += + elementResidual_heta[i]; + globalResidual[offset_hw + stride_hw * vel_gi] += elementResidual_hw[i]; + } + } + // ********** END OF CELL LOOPS ********** // + + if (SECOND_CALL_CALCULATE_RESIDUAL == 0) // This is to save some time + { + ////////////////////////////////////////////// + // ********** FIRST LOOP ON DOFs ********** // + ////////////////////////////////////////////// + + // To compute: + // * Entropy at i-th node + std::valarray eta(numDOFsPerEqn); + for (int i = 0; i < numDOFsPerEqn; i++) { + // COMPUTE ENTROPY. NOTE: WE CONSIDER A FLAT BOTTOM + double hi = h_dof_old[i]; + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); // hEps + eta[i] = + ENTROPY(g, hi, hu_dof_old[i], hv_dof_old[i], 0., one_over_hiReg); + } + + // ********** END OF FIRST LOOP ON DOFs ********** // + + /////////////////////////////////////////////// + // ********** SECOND LOOP ON DOFs ********** // + /////////////////////////////////////////////// + // To compute: + // * Hyperbolic part of the flux + // * Extended source term (eqn 6.19) + // * Smoothness indicator + // * global entropy residual + + int ij = 0; + std::valarray hyp_flux_h(numDOFsPerEqn), + hyp_flux_hu(numDOFsPerEqn), hyp_flux_hv(numDOFsPerEqn), + hyp_flux_heta(numDOFsPerEqn), hyp_flux_hw(numDOFsPerEqn), + global_entropy_residual(numDOFsPerEqn), psi(numDOFsPerEqn), + etaMax(numDOFsPerEqn), etaMin(numDOFsPerEqn); + + for (int i = 0; i < numDOFsPerEqn; i++) { + + // solution at time tn for the ith DOF + double hi = h_dof_old[i]; + double hui = hu_dof_old[i]; + double hvi = hv_dof_old[i]; + double hetai = heta_dof_old[i]; + double hwi = hw_dof_old[i]; + double Zi = b_dof[i]; + // Define some things using above + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); // hEps + double ui = hui * one_over_hiReg; + double vi = hvi * one_over_hiReg; + double etai = hetai * one_over_hiReg; + double mi = lumped_mass_matrix[i]; + double meshSizei = std::sqrt(mi); + + // For eta min and max + etaMax[i] = fabs(eta[i]); + etaMin[i] = fabs(eta[i]); + + /* COMPUTE EXTENDED SOURCE TERMS: + * Friction terms + * Source for heta equation + * Source for hw equation + * NOTE: Be careful with sign of source terms. + */ + + // Friction + if (LINEAR_FRICTION == 1) { + extendedSourceTerm_hu[i] = mannings * hui * mi; + extendedSourceTerm_hv[i] = mannings * hvi * mi; + // For use in the convex limiting function -EJT + // actually didn't need to do this but it helps with signs + new_SourceTerm_hu[i] = -mannings * hui * mi; + new_SourceTerm_hv[i] = -mannings * hvi * mi; + } else { + double veli_norm = std::sqrt(ui * ui + vi * vi); + double hi_to_the_gamma = std::pow(fmax(hi, hEps), gamma); + double friction_aux = + veli_norm == 0. + ? 0. + : (2 * g * n2 * veli_norm * mi / + (hi_to_the_gamma + + fmax(hi_to_the_gamma, xi * g * n2 * dt * veli_norm))); + extendedSourceTerm_hu[i] = friction_aux * hui; + extendedSourceTerm_hv[i] = friction_aux * hvi; + // For use in the convex limiting function -EJT + new_SourceTerm_hu[i] = -friction_aux * hui; + new_SourceTerm_hv[i] = -friction_aux * hvi; + } + + // Define some things for heta and hw sources + double ratio_i = (2.0 * hetai) / (etai * etai + hi * hi + hEps); + double diff_over_h_i = (hetai - hi * hi) * one_over_hiReg; + double hSqd_GammaPi = 6.0 * (hetai - hi * hi); + if (IF_BOTH_GAMMA_BRANCHES) { + if (hetai > std::pow(hi, 2.0)) { + hSqd_GammaPi = 6.0 * etai * diff_over_h_i; + } + } + + // heta source + extendedSourceTerm_heta[i] = -hwi * mi * ratio_i; + new_SourceTerm_heta[i] = hwi * mi * ratio_i; + + // hw source + extendedSourceTerm_hw[i] = + (LAMBDA_MGN * g / meshSizei) * hSqd_GammaPi * mi * ratio_i; + new_SourceTerm_hw[i] = + -(LAMBDA_MGN * g / meshSizei) * hSqd_GammaPi * mi * ratio_i; + + /* HYPERBOLIC FLUXES */ + hyp_flux_h[i] = 0; + hyp_flux_hu[i] = 0; + hyp_flux_hv[i] = 0; + hyp_flux_heta[i] = 0; + hyp_flux_hw[i] = 0; + + // FOR ENTROPY RESIDUAL // + double ith_flux_term1 = 0., ith_flux_term2 = 0., ith_flux_term3 = 0.; + double ith_flux_term4 = 0., ith_flux_term5 = 0.; + double entropy_flux = 0.; + + // FOR SMOOTHNESS INDICATOR // + double alphai; // smoothness indicator of solution + double alpha_numerator = 0; + double alpha_denominator = 0; + double alpha_zero = 0.75; + double alpha_factor = 1.0 / (1.0 - alpha_zero); + + // loop in j (sparsity pattern) + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + + int j = csrColumnOffsets_DofLoops[offset]; + + // solution at time tn for the jth DOF + double hj = h_dof_old[j]; + double huj = hu_dof_old[j]; + double hvj = hv_dof_old[j]; + double hetaj = heta_dof_old[j]; + double hwj = hw_dof_old[j]; + double Zj = b_dof[j]; + + // Then define some things here using above + double one_over_hjReg = + 2.0 * hj / (hj * hj + std::pow(fmax(hj, hEps), 2)); // hEps + double uj = huj * one_over_hjReg; + double vj = hvj * one_over_hjReg; + double etaj = hetaj * one_over_hjReg; + double meshSizej = + std::sqrt(lumped_mass_matrix[j]); // local mesh size in 2d + + // pTilde at jth node gets defined here + double diff_over_h_j = (hetaj - hj * hj) * one_over_hjReg; + double pTildej = -(LAMBDA_MGN * g / (3.0 * meshSizej)) * 6.0 * hj * + (hetaj - hj * hj); + + if (IF_BOTH_GAMMA_BRANCHES) { + if (hetaj > std::pow(hj, 2.0)) { + pTildej = -(LAMBDA_MGN * g / (3.0 * meshSizej)) * 2.0 * + diff_over_h_j * (etaj * etaj + etaj * hj + hj * hj); + } + } + + // auxiliary functions to compute fluxes + double aux_h = + (uj * hj - ui * hi) * Cx[ij] + (vj * hj - vi * hi) * Cy[ij]; + double aux_hu = + (uj * huj - ui * hui) * Cx[ij] + (vj * huj - vi * hui) * Cy[ij]; + double aux_hv = + (uj * hvj - ui * hvi) * Cx[ij] + (vj * hvj - vi * hvi) * Cy[ij]; + double aux_heta = (uj * hetaj - ui * hetai) * Cx[ij] + + (vj * hetaj - vi * hetai) * Cy[ij]; + double aux_hw = + (uj * hwj - ui * hwi) * Cx[ij] + (vj * hwj - vi * hwi) * Cy[ij]; + + /* HYPERBOLIC FLUX */ + hyp_flux_h[i] += aux_h; + hyp_flux_hu[i] += aux_hu + pTildej * Cx[ij]; + hyp_flux_hv[i] += aux_hv + pTildej * Cy[ij]; + hyp_flux_heta[i] += aux_heta; + hyp_flux_hw[i] += aux_hw; + + // EXTENDED SOURCE, USING 6.13 // + extendedSourceTerm_hu[i] += g * hi * (hj + Zj) * Cx[ij]; + extendedSourceTerm_hv[i] += g * hi * (hj + Zj) * Cy[ij]; + + new_SourceTerm_hu[i] += + g * (-hi * (Zj - Zi) + 0.5 * std::pow(hj - hi, 2)) * Cx[ij]; + new_SourceTerm_hv[i] += + g * (-hi * (Zj - Zi) + 0.5 * std::pow(hj - hi, 2)) * Cy[ij]; + + // flux for entropy + ith_flux_term1 += aux_h; + ith_flux_term2 += aux_hu + g * hi * (hj + 0.) * Cx[ij]; // NOTE: Zj=0 + ith_flux_term3 += aux_hv + g * hi * (hj + 0.) * Cy[ij]; // NOTE: Zj=0 + + // NOTE: WE CONSIDER FLAT BOTTOM + entropy_flux += + (Cx[ij] * ENTROPY_FLUX1(g, hj, huj, hvj, 0., one_over_hjReg) + + Cy[ij] * ENTROPY_FLUX2(g, hj, huj, hvj, 0., one_over_hjReg)); + + // COMPUTE ETA MIN AND ETA MAX // + etaMax[i] = fmax(etaMax[i], fabs(eta[j])); + etaMin[i] = fmin(etaMin[i], fabs(eta[j])); + + // FOR SMOOTHNESS INDICATOR // + alpha_numerator += hj - hi; + alpha_denominator += fabs(hj - hi); + + // update ij + ij += 1; + } // end j loop + + // Change rescaling to match TAMU code -EJT, 12/9/2019 + // Here we divide by eps = 1E-5 so that small recale = 1/2 g eps + // H_{0,max}^2 + double small_rescale = g * hEps * hEps / 1E-5; + double rescale = fmax(fabs(etaMax[i] - etaMin[i]) / 2., small_rescale); + + // COMPUTE ENTROPY RESIDUAL // + double one_over_entNormFactori = 1.0 / rescale; + // double one_over_entNormFactori = 2. / (etaMax[i] - etaMin[i] + + // 1E-15); + + double eta_prime1 = DENTROPY_DH(g, hi, hui, hvi, 0., + one_over_hiReg); // NOTE: FLAT BOTTOM + double eta_prime2 = DENTROPY_DHU(g, hi, hui, hvi, 0., one_over_hiReg); + double eta_prime3 = DENTROPY_DHV(g, hi, hui, hvi, 0., one_over_hiReg); + global_entropy_residual[i] = + one_over_entNormFactori * + fabs(entropy_flux - + (ith_flux_term1 * eta_prime1 + ith_flux_term2 * eta_prime2 + + ith_flux_term3 * eta_prime3)); + + // COMPUTE SMOOTHNESS INDICATOR // + if (hi <= hEps) { + alphai = 1.0; + psi[i] = 1.0; + global_entropy_residual[i] = 1E10; + } else { + // Force alphai=0 in constant states + if (fabs(alpha_numerator) <= hEps) { + alphai = 0.; + } else { + alphai = + (fabs(alpha_numerator) - hEps) / fabs(alpha_denominator - hEps); + } + alphai = fmax(alphai - alpha_zero, 0.0) * alpha_factor; + if (POWER_SMOOTHNESS_INDICATOR == 0) + psi[i] = 1.0; + else + psi[i] = std::pow( + alphai, POWER_SMOOTHNESS_INDICATOR); // NOTE: alpha^4 for mGN + } + } + // ********** END OF 2nd LOOP ON DOFS ********** // + + ///////////////////////////////////////////// + // ********** MAIN LOOP ON DOFs ********** + // To compute: + // * dissipative terms + // * bar states + ///////////////////////////////////////////// + + ij = 0; + for (int i = 0; i < numDOFsPerEqn; i++) { + + double hi = h_dof_old[i]; + double hui = hu_dof_old[i]; + double hvi = hv_dof_old[i]; + double hetai = heta_dof_old[i]; + double hwi = hw_dof_old[i]; + double Zi = b_dof[i]; + double mi = lumped_mass_matrix[i]; + + double one_over_hiReg = + 2 * hi / (hi * hi + std::pow(fmax(hi, hEps), 2)); + double ui = hui * one_over_hiReg; + double vi = hvi * one_over_hiReg; + double etai = hetai * one_over_hiReg; + double meshSizei = std::sqrt(mi); // local mesh size in 2d + + // We define pTilde at ith node here + double diff_over_h_i = (hetai - hi * hi) * one_over_hiReg; + double pTildei = -(LAMBDA_MGN * g / (3.0 * meshSizei)) * 6.0 * hi * + (hetai - hi * hi); + + if (IF_BOTH_GAMMA_BRANCHES) { + if (hetai > std::pow(hi, 2.0)) { + pTildei = -(LAMBDA_MGN * g / (3.0 * meshSizei)) * 2.0 * + diff_over_h_i * (etai * etai + etai * hi + hi * hi); + } + } + + // Define full pressure at ith node for definition of bar states below + double pressure_i = 0.5 * g * hi * hi + pTildei; + + // HIGH ORDER DISSIPATIVE TERMS, for Aij matrix + double ith_dHij_minus_muHij_times_hStarStates = 0., + ith_dHij_minus_muHij_times_huStarStates = 0., + ith_dHij_minus_muHij_times_hvStarStates = 0., + ith_dHij_minus_muHij_times_hetaStarStates = 0., + ith_dHij_minus_muHij_times_hwStarStates = 0., + ith_muHij_times_hStates = 0., ith_muHij_times_huStates = 0., + ith_muHij_times_hvStates = 0., ith_muHij_times_hetaStates = 0., + ith_muHij_times_hwStates = 0.; + + // loop over the sparsity pattern of the i-th DOF + for (int offset = csrRowIndeces_DofLoops[i]; + offset < csrRowIndeces_DofLoops[i + 1]; offset++) { + + int j = csrColumnOffsets_DofLoops[offset]; + + double hj = h_dof_old[j]; + double huj = hu_dof_old[j]; + double hvj = hv_dof_old[j]; + double hetaj = heta_dof_old[j]; + double hwj = hw_dof_old[j]; + double Zj = b_dof[j]; + + double one_over_hjReg = + 2.0 * hj / (hj * hj + std::pow(fmax(hj, hEps), 2)); + double uj = huj * one_over_hjReg; + double vj = hvj * one_over_hjReg; + double etaj = hetaj * one_over_hjReg; + double mj = lumped_mass_matrix[j]; + double meshSizej = std::sqrt(mj); // local mesh size in 2d + + // Here we define pTilde at jth node + double diff_over_h_j = (hetaj - hj * hj) * one_over_hjReg; + double pTildej = -(LAMBDA_MGN * g / (3.0 * meshSizej)) * 6.0 * hj * + (hetaj - hj * hj); + + if (IF_BOTH_GAMMA_BRANCHES) { + if (hetaj > std::pow(hj, 2.0)) { + pTildej = -(LAMBDA_MGN * g / (3.0 * meshSizej)) * 2.0 * + diff_over_h_j * (etaj * etaj + etaj * hj + hj * hj); + } + } + + // define pressure at jth node + double pressure_j = 0.5 * g * hj * hj + pTildej; + + // COMPUTE STAR SOLUTION // hStar, huStar, hvStar, hetaStar, hwStar + double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj)); + double huStarij = hui * hStarij * one_over_hiReg; + double hvStarij = hvi * hStarij * one_over_hiReg; + double hetaStarij = hetai * std::pow(hStarij * one_over_hiReg, 2); + double hwStarij = hwi * std::pow(hStarij * one_over_hiReg, 2); + + double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj)); + double huStarji = huj * hStarji * one_over_hjReg; + double hvStarji = hvj * hStarji * one_over_hjReg; + double hetaStarji = hetaj * std::pow(hStarji * one_over_hjReg, 2); + double hwStarji = hwj * std::pow(hStarji * one_over_hjReg, 2); + + // Dissipative well balancing term + double muLowij = 0., muLij = 0., muHij = 0.; + double dLowij = 0., dLij = 0., dHij = 0.; + if (i != j) // This is not necessary. See formula for + // ith_dissipative_terms + { + //////////////////////// + // DISSIPATIVE MATRIX // + //////////////////////// + if (lstage == 0) + dLowij = dLow[ij]; + else { + double cij_norm = sqrt(Cx[ij] * Cx[ij] + Cy[ij] * Cy[ij]); + double cji_norm = sqrt(CTx[ij] * CTx[ij] + CTy[ij] * CTy[ij]); + double nxij = Cx[ij] / cij_norm, nyij = Cy[ij] / cij_norm; + double nxji = CTx[ij] / cji_norm, nyji = CTy[ij] / cji_norm; + dLowij = fmax(maxWaveSpeedSharpInitialGuess( + g, nxij, nyij, hi, hui, hvi, hetai, mi, hj, huj, + hvj, hetaj, mj, hEps, hEps, false) * + cij_norm, + maxWaveSpeedSharpInitialGuess( + g, nxji, nyji, hj, huj, hvj, hetaj, mj, hi, hui, + hvi, hetai, mi, hEps, hEps, false) * + cji_norm); + } + + /////////////////////////////////////// + // WELL BALANCING DISSIPATIVE MATRIX // + /////////////////////////////////////// + muLowij = fmax(fmax(0., -(ui * Cx[ij] + vi * Cy[ij])), + fmax(0., (uj * Cx[ij] + vj * Cy[ij]))); + + // Define dLij as low order dijs + muLij = muLowij; + dLij = fmax(dLowij, muLij); + + // Then save dLow for limiting step, maybe a bit confusing + dLow[ij] = fmax(dLij, muLij); + + //////////////////////// + // COMPUTE BAR STATES // + //////////////////////// + double hBar_ij = 0, hTilde_ij = 0, huBar_ij = 0, huTilde_ij = 0, + hvBar_ij = 0, hvTilde_ij = 0, hetaBar_ij = 0, + hetaTilde_ij = 0, hwBar_ij = 0, hwTilde_ij = 0; + + if (dLij != 0) { + // h component + hBar_ij = -1. / (2 * dLij) * + ((uj * hj - ui * hi) * Cx[ij] + + (vj * hj - vi * hi) * Cy[ij]) + + 0.5 * (hj + hi); + hTilde_ij = (dLij - muLij) / (2 * dLij) * + ((hStarji - hj) - (hStarij - hi)); + // hu component + huBar_ij = -1. / (2 * dLij) * + ((uj * huj - ui * hui + pressure_j - pressure_i) * + Cx[ij] + + (vj * huj - vi * hui) * Cy[ij]) + + 0.5 * (huj + hui); + huTilde_ij = (dLij - muLij) / (2 * dLij) * + ((huStarji - huj) - (huStarij - hui)); + // hv component + hvBar_ij = -1. / (2 * dLij) * + ((uj * hvj - ui * hvi) * Cx[ij] + + (vj * hvj - vi * hvi + pressure_j - pressure_i) * + Cy[ij]) + + 0.5 * (hvj + hvi); + hvTilde_ij = (dLij - muLij) / (2 * dLij) * + ((hvStarji - hvj) - (hvStarij - hvi)); + // heta component + hetaBar_ij = -1. / (2 * dLij) * + ((uj * hetaj - ui * hetai) * Cx[ij] + + (vj * hetaj - vi * hetai) * Cy[ij]) + + 0.5 * (hetaj + hetai); + hetaTilde_ij = (dLij - muLij) / (2 * dLij) * + ((hetaStarji - hetaj) - (hetaStarij - hetai)); + // hw component + hwBar_ij = -1. / (2 * dLij) * + ((uj * hwj - ui * hwi) * Cx[ij] + + (vj * hwj - vi * hwi) * Cy[ij]) + + 0.5 * (hwj + hwi); + hwTilde_ij = (dLij - muLij) / (2 * dLij) * + ((hwStarji - hwj) - (hwStarij - hwi)); + } + // Here we define uBar + uTilde + hBT[ij] = hBar_ij + hTilde_ij; + huBT[ij] = huBar_ij + huTilde_ij; + hvBT[ij] = hvBar_ij + hvTilde_ij; + hetaBT[ij] = hetaBar_ij + hetaTilde_ij; + hwBT[ij] = hwBar_ij + hwTilde_ij; + + /////////////////////// + // ENTROPY VISCOSITY // + /////////////////////// + double dEVij = cE * fmax(global_entropy_residual[i], + global_entropy_residual[j]); + dHij = fmin(dLowij, dEVij); + muHij = fmin(muLowij, dEVij); + + // Assume no EV for now and just use the alpha limiting for + // higher order method. -EJT + // dHij = fmax(psi[i], psi[j]) * dLij; + // muHij = fmax(psi[i], psi[j]) * muLij; + + // compute dij_minus_muij times star solution terms + // see: eqn (6.13) + ith_dHij_minus_muHij_times_hStarStates += + (dHij - muHij) * (hStarji - hStarij); + ith_dHij_minus_muHij_times_huStarStates += + (dHij - muHij) * (huStarji - huStarij); + ith_dHij_minus_muHij_times_hvStarStates += + (dHij - muHij) * (hvStarji - hvStarij); + ith_dHij_minus_muHij_times_hetaStarStates += + (dHij - muHij) * (hetaStarji - hetaStarij); + ith_dHij_minus_muHij_times_hwStarStates += + (dHij - muHij) * (hwStarji - hwStarij); + + // compute muij times solution terms + ith_muHij_times_hStates += muHij * (hj - hi); + ith_muHij_times_huStates += muHij * (huj - hui); + ith_muHij_times_hvStates += muHij * (hvj - hvi); + ith_muHij_times_hetaStates += muHij * (hetaj - hetai); + ith_muHij_times_hwStates += muHij * (hwj - hwi); + + // compute dH_minus_dL + dH_minus_dL[ij] = dHij - dLij; + muH_minus_muL[ij] = muHij - muLij; + } else // i==j + { + dH_minus_dL[ij] = 0.; // Not true but the prod of this times + // Uj-Ui will be zero + muH_minus_muL[ij] = 0.; // Not true but the prod of this times + // Uj-Ui will be zero + } + + // update ij + ij += 1; + + } /*j loop ends here*/ + + /* Define global residual */ + if (LUMPED_MASS_MATRIX == 1) { + globalResidual[offset_h + stride_h * i] = + hi - dt / mi * + (hyp_flux_h[i] - ith_dHij_minus_muHij_times_hStarStates - + ith_muHij_times_hStates); + globalResidual[offset_hu + stride_hu * i] = + hui - dt / mi * + ((hyp_flux_hu[i] + extendedSourceTerm_hu[i]) - + ith_dHij_minus_muHij_times_huStarStates - + ith_muHij_times_huStates); + globalResidual[offset_hv + stride_hv * i] = + hvi - dt / mi * + ((hyp_flux_hv[i] + extendedSourceTerm_hv[i]) - + ith_dHij_minus_muHij_times_hvStarStates - + ith_muHij_times_hvStates); + globalResidual[offset_heta + stride_heta * i] = + hetai - dt / mi * + ((hyp_flux_heta[i] + extendedSourceTerm_heta[i]) - + ith_dHij_minus_muHij_times_hetaStarStates - + ith_muHij_times_hetaStates); + globalResidual[offset_hw + stride_hw * i] = + hwi - dt / mi * + ((hyp_flux_hw[i] + extendedSourceTerm_hw[i]) - + ith_dHij_minus_muHij_times_hwStarStates - + ith_muHij_times_hwStates); + + // clean up potential negative water height due to machine + // precision + // if (globalResidual[offset_h + stride_h * i] >= -hEps && + // globalResidual[offset_h + stride_h * i] < hEps) { + // globalResidual[offset_h + stride_h * i] = 0.0; + // globalResidual[offset_heta + stride_heta * i] = 0.0; + // } + + } else { + // Distribute residual + // NOTE: MASS MATRIX IS CONSISTENT + globalResidual[offset_h + stride_h * i] += + dt * (hyp_flux_h[i] - ith_dHij_minus_muHij_times_hStarStates - + ith_muHij_times_hStates); + globalResidual[offset_hu + stride_hu * i] += + dt * (hyp_flux_hu[i] + extendedSourceTerm_hu[i] - + ith_dHij_minus_muHij_times_huStarStates - + ith_muHij_times_huStates); + globalResidual[offset_hv + stride_hv * i] += + dt * (hyp_flux_hv[i] + extendedSourceTerm_hv[i] - + ith_dHij_minus_muHij_times_hvStarStates - + ith_muHij_times_hvStates); + globalResidual[offset_heta + stride_heta * i] += + dt * (hyp_flux_heta[i] + extendedSourceTerm_heta[i] - + ith_dHij_minus_muHij_times_hetaStarStates - + ith_muHij_times_hetaStates); + globalResidual[offset_hw + stride_hw * i] += + dt * (hyp_flux_hw[i] + extendedSourceTerm_hw[i] - + ith_dHij_minus_muHij_times_hwStarStates - + ith_muHij_times_hwStates); + } + } + // ********** END OF LOOP IN DOFs ********** // + } + + // ********** COMPUTE NORMALS ********** // + if (COMPUTE_NORMALS == 1) { + // This is to identify the normals and create a vector of normal + // components + for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { + register int + ebN = exteriorElementBoundariesArray[ebNE], + eN = elementBoundaryElementsArray[ebN * 2 + 0], + ebN_local = elementBoundaryLocalElementBoundariesArray[ebN * 2 + 0]; + register double normal[3]; + { // "Loop" in quad points + int kb = 0; // NOTE: I need to consider just one quad point since + // the element is not curved so the normal is constant + // per element + register int ebN_local_kb = + ebN_local * nQuadraturePoints_elementBoundary + kb; + register double jac_ext[nSpace * nSpace], jacDet_ext, + jacInv_ext[nSpace * nSpace], boundaryJac[nSpace * (nSpace - 1)], + metricTensor[(nSpace - 1) * (nSpace - 1)], metricTensorDetSqrt, + x_ext, y_ext; + /* compute information about mapping from reference element to + * physical element */ + ck.calculateMapping_elementBoundary( + eN, ebN_local, kb, ebN_local_kb, mesh_dof.data(), mesh_l2g.data(), + mesh_trial_trace_ref.data(), mesh_grad_trial_trace_ref.data(), boundaryJac_ref.data(), + jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, + metricTensorDetSqrt, normal_ref.data(), normal, x_ext, y_ext); + } + // distribute the normal vectors + for (int i = 0; i < nDOF_test_element; i++) { + int eN_i = eN * nDOF_test_element + i; + int gi = h_l2g[eN_i]; + normalx[gi] += 0.5 * normal[0] * (i == ebN_local ? 0. : 1.); + normaly[gi] += 0.5 * normal[1] * (i == ebN_local ? 0. : 1.); + } + } + // normalize + for (int gi = 0; gi < numDOFsPerEqn; gi++) { + double norm_factor = + sqrt(std::pow(normalx[gi], 2) + std::pow(normaly[gi], 2)); + if (norm_factor != 0) { + normalx[gi] /= norm_factor; + normaly[gi] /= norm_factor; + } + } + } + // ********** END OF COMPUTING NORMALS ********** // + } // namespace proteus + + void calculateMassMatrix( // element + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& heta_dof, xt::pyarray& hw_dof, xt::pyarray& h_dof_sge, + xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, xt::pyarray& heta_dof_sge, + xt::pyarray& hw_dof_sge, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, + // h + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, + // hu + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, + // hv + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, + // heta + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, + // hw + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, + // + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { + // + // loop over elements to compute volume integrals and load them into the + // element Jacobians and global Jacobian + // + for (int eN = 0; eN < nElements_global; eN++) { + register double elementJacobian_h_h[nDOF_test_element] + [nDOF_trial_element], + elementJacobian_hu_hu[nDOF_test_element][nDOF_trial_element], + elementJacobian_hv_hv[nDOF_test_element][nDOF_trial_element], + elementJacobian_heta_heta[nDOF_test_element][nDOF_trial_element], + elementJacobian_hw_hw[nDOF_test_element][nDOF_trial_element]; + for (int i = 0; i < nDOF_test_element; i++) + for (int j = 0; j < nDOF_trial_element; j++) { + elementJacobian_h_h[i][j] = 0.0; + elementJacobian_hu_hu[i][j] = 0.0; + elementJacobian_hv_hv[i][j] = 0.0; + elementJacobian_heta_heta[i][j] = 0.0; + elementJacobian_hw_hw[i][j] = 0.0; + } + for (int k = 0; k < nQuadraturePoints_element; k++) { + int eN_k = eN * nQuadraturePoints_element + + k, // index to a scalar at a quadrature point + eN_k_nSpace = eN_k * nSpace, + eN_nDOF_trial_element = + eN * nDOF_trial_element; // index to a vector at a + // quadrature point + + // declare local storage + register double jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace], + dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, + y, xt, yt; + // get jacobian, etc for mapping reference element + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, + y); + // get the physical integration weight + dV = fabs(jacDet) * dV_ref[k]; + // precalculate test function products with integration weights + for (int j = 0; j < nDOF_trial_element; j++) { + h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV; + vel_test_dV[j] = vel_test_ref[k * nDOF_trial_element + j] * dV; + } + for (int i = 0; i < nDOF_test_element; i++) { + register int i_nSpace = i * nSpace; + for (int j = 0; j < nDOF_trial_element; j++) { + register int j_nSpace = j * nSpace; + elementJacobian_h_h[i][j] += + h_trial_ref[k * nDOF_trial_element + j] * h_test_dV[i]; + elementJacobian_hu_hu[i][j] += + vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i]; + elementJacobian_hv_hv[i][j] += + vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i]; + elementJacobian_heta_heta[i][j] += + vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i]; + elementJacobian_hw_hw[i][j] += + vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i]; + } // j + } // i + } // k + // + // load into element Jacobian into global Jacobian + // + for (int i = 0; i < nDOF_test_element; i++) { + register int eN_i = eN * nDOF_test_element + i; + for (int j = 0; j < nDOF_trial_element; j++) { + register int eN_i_j = eN_i * nDOF_trial_element + j; + globalJacobian[csrRowIndeces_h_h[eN_i] + + csrColumnOffsets_h_h[eN_i_j]] += + elementJacobian_h_h[i][j]; + globalJacobian[csrRowIndeces_hu_hu[eN_i] + + csrColumnOffsets_hu_hu[eN_i_j]] += + elementJacobian_hu_hu[i][j]; + globalJacobian[csrRowIndeces_hv_hv[eN_i] + + csrColumnOffsets_hv_hv[eN_i_j]] += + elementJacobian_hv_hv[i][j]; + globalJacobian[csrRowIndeces_heta_heta[eN_i] + + csrColumnOffsets_heta_heta[eN_i_j]] += + elementJacobian_heta_heta[i][j]; + globalJacobian[csrRowIndeces_hw_hw[eN_i] + + csrColumnOffsets_hw_hw[eN_i_j]] += + elementJacobian_hw_hw[i][j]; + } // j + } // i + } // elements + } + + void calculateLumpedMassMatrix( // element + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + // element boundary + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, + // physics + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, + // h + xt::pyarray& csrRowIndeces_h_h, xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_hu, xt::pyarray& csrColumnOffsets_h_hu, + xt::pyarray& csrRowIndeces_h_hv, xt::pyarray& csrColumnOffsets_h_hv, + xt::pyarray& csrRowIndeces_h_heta, xt::pyarray& csrColumnOffsets_h_heta, + xt::pyarray& csrRowIndeces_h_hw, xt::pyarray& csrColumnOffsets_h_hw, + // hu + xt::pyarray& csrRowIndeces_hu_h, xt::pyarray& csrColumnOffsets_hu_h, + xt::pyarray& csrRowIndeces_hu_hu, xt::pyarray& csrColumnOffsets_hu_hu, + xt::pyarray& csrRowIndeces_hu_hv, xt::pyarray& csrColumnOffsets_hu_hv, + xt::pyarray& csrRowIndeces_hu_heta, xt::pyarray& csrColumnOffsets_hu_heta, + xt::pyarray& csrRowIndeces_hu_hw, xt::pyarray& csrColumnOffsets_hu_hw, + // hv + xt::pyarray& csrRowIndeces_hv_h, xt::pyarray& csrColumnOffsets_hv_h, + xt::pyarray& csrRowIndeces_hv_hu, xt::pyarray& csrColumnOffsets_hv_hu, + xt::pyarray& csrRowIndeces_hv_hv, xt::pyarray& csrColumnOffsets_hv_hv, + xt::pyarray& csrRowIndeces_hv_heta, xt::pyarray& csrColumnOffsets_hv_heta, + xt::pyarray& csrRowIndeces_hv_hw, xt::pyarray& csrColumnOffsets_hv_hw, + // heta + xt::pyarray& csrRowIndeces_heta_h, xt::pyarray& csrColumnOffsets_heta_h, + xt::pyarray& csrRowIndeces_heta_hu, xt::pyarray& csrColumnOffsets_heta_hu, + xt::pyarray& csrRowIndeces_heta_hv, xt::pyarray& csrColumnOffsets_heta_hv, + xt::pyarray& csrRowIndeces_heta_heta, xt::pyarray& csrColumnOffsets_heta_heta, + xt::pyarray& csrRowIndeces_heta_hw, xt::pyarray& csrColumnOffsets_heta_hw, + // hw + xt::pyarray& csrRowIndeces_hw_h, xt::pyarray& csrColumnOffsets_hw_h, + xt::pyarray& csrRowIndeces_hw_hu, xt::pyarray& csrColumnOffsets_hw_hu, + xt::pyarray& csrRowIndeces_hw_hv, xt::pyarray& csrColumnOffsets_hw_hv, + xt::pyarray& csrRowIndeces_hw_heta, xt::pyarray& csrColumnOffsets_hw_heta, + xt::pyarray& csrRowIndeces_hw_hw, xt::pyarray& csrColumnOffsets_hw_hw, + // + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { + // + // loop over elements to compute volume integrals and load them into the + // element Jacobians and global Jacobian + // + for (int eN = 0; eN < nElements_global; eN++) { + register double elementJacobian_h_h[nDOF_test_element] + [nDOF_trial_element], + elementJacobian_hu_hu[nDOF_test_element][nDOF_trial_element], + elementJacobian_hv_hv[nDOF_test_element][nDOF_trial_element], + elementJacobian_heta_heta[nDOF_test_element][nDOF_trial_element], + elementJacobian_hw_hw[nDOF_test_element][nDOF_trial_element]; + for (int i = 0; i < nDOF_test_element; i++) + for (int j = 0; j < nDOF_trial_element; j++) { + elementJacobian_h_h[i][j] = 0.0; + elementJacobian_hu_hu[i][j] = 0.0; + elementJacobian_hv_hv[i][j] = 0.0; + elementJacobian_heta_heta[i][j] = 0.0; + elementJacobian_heta_heta[i][j] = 0.0; + } + for (int k = 0; k < nQuadraturePoints_element; k++) { + int eN_k = eN * nQuadraturePoints_element + + k, // index to a scalar at a quadrature point + eN_k_nSpace = eN_k * nSpace, + eN_nDOF_trial_element = + eN * nDOF_trial_element; // index to a vector at a + // quadrature point + + // declare local storage + register double jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace], + dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, + y, xt, yt; + // get jacobian, etc for mapping reference element + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, + y); + // get the physical integration weight + dV = fabs(jacDet) * dV_ref[k]; + // precalculate test function products with integration weights + for (int j = 0; j < nDOF_trial_element; j++) { + h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV; + vel_test_dV[j] = vel_test_ref[k * nDOF_trial_element + j] * dV; + } + + for (int i = 0; i < nDOF_test_element; i++) { + register int i_nSpace = i * nSpace; + for (int j = 0; j < nDOF_trial_element; j++) { + register int j_nSpace = j * nSpace; + elementJacobian_h_h[i][j] += (i == j ? 1.0 : 0.0) * h_test_dV[i]; + elementJacobian_hu_hu[i][j] += + (i == j ? 1.0 : 0.0) * vel_test_dV[i]; + elementJacobian_hv_hv[i][j] += + (i == j ? 1.0 : 0.0) * vel_test_dV[i]; + elementJacobian_heta_heta[i][j] += + (i == j ? 1.0 : 0.0) * vel_test_dV[i]; + elementJacobian_hw_hw[i][j] += + (i == j ? 1.0 : 0.0) * vel_test_dV[i]; + } // j + } // i + } // k + // + // load into element Jacobian into global Jacobian + // + for (int i = 0; i < nDOF_test_element; i++) { + register int eN_i = eN * nDOF_test_element + i; + for (int j = 0; j < nDOF_trial_element; j++) { + register int eN_i_j = eN_i * nDOF_trial_element + j; + globalJacobian[csrRowIndeces_h_h[eN_i] + + csrColumnOffsets_h_h[eN_i_j]] += + elementJacobian_h_h[i][j]; + globalJacobian[csrRowIndeces_hu_hu[eN_i] + + csrColumnOffsets_hu_hu[eN_i_j]] += + elementJacobian_hu_hu[i][j]; + globalJacobian[csrRowIndeces_hv_hv[eN_i] + + csrColumnOffsets_hv_hv[eN_i_j]] += + elementJacobian_hv_hv[i][j]; + globalJacobian[csrRowIndeces_heta_heta[eN_i] + + csrColumnOffsets_heta_heta[eN_i_j]] += + elementJacobian_heta_heta[i][j]; + globalJacobian[csrRowIndeces_hw_hw[eN_i] + + csrColumnOffsets_hw_hw[eN_i_j]] += + elementJacobian_hw_hw[i][j]; + } // j + } // i + } // elements + } +}; // GN_SW2DCV + +inline GN_SW2DCV_base * +newGN_SW2DCV(int nSpaceIn, int nQuadraturePoints_elementIn, + int nDOF_mesh_trial_elementIn, int nDOF_trial_elementIn, + int nDOF_test_elementIn, int nQuadraturePoints_elementBoundaryIn, + int CompKernelFlag) { + return proteus::chooseAndAllocateDiscretization2D( + nSpaceIn, nQuadraturePoints_elementIn, nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, CompKernelFlag); +} +} // namespace proteus + +#endif diff --git a/proteus/mprans/GN_SW2DCV.py b/proteus/mprans/GN_SW2DCV.py index 18ba98f7bb..a1787b77d4 100644 --- a/proteus/mprans/GN_SW2DCV.py +++ b/proteus/mprans/GN_SW2DCV.py @@ -5,6 +5,10 @@ from past.utils import old_div import proteus from proteus.mprans.cGN_SW2DCV import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class NumericalFlux(proteus.NumericalFlux.ShallowWater_2D): @@ -1632,7 +1636,7 @@ def getJacobian(self, jacobian): self.csrRowIndeces[(4, 2)], self.csrColumnOffsets[(4, 2)], self.csrRowIndeces[(4, 3)], self.csrColumnOffsets[(4, 3)], self.csrRowIndeces[(4, 4)], self.csrColumnOffsets[(4, 4)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/Kappa.cpp b/proteus/mprans/Kappa.cpp new file mode 100644 index 0000000000..cbfe1754fd --- /dev/null +++ b/proteus/mprans/Kappa.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "Kappa.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::Kappa_base; + +PYBIND11_MODULE(cKappa, m) +{ + xt::import_numpy(); + + py::class_(m, "cKappa_base") + .def(py::init(&proteus::newKappa)) + .def("calculateResidual", &Kappa_base::calculateResidual) + .def("calculateJacobian", &Kappa_base::calculateJacobian); +} diff --git a/proteus/mprans/Kappa.h b/proteus/mprans/Kappa.h index 21ebd22d74..d983ed4a97 100644 --- a/proteus/mprans/Kappa.h +++ b/proteus/mprans/Kappa.h @@ -5,6 +5,9 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "SedClosure.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -31,27 +34,27 @@ namespace proteus double vos_limiter, double mu_fr_limiter){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -63,15 +66,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -80,67 +83,67 @@ namespace proteus int lag_shockCapturing, double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_dissipation, //dissipation rate variable - double* q_grad_dissipation, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_dissipation, //dissipation rate variable + xt::pyarray& q_grad_dissipation, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_dissipation, //dissipation rate variable on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_dissipation, //dissipation rate variable on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion @@ -156,52 +159,52 @@ namespace proteus double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_dissipation, //dissipation rate - double* q_grad_dissipation, - double* q_porosity,//VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_dissipation, //dissipation rate + xt::pyarray& q_grad_dissipation, + xt::pyarray& q_porosity,//VRANS // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_phi,double epsFact, - double* ebqe_dissipation,//dissipation rate on boundary - double* ebqe_porosity)=0; //VRANS + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_dissipation,//dissipation rate on boundary + xt::pyarray& ebqe_porosity)=0; //VRANS }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -850,15 +853,15 @@ namespace proteus double rho_1, // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment int dissipation_model_flag, //end diffusion @@ -867,45 +870,45 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_dissipation, //dissipation rate - double* q_grad_dissipation, - double* q_porosity, //VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_dissipation, //dissipation rate + xt::pyarray& q_grad_dissipation, + xt::pyarray& q_porosity, //VRANS //velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_dissipation, //dissipation rate on boundary - double* ebqe_porosity, //VRANS - double* ebqe_u, - double* ebqe_flux) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_dissipation, //dissipation rate on boundary + xt::pyarray& ebqe_porosity, //VRANS + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux) { //cek should this be read in? double Ct_sge = 4.0; @@ -974,19 +977,19 @@ namespace proteus // } ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; @@ -994,17 +997,17 @@ namespace proteus //get the trial function gradients ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution and previous solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u_old); + ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u_old); // //compute velocity production terms, ***assumes same spaces for velocity dofs and kappa!*** - ck.gradFromDOF(velocity_dof_u,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx); - ck.gradFromDOF(velocity_dof_v,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy); - ck.gradFromDOF(velocity_dof_w,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz); + ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx); + ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy); + ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz); // // @@ -1211,27 +1214,27 @@ namespace proteus ebN_local, kb, ebN_local_kb, - mesh_dof, - mesh_l2g, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - boundaryJac_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, metricTensorDetSqrt, - normal_ref, + normal_ref.data(), normal, x_ext,y_ext,z_ext); ck.calculateMappingVelocity_elementBoundary(eN, ebN_local, kb, ebN_local_kb, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_trace_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), xt_ext,yt_ext,zt_ext, normal, boundaryJac, @@ -1245,18 +1248,18 @@ namespace proteus //shape ck.gradTrialFromRef(&u_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace); //solution and gradients - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext); - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext); + ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext); + ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext); + ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext); //mwf hack, skip on boundary for now grad_dissipation_ext_dummy[0] = 0.0; grad_dissipation_ext_dummy[1] = 0.0; grad_dissipation_ext_dummy[2] = 0.0; // //compute velocity production terms, ***assumes same spaces for velocity dofs and kappa!*** - ck.gradFromDOF(velocity_dof_u,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext); - ck.gradFromDOF(velocity_dof_v,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext); - ck.gradFromDOF(velocity_dof_w,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext); + ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext); + ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext); + ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext); // //precalculate test function products with integration weights @@ -1402,27 +1405,27 @@ namespace proteus } void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, //diffusion terms @@ -1438,51 +1441,51 @@ namespace proteus double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, double* u_dof_old, - double* velocity, - double* phi_ls, //level set variable - double* q_dissipation, //dissipation rate - double* q_grad_dissipation, - double* q_porosity,//VRANS + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& phi_ls, //level set variable + xt::pyarray& q_dissipation, //dissipation rate + xt::pyarray& q_grad_dissipation, + xt::pyarray& q_porosity,//VRANS // Argumentlist for sediment double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, + xt::pyarray& q_vos, + xt::pyarray& q_vos_gradc, + xt::pyarray& ebqe_q_vos, + xt::pyarray& ebqe_q_vos_gradc, double rho_f, double rho_s, - double* vs, - double* ebqe_vs, - double* g, + xt::pyarray& vs, + xt::pyarray& ebqe_vs, + xt::pyarray& g, //end sediment - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, + xt::pyarray& velocity_dof_u, + xt::pyarray& velocity_dof_v, + xt::pyarray& velocity_dof_w, //end velocity dof - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - double* ebqe_penalty_ext, //penalty - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& ebqe_penalty_ext, //penalty + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isAdvectiveFluxBoundary_u, - double* ebqe_bc_advectiveFlux_u_ext, - int* isDiffusiveFluxBoundary_u, - double* ebqe_bc_diffusiveFlux_u_ext, - int* csrColumnOffsets_eb_u_u, - double* ebqe_phi,double epsFact, - double* ebqe_dissipation,//dissipation rate on boundary - double* ebqe_porosity) //VRANS + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& ebqe_bc_advectiveFlux_u_ext, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& ebqe_bc_diffusiveFlux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_dissipation,//dissipation rate on boundary + xt::pyarray& ebqe_porosity) //VRANS { double Ct_sge = 4.0; @@ -1545,19 +1548,19 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; @@ -1565,15 +1568,15 @@ namespace proteus //get the trial function gradients ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution at old and new time step - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); // //compute velocity production terms, ***assumes same spaces for velocity dofs and kappa!*** - ck.gradFromDOF(velocity_dof_u,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx); - ck.gradFromDOF(velocity_dof_v,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy); - ck.gradFromDOF(velocity_dof_w,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz); + ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx); + ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy); + ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz); // //precalculate test function products with integration weights @@ -1609,7 +1612,7 @@ namespace proteus rho_f, rho_s, &vs[eN_k_nSpace], - g, + g.data(), //end sediment dissipation_model_flag, grad_u_old, @@ -1789,27 +1792,27 @@ namespace proteus ebN_local, kb, ebN_local_kb, - mesh_dof, - mesh_l2g, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - boundaryJac_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, metricTensorDetSqrt, - normal_ref, + normal_ref.data(), normal, x_ext,y_ext,z_ext); ck.calculateMappingVelocity_elementBoundary(eN, ebN_local, kb, ebN_local_kb, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_trace_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), xt_ext,yt_ext,zt_ext, normal, boundaryJac, @@ -1822,18 +1825,18 @@ namespace proteus //shape ck.gradTrialFromRef(&u_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace); //solution and gradients - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext); - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext); + ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext); + ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext); + ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext); //mwf hack, skip on boundary for now grad_dissipation_ext_dummy[0] = 0.0; grad_dissipation_ext_dummy[1] = 0.0; grad_dissipation_ext_dummy[2] = 0.0; // //compute velocity production terms, ***assumes same spaces for velocity dofs and kappa!*** - ck.gradFromDOF(velocity_dof_u,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext); - ck.gradFromDOF(velocity_dof_v,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext); - ck.gradFromDOF(velocity_dof_w,&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext); + ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext); + ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext); + ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext); // //precalculate test function products with integration weights diff --git a/proteus/mprans/Kappa.py b/proteus/mprans/Kappa.py index b714958896..672939c5f7 100644 --- a/proteus/mprans/Kappa.py +++ b/proteus/mprans/Kappa.py @@ -5,6 +5,10 @@ import proteus from proteus.mprans.cKappa import * from proteus.mprans.cKappa2D import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport """ NOTES: @@ -1186,7 +1190,7 @@ def getJacobian(self, jacobian): self.shockCapturing.numDiff_last[0], self.ebqe['penalty'], self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/Kappa2D.cpp b/proteus/mprans/Kappa2D.cpp new file mode 100644 index 0000000000..bff38558c0 --- /dev/null +++ b/proteus/mprans/Kappa2D.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "Kappa2D.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::Kappa2D_base; + +PYBIND11_MODULE(cKappa2D, m) +{ + xt::import_numpy(); + + py::class_(m, "cKappa2D_base") + .def(py::init(&proteus::newKappa2D)) + .def("calculateResidual", &Kappa2D_base::calculateResidual) + .def("calculateJacobian", &Kappa2D_base::calculateJacobian); +} diff --git a/proteus/mprans/Kappa2D.h b/proteus/mprans/Kappa2D.h index 62a507fc43..bcc8e35619 100644 --- a/proteus/mprans/Kappa2D.h +++ b/proteus/mprans/Kappa2D.h @@ -5,6 +5,9 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "SedClosure.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { diff --git a/proteus/mprans/MCorr.cpp b/proteus/mprans/MCorr.cpp new file mode 100644 index 0000000000..9099c92e15 --- /dev/null +++ b/proteus/mprans/MCorr.cpp @@ -0,0 +1,38 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "MCorr.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::MCorr_base; +using pybind11::return_value_policy; + +PYBIND11_MODULE(cMCorr, m) +{ + xt::import_numpy(); + + py::class_(m, "cMCorr_base") + .def(py::init(&proteus::newMCorr)) + .def("calculateResidual" , &MCorr_base::calculateResidual ) + .def("calculateJacobian" , &MCorr_base::calculateJacobian ) + .def("elementSolve" , &MCorr_base::elementSolve ) + .def("elementConstantSolve" , &MCorr_base::elementConstantSolve ) + .def("globalConstantRJ" , &MCorr_base::globalConstantRJ, return_value_policy::take_ownership) + .def("calculateMass" , &MCorr_base::calculateMass, return_value_policy::take_ownership) + .def("setMassQuadrature" , &MCorr_base::setMassQuadrature ) + .def("FCTStep" , &MCorr_base::FCTStep ) + .def("calculateMassMatrix" , &MCorr_base::calculateMassMatrix ) + .def("setMassQuadratureEdgeBasedStabilizationMethods" , &MCorr_base::setMassQuadratureEdgeBasedStabilizationMethods ); +} diff --git a/proteus/mprans/MCorr.h b/proteus/mprans/MCorr.h index dfe4081979..9098d1f540 100644 --- a/proteus/mprans/MCorr.h +++ b/proteus/mprans/MCorr.h @@ -7,6 +7,9 @@ #include "ModelFactory.h" #include "equivalent_polynomials.h" #include PROTEUS_LAPACK_H +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -23,444 +26,441 @@ namespace proteus std::valarray FluxCorrectionMatrix; virtual ~MCorr_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, bool useExact)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_porosity, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_porosity, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, bool useExact)=0; virtual void elementSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol)=0; virtual void elementConstantSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol)=0; - virtual void globalConstantRJ(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + virtual std::tuple globalConstantRJ(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol, - double constant_u, - double* constantResidual, - double* constantJacobian)=0; - virtual void calculateMass(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + double constant_u)=0; + virtual double calculateMass(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* globalMass, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, bool useExact)=0; virtual void setMassQuadrature(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* H_dof, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& H_dof, bool useExact)=0; virtual void FCTStep(int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* lumped_mass_matrix, //lumped mass matrix (as vector) - double* solH, //DOFs of high order solution at tnp1 - double* solL, - double* limited_solution, - int* csrRowIndeces_DofLoops, //csr row indeces - int* csrColumnOffsets_DofLoops, //csr column offsets - double* MassMatrix //mass matrix + xt::pyarray& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& solL, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix //mass matrix )=0; virtual void calculateMassMatrix(//element (MQL) - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_porosity, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - double* globalLumpedMassMatrix)=0; + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_porosity, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + xt::pyarray& globalLumpedMassMatrix)=0; virtual void setMassQuadratureEdgeBasedStabilizationMethods(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* rhs_mass_correction, - double* lumped_L2p_vof_mass_correction, - double* lumped_mass_matrix, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& rhs_mass_correction, + xt::pyarray& lumped_L2p_vof_mass_correction, + xt::pyarray& lumped_mass_matrix, int numDOFs, bool useExact)=0; }; @@ -663,55 +663,55 @@ namespace proteus } } void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, bool useExact) { // @@ -732,61 +732,61 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - // double* u_trial, - // double* u_grad_trial, - // double* u_test_dV, - // double* u_grad_test_dV, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_porosity, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + // xt::pyarray& u_trial, + // xt::pyarray& u_grad_trial, + // xt::pyarray& u_test_dV, + // xt::pyarray& u_grad_test_dV, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_porosity, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, bool useExact) { // @@ -1093,48 +1093,48 @@ namespace proteus for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol) { @@ -1227,50 +1227,50 @@ namespace proteus { element_u[i]=0.0; }//i - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_porosity.data(), offset_u,stride_u, elementResidual_u, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1287,37 +1287,37 @@ namespace proteus while (resNorm >= atol && its < maxIts) { its+=1; - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - q_H, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_porosity.data(), elementJacobian_u_u, element_u, eN); @@ -1361,50 +1361,50 @@ namespace proteus }//i lambda /= 2.0; //compute new residual - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_porosity.data(), offset_u,stride_u, elementResidual_u, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); lsIts +=1; @@ -1425,52 +1425,52 @@ namespace proteus }//elements } void elementConstantSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol) { @@ -1485,50 +1485,50 @@ namespace proteus { element_u[i]=elementConstant_u; }//i - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_porosity.data(), offset_u,stride_u, elementResidual_u, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1545,37 +1545,37 @@ namespace proteus while (resNorm >= atol && its < maxIts) { its+=1; - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - q_H, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_porosity.data(), elementJacobian_u_u, element_u, eN); @@ -1595,50 +1595,50 @@ namespace proteus element_u[i] = elementConstant_u; }//i //compute new residual - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_porosity, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_porosity.data(), offset_u,stride_u, elementResidual_u, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1653,64 +1653,62 @@ namespace proteus }//elements } - void globalConstantRJ(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + std::tuple globalConstantRJ(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol, - double constant_u, - double* constantResidual, - double* constantJacobian) + double constant_u) { register double element_u[nDOF_test_element], elementResidual_u[nDOF_test_element], elementJacobian_u_u[nDOF_test_element*nDOF_trial_element]; - *constantResidual = 0.0; - *constantJacobian = 0.0; + double constantResidual = 0.0; + double constantJacobian = 0.0; for (int i=0;i(constantResidual, constantJacobian); } - void calculateMass(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + double calculateMass(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* globalMass, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, bool useExact) { - *globalMass = 0.0; + double globalMass = 0.0; gf.useExact=useExact; for(int eN=0;eN& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* H_dof, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& H_dof, bool useExact) { gf.useExact=useExact; @@ -2000,16 +1999,16 @@ namespace proteus for (int i=0;i& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& solL, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix //mass matrix ) { Rpos.resize(numDOFs,0.0), Rneg.resize(numDOFs,0.0); @@ -2094,18 +2093,18 @@ namespace proteus for (int i=0; i0) ? std::min(Rposi,Rneg[j]) : std::min(Rnegi,Rpos[j])) * FluxCorrectionMatrix[ij]; @@ -2148,7 +2147,7 @@ namespace proteus //update ij ij+=1; } - limited_solution[i] = fmax(0.0,solL[i] + 1./lumped_mass_matrix[i]*ith_Limiter_times_FluxCorrectionMatrix); + limited_solution.data()[i] = fmax(0.0,solL.data()[i] + 1./lumped_mass_matrix.data()[i]*ith_Limiter_times_FluxCorrectionMatrix); } } @@ -2301,46 +2300,46 @@ namespace proteus } void calculateMassMatrix(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - // double* u_trial, - // double* u_grad_trial, - // double* u_test_dV, - // double* u_grad_test_dV, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_porosity, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalMassMatrix, - double* globalLumpedMassMatrix) + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + // xt::pyarray& u_trial, + // xt::pyarray& u_grad_trial, + // xt::pyarray& u_test_dV, + // xt::pyarray& u_grad_test_dV, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_porosity, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalMassMatrix, + xt::pyarray& globalLumpedMassMatrix) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -2351,39 +2350,39 @@ namespace proteus for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_porosity, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_porosity, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* rhs_mass_correction, - double* lumped_L2p_vof_mass_correction, - double* lumped_mass_matrix, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& rhs_mass_correction, + xt::pyarray& lumped_L2p_vof_mass_correction, + xt::pyarray& lumped_mass_matrix, int numDOFs, bool useExact) { @@ -2472,16 +2471,16 @@ namespace proteus for (int i=0;i ai; + std::allocator ad; + } + } +#endif +} + +namespace py = pybind11; + +PYBIND11_MODULE(cMCorr3P, m) +{ + using proteus::cppMCorr3P_base; + using proteus::newMCorr3P; + + xt::import_numpy(); + + py::class_(m, "cppMCorr3P_base") + .def("calculateResidual", &cppMCorr3P_base::calculateResidual) + .def("calculateJacobian", &cppMCorr3P_base::calculateJacobian) + .def("elementSolve", &cppMCorr3P_base::elementSolve) + .def("elementConstantSolve", &cppMCorr3P_base::elementConstantSolve) + .def("globalConstantRJ", &cppMCorr3P_base::globalConstantRJ) + .def("calculateMass", &cppMCorr3P_base::calculateMass) + .def("setMassQuadrature", &cppMCorr3P_base::setMassQuadrature) + .def("calculateStiffnessMatrix", &cppMCorr3P_base::calculateStiffnessMatrix); + + m.def("newMCorr3P", newMCorr3P); +} diff --git a/proteus/mprans/MCorr3P.h b/proteus/mprans/MCorr3P.h index b217d499ec..c5dd8c4644 100644 --- a/proteus/mprans/MCorr3P.h +++ b/proteus/mprans/MCorr3P.h @@ -6,6 +6,8 @@ #include "ModelFactory.h" #include PROTEUS_LAPACK_H +#include "xtensor-python/pyarray.hpp" + #define FAST_ASSEMBLY 1 namespace proteus @@ -15,357 +17,357 @@ namespace proteus public: virtual ~cppMCorr3P_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, // fast (jacobian) assembly - double* interface_lumpedMassMatrix)=0; + xt::pyarray& interface_lumpedMassMatrix)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_vos, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_vos, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, // Fast assembly int numDOFs, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - double* stiffness_matrix, - double* interface_lumpedMassMatrix)=0; + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& stiffness_matrix, + xt::pyarray& interface_lumpedMassMatrix)=0; virtual void elementSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol)=0; virtual void elementConstantSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol)=0; virtual void globalConstantRJ(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol, double constant_u, - double* constantResidual, - double* constantJacobian)=0; + double& constantResidual, + double& constantJacobian)=0; virtual void calculateMass(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* globalMass)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + double& globalMass)=0; virtual void setMassQuadrature(//element - double* mesh_trial_ip, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ip, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* H_dof)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& H_dof)=0; virtual void calculateStiffnessMatrix(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_grad_trial_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_grad_trial_ref, int nElements_global, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, double useMetrics, double epsFactDiffusion, - double* elementDiameter, - double* nodeDiametersArray)=0; + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, // fast (jacobian) assembly - double* interface_lumpedMassMatrix) + xt::pyarray& interface_lumpedMassMatrix) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -676,51 +678,51 @@ namespace proteus register int eN_i=eN*nDOF_test_element+i; element_u[i] = u_dof[u_l2g[eN_i]]; }//i - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_vos.data(), offset_u,stride_u, elementResidual_u, elementInterface_lumpedMassMatrix, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); // @@ -792,18 +794,18 @@ namespace proteus ebN_local, kb, ebN_local_kb, - mesh_dof, - mesh_l2g, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - boundaryJac_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, metricTensorDetSqrt, - normal_ref, + normal_ref.data(), normal, x_ext,y_ext,z_ext); dS = metricTensorDetSqrt*dS_ref[kb]; @@ -982,51 +984,51 @@ namespace proteus }//k } void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - // double* u_trial, - // double* u_grad_trial, - // double* u_test_dV, - // double* u_grad_test_dV, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_vos, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + // xt::pyarray& u_trial, + // xt::pyarray& u_grad_trial, + // xt::pyarray& u_test_dV, + // xt::pyarray& u_grad_test_dV, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_vos, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, // Fast assembly int numDOFs, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - double* stiffness_matrix, - double* interface_lumpedMassMatrix) + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& stiffness_matrix, + xt::pyarray& interface_lumpedMassMatrix) { if (FAST_ASSEMBLY==1) { @@ -1054,37 +1056,37 @@ namespace proteus register int eN_j = eN*nDOF_trial_element+j; element_u[j] = u_dof[u_l2g[eN_j]]; } - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - q_H, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_vos.data(), elementJacobian_u_u, element_u, eN); @@ -1106,52 +1108,52 @@ namespace proteus }//computeJacobian void elementSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol) { @@ -1180,51 +1182,51 @@ namespace proteus { element_u[i]=0.0; }//i - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_vos.data(), offset_u,stride_u, elementResidual_u, dummy, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1241,37 +1243,37 @@ namespace proteus while (resNorm >= atol && its < maxIts) { its+=1; - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - q_H, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_vos.data(), elementJacobian_u_u, element_u, eN); @@ -1315,51 +1317,51 @@ namespace proteus }//i lambda /= 2.0; //compute new residual - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_vos.data(), offset_u,stride_u, elementResidual_u, dummy, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); lsIts +=1; @@ -1380,52 +1382,52 @@ namespace proteus }//elements } void elementConstantSolve(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol) { @@ -1442,51 +1444,51 @@ namespace proteus { element_u[i]=elementConstant_u; }//i - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_vos.data(), offset_u,stride_u, elementResidual_u, dummy, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1503,37 +1505,37 @@ namespace proteus while (resNorm >= atol && its < maxIts) { its+=1; - calculateElementJacobian(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - q_H, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_vos.data(), elementJacobian_u_u, element_u, eN); @@ -1553,51 +1555,51 @@ namespace proteus element_u[i] = elementConstant_u; }//i //compute new residual - calculateElementResidual(mesh_trial_ref, - mesh_grad_trial_ref, - mesh_dof, - mesh_l2g, - dV_ref, - u_trial_ref, - u_grad_trial_ref, - u_test_ref, - u_grad_test_ref, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - dS_ref, - u_trial_trace_ref, - u_grad_trial_trace_ref, - u_test_trace_ref, - u_grad_test_trace_ref, - normal_ref, - boundaryJac_ref, + calculateElementResidual(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), nElements_global, useMetrics, epsFactHeaviside, epsFactDirac, epsFactDiffusion, - u_l2g, - elementDiameter, - nodeDiametersArray, - u_dof, - q_phi, - q_normal_phi, - ebqe_phi, - ebqe_normal_phi, - q_H, - q_u, - q_n, - ebqe_u, - ebqe_n, - q_r, - q_vos, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + ebqe_phi.data(), + ebqe_normal_phi.data(), + q_H.data(), + q_u.data(), + q_n.data(), + ebqe_u.data(), + ebqe_n.data(), + q_r.data(), + q_vos.data(), offset_u,stride_u, elementResidual_u, dummy, nExteriorElementBoundaries_global, - exteriorElementBoundariesArray, - elementBoundaryElementsArray, - elementBoundaryLocalElementBoundariesArray, + exteriorElementBoundariesArray.data(), + elementBoundaryElementsArray.data(), + elementBoundaryLocalElementBoundariesArray.data(), element_u, eN); //compute l2 norm @@ -1613,64 +1615,64 @@ namespace proteus } void globalConstantRJ(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int maxIts, double atol, double constant_u, - double* constantResidual, - double* constantJacobian) + double& constantResidual, + double& constantJacobian) { register double element_u[nDOF_test_element], elementResidual_u[nDOF_test_element], dummy[nDOF_test_element], elementJacobian_u_u[nDOF_test_element*nDOF_trial_element]; - *constantResidual = 0.0; - *constantJacobian = 0.0; + constantResidual = 0.0; + constantJacobian = 0.0; for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_owned, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* globalMass) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + double& globalMass) { - *globalMass = 0.0; + globalMass = 0.0; for(int eN=0;eN& mesh_trial_ip, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* phi_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* phi_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& phi_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& phi_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* H_dof) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& H_dof) { for(int eN=0;eN& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_grad_trial_ref, //physics int nElements_global, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, // for weight within stiffness matrix double useMetrics, double epsFactDiffusion, - double* elementDiameter, - double* nodeDiametersArray) + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray) { // //loop over elements @@ -2037,19 +2039,19 @@ namespace proteus // ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; diff --git a/proteus/mprans/MCorr3P.py b/proteus/mprans/MCorr3P.py index 30b5d4f451..8bdecf2c63 100644 --- a/proteus/mprans/MCorr3P.py +++ b/proteus/mprans/MCorr3P.py @@ -662,7 +662,7 @@ def __init__(self, self.elementDiameter[:] = max(self.mesh.elementDiametersArray) else: self.elementDiameter = self.mesh.elementDiametersArray - self.mcorr3p = cMCorr3P.MCorr3P( + self.mcorr3p = cMCorr3P.newMCorr3P( self.nSpace_global, self.nQuadraturePoints_element, self.u[0].femSpace.elementMaps.localFunctionSpace.dim, @@ -772,7 +772,7 @@ def getStiffnessMatrix(self): self.u[0].femSpace.grad_psi, self.mesh.nElements_global, self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - self.stiffness_matrix, + self.stiffness_matrix.getCSRrepresentation()[2], self.coefficients.useMetrics, self.coefficients.epsFactDiffusion, self.elementDiameter, @@ -818,7 +818,7 @@ def getJacobian(self, jacobian): self.coefficients.q_H_vof, self.coefficients.q_vos, self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - jacobian, + jacobian.getCSRrepresentation()[2], # FAST ASSEMBLY len(self.u[0].dof), self.rowptr, diff --git a/proteus/mprans/MoveMesh.cpp b/proteus/mprans/MoveMesh.cpp new file mode 100644 index 0000000000..392fcc9cd4 --- /dev/null +++ b/proteus/mprans/MoveMesh.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "MoveMesh.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::MoveMesh_base; + +PYBIND11_MODULE(cMoveMesh, m) +{ + xt::import_numpy(); + + py::class_(m, "cMoveMesh_base") + .def(py::init(&proteus::newMoveMesh)) + .def("calculateResidual", &MoveMesh_base::calculateResidual) + .def("calculateJacobian", &MoveMesh_base::calculateJacobian); +} diff --git a/proteus/mprans/MoveMesh.h b/proteus/mprans/MoveMesh.h index 2fe65ec6ce..bed3362be4 100644 --- a/proteus/mprans/MoveMesh.h +++ b/proteus/mprans/MoveMesh.h @@ -4,6 +4,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -12,111 +15,111 @@ namespace proteus public: virtual ~MoveMesh_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, int offset_u, int offset_v, int offset_w, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, int offset_u, int offset_v, int offset_w, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -469,31 +472,31 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&disp_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); + ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); //get the solution - ck.valFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],w); + ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],w); //get the solution gradients - ck.gradFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_v); - ck.gradFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_w); + ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v); + ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w); //precalculate test function products with integration weights for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w) { CompKernel ck; const int nSymTen(ck.nSymTen); @@ -801,31 +804,31 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&disp_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); + ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); //get the solution - ck.valFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],w); + ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],w); //get the solution gradients - ck.gradFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_v); - ck.gradFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_w); + ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v); + ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w); //precalculate test function products with integration weights for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::MoveMesh2D_base; + +PYBIND11_MODULE(cMoveMesh2D, m) +{ + xt::import_numpy(); + + py::class_(m, "cMoveMesh2D_base") + .def(py::init(&proteus::newMoveMesh2D)) + .def("calculateResidual", &MoveMesh2D_base::calculateResidual) + .def("calculateJacobian", &MoveMesh2D_base::calculateJacobian); +} diff --git a/proteus/mprans/MoveMesh2D.h b/proteus/mprans/MoveMesh2D.h index 5fbfde8334..3bd9c91cd9 100644 --- a/proteus/mprans/MoveMesh2D.h +++ b/proteus/mprans/MoveMesh2D.h @@ -4,6 +4,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -12,111 +15,111 @@ namespace proteus public: virtual ~MoveMesh2D_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, int offset_u, int offset_v, int offset_w, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* disp_trial_ref, - double* disp_grad_trial_ref, - double* disp_test_ref, - double* disp_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* bodyForce, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& bodyForce, int offset_u, int offset_v, int offset_w, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - double* ebqe_bc_u_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_stressFlux_u_ext, - double* ebqe_bc_stressFlux_v_ext, - double* ebqe_bc_stressFlux_w_ext) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_stressFlux_u_ext, + xt::pyarray& ebqe_bc_stressFlux_v_ext, + xt::pyarray& ebqe_bc_stressFlux_w_ext) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -469,31 +472,31 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&disp_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); + ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); //get the solution - ck.valFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],v); - /* ck.valFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],w); */ + ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],v); + /* ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],w); */ //get the solution gradients - ck.gradFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_v); - /* ck.gradFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_w); */ + ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v); + /* ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w); */ //precalculate test function products with integration weights for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& disp_trial_ref, + xt::pyarray& disp_grad_trial_ref, + xt::pyarray& disp_test_ref, + xt::pyarray& disp_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* disp_trial_trace_ref, - double* disp_grad_trial_trace_ref, - double* disp_test_trace_ref, - double* disp_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& disp_trial_trace_ref, + xt::pyarray& disp_grad_trial_trace_ref, + xt::pyarray& disp_test_trace_ref, + xt::pyarray& disp_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* materialTypes, + xt::pyarray& materialTypes, int nMaterialProperties, - double* materialProperties, - int* disp_l2g, - double* u_dof, double* v_dof, double* w_dof, - double* bodyForce, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& materialProperties, + xt::pyarray& disp_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& bodyForce, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isStressFluxBoundary_u, - int* isStressFluxBoundary_v, - int* isStressFluxBoundary_w, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isStressFluxBoundary_u, + xt::pyarray& isStressFluxBoundary_v, + xt::pyarray& isStressFluxBoundary_w, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w) { CompKernel ck; const int nSymTen(ck.nSymTen); @@ -801,31 +804,31 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&disp_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); + ck.gradTrialFromRef(&disp_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,disp_grad_trial); //get the solution - ck.valFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],v); - /* ck.valFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],&disp_trial_ref[k*nDOF_trial_element],w); */ + ck.valFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],v); + /* ck.valFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],&disp_trial_ref.data()[k*nDOF_trial_element],w); */ //get the solution gradients - ck.gradFromDOF(u_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_v); - /* ck.gradFromDOF(w_dof,&disp_l2g[eN_nDOF_trial_element],disp_grad_trial,grad_w); */ + ck.gradFromDOF(u_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_v); + /* ck.gradFromDOF(w_dof.data(),&disp_l2g.data()[eN_nDOF_trial_element],disp_grad_trial,grad_w); */ //precalculate test function products with integration weights for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::NCLS_base; + +PYBIND11_MODULE(cNCLS, m) +{ + xt::import_numpy(); + + py::class_(m, "cNCLS_base") + .def(py::init(&proteus::newNCLS)) + .def("calculateResidual" , &NCLS_base::calculateResidual ) + .def("calculateJacobian" , &NCLS_base::calculateJacobian ) + .def("calculateWaterline" , &NCLS_base::calculateWaterline ) + .def("calculateRedistancingResidual" , &NCLS_base::calculateRedistancingResidual ) + .def("calculateRhsSmoothing" , &NCLS_base::calculateRhsSmoothing ) + .def("calculateResidual_entropy_viscosity" , &NCLS_base::calculateResidual_entropy_viscosity ) + .def("calculateMassMatrix" , &NCLS_base::calculateMassMatrix ) + .def("calculateSmoothingMatrix" , &NCLS_base::calculateSmoothingMatrix ); +} diff --git a/proteus/mprans/NCLS.h b/proteus/mprans/NCLS.h index 301fb02603..9c1dc1e860 100644 --- a/proteus/mprans/NCLS.h +++ b/proteus/mprans/NCLS.h @@ -5,6 +5,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; #define POWER_SMOOTHNESS_INDICATOR 2 #define IS_BETAij_ONE 0 @@ -45,27 +48,27 @@ namespace proteus virtual ~NCLS_base(){} virtual void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -73,53 +76,53 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* uStar_dof, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_grad_u, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& interface_locator, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, // AUX QUANTITIES OF INTEREST - double* quantDOFs, + xt::pyarray& quantDOFs, // COUPEZ double lambda_coupez, double epsCoupez, @@ -127,90 +130,90 @@ namespace proteus int COUPEZ, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML, int STABILIZATION_TYPE, int ENTROPY_TYPE, double cE )=0; virtual void calculateJacobian(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int PURE_BDF, int LUMPED_MASS_MATRIX )=0; virtual void calculateWaterline(//element - int* wlc, - double* waterline, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& wlc, + xt::pyarray& waterline, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -218,111 +221,111 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypes, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypes, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u)=0; virtual double calculateRedistancingResidual( double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* u_dof_old, - double* uStar_dof, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, // PARAMETERS FOR EDGE BASED STABILIZATION int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, // COUPEZ double lambda_coupez, double epsCoupez, double epsFactRedistancing, - double* edge_based_cfl, + xt::pyarray& edge_based_cfl, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML )=0; virtual double calculateRhsSmoothing( - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof_old, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof_old, int offset_u, int stride_u, - double* globalResidual + xt::pyarray& globalResidual )=0; virtual void calculateResidual_entropy_viscosity(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -330,53 +333,53 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* uStar_dof, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_grad_u, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& interface_locator, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, // AUX QUANTITIES OF INTEREST - double* quantDOFs, + xt::pyarray& quantDOFs, // COUPEZ double lambda_coupez, double epsCoupez, @@ -384,115 +387,115 @@ namespace proteus int COUPEZ, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML, int STABILIZATION_TYPE, int ENTROPY_TYPE, double cE )=0; virtual void calculateMassMatrix(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int PURE_BDF, int LUMPED_MASS_MATRIX )=0; virtual void calculateSmoothingMatrix(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, double he )=0; }; @@ -649,27 +652,27 @@ namespace proteus void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -677,53 +680,53 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* uStar_dof, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_grad_u, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& interface_locator, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, // AUX QUANTITIES OF INTEREST - double* quantDOFs, + xt::pyarray& quantDOFs, // COUPEZ double lambda_coupez, double epsCoupez, @@ -731,10 +734,10 @@ namespace proteus int COUPEZ, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML, int STABILIZATION_TYPE, int ENTROPY_TYPE, double cE @@ -790,46 +793,46 @@ namespace proteus // ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u); //precalculate test function products with integration weights for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int PURE_BDF, int LUMPED_MASS_MATRIX) { @@ -1231,33 +1234,33 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u); //precalculate test function products with integration weights for (int j=0;j& wlc, + xt::pyarray& waterline, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1586,29 +1589,29 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypes, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypes, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u) { // Tetrehedral elements specific extraction routine for waterline extraction @@ -1620,11 +1623,11 @@ namespace proteus for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; - register int eN = elementBoundaryElementsArray[ebN*2+0]; - register int bN = elementBoundaryLocalElementBoundariesArray[ebN*2+0]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; + register int eN = elementBoundaryElementsArray.data()[ebN*2+0]; + register int bN = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0]; - if (elementBoundaryMaterialTypes[ebN] >6) + if (elementBoundaryMaterialTypes.data()[ebN] >6) { double val,x,y,z; @@ -1637,10 +1640,10 @@ namespace proteus if (j != bN) { int eN_nDOF_trial_element_j = eN*nDOF_trial_element + j; int eN_nDOF_mesh_trial_element_j = eN*nDOF_mesh_trial_element + j; - val = u_dof[u_l2g[eN_nDOF_trial_element_j]]; - x = mesh_dof[mesh_l2g[eN_nDOF_mesh_trial_element_j]*3+0]; - y = mesh_dof[mesh_l2g[eN_nDOF_mesh_trial_element_j]*3+1]; - z = mesh_dof[mesh_l2g[eN_nDOF_mesh_trial_element_j]*3+2]; + val = u_dof.data()[u_l2g.data()[eN_nDOF_trial_element_j]]; + x = mesh_dof.data()[mesh_l2g.data()[eN_nDOF_mesh_trial_element_j]*3+0]; + y = mesh_dof.data()[mesh_l2g.data()[eN_nDOF_mesh_trial_element_j]*3+1]; + z = mesh_dof.data()[mesh_l2g.data()[eN_nDOF_mesh_trial_element_j]*3+2]; if (val < 0.0) { @@ -1669,10 +1672,10 @@ namespace proteus double alpha = vp/(vp -vn); - waterline[wlc[0]*3 + 0] = alpha*(xn/neg) + (1.0-alpha)*(xp/pos); - waterline[wlc[0]*3 + 1] = alpha*(yn/neg) + (1.0-alpha)*(yp/pos); - waterline[wlc[0]*3 + 2] = alpha*(zn/neg) + (1.0-alpha)*(zp/pos); - wlc[0]++; + waterline.data()[wlc.data()[0]*3 + 0] = alpha*(xn/neg) + (1.0-alpha)*(xp/pos); + waterline.data()[wlc.data()[0]*3 + 1] = alpha*(yn/neg) + (1.0-alpha)*(yp/pos); + waterline.data()[wlc.data()[0]*3 + 2] = alpha*(zn/neg) + (1.0-alpha)*(zp/pos); + wlc.data()[0]++; } // end value if @@ -1680,48 +1683,48 @@ namespace proteus }//ebNE - //std::cout<<"CPP WLC "<& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* u_dof_old, - double* uStar_dof, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, // PARAMETERS FOR EDGE BASED STABILIZATION int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, // COUPEZ double lambda_coupez, // double epsCoupez, double epsFactRedistancing, - double* edge_based_cfl, + xt::pyarray& edge_based_cfl, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML ) { L2_norm_per_node.resize(numDOFs,0.0); @@ -1772,23 +1775,23 @@ namespace proteus jac[nSpace*nSpace], jacDet, jacInv[nSpace*nSpace], dV,x,y,z; //get the physical integration weight - ck.calculateMapping_element(eN,k,mesh_dof,mesh_l2g,mesh_trial_ref,mesh_grad_trial_ref,jac,jacDet,jacInv,x,y,z); - dV = fabs(jacDet)*dV_ref[k]; + ck.calculateMapping_element(eN,k,mesh_dof.data(),mesh_l2g.data(),mesh_trial_ref.data(),mesh_grad_trial_ref.data(),jac,jacDet,jacInv,x,y,z); + dV = fabs(jacDet)*dV_ref.data()[k]; // get h at quad points - ck.valFromDOF(nodeDiametersArray,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],hquad); + ck.valFromDOF(nodeDiametersArray.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],hquad); // get the star solution at quad points - ck.valFromDOF(uStar_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],uStar); + ck.valFromDOF(uStar_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],uStar); //get the solution at quad points - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution at quad point at tn - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); + ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],un); // solution and grads at old times at quad points - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_un); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_un); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof_old, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof_old, int offset_u, int stride_u, - double* globalResidual) + xt::pyarray& globalResidual) { ////////////////////////////////////////////// // ** LOOP IN CELLS FOR CELL BASED TERMS ** // @@ -1962,13 +1965,13 @@ namespace proteus jac[nSpace*nSpace], jacDet, jacInv[nSpace*nSpace], dV,x,y,z; //get the physical integration weight - ck.calculateMapping_element(eN,k,mesh_dof,mesh_l2g,mesh_trial_ref,mesh_grad_trial_ref,jac,jacDet,jacInv,x,y,z); - dV = fabs(jacDet)*dV_ref[k]; + ck.calculateMapping_element(eN,k,mesh_dof.data(),mesh_l2g.data(),mesh_trial_ref.data(),mesh_grad_trial_ref.data(),jac,jacDet,jacInv,x,y,z); + dV = fabs(jacDet)*dV_ref.data()[k]; //get the solution at quad point at tn - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); + ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],un); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -2021,53 +2024,53 @@ namespace proteus int lag_shockCapturing, double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* uStar_dof, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& uStar_dof, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_grad_u, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& interface_locator, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, // AUX QUANTITIES OF INTEREST - double* quantDOFs, + xt::pyarray& quantDOFs, // COPUEZ double lambda_coupez, double epsCoupez, @@ -2075,10 +2078,10 @@ namespace proteus int COUPEZ, int SATURATED_LEVEL_SET, // C-Matrices - double* Cx, - double* Cy, - double* Cz, - double* ML, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& ML, int STABILIZATION_TYPE, int ENTROPY_TYPE, double cE) @@ -2161,35 +2164,35 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv,x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; JacDet = fabs(jacDet); // get h at quad points - ck.valFromDOF(nodeDiametersArray,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],hquad); + ck.valFromDOF(nodeDiametersArray.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],hquad); //get the solution (of Newton's solver). To compute time derivative term - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(uStar_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],uStar); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(uStar_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],uStar); //get the solution at quad point at tn and tnm1 for entropy viscosity // solution and grads at old times at quad points - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); + ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],un); //get the solution gradients at tn for entropy viscosity - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_un); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_un); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j= 0.) @@ -2366,10 +2369,10 @@ namespace proteus //update ij ij+=1; } - gx[i] /= ML[i]; - gy[i] /= ML[i]; + gx[i] /= ML.data()[i]; + gy[i] /= ML.data()[i]; #if nSpace==3 - gz[i] /= ML[i]; + gz[i] /= ML.data()[i]; #endif } } @@ -2393,15 +2396,15 @@ namespace proteus } else //smoothness based stab { - xi = mesh_dof[i*3+0]; - yi = mesh_dof[i*3+1]; + xi = mesh_dof.data()[i*3+0]; + yi = mesh_dof.data()[i*3+1]; #if nSpace==3 - zi = mesh_dof[i*3+2]; + zi = mesh_dof.data()[i*3+2]; #endif } - for (int offset=csrRowIndeces_DofLoops[i]; offset& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int PURE_BDF, int LUMPED_MASS_MATRIX) { @@ -2773,33 +2776,33 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u); //precalculate test function products with integration weights for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, double he) { double Ct_sge = 4.0; @@ -3015,33 +3018,33 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; ck.calculateG(jacInv,G,G_dd_G,tr_G); //get the trial function gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u); //precalculate test function products with integration weights for (int j=0;j ai; + std::allocator ad; + } + } +#endif +} + +namespace py = pybind11; + +PYBIND11_MODULE(cNCLS3P, m) +{ + using proteus::cppNCLS3P_base; + using proteus::newNCLS3P; + + xt::import_numpy(); + + py::class_(m, "cppNCLS3P_base") + .def("calculateResidual", &cppNCLS3P_base::calculateResidual) + .def("calculateJacobian", &cppNCLS3P_base::calculateJacobian) + .def("calculateWaterline", &cppNCLS3P_base::calculateWaterline); + + m.def("newNCLS3P", newNCLS3P); +} + diff --git a/proteus/mprans/NCLS3P.h b/proteus/mprans/NCLS3P.h index a16ac4451e..768134c1e6 100644 --- a/proteus/mprans/NCLS3P.h +++ b/proteus/mprans/NCLS3P.h @@ -5,6 +5,8 @@ #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + #define cE 0.1 #define cMax 0.1 @@ -29,27 +31,27 @@ namespace proteus public: virtual ~cppNCLS3P_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -57,115 +59,115 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* cell_interface_locator, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& cell_interface_locator, + xt::pyarray& interface_locator, // FOR TAYLOR GALERKIN METHODS int EXPLICIT_METHOD, double degree_polynomial, int stage, - double* uTilde_dof, + xt::pyarray& uTilde_dof, double dt, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // FOR TAYLOR GALERKIN METHODS int EXPLICIT_METHOD, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF)=0; virtual void calculateWaterline(//element - int* wlc, - double* waterline, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, + xt::pyarray& wlc, + xt::pyarray& waterline, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -173,28 +175,28 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypes, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypes, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -359,38 +361,38 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* cell_interface_locator, - double* interface_locator, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& cell_interface_locator, + xt::pyarray& interface_locator, // FOR TAYLOR GALERKIN METHODS int EXPLICIT_METHOD, double degree_polynomial, int stage, - double* uTilde_dof, + xt::pyarray& uTilde_dof, double dt, // TO KILL SUPG AND SHOCK CAPTURING int PURE_BDF) @@ -451,19 +453,19 @@ namespace proteus // ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; @@ -473,24 +475,24 @@ namespace proteus jacInv, u_grad_trial); //get the solution - ck.valFromDOF(u_dof, + ck.valFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_ref[k*nDOF_trial_element], u); - ck.valFromDOF(u_dof_old, + ck.valFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_ref[k*nDOF_trial_element], un); //get the solution gradients - ck.gradFromDOF(u_dof, + ck.gradFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_u); - ck.gradFromDOF(u_dof_old, + ck.gradFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_u_old); - ck.gradFromDOF(uTilde_dof, + ck.gradFromDOF(uTilde_dof.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_uTilde); @@ -794,27 +796,27 @@ namespace proteus ebN_local, kb, ebN_local_kb, - mesh_dof, - mesh_l2g, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - boundaryJac_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, metricTensorDetSqrt, - normal_ref, + normal_ref.data(), normal, x_ext,y_ext,z_ext); ck.calculateMappingVelocity_elementBoundary(eN, ebN_local, kb, ebN_local_kb, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_trace_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_trace_ref.data(), xt_ext,yt_ext,zt_ext, normal, boundaryJac, @@ -832,22 +834,22 @@ namespace proteus //solution and gradients if (EXPLICIT_METHOD==1) // explicit { - ck.valFromDOF(u_dof_old, + ck.valFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_trace_ref[ebN_local_kb*nDOF_test_element], u_ext); - ck.gradFromDOF(u_dof_old, + ck.gradFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial_trace, grad_u_ext); } else { - ck.valFromDOF(u_dof, + ck.valFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_trace_ref[ebN_local_kb*nDOF_test_element], u_ext); - ck.gradFromDOF(u_dof, + ck.gradFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial_trace, grad_u_ext); @@ -929,51 +931,51 @@ namespace proteus } void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double alphaBDF, int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_rd_u_ext, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_rd_u_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // FOR TAYLOR GALERKIN METHODS int EXPLICIT_METHOD, // TO KILL SUPG AND SHOCK CAPTURING @@ -1024,19 +1026,19 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; @@ -1044,9 +1046,9 @@ namespace proteus //get the trial function gradients ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); //get the solution - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); //get the solution gradients - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); + ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u); //precalculate test function products with integration weights for (int j=0;j& wlc, + xt::pyarray& waterline, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1395,28 +1397,28 @@ namespace proteus int lag_shockCapturing, /*mwf not used yet*/ double shockCapturingDiffusion, double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof,xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* elementBoundaryMaterialTypes, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& elementBoundaryMaterialTypes, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u) { // Tetrehedral elements specific extraction routine for waterline extraction diff --git a/proteus/mprans/NCLS3P.py b/proteus/mprans/NCLS3P.py index 5f45c09c78..feab9c18be 100644 --- a/proteus/mprans/NCLS3P.py +++ b/proteus/mprans/NCLS3P.py @@ -725,7 +725,7 @@ def __init__(self, # calculateCoefficients,calculateElementResidual etc self.globalResidualDummy = None compKernelFlag = 0 - self.ncls3p = cNCLS3P.NCLS3P( + self.ncls3p = cNCLS3P.newNCLS3P( self.nSpace_global, self.nQuadraturePoints_element, self.u[0].femSpace.elementMaps.localFunctionSpace.dim, @@ -939,6 +939,7 @@ def getJacobian(self, jacobian): # pdb.set_trace() # cNCLS3P.calculateJacobian(self.mesh.nElements_global, + (rowptr, colind, globalJacobian) = jacobian.getCSRrepresentation() self.ncls3p.calculateJacobian( # element self.u[0].femSpace.elementMaps.psi, self.u[0].femSpace.elementMaps.grad_psi, @@ -975,7 +976,7 @@ def getJacobian(self, jacobian): self.q[('cfl', 0)], self.shockCapturing.numDiff_last[0], self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - jacobian, + globalJacobian, self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/Pres.cpp b/proteus/mprans/Pres.cpp new file mode 100644 index 0000000000..a402cf81e0 --- /dev/null +++ b/proteus/mprans/Pres.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "Pres.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppPres_base; + +PYBIND11_MODULE(cPres, m) +{ + xt::import_numpy(); + + py::class_(m, "Pres") + .def(py::init(&proteus::newPres)) + .def("calculateResidual", &cppPres_base::calculateResidual) + .def("calculateJacobian", &cppPres_base::calculateJacobian); +} diff --git a/proteus/mprans/Pres.h b/proteus/mprans/Pres.h index 97e074aa95..c3f1d02d99 100644 --- a/proteus/mprans/Pres.h +++ b/proteus/mprans/Pres.h @@ -4,6 +4,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -12,66 +15,66 @@ namespace proteus public: virtual ~cppPres_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* u_l2g, - double* u_dof, - double* q_u, - double* q_grad_u, - double* q_p_last, - double* q_p_inc, - double* q_massFlux, - double* ebqe_massFlux, - double* ebqe_u, - double* ebqe_grad_u, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_p_last, + xt::pyarray& q_p_inc, + xt::pyarray& q_massFlux, + xt::pyarray& ebqe_massFlux, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, int nElements_global, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian)=0; + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* u_l2g, - double* u_dof, - double* q_u, - double* q_grad_u, - double* q_p_last, - double* q_p_inc, - double* q_massFlux, - double* ebqe_massFlux, - double* ebqe_u, - double* ebqe_grad_u, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_p_last, + xt::pyarray& q_p_inc, + xt::pyarray& q_massFlux, + xt::pyarray& ebqe_massFlux, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -273,43 +276,43 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian) + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -525,24 +528,24 @@ namespace proteus for(int eN=0;eN a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppPresInc_base; + +PYBIND11_MODULE(cPresInc, m) +{ + xt::import_numpy(); + + py::class_(m, "PresInc") + .def(py::init(&proteus::newPresInc)) + .def("calculateResidual", &cppPresInc_base::calculateResidual) + .def("calculateJacobian", &cppPresInc_base::calculateJacobian); +} diff --git a/proteus/mprans/PresInc.h b/proteus/mprans/PresInc.h index 9c0be15a52..07d67113ff 100644 --- a/proteus/mprans/PresInc.h +++ b/proteus/mprans/PresInc.h @@ -4,6 +4,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -12,109 +15,109 @@ namespace proteus public: virtual ~cppPresInc_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* isDOFBoundary, - int* isFluxBoundary, - int* u_l2g, - double* u_dof, + xt::pyarray& isDOFBoundary, + xt::pyarray& isFluxBoundary, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, double alphaBDF, - double* q_vf, - double* q_divU, - double* q_vs, - double* q_vos, + xt::pyarray& q_vf, + xt::pyarray& q_divU, + xt::pyarray& q_vs, + xt::pyarray& q_vos, double rho_s, - double* q_rho_f, + xt::pyarray& q_rho_f, double rho_s_min, double rho_f_min, - double* ebqe_vf, - double* ebqe_vs, - double* ebqe_vos, - double* ebqe_rho_f, - double* q_u, - double* q_grad_u, - double* ebqe_u, - double* ebqe_grad_u, - double* ebqe_bc_u_ext, - double* ebqe_adv_flux, - double* ebqe_diff_flux, - double* bc_adv_flux, - double* bc_diff_flux, + xt::pyarray& ebqe_vf, + xt::pyarray& ebqe_vs, + xt::pyarray& ebqe_vos, + xt::pyarray& ebqe_rho_f, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_adv_flux, + xt::pyarray& ebqe_diff_flux, + xt::pyarray& bc_adv_flux, + xt::pyarray& bc_diff_flux, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int INTEGRATE_BY_PARTS_DIV_U, - double* q_a, - double* ebqe_a)=0; + xt::pyarray& q_a, + xt::pyarray& ebqe_a)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* isDOFBoundary, - int* isFluxBoundary, - int* u_l2g, - double* u_dof, + xt::pyarray& isDOFBoundary, + xt::pyarray& isFluxBoundary, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, double alphaBDF, - double* q_vf, - double* q_vs, - double* q_vos, + xt::pyarray& q_vf, + xt::pyarray& q_vs, + xt::pyarray& q_vos, double rho_s, - double* q_rho_f, + xt::pyarray& q_rho_f, double rho_s_min, double rho_f_min, - double* ebqe_vf, - double* ebqe_vs, - double* ebqe_vos, - double* ebqe_rho_f, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& ebqe_vf, + xt::pyarray& ebqe_vs, + xt::pyarray& ebqe_vos, + xt::pyarray& ebqe_rho_f, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* csrColumnOffsets_eb_u_u)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& csrColumnOffsets_eb_u_u)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* isDOFBoundary, - int* isFluxBoundary, - int* u_l2g, - double* u_dof, + xt::pyarray& isDOFBoundary, + xt::pyarray& isFluxBoundary, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, double alphaBDF, - double* q_vf, - double* q_divU, - double* q_vs, - double* q_vos, + xt::pyarray& q_vf, + xt::pyarray& q_divU, + xt::pyarray& q_vs, + xt::pyarray& q_vos, double rho_s, - double* q_rho_f, + xt::pyarray& q_rho_f, double rho_s_min, double rho_f_min, - double* ebqe_vf, - double* ebqe_vs, - double* ebqe_vos, - double* ebqe_rho_f, - double* q_u, - double* q_grad_u, - double* ebqe_u, - double* ebqe_grad_u, - double* ebqe_bc_u_ext, - double* ebqe_adv_flux, - double* ebqe_diff_flux, - double* bc_adv_flux, - double* bc_diff_flux, + xt::pyarray& ebqe_vf, + xt::pyarray& ebqe_vs, + xt::pyarray& ebqe_vos, + xt::pyarray& ebqe_rho_f, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_grad_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_adv_flux, + xt::pyarray& ebqe_diff_flux, + xt::pyarray& bc_adv_flux, + xt::pyarray& bc_diff_flux, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, int INTEGRATE_BY_PARTS_DIV_U, - double* q_a, - double* ebqe_a) + xt::pyarray& q_a, + xt::pyarray& ebqe_a) { double compatibility_condition=0.; /* // COMPUTE COMPATIBILITY CONSTANT */ @@ -436,17 +439,17 @@ namespace proteus /* dV,x,y,z; */ /* ck.calculateMapping_element(eN, */ /* k, */ - /* mesh_dof, */ - /* mesh_l2g, */ - /* mesh_trial_ref, */ - /* mesh_grad_trial_ref, */ + /* mesh_dof.data(), */ + /* mesh_l2g.data(), */ + /* mesh_trial_ref.data(), */ + /* mesh_grad_trial_ref.data(), */ /* jac, */ /* jacDet, */ /* jacInv, */ /* x,y,z); */ /* //get the physical integration weight */ - /* dV = fabs(jacDet)*dV_ref[k]; */ - /* compatibility_condition -= q_divU[eN_k]*dV; */ + /* dV = fabs(jacDet)*dV_ref.data()[k]; */ + /* compatibility_condition -= q_divU.data()[eN_k]*dV; */ /* } */ /* } */ // @@ -466,65 +469,65 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, - int* isDOFBoundary, - int* isFluxBoundary, - int* u_l2g, - double* u_dof, + xt::pyarray& isDOFBoundary, + xt::pyarray& isFluxBoundary, + xt::pyarray& u_l2g, + xt::pyarray& u_dof, double alphaBDF, - double* q_vf, - double* q_vs, - double* q_vos, + xt::pyarray& q_vf, + xt::pyarray& q_vs, + xt::pyarray& q_vos, double rho_s, - double* q_rho_f, + xt::pyarray& q_rho_f, double rho_s_min, double rho_f_min, - double* ebqe_vf, - double* ebqe_vs, - double* ebqe_vos, - double* ebqe_rho_f, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& ebqe_vf, + xt::pyarray& ebqe_vs, + xt::pyarray& ebqe_vos, + xt::pyarray& ebqe_rho_f, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* csrColumnOffsets_eb_u_u) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& csrColumnOffsets_eb_u_u) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -865,35 +868,35 @@ namespace proteus for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppPresInit_base; + +PYBIND11_MODULE(cPresInit, m) +{ + xt::import_numpy(); + + py::class_(m, "PresInit") + .def(py::init(&proteus::newPresInit)) + .def("calculateResidual", &cppPresInit_base::calculateResidual) + .def("calculateJacobian", &cppPresInit_base::calculateJacobian); +} diff --git a/proteus/mprans/PresInit.h b/proteus/mprans/PresInit.h index 7e4a67b205..257e0cd2c7 100644 --- a/proteus/mprans/PresInit.h +++ b/proteus/mprans/PresInit.h @@ -4,6 +4,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; namespace proteus { @@ -12,88 +15,88 @@ namespace proteus public: virtual ~cppPresInit_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_vos, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian)=0; + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_vos, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* q_phi, - double* q_normal_phi, - double* ebqe_phi, - double* ebqe_normal_phi, - double* q_H, - double* q_u, - double* q_n, - double* ebqe_u, - double* ebqe_n, - double* q_r, - double* q_vos, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& ebqe_phi, + xt::pyarray& ebqe_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, + xt::pyarray& q_r, + xt::pyarray& q_vos, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -397,52 +400,52 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, double epsFactHeaviside, double epsFactDirac, double epsFactDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - // double* u_trial, - // double* u_grad_trial, - // double* u_test_dV, - // double* u_grad_test_dV, - double* q_phi, - double* q_normal_phi, - double* q_H, - double* q_vos, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian) + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + // xt::pyarray& u_trial, + // xt::pyarray& u_grad_trial, + // xt::pyarray& u_test_dV, + // xt::pyarray& u_grad_test_dV, + xt::pyarray& q_phi, + xt::pyarray& q_normal_phi, + xt::pyarray& q_H, + xt::pyarray& q_vos, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -730,39 +733,39 @@ namespace proteus for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::RANS2P_base; + +PYBIND11_MODULE(cRANS2P, m) +{ + xt::import_numpy(); + + py::class_(m, "cRANS2P_base") + .def(py::init(&proteus::newRANS2P)) + .def("calculateResidual" , &RANS2P_base::calculateResidual ) + .def("calculateJacobian" , &RANS2P_base::calculateJacobian ) + .def("calculateVelocityAverage" , &RANS2P_base::calculateVelocityAverage ) + .def("getTwoPhaseAdvectionOperator" , &RANS2P_base::getTwoPhaseAdvectionOperator ) + .def("getTwoPhaseInvScaledLaplaceOperator" , &RANS2P_base::getTwoPhaseInvScaledLaplaceOperator ) + .def("getTwoPhaseScaledMassOperator" , &RANS2P_base::getTwoPhaseScaledMassOperator ); +} diff --git a/proteus/mprans/RANS2P.h b/proteus/mprans/RANS2P.h index 7339c4e299..2ecc6d7223 100644 --- a/proteus/mprans/RANS2P.h +++ b/proteus/mprans/RANS2P.h @@ -7,6 +7,10 @@ #include "MixedModelFactory.h" #include "PyEmbeddedFunctions.h" #include "equivalent_polynomials.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + const double DM=0.0;//1-mesh conservation and divergence, 0 - weak div(v) only const double DM2=0.0;//1-point-wise mesh volume strong-residual, 0 - div(v) only const double DM3=1.0;//1-point-wise divergence, 0-point-wise rate of volume change @@ -25,42 +29,42 @@ namespace proteus double PRESSURE_SGE, double VELOCITY_SGE, double PRESSURE_PROJECTION_STABLIZATION, - double *numerical_viscosity, + xt::pyarray &numerical_viscosity, //element - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray &mesh_trial_ref, + xt::pyarray &mesh_grad_trial_ref, + xt::pyarray &mesh_dof, + xt::pyarray &mesh_velocity_dof, double MOVING_DOMAIN, //0 or 1 - int *mesh_l2g, - double *x_ref, - double *dV_ref, - double *p_trial_ref, - double *p_grad_trial_ref, - double *p_test_ref, - double *p_grad_test_ref, - double *vel_trial_ref, - double *vel_grad_trial_ref, - double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray &mesh_l2g, + xt::pyarray &x_ref, + xt::pyarray &dV_ref, + xt::pyarray &p_trial_ref, + xt::pyarray &p_grad_trial_ref, + xt::pyarray &p_test_ref, + xt::pyarray &p_grad_test_ref, + xt::pyarray &vel_trial_ref, + xt::pyarray &vel_grad_trial_ref, + xt::pyarray &vel_test_ref, + xt::pyarray &vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray &mesh_trial_trace_ref, + xt::pyarray &mesh_grad_trial_trace_ref, + xt::pyarray &dS_ref, + xt::pyarray &p_trial_trace_ref, + xt::pyarray &p_grad_trial_trace_ref, + xt::pyarray &p_test_trace_ref, + xt::pyarray &p_grad_test_trace_ref, + xt::pyarray &vel_trial_trace_ref, + xt::pyarray &vel_grad_trial_trace_ref, + xt::pyarray &vel_test_trace_ref, + xt::pyarray &vel_grad_test_trace_ref, + xt::pyarray &normal_ref, + xt::pyarray &boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray &elementDiameter, + xt::pyarray &nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -81,146 +85,146 @@ namespace proteus double C_dc, double C_b, //VRANS - const double *eps_solid, - double *phi_solid, - const double *q_velocity_solid, - const double *q_porosity, - const double *q_dragAlpha, - const double *q_dragBeta, - const double *q_mass_source, - const double *q_turb_var_0, - const double *q_turb_var_1, - const double *q_turb_var_grad_0, + const xt::pyarray &eps_solid, + xt::pyarray &phi_solid, + const xt::pyarray &q_velocity_solid, + const xt::pyarray &q_porosity, + const xt::pyarray &q_dragAlpha, + const xt::pyarray &q_dragBeta, + const xt::pyarray &q_mass_source, + const xt::pyarray &q_turb_var_0, + const xt::pyarray &q_turb_var_1, + const xt::pyarray &q_turb_var_grad_0, const double LAG_LES, - double *q_eddy_viscosity, - double *q_eddy_viscosity_last, - double *ebqe_eddy_viscosity, - double *ebqe_eddy_viscosity_last, - int *p_l2g, - int *vel_l2g, - int* rp_l2g, - int* rvel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double *p_old_dof, - double *u_old_dof, - double *v_old_dof, - double *w_old_dof, - double *g, + xt::pyarray &q_eddy_viscosity, + xt::pyarray &q_eddy_viscosity_last, + xt::pyarray &ebqe_eddy_viscosity, + xt::pyarray &ebqe_eddy_viscosity_last, + xt::pyarray &p_l2g, + xt::pyarray &vel_l2g, + xt::pyarray& rp_l2g, + xt::pyarray& rvel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray &p_old_dof, + xt::pyarray &u_old_dof, + xt::pyarray &v_old_dof, + xt::pyarray &w_old_dof, + xt::pyarray &g, const double useVF, - double *q_rho, - double *vf, - double *phi, - double *phi_nodes, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc, - double *q_mom_v_acc, - double *q_mom_w_acc, - double *q_mass_adv, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *q_cfl, - double *q_numDiff_u, double *q_numDiff_v, double *q_numDiff_w, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, + xt::pyarray &q_rho, + xt::pyarray &vf, + xt::pyarray &phi, + xt::pyarray &phi_nodes, + xt::pyarray &normal_phi, + xt::pyarray &kappa_phi, + xt::pyarray &q_mom_u_acc, + xt::pyarray &q_mom_v_acc, + xt::pyarray &q_mom_w_acc, + xt::pyarray &q_mass_adv, + xt::pyarray &q_mom_u_acc_beta_bdf, xt::pyarray &q_mom_v_acc_beta_bdf, xt::pyarray &q_mom_w_acc_beta_bdf, + xt::pyarray &q_dV, + xt::pyarray &q_dV_last, + xt::pyarray &q_velocity_sge, + xt::pyarray &q_cfl, + xt::pyarray &q_numDiff_u, xt::pyarray &q_numDiff_v, xt::pyarray &q_numDiff_w, + xt::pyarray &q_numDiff_u_last, xt::pyarray &q_numDiff_v_last, xt::pyarray &q_numDiff_w_last, + xt::pyarray &sdInfo_u_u_rowptr, xt::pyarray &sdInfo_u_u_colind, + xt::pyarray &sdInfo_u_v_rowptr, xt::pyarray &sdInfo_u_v_colind, + xt::pyarray &sdInfo_u_w_rowptr, xt::pyarray &sdInfo_u_w_colind, + xt::pyarray &sdInfo_v_v_rowptr, xt::pyarray &sdInfo_v_v_colind, + xt::pyarray &sdInfo_v_u_rowptr, xt::pyarray &sdInfo_v_u_colind, + xt::pyarray &sdInfo_v_w_rowptr, xt::pyarray &sdInfo_v_w_colind, + xt::pyarray &sdInfo_w_w_rowptr, xt::pyarray &sdInfo_w_w_colind, + xt::pyarray &sdInfo_w_u_rowptr, xt::pyarray &sdInfo_w_u_colind, + xt::pyarray &sdInfo_w_v_rowptr, xt::pyarray &sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double *globalResidual, + xt::pyarray &globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray &exteriorElementBoundariesArray, + xt::pyarray &elementBoundaryElementsArray, + xt::pyarray &elementBoundaryLocalElementBoundariesArray, + xt::pyarray &ebqe_vf_ext, + xt::pyarray &bc_ebqe_vf_ext, + xt::pyarray &ebqe_phi_ext, + xt::pyarray &bc_ebqe_phi_ext, + xt::pyarray &ebqe_normal_phi_ext, + xt::pyarray &ebqe_kappa_phi_ext, //VRANS - const double *ebqe_porosity_ext, - const double *ebqe_turb_var_0, - const double *ebqe_turb_var_1, + const xt::pyarray &ebqe_porosity_ext, + const xt::pyarray &ebqe_turb_var_0, + const xt::pyarray &ebqe_turb_var_1, //VRANS end - int *isDOFBoundary_p, - int *isDOFBoundary_u, - int *isDOFBoundary_v, - int *isDOFBoundary_w, - int *isAdvectiveFluxBoundary_p, - int *isAdvectiveFluxBoundary_u, - int *isAdvectiveFluxBoundary_v, - int *isAdvectiveFluxBoundary_w, - int *isDiffusiveFluxBoundary_u, - int *isDiffusiveFluxBoundary_v, - int *isDiffusiveFluxBoundary_w, - double *ebqe_bc_p_ext, - double *ebqe_bc_flux_mass_ext, - double *ebqe_bc_flux_mom_u_adv_ext, - double *ebqe_bc_flux_mom_v_adv_ext, - double *ebqe_bc_flux_mom_w_adv_ext, - double *ebqe_bc_u_ext, - double *ebqe_bc_flux_u_diff_ext, - double *ebqe_penalty_ext, - double *ebqe_bc_v_ext, - double *ebqe_bc_flux_v_diff_ext, - double *ebqe_bc_w_ext, - double *ebqe_bc_flux_w_diff_ext, - double *q_x, - double *q_velocity, - double *ebqe_velocity, - double *flux, - double *elementResidual_p, - int *elementFlags, - int *boundaryFlags, - double *barycenters, - double *wettedAreas, - double *netForces_p, - double *netForces_v, - double *netMoments, - double *velocityError, - double *velocityErrorNodal, - double *forcex, - double *forcey, - double *forcez, + xt::pyarray &isDOFBoundary_p, + xt::pyarray &isDOFBoundary_u, + xt::pyarray &isDOFBoundary_v, + xt::pyarray &isDOFBoundary_w, + xt::pyarray &isAdvectiveFluxBoundary_p, + xt::pyarray &isAdvectiveFluxBoundary_u, + xt::pyarray &isAdvectiveFluxBoundary_v, + xt::pyarray &isAdvectiveFluxBoundary_w, + xt::pyarray &isDiffusiveFluxBoundary_u, + xt::pyarray &isDiffusiveFluxBoundary_v, + xt::pyarray &isDiffusiveFluxBoundary_w, + xt::pyarray &ebqe_bc_p_ext, + xt::pyarray &ebqe_bc_flux_mass_ext, + xt::pyarray &ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray &ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray &ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray &ebqe_bc_u_ext, + xt::pyarray &ebqe_bc_flux_u_diff_ext, + xt::pyarray &ebqe_penalty_ext, + xt::pyarray &ebqe_bc_v_ext, + xt::pyarray &ebqe_bc_flux_v_diff_ext, + xt::pyarray &ebqe_bc_w_ext, + xt::pyarray &ebqe_bc_flux_w_diff_ext, + xt::pyarray &q_x, + xt::pyarray &q_velocity, + xt::pyarray &ebqe_velocity, + xt::pyarray &flux, + xt::pyarray &elementResidual_p, + xt::pyarray &elementFlags, + xt::pyarray &boundaryFlags, + xt::pyarray &barycenters, + xt::pyarray &wettedAreas, + xt::pyarray &netForces_p, + xt::pyarray &netForces_v, + xt::pyarray &netMoments, + xt::pyarray &velocityError, + xt::pyarray &velocityErrorNodal, + xt::pyarray &forcex, + xt::pyarray &forcey, + xt::pyarray &forcez, int use_ball_as_particle, - double *ball_center, - double *ball_radius, - double *ball_velocity, - double *ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, + xt::pyarray &ball_center, + xt::pyarray &ball_radius, + xt::pyarray &ball_velocity, + xt::pyarray &ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, + xt::pyarray &particle_netForces, + xt::pyarray &particle_netMoments, + xt::pyarray &particle_surfaceArea, int nElements_owned, double particle_nitsche, double particle_epsFact, double particle_alpha, double particle_beta, double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, const int use_pseudo_penalty, bool useExact) = 0; virtual void calculateJacobian(double NONCONSERVATIVE_FORM, @@ -229,40 +233,40 @@ namespace proteus double VELOCITY_SGE, double PRESSURE_PROJECTION_STABILIZATION, //element - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray &mesh_trial_ref, + xt::pyarray &mesh_grad_trial_ref, + xt::pyarray &mesh_dof, + xt::pyarray &mesh_velocity_dof, double MOVING_DOMAIN, - int *mesh_l2g, - double *x_ref, - double *dV_ref, - double *p_trial_ref, - double *p_grad_trial_ref, - double *p_test_ref, - double *p_grad_test_ref, - double *vel_trial_ref, - double *vel_grad_trial_ref, - double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray &mesh_l2g, + xt::pyarray &x_ref, + xt::pyarray &dV_ref, + xt::pyarray &p_trial_ref, + xt::pyarray &p_grad_trial_ref, + xt::pyarray &p_test_ref, + xt::pyarray &p_grad_test_ref, + xt::pyarray &vel_trial_ref, + xt::pyarray &vel_grad_trial_ref, + xt::pyarray &vel_test_ref, + xt::pyarray &vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray &mesh_trial_trace_ref, + xt::pyarray &mesh_grad_trial_trace_ref, + xt::pyarray &dS_ref, + xt::pyarray &p_trial_trace_ref, + xt::pyarray &p_grad_trial_trace_ref, + xt::pyarray &p_test_trace_ref, + xt::pyarray &p_grad_test_trace_ref, + xt::pyarray &vel_trial_trace_ref, + xt::pyarray &vel_grad_trial_trace_ref, + xt::pyarray &vel_test_trace_ref, + xt::pyarray &vel_grad_test_trace_ref, + xt::pyarray &normal_ref, + xt::pyarray &boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray &elementDiameter, + xt::pyarray &nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -282,138 +286,138 @@ namespace proteus double C_dg, double C_b, //VRANS - const double *eps_solid, - const double *phi_solid, - const double *q_velocity_solid, - const double *q_porosity, - const double *q_dragAlpha, - const double *q_dragBeta, - const double *q_mass_source, - const double *q_turb_var_0, - const double *q_turb_var_1, - const double *q_turb_var_grad_0, + const xt::pyarray &eps_solid, + const xt::pyarray &phi_solid, + const xt::pyarray &q_velocity_solid, + const xt::pyarray &q_porosity, + const xt::pyarray &q_dragAlpha, + const xt::pyarray &q_dragBeta, + const xt::pyarray &q_mass_source, + const xt::pyarray &q_turb_var_0, + const xt::pyarray &q_turb_var_1, + const xt::pyarray &q_turb_var_grad_0, const double LAG_LES, - double *q_eddy_viscosity_last, - double *ebqe_eddy_viscosity_last, - int *p_l2g, - int *vel_l2g, - double *p_dof, double *u_dof, double *v_dof, double *w_dof, - double *p_old_dof, - double *u_old_dof, - double *v_old_dof, - double *w_old_dof, - double *g, + xt::pyarray &q_eddy_viscosity_last, + xt::pyarray &ebqe_eddy_viscosity_last, + xt::pyarray &p_l2g, + xt::pyarray &vel_l2g, + xt::pyarray &p_dof, xt::pyarray &u_dof, xt::pyarray &v_dof, xt::pyarray &w_dof, + xt::pyarray &p_old_dof, + xt::pyarray &u_old_dof, + xt::pyarray &v_old_dof, + xt::pyarray &w_old_dof, + xt::pyarray &g, const double useVF, - double *vf, - double *phi, - double *phi_nodes, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *q_cfl, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, - int *csrRowIndeces_p_p, int *csrColumnOffsets_p_p, - int *csrRowIndeces_p_u, int *csrColumnOffsets_p_u, - int *csrRowIndeces_p_v, int *csrColumnOffsets_p_v, - int *csrRowIndeces_p_w, int *csrColumnOffsets_p_w, - int *csrRowIndeces_u_p, int *csrColumnOffsets_u_p, - int *csrRowIndeces_u_u, int *csrColumnOffsets_u_u, - int *csrRowIndeces_u_v, int *csrColumnOffsets_u_v, - int *csrRowIndeces_u_w, int *csrColumnOffsets_u_w, - int *csrRowIndeces_v_p, int *csrColumnOffsets_v_p, - int *csrRowIndeces_v_u, int *csrColumnOffsets_v_u, - int *csrRowIndeces_v_v, int *csrColumnOffsets_v_v, - int *csrRowIndeces_v_w, int *csrColumnOffsets_v_w, - int *csrRowIndeces_w_p, int *csrColumnOffsets_w_p, - int *csrRowIndeces_w_u, int *csrColumnOffsets_w_u, - int *csrRowIndeces_w_v, int *csrColumnOffsets_w_v, - int *csrRowIndeces_w_w, int *csrColumnOffsets_w_w, - double *globalJacobian, + xt::pyarray &vf, + xt::pyarray &phi, + xt::pyarray &phi_nodes, + xt::pyarray &normal_phi, + xt::pyarray &kappa_phi, + xt::pyarray &q_mom_u_acc_beta_bdf, xt::pyarray &q_mom_v_acc_beta_bdf, xt::pyarray &q_mom_w_acc_beta_bdf, + xt::pyarray &q_dV, + xt::pyarray &q_dV_last, + xt::pyarray &q_velocity_sge, + xt::pyarray &q_cfl, + xt::pyarray &q_numDiff_u_last, xt::pyarray &q_numDiff_v_last, xt::pyarray &q_numDiff_w_last, + xt::pyarray &sdInfo_u_u_rowptr, xt::pyarray &sdInfo_u_u_colind, + xt::pyarray &sdInfo_u_v_rowptr, xt::pyarray &sdInfo_u_v_colind, + xt::pyarray &sdInfo_u_w_rowptr, xt::pyarray &sdInfo_u_w_colind, + xt::pyarray &sdInfo_v_v_rowptr, xt::pyarray &sdInfo_v_v_colind, + xt::pyarray &sdInfo_v_u_rowptr, xt::pyarray &sdInfo_v_u_colind, + xt::pyarray &sdInfo_v_w_rowptr, xt::pyarray &sdInfo_v_w_colind, + xt::pyarray &sdInfo_w_w_rowptr, xt::pyarray &sdInfo_w_w_colind, + xt::pyarray &sdInfo_w_u_rowptr, xt::pyarray &sdInfo_w_u_colind, + xt::pyarray &sdInfo_w_v_rowptr, xt::pyarray &sdInfo_w_v_colind, + xt::pyarray &csrRowIndeces_p_p, xt::pyarray &csrColumnOffsets_p_p, + xt::pyarray &csrRowIndeces_p_u, xt::pyarray &csrColumnOffsets_p_u, + xt::pyarray &csrRowIndeces_p_v, xt::pyarray &csrColumnOffsets_p_v, + xt::pyarray &csrRowIndeces_p_w, xt::pyarray &csrColumnOffsets_p_w, + xt::pyarray &csrRowIndeces_u_p, xt::pyarray &csrColumnOffsets_u_p, + xt::pyarray &csrRowIndeces_u_u, xt::pyarray &csrColumnOffsets_u_u, + xt::pyarray &csrRowIndeces_u_v, xt::pyarray &csrColumnOffsets_u_v, + xt::pyarray &csrRowIndeces_u_w, xt::pyarray &csrColumnOffsets_u_w, + xt::pyarray &csrRowIndeces_v_p, xt::pyarray &csrColumnOffsets_v_p, + xt::pyarray &csrRowIndeces_v_u, xt::pyarray &csrColumnOffsets_v_u, + xt::pyarray &csrRowIndeces_v_v, xt::pyarray &csrColumnOffsets_v_v, + xt::pyarray &csrRowIndeces_v_w, xt::pyarray &csrColumnOffsets_v_w, + xt::pyarray &csrRowIndeces_w_p, xt::pyarray &csrColumnOffsets_w_p, + xt::pyarray &csrRowIndeces_w_u, xt::pyarray &csrColumnOffsets_w_u, + xt::pyarray &csrRowIndeces_w_v, xt::pyarray &csrColumnOffsets_w_v, + xt::pyarray &csrRowIndeces_w_w, xt::pyarray &csrColumnOffsets_w_w, + xt::pyarray &globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray &exteriorElementBoundariesArray, + xt::pyarray &elementBoundaryElementsArray, + xt::pyarray &elementBoundaryLocalElementBoundariesArray, + xt::pyarray &ebqe_vf_ext, + xt::pyarray &bc_ebqe_vf_ext, + xt::pyarray &ebqe_phi_ext, + xt::pyarray &bc_ebqe_phi_ext, + xt::pyarray &ebqe_normal_phi_ext, + xt::pyarray &ebqe_kappa_phi_ext, //VRANS - const double *ebqe_porosity_ext, - const double *ebqe_turb_var_0, - const double *ebqe_turb_var_1, + const xt::pyarray &ebqe_porosity_ext, + const xt::pyarray &ebqe_turb_var_0, + const xt::pyarray &ebqe_turb_var_1, //VRANS end - int *isDOFBoundary_p, - int *isDOFBoundary_u, - int *isDOFBoundary_v, - int *isDOFBoundary_w, - int *isAdvectiveFluxBoundary_p, - int *isAdvectiveFluxBoundary_u, - int *isAdvectiveFluxBoundary_v, - int *isAdvectiveFluxBoundary_w, - int *isDiffusiveFluxBoundary_u, - int *isDiffusiveFluxBoundary_v, - int *isDiffusiveFluxBoundary_w, - double *ebqe_bc_p_ext, - double *ebqe_bc_flux_mass_ext, - double *ebqe_bc_flux_mom_u_adv_ext, - double *ebqe_bc_flux_mom_v_adv_ext, - double *ebqe_bc_flux_mom_w_adv_ext, - double *ebqe_bc_u_ext, - double *ebqe_bc_flux_u_diff_ext, - double *ebqe_penalty_ext, - double *ebqe_bc_v_ext, - double *ebqe_bc_flux_v_diff_ext, - double *ebqe_bc_w_ext, - double *ebqe_bc_flux_w_diff_ext, - int *csrColumnOffsets_eb_p_p, - int *csrColumnOffsets_eb_p_u, - int *csrColumnOffsets_eb_p_v, - int *csrColumnOffsets_eb_p_w, - int *csrColumnOffsets_eb_u_p, - int *csrColumnOffsets_eb_u_u, - int *csrColumnOffsets_eb_u_v, - int *csrColumnOffsets_eb_u_w, - int *csrColumnOffsets_eb_v_p, - int *csrColumnOffsets_eb_v_u, - int *csrColumnOffsets_eb_v_v, - int *csrColumnOffsets_eb_v_w, - int *csrColumnOffsets_eb_w_p, - int *csrColumnOffsets_eb_w_u, - int *csrColumnOffsets_eb_w_v, - int *csrColumnOffsets_eb_w_w, - int *elementFlags, - int *boundaryFlags, + xt::pyarray &isDOFBoundary_p, + xt::pyarray &isDOFBoundary_u, + xt::pyarray &isDOFBoundary_v, + xt::pyarray &isDOFBoundary_w, + xt::pyarray &isAdvectiveFluxBoundary_p, + xt::pyarray &isAdvectiveFluxBoundary_u, + xt::pyarray &isAdvectiveFluxBoundary_v, + xt::pyarray &isAdvectiveFluxBoundary_w, + xt::pyarray &isDiffusiveFluxBoundary_u, + xt::pyarray &isDiffusiveFluxBoundary_v, + xt::pyarray &isDiffusiveFluxBoundary_w, + xt::pyarray &ebqe_bc_p_ext, + xt::pyarray &ebqe_bc_flux_mass_ext, + xt::pyarray &ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray &ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray &ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray &ebqe_bc_u_ext, + xt::pyarray &ebqe_bc_flux_u_diff_ext, + xt::pyarray &ebqe_penalty_ext, + xt::pyarray &ebqe_bc_v_ext, + xt::pyarray &ebqe_bc_flux_v_diff_ext, + xt::pyarray &ebqe_bc_w_ext, + xt::pyarray &ebqe_bc_flux_w_diff_ext, + xt::pyarray &csrColumnOffsets_eb_p_p, + xt::pyarray &csrColumnOffsets_eb_p_u, + xt::pyarray &csrColumnOffsets_eb_p_v, + xt::pyarray &csrColumnOffsets_eb_p_w, + xt::pyarray &csrColumnOffsets_eb_u_p, + xt::pyarray &csrColumnOffsets_eb_u_u, + xt::pyarray &csrColumnOffsets_eb_u_v, + xt::pyarray &csrColumnOffsets_eb_u_w, + xt::pyarray &csrColumnOffsets_eb_v_p, + xt::pyarray &csrColumnOffsets_eb_v_u, + xt::pyarray &csrColumnOffsets_eb_v_v, + xt::pyarray &csrColumnOffsets_eb_v_w, + xt::pyarray &csrColumnOffsets_eb_w_p, + xt::pyarray &csrColumnOffsets_eb_w_u, + xt::pyarray &csrColumnOffsets_eb_w_v, + xt::pyarray &csrColumnOffsets_eb_w_w, + xt::pyarray &elementFlags, + xt::pyarray &boundaryFlags, int use_ball_as_particle, - double *ball_center, - double *ball_radius, - double *ball_velocity, - double *ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray &ball_center, + xt::pyarray &ball_radius, + xt::pyarray &ball_velocity, + xt::pyarray &ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, int nParticles, int nElements_owned, double particle_nitsche, @@ -424,37 +428,37 @@ namespace proteus const int use_pseudo_penalty, bool useExact) = 0; virtual void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage)=0; - virtual void getTwoPhaseAdvectionOperator(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* vel_trail_ref, - double* vel_grad_trial_ref, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage)=0; + virtual void getTwoPhaseAdvectionOperator(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_trail_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -463,25 +467,25 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* vel_l2g, - double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double *vf, - double *phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* advection_matrix) = 0; - virtual void getTwoPhaseInvScaledLaplaceOperator(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_grad_trial_ref, - double* vel_grad_trial_ref, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray &vf, + xt::pyarray &phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& advection_matrix) = 0; + virtual void getTwoPhaseInvScaledLaplaceOperator(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -490,36 +494,36 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* sdInfo_p_p_rowptr, int* sdInfo_p_p_colind, - int* sdInfo_u_u_rowptr, int* sdInfo_u_u_colind, - int* sdInfo_v_v_rowptr, int* sdInfo_v_v_colind, - int* sdInfo_w_w_rowptr, int* sdInfo_w_w_colind, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* laplace_matrix)=0; + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& sdInfo_p_p_rowptr, xt::pyarray& sdInfo_p_p_colind, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& laplace_matrix)=0; virtual void getTwoPhaseScaledMassOperator(int scale_type, int use_numerical_viscosity, int lumped, - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_test_ref, - double* vel_trial_ref, - double* vel_test_ref, - double* elementDiameter, - double* nodeDiametersArray, - double* numerical_viscosity, + xt::pyarray &mesh_trial_ref, + xt::pyarray &mesh_grad_trial_ref, + xt::pyarray &mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& numerical_viscosity, int nElements_global, double useMetrics, double epsFact_rho, @@ -528,21 +532,21 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* csrRowIndeces_p_p, - int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, - int* csrColumnOffsets_w_w, - double* mass_matrix)=0; + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, + xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, + xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& mass_matrix)=0; }; template& numerical_viscosity, //element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -2457,147 +2461,147 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, const double LAG_LES, - double * q_eddy_viscosity, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity, - double * ebqe_eddy_viscosity_last, + xt::pyarray & q_eddy_viscosity, + xt::pyarray & q_eddy_viscosity_last, + xt::pyarray & ebqe_eddy_viscosity, + xt::pyarray & ebqe_eddy_viscosity_last, // - int* p_l2g, - int* vel_l2g, - int* rp_l2g, - int* rvel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* p_old_dof, - double* u_old_dof, - double* v_old_dof, - double* w_old_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& rp_l2g, + xt::pyarray& rvel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double* q_rho, - double* vf, - double* phi, - double* phi_nodes, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& q_rho, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* velocityError, - double* velocityErrorNodal, - double* forcex, - double* forcey, - double* forcez, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& velocityError, + xt::pyarray& velocityErrorNodal, + xt::pyarray& forcex, + xt::pyarray& forcey, + xt::pyarray& forcez, int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, + xt::pyarray &particle_netForces, + xt::pyarray &particle_netMoments, + xt::pyarray &particle_surfaceArea, int nElements_owned, double particle_nitsche, double particle_epsFact, double particle_alpha, double particle_beta, double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, const int use_pseudo_penalty, bool useExact) { @@ -2627,7 +2631,7 @@ namespace proteus for (int i=0;i 0) - phi_solid[eN_k] = distance_to_solids[eN_k]; + phi_solid.data()[eN_k] = distance_to_solids.data()[eN_k]; // //calculate pde coefficients at quadrature points // @@ -2892,18 +2896,18 @@ namespace proteus nu_0, rho_1, nu_1, - elementDiameter[eN], + elementDiameter.data()[eN], smagorinskyConstant, turbulenceClosureModel, - g, + g.data(), useVF, - vf[eN_k], - phi[eN_k], - &normal_phi[eN_k_nSpace], - kappa_phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], + &normal_phi.data()[eN_k_nSpace], + kappa_phi.data()[eN_k], //VRANS porosity, - phi_solid[eN_k],//distance to solid + phi_solid.data()[eN_k],//distance to solid p_old, u_old, v_old, @@ -2923,8 +2927,8 @@ namespace proteus v, w, LAG_LES, - q_eddy_viscosity[eN_k], - q_eddy_viscosity_last[eN_k], + q_eddy_viscosity.data()[eN_k], + q_eddy_viscosity_last.data()[eN_k], mom_u_acc, dmom_u_acc_u, mom_v_acc, @@ -2977,20 +2981,20 @@ namespace proteus dmom_w_ham_u, dmom_w_ham_v, dmom_w_ham_w, - q_rho[eN_k], - forcex[eN_k], - forcey[eN_k], - forcez[eN_k]); + q_rho.data()[eN_k], + forcex.data()[eN_k], + forcey.data()[eN_k], + forcez.data()[eN_k]); //VRANS - mass_source = q_mass_source[eN_k]; + mass_source = q_mass_source.data()[eN_k]; //todo: decide if these should be lagged or not? updateDarcyForchheimerTerms_Ergun(NONCONSERVATIVE_FORM, /* linearDragFactor, */ /* nonlinearDragFactor, */ /* porosity, */ /* meanGrainSize, */ - q_dragAlpha[eN_k], - q_dragBeta[eN_k], + q_dragAlpha.data()[eN_k], + q_dragBeta.data()[eN_k], eps_rho, eps_mu, rho_0, @@ -2998,19 +3002,19 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+2], - eps_solid[elementFlags[eN]], - phi_solid[eN_k], - q_velocity_solid[eN_k_nSpace+0], - q_velocity_solid[eN_k_nSpace+1], - q_velocity_solid[eN_k_nSpace+2], + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+2], + eps_solid.data()[elementFlags.data()[eN]], + phi_solid.data()[eN_k], + q_velocity_solid.data()[eN_k_nSpace+0], + q_velocity_solid.data()[eN_k_nSpace+1], + q_velocity_solid.data()[eN_k_nSpace+2], mom_u_source, mom_v_source, mom_w_source, @@ -3018,7 +3022,7 @@ namespace proteus dmom_v_source, dmom_w_source); - const double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + const double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); if(nParticles > 0) updateSolidParticleTerms(NONCONSERVATIVE_FORM, eN < nElements_owned, @@ -3026,18 +3030,18 @@ namespace proteus dV, nParticles, nQuadraturePoints_global, - &particle_signed_distances[eN_k], - &particle_signed_distance_normals[eN_k_3d], - &particle_velocities[eN_k_3d], - particle_centroids, + &particle_signed_distances.data()[eN_k], + &particle_signed_distance_normals.data()[eN_k_3d], + &particle_velocities.data()[eN_k_3d], + particle_centroids.data(), use_ball_as_particle, - ball_center, - ball_radius, - ball_velocity, - ball_angular_velocity, - ball_center_acceleration, - ball_angular_acceleration, - ball_density, + ball_center.data(), + ball_radius.data(), + ball_velocity.data(), + ball_angular_velocity.data(), + ball_center_acceleration.data(), + ball_angular_acceleration.data(), + ball_density.data(), porosity, particle_penalty_constant/h_phi,//penalty, particle_alpha, @@ -3049,8 +3053,8 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], x, y, z, @@ -3058,9 +3062,9 @@ namespace proteus u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+1], particle_eps, grad_u, grad_v, @@ -3096,9 +3100,9 @@ namespace proteus dmass_ham_u, dmass_ham_v, dmass_ham_w, - &particle_netForces[0], - &particle_netMoments[0], - &particle_surfaceArea[0], + &particle_netForces.data()[0], + &particle_netMoments.data()[0], + &particle_surfaceArea.data()[0], use_pseudo_penalty); //Turbulence closure model if (turbulenceClosureModel >= 3) @@ -3113,14 +3117,14 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], porosity, c_mu, //mwf hack - q_turb_var_0[eN_k], - q_turb_var_1[eN_k], - &q_turb_var_grad_0[eN_k_nSpace], - q_eddy_viscosity[eN_k], + q_turb_var_0.data()[eN_k], + q_turb_var_1.data()[eN_k], + &q_turb_var_grad_0.data()[eN_k_nSpace], + q_eddy_viscosity.data()[eN_k], mom_uu_diff_ten, mom_vv_diff_ten, mom_ww_diff_ten, @@ -3138,13 +3142,13 @@ namespace proteus // //save momentum for time history and velocity for subgrid error // - q_mom_u_acc[eN_k] = mom_u_acc; - q_mom_v_acc[eN_k] = mom_v_acc; - q_mom_w_acc[eN_k] = mom_w_acc; + q_mom_u_acc.data()[eN_k] = mom_u_acc; + q_mom_v_acc.data()[eN_k] = mom_v_acc; + q_mom_w_acc.data()[eN_k] = mom_w_acc; //subgrid error uses grid scale velocity - q_mass_adv[eN_k_nSpace+0] = u; - q_mass_adv[eN_k_nSpace+1] = v; - q_mass_adv[eN_k_nSpace+2] = w; + q_mass_adv.data()[eN_k_nSpace+0] = u; + q_mass_adv.data()[eN_k_nSpace+1] = v; + q_mass_adv.data()[eN_k_nSpace+2] = w; // //moving mesh // @@ -3201,36 +3205,36 @@ namespace proteus // //calculate time derivative at quadrature points // - if (q_dV_last[eN_k] <= -100) - q_dV_last[eN_k] = dV; - q_dV[eN_k] = dV; + if (q_dV_last.data()[eN_k] <= -100) + q_dV_last.data()[eN_k] = dV; + q_dV.data()[eN_k] = dV; ck.bdf(alphaBDF, - q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_u_acc, dmom_u_acc_u, mom_u_acc_t, dmom_u_acc_u_t); ck.bdf(alphaBDF, - q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_v_acc, dmom_v_acc_v, mom_v_acc_t, dmom_v_acc_v_t); ck.bdf(alphaBDF, - q_mom_w_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_w_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_w_acc, dmom_w_acc_w, mom_w_acc_t, dmom_w_acc_w_t); - if(use_pseudo_penalty > 0 && phi_solid[eN_k]<0.0)//Do not have to change Jacobian + if(use_pseudo_penalty > 0 && phi_solid.data()[eN_k]<0.0)//Do not have to change Jacobian { double distance,vx,vy,vz; - int index_ball = get_distance_to_ball(nParticles, ball_center, ball_radius,x,y,z,distance); - get_velocity_to_ith_ball(nParticles,ball_center,ball_radius,ball_velocity,ball_angular_velocity,index_ball,x,y,z,vx,vy,vz); + int index_ball = get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),x,y,z,distance); + get_velocity_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),ball_velocity.data(),ball_angular_velocity.data(),index_ball,x,y,z,vx,vy,vz); mom_u_acc_t = alphaBDF*(mom_u_acc - vx); mom_v_acc_t = alphaBDF*(mom_v_acc - vy); mom_w_acc_t = alphaBDF*(mom_w_acc - vz); - }else if(use_pseudo_penalty == -1 && phi_solid[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian + }else if(use_pseudo_penalty == -1 && phi_solid.data()[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian { mom_u_acc_t = 0.0; mom_v_acc_t = 0.0; @@ -3252,7 +3256,7 @@ namespace proteus pdeResidual_p = ck.Advection_strong(dmass_adv_u,grad_u) + ck.Advection_strong(dmass_adv_v,grad_v) + ck.Advection_strong(dmass_adv_w,grad_w) + - DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) + + DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) + //VRANS ck.Reaction_strong(mass_source); // @@ -3261,15 +3265,15 @@ namespace proteus dmom_adv_sge[0] = 0.0; dmom_adv_sge[1] = 0.0; dmom_adv_sge[2] = 0.0; - dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); - dmom_ham_grad_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); + dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_ham_grad_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt); } else { - dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); - dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); + dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt); dmom_ham_grad_sge[0] = 0.0; dmom_ham_grad_sge[1] = 0.0; dmom_ham_grad_sge[2] = 0.0; @@ -3304,7 +3308,7 @@ namespace proteus //add contributions from mass and source terms double tmpR=dmom_u_acc_u_t + dmom_u_source[0]; calculateSubgridError_tau(hFactor, - elementDiameter[eN], + elementDiameter.data()[eN], tmpR,//dmom_u_acc_u_t, dmom_u_acc_u, mv_tau,//dmom_adv_sge, @@ -3312,7 +3316,7 @@ namespace proteus dmom_u_ham_grad_p[0], tau_v0, tau_p0, - q_cfl[eN_k]); + q_cfl.data()[eN_k]); calculateSubgridError_tau(Ct_sge,Cd_sge, G,G_dd_G,tr_G, @@ -3322,7 +3326,7 @@ namespace proteus dmom_u_ham_grad_p[0], tau_v1, tau_p1, - q_cfl[eN_k]); + q_cfl.data()[eN_k]); tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0; tau_p = useMetrics*tau_p1+(1.0-useMetrics)*tau_p0; @@ -3338,21 +3342,21 @@ namespace proteus subgridError_v, subgridError_w); // velocity used in adjoint (VMS or RBLES, with or without lagging the grid scale velocity) - dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u); - dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v); - dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w); + dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u); + dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v); + dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w); - mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+0]); - mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+0]); - mom_u_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge[eN_k_nSpace+0]); + mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+0]); + mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+0]); + mom_u_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge.data()[eN_k_nSpace+0]); - mom_v_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+1]); - mom_v_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+1]); - mom_v_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge[eN_k_nSpace+1]); + mom_v_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+1]); + mom_v_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+1]); + mom_v_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge.data()[eN_k_nSpace+1]); - mom_w_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+2]); - mom_w_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+2]); - mom_w_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge[eN_k_nSpace+2]); + mom_w_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+2]); + mom_w_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+2]); + mom_w_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge.data()[eN_k_nSpace+2]); // adjoint times the test functions for (int i=0;i 0) + if(true)//boundaryFlags.data()[ebN] > 0) { //ignore flux contributions on interpart boundaries for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -4537,139 +4541,139 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, // const double LAG_LES, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity_last, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* p_old_dof, - double* u_old_dof, - double* v_old_dof, - double* w_old_dof, - double* g, + xt::pyarray & q_eddy_viscosity_last, + xt::pyarray & ebqe_eddy_viscosity_last, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* phi_nodes, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, - int* csrRowIndeces_p_p,int* csrColumnOffsets_p_p, - int* csrRowIndeces_p_u,int* csrColumnOffsets_p_u, - int* csrRowIndeces_p_v,int* csrColumnOffsets_p_v, - int* csrRowIndeces_p_w,int* csrColumnOffsets_p_w, - int* csrRowIndeces_u_p,int* csrColumnOffsets_u_p, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_p,int* csrColumnOffsets_v_p, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_p,int* csrColumnOffsets_w_p, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p,xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u,xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v,xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w,xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p,xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p,xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p,xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, // - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - int* elementFlags, - int* boundaryFlags, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, int nParticles, int nElements_owned, double particle_nitsche, @@ -4739,18 +4743,18 @@ namespace proteus for (int j=0;j 0) updateSolidParticleTerms(NONCONSERVATIVE_FORM, eN < nElements_owned, @@ -5110,18 +5114,18 @@ namespace proteus dV, nParticles, nQuadraturePoints_global, - &particle_signed_distances[eN_k], - &particle_signed_distance_normals[eN_k_3d], - &particle_velocities[eN_k_3d], - particle_centroids, + &particle_signed_distances.data()[eN_k], + &particle_signed_distance_normals.data()[eN_k_3d], + &particle_velocities.data()[eN_k_3d], + particle_centroids.data(), use_ball_as_particle, - ball_center, - ball_radius, - ball_velocity, - ball_angular_velocity, - ball_center_acceleration, - ball_angular_acceleration, - ball_density, + ball_center.data(), + ball_radius.data(), + ball_velocity.data(), + ball_angular_velocity.data(), + ball_center_acceleration.data(), + ball_angular_acceleration.data(), + ball_density.data(), porosity, particle_penalty_constant/h_phi,//penalty, particle_alpha, @@ -5133,8 +5137,8 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], x, y, z, @@ -5142,9 +5146,9 @@ namespace proteus u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+1], particle_eps, grad_u, grad_v, @@ -5197,13 +5201,13 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], porosity, c_mu, //mwf hack - q_turb_var_0[eN_k], - q_turb_var_1[eN_k], - &q_turb_var_grad_0[eN_k_nSpace], + q_turb_var_0.data()[eN_k], + q_turb_var_1.data()[eN_k], + &q_turb_var_grad_0.data()[eN_k_nSpace], eddy_viscosity, mom_uu_diff_ten, mom_vv_diff_ten, @@ -5277,24 +5281,24 @@ namespace proteus //calculate time derivatives // ck.bdf(alphaBDF, - q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_u_acc, dmom_u_acc_u, mom_u_acc_t, dmom_u_acc_u_t); ck.bdf(alphaBDF, - q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_v_acc, dmom_v_acc_v, mom_v_acc_t, dmom_v_acc_v_t); ck.bdf(alphaBDF, - q_mom_w_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_w_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_w_acc, dmom_w_acc_w, mom_w_acc_t, dmom_w_acc_w_t); - if(use_pseudo_penalty == -1 && phi_solid[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian + if(use_pseudo_penalty == -1 && phi_solid.data()[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian { mom_u_acc_t = 0.0; mom_v_acc_t = 0.0; @@ -5317,15 +5321,15 @@ namespace proteus dmom_adv_sge[0] = 0.0; dmom_adv_sge[1] = 0.0; dmom_adv_sge[2] = 0.0; - dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); - dmom_ham_grad_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); + dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_ham_grad_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt); } else { - dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); - dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); + dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt); dmom_ham_grad_sge[0] = 0.0; dmom_ham_grad_sge[1] = 0.0; dmom_ham_grad_sge[2] = 0.0; @@ -5340,7 +5344,7 @@ namespace proteus pdeResidual_p = ck.Advection_strong(dmass_adv_u,grad_u) + ck.Advection_strong(dmass_adv_v,grad_v) + ck.Advection_strong(dmass_adv_w,grad_w) + - DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) + + DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) + //VRANS ck.Reaction_strong(mass_source); // @@ -5373,22 +5377,22 @@ namespace proteus dpdeResidual_p_u[j]=ck.AdvectionJacobian_strong(dmass_adv_u,&vel_grad_trial[j_nSpace]); dpdeResidual_p_v[j]=ck.AdvectionJacobian_strong(dmass_adv_v,&vel_grad_trial[j_nSpace]); dpdeResidual_p_w[j]=ck.AdvectionJacobian_strong(dmass_adv_w,&vel_grad_trial[j_nSpace]); - dpdeResidual_u_u[j]=ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref[k*nDOF_v_trial_element+j]) + + dpdeResidual_u_u[j]=ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_v_trial_element+j]) + ck.HamiltonianJacobian_strong(dmom_ham_grad_sge,&vel_grad_trial[j_nSpace]) + ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) - - ck.ReactionJacobian_strong(dmom_u_acc_u*div_mesh_velocity,vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_v_v[j]=ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref[k*nDOF_v_trial_element+j]) + + ck.ReactionJacobian_strong(dmom_u_acc_u*div_mesh_velocity,vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_v_v[j]=ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_v_trial_element+j]) + ck.HamiltonianJacobian_strong(dmom_ham_grad_sge,&vel_grad_trial[j_nSpace]) + ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) - - ck.ReactionJacobian_strong(dmom_v_acc_v*div_mesh_velocity,vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_w_w[j]=ck.MassJacobian_strong(dmom_w_acc_w_t,vel_trial_ref[k*nDOF_v_trial_element+j]) + + ck.ReactionJacobian_strong(dmom_v_acc_v*div_mesh_velocity,vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_w_w[j]=ck.MassJacobian_strong(dmom_w_acc_w_t,vel_trial_ref.data()[k*nDOF_v_trial_element+j]) + ck.HamiltonianJacobian_strong(dmom_ham_grad_sge,&vel_grad_trial[j_nSpace]) + ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) - - ck.ReactionJacobian_strong(dmom_w_acc_w*div_mesh_velocity,vel_trial_ref[k*nDOF_trial_element+j]); + ck.ReactionJacobian_strong(dmom_w_acc_w*div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]); //VRANS account for drag terms, diagonal only here ... decide if need off diagonal terms too - dpdeResidual_u_u[j]+= ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_v_v[j]+= ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_w_w[j]+= ck.ReactionJacobian_strong(dmom_w_source[2],vel_trial_ref[k*nDOF_v_trial_element+j]); + dpdeResidual_u_u[j]+= ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_v_v[j]+= ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_w_w[j]+= ck.ReactionJacobian_strong(dmom_w_source[2],vel_trial_ref.data()[k*nDOF_v_trial_element+j]); } for (int j=0;j 0) + penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb]; + if(true)//boundaryFlags.data()[ebN] > 0) { //if boundary flag positive, then include flux contributions on interpart boundaries for (int j=0;j& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage) + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage) { int permutations[nQuadraturePoints_elementBoundary]; double xArray_left[nQuadraturePoints_elementBoundary*3], @@ -6670,23 +6674,23 @@ namespace proteus permutations[i]=i;//just to initialize for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; for (int kb=0;kb& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -6989,16 +6993,16 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* vel_l2g, - double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double *vf, - double *phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* advection_matrix) + xt::pyarray &vf, + xt::pyarray &phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& advection_matrix) { for (int eN=0 ; eN < nElements_global ; ++eN) @@ -7037,10 +7041,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -7048,26 +7052,26 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); - ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&p_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],w); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],w); for (int j=0; j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -7142,21 +7146,21 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* sdInfo_p_p_rowptr, int* sdInfo_p_p_colind, - int* sdInfo_u_u_rowptr, int* sdInfo_u_u_colind, - int* sdInfo_v_v_rowptr, int* sdInfo_v_v_colind, - int* sdInfo_w_w_rowptr, int* sdInfo_w_w_colind, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* laplace_matrix) + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& sdInfo_p_p_rowptr, xt::pyarray& sdInfo_p_p_colind, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& laplace_matrix) { gf.useExact = false; for (int eN=0 ; eN < nElements_global ; ++eN) @@ -7200,10 +7204,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -7211,23 +7215,23 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - eps_rho = epsFact_rho * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + eps_rho = epsFact_rho * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); - ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&p_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); - ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial,grad_p); - ck.gradFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v); - ck.gradFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_w); + ck.gradFromDOF(p_dof.data(),&p_l2g.data()[eN_nDOF_trial_element],p_grad_trial,grad_p); + ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v); + ck.gradFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_w); for (int j=0; j &mesh_trial_ref, + xt::pyarray &mesh_grad_trial_ref, + xt::pyarray &mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& numerical_viscosity, int nElements_global, double useMetrics, double epsFact_rho, @@ -7331,17 +7335,17 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* mass_matrix) + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& mass_matrix) { // Step 1.1 - Initialize local matrix @@ -7383,10 +7387,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -7394,30 +7398,30 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_ref[k*nDOF_trial_element],p); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],w); + ck.valFromDOF(p_dof.data(),&p_l2g.data()[eN_nDOF_trial_element],&p_trial_ref.data()[k*nDOF_trial_element],p); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],w); - eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); // Step 1.2.2 Scale test functions with integration weights. for (int j=0 ; j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::RANS2P2D_base; + +PYBIND11_MODULE(cRANS2P2D, m) +{ + xt::import_numpy(); + + py::class_(m, "cRANS2P2D_base") + .def(py::init(&proteus::newRANS2P2D)) + .def("calculateResidual" , &RANS2P2D_base::calculateResidual ) + .def("calculateJacobian" , &RANS2P2D_base::calculateJacobian ) + .def("calculateVelocityAverage" , &RANS2P2D_base::calculateVelocityAverage ) + .def("getTwoPhaseAdvectionOperator" , &RANS2P2D_base::getTwoPhaseAdvectionOperator ) + .def("getTwoPhaseInvScaledLaplaceOperator" , &RANS2P2D_base::getTwoPhaseInvScaledLaplaceOperator ) + .def("getTwoPhaseScaledMassOperator" , &RANS2P2D_base::getTwoPhaseScaledMassOperator ); +} diff --git a/proteus/mprans/RANS2P2D.h b/proteus/mprans/RANS2P2D.h index 8a707acb69..a803663d31 100644 --- a/proteus/mprans/RANS2P2D.h +++ b/proteus/mprans/RANS2P2D.h @@ -7,6 +7,10 @@ #include "MixedModelFactory.h" #include "PyEmbeddedFunctions.h" #include "equivalent_polynomials.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + const double DM=0.0;//1-mesh conservation and divergence, 0 - weak div(v) only const double DM2=0.0;//1-point-wise mesh volume strong-residual, 0 - div(v) only const double DM3=1.0;//1-point-wise divergence, 0-point-wise rate of volume change @@ -24,42 +28,42 @@ namespace proteus double PRESSURE_SGE, double VELOCITY_SGE, double PRESSURE_PROJECTION_STABLIZATION, - double *numerical_viscosity, + xt::pyarray& numerical_viscosity, //element - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, //0 or 1 - int *mesh_l2g, - double *x_ref, - double *dV_ref, - double *p_trial_ref, - double *p_grad_trial_ref, - double *p_test_ref, - double *p_grad_test_ref, - double *vel_trial_ref, - double *vel_grad_trial_ref, - double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -80,146 +84,146 @@ namespace proteus double C_dc, double C_b, //VRANS - const double *eps_solid, - double *phi_solid, - const double *q_velocity_solid, - const double *q_porosity, - const double *q_dragAlpha, - const double *q_dragBeta, - const double *q_mass_source, - const double *q_turb_var_0, - const double *q_turb_var_1, - const double *q_turb_var_grad_0, + const xt::pyarray& eps_solid, + xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, const double LAG_LES, - double *q_eddy_viscosity, - double *q_eddy_viscosity_last, - double *ebqe_eddy_viscosity, - double *ebqe_eddy_viscosity_last, - int *p_l2g, - int *vel_l2g, - int* rp_l2g, - int* rvel_l2g, - double *p_dof, - double *u_dof, - double *v_dof, - double *w_dof, - double *p_old_dof, - double *u_old_dof, - double *v_old_dof, - double *w_old_dof, - double *g, + xt::pyarray& q_eddy_viscosity, + xt::pyarray& q_eddy_viscosity_last, + xt::pyarray& ebqe_eddy_viscosity, + xt::pyarray& ebqe_eddy_viscosity_last, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& rp_l2g, + xt::pyarray& rvel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double *q_rho, - double *vf, - double *phi, - double *phi_nodes, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc, - double *q_mom_v_acc, - double *q_mom_w_acc, - double *q_mass_adv, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *q_cfl, - double *q_numDiff_u, double *q_numDiff_v, double *q_numDiff_w, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, + xt::pyarray& q_rho, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr, xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr, xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr, xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr, xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double *globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double *ebqe_porosity_ext, - const double *ebqe_turb_var_0, - const double *ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int *isDOFBoundary_p, - int *isDOFBoundary_u, - int *isDOFBoundary_v, - int *isDOFBoundary_w, - int *isAdvectiveFluxBoundary_p, - int *isAdvectiveFluxBoundary_u, - int *isAdvectiveFluxBoundary_v, - int *isAdvectiveFluxBoundary_w, - int *isDiffusiveFluxBoundary_u, - int *isDiffusiveFluxBoundary_v, - int *isDiffusiveFluxBoundary_w, - double *ebqe_bc_p_ext, - double *ebqe_bc_flux_mass_ext, - double *ebqe_bc_flux_mom_u_adv_ext, - double *ebqe_bc_flux_mom_v_adv_ext, - double *ebqe_bc_flux_mom_w_adv_ext, - double *ebqe_bc_u_ext, - double *ebqe_bc_flux_u_diff_ext, - double *ebqe_penalty_ext, - double *ebqe_bc_v_ext, - double *ebqe_bc_flux_v_diff_ext, - double *ebqe_bc_w_ext, - double *ebqe_bc_flux_w_diff_ext, - double *q_x, - double *q_velocity, - double *ebqe_velocity, - double *flux, - double *elementResidual_p, - int *elementFlags, - int *boundaryFlags, - double *barycenters, - double *wettedAreas, - double *netForces_p, - double *netForces_v, - double *netMoments, - double *velocityError, - double *velocityErrorNodal, - double *forcex, - double *forcey, - double *forcez, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& velocityError, + xt::pyarray& velocityErrorNodal, + xt::pyarray& forcex, + xt::pyarray& forcey, + xt::pyarray& forcez, int use_ball_as_particle, - double *ball_center, - double *ball_radius, - double *ball_velocity, - double *ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, + xt::pyarray& particle_netForces, + xt::pyarray& particle_netMoments, + xt::pyarray& particle_surfaceArea, int nElements_owned, double particle_nitsche, double particle_epsFact, double particle_alpha, double particle_beta, double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, const int use_pseudo_penalty, bool useExact) = 0; virtual void calculateJacobian(double NONCONSERVATIVE_FORM, @@ -228,40 +232,40 @@ namespace proteus double VELOCITY_SGE, double PRESSURE_PROJECTION_STABILIZATION, //element - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int *mesh_l2g, - double *x_ref, - double *dV_ref, - double *p_trial_ref, - double *p_grad_trial_ref, - double *p_test_ref, - double *p_grad_test_ref, - double *vel_trial_ref, - double *vel_grad_trial_ref, - double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -281,138 +285,138 @@ namespace proteus double C_dg, double C_b, //VRANS - const double *eps_solid, - const double *phi_solid, - const double *q_velocity_solid, - const double *q_porosity, - const double *q_dragAlpha, - const double *q_dragBeta, - const double *q_mass_source, - const double *q_turb_var_0, - const double *q_turb_var_1, - const double *q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, const double LAG_LES, - double *q_eddy_viscosity_last, - double *ebqe_eddy_viscosity_last, - int *p_l2g, - int *vel_l2g, - double *p_dof, double *u_dof, double *v_dof, double *w_dof, - double *p_old_dof, - double *u_old_dof, - double *v_old_dof, - double *w_old_dof, - double *g, + xt::pyarray& q_eddy_viscosity_last, + xt::pyarray& ebqe_eddy_viscosity_last, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double *vf, - double *phi, - double *phi_nodes, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *q_cfl, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, - int *csrRowIndeces_p_p, int *csrColumnOffsets_p_p, - int *csrRowIndeces_p_u, int *csrColumnOffsets_p_u, - int *csrRowIndeces_p_v, int *csrColumnOffsets_p_v, - int *csrRowIndeces_p_w, int *csrColumnOffsets_p_w, - int *csrRowIndeces_u_p, int *csrColumnOffsets_u_p, - int *csrRowIndeces_u_u, int *csrColumnOffsets_u_u, - int *csrRowIndeces_u_v, int *csrColumnOffsets_u_v, - int *csrRowIndeces_u_w, int *csrColumnOffsets_u_w, - int *csrRowIndeces_v_p, int *csrColumnOffsets_v_p, - int *csrRowIndeces_v_u, int *csrColumnOffsets_v_u, - int *csrRowIndeces_v_v, int *csrColumnOffsets_v_v, - int *csrRowIndeces_v_w, int *csrColumnOffsets_v_w, - int *csrRowIndeces_w_p, int *csrColumnOffsets_w_p, - int *csrRowIndeces_w_u, int *csrColumnOffsets_w_u, - int *csrRowIndeces_w_v, int *csrColumnOffsets_w_v, - int *csrRowIndeces_w_w, int *csrColumnOffsets_w_w, - double *globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr, xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr, xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr, xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr, xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u, xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v, xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w, xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p, xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w, xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p, xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u, xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w, xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p, xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u, xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v, xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double *ebqe_porosity_ext, - const double *ebqe_turb_var_0, - const double *ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int *isDOFBoundary_p, - int *isDOFBoundary_u, - int *isDOFBoundary_v, - int *isDOFBoundary_w, - int *isAdvectiveFluxBoundary_p, - int *isAdvectiveFluxBoundary_u, - int *isAdvectiveFluxBoundary_v, - int *isAdvectiveFluxBoundary_w, - int *isDiffusiveFluxBoundary_u, - int *isDiffusiveFluxBoundary_v, - int *isDiffusiveFluxBoundary_w, - double *ebqe_bc_p_ext, - double *ebqe_bc_flux_mass_ext, - double *ebqe_bc_flux_mom_u_adv_ext, - double *ebqe_bc_flux_mom_v_adv_ext, - double *ebqe_bc_flux_mom_w_adv_ext, - double *ebqe_bc_u_ext, - double *ebqe_bc_flux_u_diff_ext, - double *ebqe_penalty_ext, - double *ebqe_bc_v_ext, - double *ebqe_bc_flux_v_diff_ext, - double *ebqe_bc_w_ext, - double *ebqe_bc_flux_w_diff_ext, - int *csrColumnOffsets_eb_p_p, - int *csrColumnOffsets_eb_p_u, - int *csrColumnOffsets_eb_p_v, - int *csrColumnOffsets_eb_p_w, - int *csrColumnOffsets_eb_u_p, - int *csrColumnOffsets_eb_u_u, - int *csrColumnOffsets_eb_u_v, - int *csrColumnOffsets_eb_u_w, - int *csrColumnOffsets_eb_v_p, - int *csrColumnOffsets_eb_v_u, - int *csrColumnOffsets_eb_v_v, - int *csrColumnOffsets_eb_v_w, - int *csrColumnOffsets_eb_w_p, - int *csrColumnOffsets_eb_w_u, - int *csrColumnOffsets_eb_w_v, - int *csrColumnOffsets_eb_w_w, - int *elementFlags, - int *boundaryFlags, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, int use_ball_as_particle, - double *ball_center, - double *ball_radius, - double *ball_velocity, - double *ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, int nParticles, int nElements_owned, double particle_nitsche, @@ -423,37 +427,37 @@ namespace proteus const int use_pseudo_penalty, bool useExact) = 0; virtual void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage)=0; - virtual void getTwoPhaseAdvectionOperator(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* vel_trail_ref, - double* vel_grad_trial_ref, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage)=0; + virtual void getTwoPhaseAdvectionOperator(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_trail_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -462,25 +466,25 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* vel_l2g, - double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double *vf, - double *phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* advection_matrix) = 0; - virtual void getTwoPhaseInvScaledLaplaceOperator(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_grad_trial_ref, - double* vel_grad_trial_ref, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& advection_matrix) = 0; + virtual void getTwoPhaseInvScaledLaplaceOperator(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -489,36 +493,36 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* sdInfo_p_p_rowptr, int* sdInfo_p_p_colind, - int* sdInfo_u_u_rowptr, int* sdInfo_u_u_colind, - int* sdInfo_v_v_rowptr, int* sdInfo_v_v_colind, - int* sdInfo_w_w_rowptr, int* sdInfo_w_w_colind, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* laplace_matrix)=0; + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& sdInfo_p_p_rowptr, xt::pyarray& sdInfo_p_p_colind, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& laplace_matrix)=0; virtual void getTwoPhaseScaledMassOperator(int scale_type, int use_numerical_viscosity, int lumped, - double *mesh_trial_ref, - double *mesh_grad_trial_ref, - double *mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_test_ref, - double* vel_trial_ref, - double* vel_test_ref, - double* elementDiameter, - double* nodeDiametersArray, - double* numerical_viscosity, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& numerical_viscosity, int nElements_global, double useMetrics, double epsFact_rho, @@ -527,21 +531,21 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* csrRowIndeces_p_p, - int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, - int* csrColumnOffsets_w_w, - double* mass_matrix)=0; + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, + xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, + xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& mass_matrix)=0; }; template& numerical_viscosity, //element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -2108,147 +2112,147 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, const double LAG_LES, - double * q_eddy_viscosity, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity, - double * ebqe_eddy_viscosity_last, + xt::pyarray& q_eddy_viscosity, + xt::pyarray& q_eddy_viscosity_last, + xt::pyarray& ebqe_eddy_viscosity, + xt::pyarray& ebqe_eddy_viscosity_last, // - int* p_l2g, - int* vel_l2g, - int* rp_l2g, - int* rvel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* p_old_dof, - double* u_old_dof, - double* v_old_dof, - double* w_old_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& rp_l2g, + xt::pyarray& rvel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double* q_rho, - double* vf, - double* phi, - double* phi_nodes, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& q_rho, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* velocityError, - double* velocityErrorNodal, - double* forcex, - double* forcey, - double* forcez, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& velocityError, + xt::pyarray& velocityErrorNodal, + xt::pyarray& forcex, + xt::pyarray& forcey, + xt::pyarray& forcez, int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, + xt::pyarray& particle_netForces, + xt::pyarray& particle_netMoments, + xt::pyarray& particle_surfaceArea, int nElements_owned, double particle_nitsche, double particle_epsFact, double particle_alpha, double particle_beta, double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, const int use_pseudo_penalty, bool useExact) { @@ -2279,7 +2283,7 @@ namespace proteus for (int i=0;i 0) - phi_solid[eN_k] = distance_to_solids[eN_k]; + phi_solid.data()[eN_k] = distance_to_solids.data()[eN_k]; // //calculate pde coefficients at quadrature points // @@ -2549,18 +2553,18 @@ namespace proteus nu_0, rho_1, nu_1, - elementDiameter[eN], + elementDiameter.data()[eN], smagorinskyConstant, turbulenceClosureModel, - g, + g.data(), useVF, - vf[eN_k], - phi[eN_k], - &normal_phi[eN_k_nSpace], - kappa_phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], + &normal_phi.data()[eN_k_nSpace], + kappa_phi.data()[eN_k], //VRANS porosity, - phi_solid[eN_k],//distance to solid + phi_solid.data()[eN_k],//distance to solid p_old, u_old, v_old, @@ -2580,8 +2584,8 @@ namespace proteus v, w, LAG_LES, - q_eddy_viscosity[eN_k], - q_eddy_viscosity_last[eN_k], + q_eddy_viscosity.data()[eN_k], + q_eddy_viscosity_last.data()[eN_k], mom_u_acc, dmom_u_acc_u, mom_v_acc, @@ -2634,20 +2638,20 @@ namespace proteus dmom_w_ham_u, dmom_w_ham_v, dmom_w_ham_w, - q_rho[eN_k], - forcex[eN_k], - forcey[eN_k], - forcez[eN_k]); + q_rho.data()[eN_k], + forcex.data()[eN_k], + forcey.data()[eN_k], + forcez.data()[eN_k]); //VRANS - mass_source = q_mass_source[eN_k]; + mass_source = q_mass_source.data()[eN_k]; //todo: decide if these should be lagged or not? updateDarcyForchheimerTerms_Ergun(NONCONSERVATIVE_FORM, /* linearDragFactor, */ /* nonlinearDragFactor, */ /* porosity, */ /* meanGrainSize, */ - q_dragAlpha[eN_k], - q_dragBeta[eN_k], + q_dragAlpha.data()[eN_k], + q_dragBeta.data()[eN_k], eps_rho, eps_mu, rho_0, @@ -2655,19 +2659,19 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+1],//cek hack, should not be used - eps_solid[elementFlags[eN]], - phi_solid[eN_k], - q_velocity_solid[eN_k_nSpace+0], - q_velocity_solid[eN_k_nSpace+1], - q_velocity_solid[eN_k_nSpace+1],//cek hack, should not be used + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+1],//cek hack, should not be used + eps_solid.data()[elementFlags.data()[eN]], + phi_solid.data()[eN_k], + q_velocity_solid.data()[eN_k_nSpace+0], + q_velocity_solid.data()[eN_k_nSpace+1], + q_velocity_solid.data()[eN_k_nSpace+1],//cek hack, should not be used mom_u_source, mom_v_source, mom_w_source, @@ -2675,7 +2679,7 @@ namespace proteus dmom_v_source, dmom_w_source); - const double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + const double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); if(nParticles > 0) updateSolidParticleTerms(NONCONSERVATIVE_FORM, eN < nElements_owned, @@ -2683,18 +2687,18 @@ namespace proteus dV, nParticles, nQuadraturePoints_global, - &particle_signed_distances[eN_k], - &particle_signed_distance_normals[eN_k_3d], - &particle_velocities[eN_k_3d], - particle_centroids, + &particle_signed_distances.data()[eN_k], + &particle_signed_distance_normals.data()[eN_k_3d], + &particle_velocities.data()[eN_k_3d], + particle_centroids.data(), use_ball_as_particle, - ball_center, - ball_radius, - ball_velocity, - ball_angular_velocity, - ball_center_acceleration, - ball_angular_acceleration, - ball_density, + ball_center.data(), + ball_radius.data(), + ball_velocity.data(), + ball_angular_velocity.data(), + ball_center_acceleration.data(), + ball_angular_acceleration.data(), + ball_density.data(), porosity, particle_penalty_constant/h_phi,//penalty, particle_alpha, @@ -2706,8 +2710,8 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], x, y, z, @@ -2715,9 +2719,9 @@ namespace proteus u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+1], particle_eps, grad_u, grad_v, @@ -2753,9 +2757,9 @@ namespace proteus dmass_ham_u, dmass_ham_v, dmass_ham_w, - &particle_netForces[0], - &particle_netMoments[0], - &particle_surfaceArea[0], + &particle_netForces.data()[0], + &particle_netMoments.data()[0], + &particle_surfaceArea.data()[0], use_pseudo_penalty); //Turbulence closure model if (turbulenceClosureModel >= 3) @@ -2770,14 +2774,14 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], porosity, c_mu, //mwf hack - q_turb_var_0[eN_k], - q_turb_var_1[eN_k], - &q_turb_var_grad_0[eN_k_nSpace], - q_eddy_viscosity[eN_k], + q_turb_var_0.data()[eN_k], + q_turb_var_1.data()[eN_k], + &q_turb_var_grad_0.data()[eN_k_nSpace], + q_eddy_viscosity.data()[eN_k], mom_uu_diff_ten, mom_vv_diff_ten, mom_ww_diff_ten, @@ -2795,11 +2799,11 @@ namespace proteus // //save momentum for time history and velocity for subgrid error // - q_mom_u_acc[eN_k] = mom_u_acc; - q_mom_v_acc[eN_k] = mom_v_acc; + q_mom_u_acc.data()[eN_k] = mom_u_acc; + q_mom_v_acc.data()[eN_k] = mom_v_acc; //subgrid error uses grid scale velocity - q_mass_adv[eN_k_nSpace+0] = u; - q_mass_adv[eN_k_nSpace+1] = v; + q_mass_adv.data()[eN_k_nSpace+0] = u; + q_mass_adv.data()[eN_k_nSpace+1] = v; // //moving mesh // @@ -2834,29 +2838,29 @@ namespace proteus // //calculate time derivative at quadrature points // - if (q_dV_last[eN_k] <= -100) - q_dV_last[eN_k] = dV; - q_dV[eN_k] = dV; + if (q_dV_last.data()[eN_k] <= -100) + q_dV_last.data()[eN_k] = dV; + q_dV.data()[eN_k] = dV; ck.bdf(alphaBDF, - q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_u_acc, dmom_u_acc_u, mom_u_acc_t, dmom_u_acc_u_t); ck.bdf(alphaBDF, - q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_v_acc, dmom_v_acc_v, mom_v_acc_t, dmom_v_acc_v_t); - if(use_pseudo_penalty > 0 && phi_solid[eN_k]<0.0)//Do not have to change Jacobian + if(use_pseudo_penalty > 0 && phi_solid.data()[eN_k]<0.0)//Do not have to change Jacobian { double distance,vx,vy; - int index_ball = get_distance_to_ball(nParticles, ball_center, ball_radius,x,y,z,distance); - get_velocity_to_ith_ball(nParticles,ball_center,ball_radius,ball_velocity,ball_angular_velocity,index_ball,x,y,z,vx,vy); + int index_ball = get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),x,y,z,distance); + get_velocity_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),ball_velocity.data(),ball_angular_velocity.data(),index_ball,x,y,z,vx,vy); mom_u_acc_t = alphaBDF*(mom_u_acc - vx); mom_v_acc_t = alphaBDF*(mom_v_acc - vy); - }else if(use_pseudo_penalty == -1 && phi_solid[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian + }else if(use_pseudo_penalty == -1 && phi_solid.data()[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian { mom_u_acc_t = 0.0; mom_v_acc_t = 0.0; @@ -2874,7 +2878,7 @@ namespace proteus //calculate strong residual pdeResidual_p = ck.Advection_strong(dmass_adv_u,grad_u) + ck.Advection_strong(dmass_adv_v,grad_v) + - DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) + + DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) + //VRANS ck.Reaction_strong(mass_source); // @@ -2882,13 +2886,13 @@ namespace proteus { dmom_adv_sge[0] = 0.0; dmom_adv_sge[1] = 0.0; - dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); } else { - dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); dmom_ham_grad_sge[0] = 0.0; dmom_ham_grad_sge[1] = 0.0; } @@ -2914,7 +2918,7 @@ namespace proteus //add contributions from mass and source terms double tmpR=dmom_u_acc_u_t + dmom_u_source[0]; calculateSubgridError_tau(hFactor, - elementDiameter[eN], + elementDiameter.data()[eN], tmpR,//dmom_u_acc_u_t, dmom_u_acc_u, mv_tau,//dmom_adv_sge, @@ -2922,7 +2926,7 @@ namespace proteus dmom_u_ham_grad_p[0], tau_v0, tau_p0, - q_cfl[eN_k]); + q_cfl.data()[eN_k]); calculateSubgridError_tau(Ct_sge,Cd_sge, G,G_dd_G,tr_G, @@ -2932,7 +2936,7 @@ namespace proteus dmom_u_ham_grad_p[0], tau_v1, tau_p1, - q_cfl[eN_k]); + q_cfl.data()[eN_k]); tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0; tau_p = useMetrics*tau_p1+(1.0-useMetrics)*tau_p0; @@ -2948,14 +2952,14 @@ namespace proteus subgridError_v, subgridError_w); // velocity used in adjoint (VMS or RBLES, with or without lagging the grid scale velocity) - dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u); - dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v); + dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u); + dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v); - mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+0]); - mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+0]); + mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+0]); + mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+0]); - mom_v_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+1]); - mom_v_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+1]); + mom_v_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+1]); + mom_v_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+1]); // adjoint times the test functions for (int i=0;i 0) + if(true)//boundaryFlags.data()[ebN] > 0) { //if boundary flag positive, then include flux contributions on interpart boundaries for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -3943,139 +3947,139 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, // const double LAG_LES, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity_last, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* p_old_dof, - double* u_old_dof, - double* v_old_dof, - double* w_old_dof, - double* g, + xt::pyarray& q_eddy_viscosity_last, + xt::pyarray& ebqe_eddy_viscosity_last, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& p_old_dof, + xt::pyarray& u_old_dof, + xt::pyarray& v_old_dof, + xt::pyarray& w_old_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* phi_nodes, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, - int* csrRowIndeces_p_p,int* csrColumnOffsets_p_p, - int* csrRowIndeces_p_u,int* csrColumnOffsets_p_u, - int* csrRowIndeces_p_v,int* csrColumnOffsets_p_v, - int* csrRowIndeces_p_w,int* csrColumnOffsets_p_w, - int* csrRowIndeces_u_p,int* csrColumnOffsets_u_p, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_p,int* csrColumnOffsets_v_p, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_p,int* csrColumnOffsets_w_p, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& phi_nodes, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p,xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u,xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v,xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w,xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p,xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p,xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p,xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, // - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - int* elementFlags, - int* boundaryFlags, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, + xt::pyarray& ball_center, + xt::pyarray& ball_radius, + xt::pyarray& ball_velocity, + xt::pyarray& ball_angular_velocity, + xt::pyarray& ball_center_acceleration, + xt::pyarray& ball_angular_acceleration, + xt::pyarray& ball_density, + xt::pyarray& particle_signed_distances, + xt::pyarray& particle_signed_distance_normals, + xt::pyarray& particle_velocities, + xt::pyarray& particle_centroids, + xt::pyarray& ebq_global_phi_s, + xt::pyarray& ebq_global_grad_phi_s, + xt::pyarray& ebq_particle_velocity_s, + xt::pyarray& phi_solid_nodes, + xt::pyarray& distance_to_solids, int nParticles, int nElements_owned, double particle_nitsche, @@ -4145,18 +4149,18 @@ namespace proteus for (int j=0;j 0) updateSolidParticleTerms(NONCONSERVATIVE_FORM, eN < nElements_owned, @@ -4511,18 +4515,18 @@ namespace proteus dV, nParticles, nQuadraturePoints_global, - &particle_signed_distances[eN_k], - &particle_signed_distance_normals[eN_k_3d], - &particle_velocities[eN_k_3d], - particle_centroids, + &particle_signed_distances.data()[eN_k], + &particle_signed_distance_normals.data()[eN_k_3d], + &particle_velocities.data()[eN_k_3d], + particle_centroids.data(), use_ball_as_particle, - ball_center, - ball_radius, - ball_velocity, - ball_angular_velocity, - ball_center_acceleration, - ball_angular_acceleration, - ball_density, + ball_center.data(), + ball_radius.data(), + ball_velocity.data(), + ball_angular_velocity.data(), + ball_center_acceleration.data(), + ball_angular_acceleration.data(), + ball_density.data(), porosity, particle_penalty_constant/h_phi,//penalty, particle_alpha, @@ -4534,8 +4538,8 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], x, y, z, @@ -4543,9 +4547,9 @@ namespace proteus u, v, w, - q_velocity_sge[eN_k_nSpace+0], - q_velocity_sge[eN_k_nSpace+1], - q_velocity_sge[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+0], + q_velocity_sge.data()[eN_k_nSpace+1], + q_velocity_sge.data()[eN_k_nSpace+1], particle_eps, grad_u, grad_v, @@ -4598,13 +4602,13 @@ namespace proteus rho_1, nu_1, useVF, - vf[eN_k], - phi[eN_k], + vf.data()[eN_k], + phi.data()[eN_k], porosity, c_mu, //mwf hack - q_turb_var_0[eN_k], - q_turb_var_1[eN_k], - &q_turb_var_grad_0[eN_k_nSpace], + q_turb_var_0.data()[eN_k], + q_turb_var_1.data()[eN_k], + &q_turb_var_grad_0.data()[eN_k_nSpace], eddy_viscosity, mom_uu_diff_ten, mom_vv_diff_ten, @@ -4655,18 +4659,18 @@ namespace proteus //calculate time derivatives // ck.bdf(alphaBDF, - q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_u_acc, dmom_u_acc_u, mom_u_acc_t, dmom_u_acc_u_t); ck.bdf(alphaBDF, - q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, + q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV, mom_v_acc, dmom_v_acc_v, mom_v_acc_t, dmom_v_acc_v_t); - if(use_pseudo_penalty == -1 && phi_solid[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian + if(use_pseudo_penalty == -1 && phi_solid.data()[eN_k]<0.0)//no derivative term inside the solid; Has to change Jacobian { mom_u_acc_t = 0.0; mom_v_acc_t = 0.0; @@ -4685,13 +4689,13 @@ namespace proteus { dmom_adv_sge[0] = 0.0; dmom_adv_sge[1] = 0.0; - dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_ham_grad_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_ham_grad_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); } else { - dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt); - dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt); + dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*xt); + dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt); dmom_ham_grad_sge[0] = 0.0; dmom_ham_grad_sge[1] = 0.0; } @@ -4703,7 +4707,7 @@ namespace proteus // pdeResidual_p = ck.Advection_strong(dmass_adv_u,grad_u) + ck.Advection_strong(dmass_adv_v,grad_v) + - DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) + + DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) + //VRANS ck.Reaction_strong(mass_source); // @@ -4728,17 +4732,17 @@ namespace proteus register int j_nSpace = j*nSpace; dpdeResidual_p_u[j]=ck.AdvectionJacobian_strong(dmass_adv_u,&vel_grad_trial[j_nSpace]); dpdeResidual_p_v[j]=ck.AdvectionJacobian_strong(dmass_adv_v,&vel_grad_trial[j_nSpace]); - dpdeResidual_u_u[j]=ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref[k*nDOF_v_trial_element+j]) + + dpdeResidual_u_u[j]=ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_v_trial_element+j]) + ck.HamiltonianJacobian_strong(dmom_ham_grad_sge,&vel_grad_trial[j_nSpace]) + ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) - - ck.ReactionJacobian_strong(dmom_u_acc_u*div_mesh_velocity,vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_v_v[j]=ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref[k*nDOF_v_trial_element+j]) + + ck.ReactionJacobian_strong(dmom_u_acc_u*div_mesh_velocity,vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_v_v[j]=ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_v_trial_element+j]) + ck.HamiltonianJacobian_strong(dmom_ham_grad_sge,&vel_grad_trial[j_nSpace]) + ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) - - ck.ReactionJacobian_strong(dmom_v_acc_v*div_mesh_velocity,vel_trial_ref[k*nDOF_v_trial_element+j]); + ck.ReactionJacobian_strong(dmom_v_acc_v*div_mesh_velocity,vel_trial_ref.data()[k*nDOF_v_trial_element+j]); //VRANS account for drag terms, diagonal only here ... decide if need off diagonal terms too - dpdeResidual_u_u[j]+= ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref[k*nDOF_v_trial_element+j]); - dpdeResidual_v_v[j]+= ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref[k*nDOF_v_trial_element+j]); + dpdeResidual_u_u[j]+= ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_v_trial_element+j]); + dpdeResidual_v_v[j]+= ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_v_trial_element+j]); } for (int j=0;j 0) { //if boundary flag positive, then include flux contributions on interpart boundaries for (int j=0;j& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage) + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage) { int permutations[nQuadraturePoints_elementBoundary]; double xArray_left[nQuadraturePoints_elementBoundary*2], @@ -5796,22 +5800,22 @@ namespace proteus permutations[i]=i;//just to initialize for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; for (int kb=0;kb& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -6080,16 +6084,16 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* vel_l2g, - double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double *vf, - double *phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* advection_matrix) + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& advection_matrix) { gf.useExact = false; for (int eN=0 ; eN < nElements_global ; ++eN) @@ -6127,10 +6131,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -6138,25 +6142,25 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); - ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&p_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); for (int j=0; j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, int nElements_global, double useMetrics, double epsFact_rho, @@ -6227,21 +6231,21 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* sdInfo_p_p_rowptr, int* sdInfo_p_p_colind, - int* sdInfo_u_u_rowptr, int* sdInfo_u_u_colind, - int* sdInfo_v_v_rowptr, int* sdInfo_v_v_colind, - int* sdInfo_w_w_rowptr, int* sdInfo_w_w_colind, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* laplace_matrix) + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& sdInfo_p_p_rowptr, xt::pyarray& sdInfo_p_p_colind, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& laplace_matrix) { for (int eN=0 ; eN < nElements_global ; ++eN) { @@ -6281,10 +6285,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -6292,22 +6296,22 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - eps_rho = epsFact_rho * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + eps_rho = epsFact_rho * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); - ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&p_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); - ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial,grad_p); - ck.gradFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v); + ck.gradFromDOF(p_dof.data(),&p_l2g.data()[eN_nDOF_trial_element],p_grad_trial,grad_p); + ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v); for (int j=0; j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& numerical_viscosity, int nElements_global, double useMetrics, double epsFact_rho, @@ -6405,17 +6409,17 @@ namespace proteus double nu_0, double rho_1, double nu_1, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, const double useVF, - double* vf, - double* phi, - int* csrRowIndeces_p_p, int* csrColumnOffsets_p_p, - int* csrRowIndeces_u_u, int* csrColumnOffsets_u_u, - int* csrRowIndeces_v_v, int* csrColumnOffsets_v_v, - int* csrRowIndeces_w_w, int* csrColumnOffsets_w_w, - double* mass_matrix) + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& mass_matrix) { // Step 1.1 - Initialize local matrix @@ -6454,10 +6458,10 @@ namespace proteus ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, @@ -6465,29 +6469,29 @@ namespace proteus ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; - ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_ref[k*nDOF_trial_element],p); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); + ck.valFromDOF(p_dof.data(),&p_l2g.data()[eN_nDOF_trial_element],&p_trial_ref.data()[k*nDOF_trial_element],p); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); - eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); + eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + eps_mu = epsFact_mu * (useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); // Step 1.2.2 Scale test functions with integration weights. for (int j=0 ; j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::RANS2P_IB_base; + +PYBIND11_MODULE(cRANS2P_IB, m) +{ + xt::import_numpy(); + + py::class_(m, "cRANS2P_IB_base") + .def(py::init(&proteus::newRANS2P_IB)) + .def("calculateResidual" , &RANS2P_IB_base::calculateResidual ) + .def("calculateBeams" , &RANS2P_IB_base::calculateBeams ) + .def("calculateJacobian" , &RANS2P_IB_base::calculateJacobian ) + .def("calculateForce" , &RANS2P_IB_base::calculateForce ) + .def("calculateVelocityAverage", &RANS2P_IB_base::calculateVelocityAverage); +} diff --git a/proteus/mprans/RANS2P_IB.h b/proteus/mprans/RANS2P_IB.h index 96a9ce6e57..4543167412 100644 --- a/proteus/mprans/RANS2P_IB.h +++ b/proteus/mprans/RANS2P_IB.h @@ -4,6 +4,10 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + //#define COMPRESSIBLE_FORM namespace proteus { @@ -12,39 +16,39 @@ namespace proteus public: virtual ~RANS2P_IB_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -65,138 +69,138 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3)=0; + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3)=0; virtual void calculateBeams(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -217,153 +221,153 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3, int nBeams, int nBeamElements, int beam_quadOrder, double beam_Cd, - double* beamRadius, - double* xq, - double* yq, - double* zq, - double* Beam_h, - double* dV_beam, - double* q1, - double* q2, - double* q3, - double* vel_avg, - double* netBeamDrag)=0; + xt::pyarray& beamRadius, + xt::pyarray& xq, + xt::pyarray& yq, + xt::pyarray& zq, + xt::pyarray& Beam_h, + xt::pyarray& dV_beam, + xt::pyarray& q1, + xt::pyarray& q2, + xt::pyarray& q3, + xt::pyarray& vel_avg, + xt::pyarray& netBeamDrag)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -383,146 +387,146 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* g, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, - int* csrRowIndeces_p_p,int* csrColumnOffsets_p_p, - int* csrRowIndeces_p_u,int* csrColumnOffsets_p_u, - int* csrRowIndeces_p_v,int* csrColumnOffsets_p_v, - int* csrRowIndeces_p_w,int* csrColumnOffsets_p_w, - int* csrRowIndeces_u_p,int* csrColumnOffsets_u_p, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_p,int* csrColumnOffsets_v_p, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_p,int* csrColumnOffsets_w_p, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p,xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u,xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v,xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w,xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p,xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p,xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p,xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3)=0; + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3)=0; virtual void calculateForce(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -541,95 +545,95 @@ namespace proteus double Cd_sge, double C_dc, double C_b, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, - double* rho_init, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, + xt::pyarray& rho_init, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* cg, double* force, double* moment, + xt::pyarray& cg, xt::pyarray& force, xt::pyarray& moment, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* forceExtractionFaces, int nForceExtractionFaces, - double* ebqe_vf_ext, - double* ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& forceExtractionFaces, int nForceExtractionFaces, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p)=0; virtual void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage )=0; + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage )=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -2038,105 +2042,105 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, // - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3 ) + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3 ) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -2153,7 +2157,7 @@ namespace proteus for (int i=0;i= 3) @@ -3076,12 +3080,12 @@ namespace proteus rho_1, nu_1, useVF, - ebqe_vf_ext[ebNE_kb], - ebqe_phi_ext[ebNE_kb], + ebqe_vf_ext.data()[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], porosity_ext, c_mu, //mwf hack - ebqe_turb_var_0[ebNE_kb], - ebqe_turb_var_1[ebNE_kb], + ebqe_turb_var_0.data()[ebNE_kb], + ebqe_turb_var_1.data()[ebNE_kb], turb_var_grad_0_dummy, //not needed mom_uu_diff_ten_ext, mom_vv_diff_ten_ext, @@ -3104,12 +3108,12 @@ namespace proteus rho_1, nu_1, useVF, - bc_ebqe_vf_ext[ebNE_kb], - bc_ebqe_phi_ext[ebNE_kb], + bc_ebqe_vf_ext.data()[ebNE_kb], + bc_ebqe_phi_ext.data()[ebNE_kb], porosity_ext, c_mu, //mwf hack - ebqe_turb_var_0[ebNE_kb], - ebqe_turb_var_1[ebNE_kb], + ebqe_turb_var_0.data()[ebNE_kb], + ebqe_turb_var_1.data()[ebNE_kb], turb_var_grad_0_dummy, //not needed bc_mom_uu_diff_ten_ext, bc_mom_vv_diff_ten_ext, @@ -3170,15 +3174,15 @@ namespace proteus //calculate the numerical fluxes // ck.calculateGScale(G,normal,h_penalty); - penalty = useMetrics*C_b*h_penalty + (1.0-useMetrics)*ebqe_penalty_ext[ebNE_kb]; - exteriorNumericalAdvectiveFlux(isDOFBoundary_p[ebNE_kb], - isDOFBoundary_u[ebNE_kb], - isDOFBoundary_v[ebNE_kb], - isDOFBoundary_w[ebNE_kb], - isAdvectiveFluxBoundary_p[ebNE_kb], - isAdvectiveFluxBoundary_u[ebNE_kb], - isAdvectiveFluxBoundary_v[ebNE_kb], - isAdvectiveFluxBoundary_w[ebNE_kb], + penalty = useMetrics*C_b*h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb]; + exteriorNumericalAdvectiveFlux(isDOFBoundary_p.data()[ebNE_kb], + isDOFBoundary_u.data()[ebNE_kb], + isDOFBoundary_v.data()[ebNE_kb], + isDOFBoundary_w.data()[ebNE_kb], + isAdvectiveFluxBoundary_p.data()[ebNE_kb], + isAdvectiveFluxBoundary_u.data()[ebNE_kb], + isAdvectiveFluxBoundary_v.data()[ebNE_kb], + isAdvectiveFluxBoundary_w.data()[ebNE_kb], dmom_u_ham_grad_p_ext[0],//=1/rho, bc_dmom_u_ham_grad_p_ext[0],//=1/bc_rho, normal, @@ -3187,10 +3191,10 @@ namespace proteus bc_mom_u_adv_ext, bc_mom_v_adv_ext, bc_mom_w_adv_ext, - ebqe_bc_flux_mass_ext[ebNE_kb], - ebqe_bc_flux_mom_u_adv_ext[ebNE_kb], - ebqe_bc_flux_mom_v_adv_ext[ebNE_kb], - ebqe_bc_flux_mom_w_adv_ext[ebNE_kb], + ebqe_bc_flux_mass_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb], p_ext, mass_adv_ext, mom_u_adv_ext, @@ -3215,28 +3219,28 @@ namespace proteus flux_mom_u_adv_ext, flux_mom_v_adv_ext, flux_mom_w_adv_ext, - &ebqe_velocity[ebNE_kb_nSpace]); + &ebqe_velocity.data()[ebNE_kb_nSpace]); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_u_u_rowptr, - sdInfo_u_u_colind, - isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_u_u_rowptr.data(), + sdInfo_u_u_colind.data(), + isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], normal, bc_mom_uu_diff_ten_ext, bc_u_ext, - ebqe_bc_flux_u_diff_ext[ebNE_kb], + ebqe_bc_flux_u_diff_ext.data()[ebNE_kb], mom_uu_diff_ten_ext, grad_u_ext, u_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_uu_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_u_v_rowptr, - sdInfo_u_v_colind, - isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_u_v_rowptr.data(), + sdInfo_u_v_colind.data(), + isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], normal, bc_mom_uv_diff_ten_ext, bc_v_ext, @@ -3244,14 +3248,14 @@ namespace proteus mom_uv_diff_ten_ext, grad_v_ext, v_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_uv_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_u_w_rowptr, - sdInfo_u_w_colind, - isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_u_w_rowptr.data(), + sdInfo_u_w_colind.data(), + isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], normal, bc_mom_uw_diff_ten_ext, bc_w_ext, @@ -3259,14 +3263,14 @@ namespace proteus mom_uw_diff_ten_ext, grad_w_ext, w_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_uw_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_v_u_rowptr, - sdInfo_v_u_colind, - isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_v_u_rowptr.data(), + sdInfo_v_u_colind.data(), + isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], normal, bc_mom_vu_diff_ten_ext, bc_u_ext, @@ -3274,29 +3278,29 @@ namespace proteus mom_vu_diff_ten_ext, grad_u_ext, u_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_vu_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_v_v_rowptr, - sdInfo_v_v_colind, - isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_v_v_rowptr.data(), + sdInfo_v_v_colind.data(), + isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], normal, bc_mom_vv_diff_ten_ext, bc_v_ext, - ebqe_bc_flux_v_diff_ext[ebNE_kb], + ebqe_bc_flux_v_diff_ext.data()[ebNE_kb], mom_vv_diff_ten_ext, grad_v_ext, v_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_vv_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_v_w_rowptr, - sdInfo_v_w_colind, - isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_v_w_rowptr.data(), + sdInfo_v_w_colind.data(), + isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], normal, bc_mom_vw_diff_ten_ext, bc_w_ext, @@ -3304,14 +3308,14 @@ namespace proteus mom_vw_diff_ten_ext, grad_w_ext, w_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_vw_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_w_u_rowptr, - sdInfo_w_u_colind, - isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_w_u_rowptr.data(), + sdInfo_w_u_colind.data(), + isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], normal, bc_mom_wu_diff_ten_ext, bc_u_ext, @@ -3319,14 +3323,14 @@ namespace proteus mom_wu_diff_ten_ext, grad_u_ext, u_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_wu_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_w_v_rowptr, - sdInfo_w_v_colind, - isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_w_v_rowptr.data(), + sdInfo_w_v_colind.data(), + isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], normal, bc_mom_wv_diff_ten_ext, bc_v_ext, @@ -3334,24 +3338,24 @@ namespace proteus mom_wv_diff_ten_ext, grad_v_ext, v_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_wv_diff_ext); exteriorNumericalDiffusiveFlux(eps_rho, - ebqe_phi_ext[ebNE_kb], - sdInfo_w_w_rowptr, - sdInfo_w_w_colind, - isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], + sdInfo_w_w_rowptr.data(), + sdInfo_w_w_colind.data(), + isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], normal, bc_mom_ww_diff_ten_ext, bc_w_ext, - ebqe_bc_flux_w_diff_ext[ebNE_kb], + ebqe_bc_flux_w_diff_ext.data()[ebNE_kb], mom_ww_diff_ten_ext, grad_w_ext, w_ext, - penalty,//ebqe_penalty_ext[ebNE_kb], + penalty,//ebqe_penalty_ext.data()[ebNE_kb], flux_mom_ww_diff_ext); - flux[ebN*nQuadraturePoints_elementBoundary+kb] = flux_mass_ext; + flux.data()[ebN*nQuadraturePoints_elementBoundary+kb] = flux_mass_ext; // //integrate the net force and moment on flagged boundaries // @@ -3369,23 +3373,23 @@ namespace proteus force_y = force_p_y + force_v_y; force_z = force_p_z + force_v_z; - r_x = x_ext - barycenters[3*boundaryFlags[ebN]+0]; - r_y = y_ext - barycenters[3*boundaryFlags[ebN]+1]; - r_z = z_ext - barycenters[3*boundaryFlags[ebN]+2]; + r_x = x_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+0]; + r_y = y_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+1]; + r_z = z_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+2]; - wettedAreas[boundaryFlags[ebN]] += dS*(1.0-ebqe_vf_ext[ebNE_kb]); + wettedAreas.data()[boundaryFlags.data()[ebN]] += dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); - netForces_p[3*boundaryFlags[ebN]+0] += force_p_x*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netForces_p[3*boundaryFlags[ebN]+1] += force_p_y*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netForces_p[3*boundaryFlags[ebN]+2] += force_p_z*dS*(1.0-ebqe_vf_ext[ebNE_kb]); + netForces_p.data()[3*boundaryFlags.data()[ebN]+0] += force_p_x*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netForces_p.data()[3*boundaryFlags.data()[ebN]+1] += force_p_y*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netForces_p.data()[3*boundaryFlags.data()[ebN]+2] += force_p_z*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); - netForces_v[3*boundaryFlags[ebN]+0] += force_v_x*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netForces_v[3*boundaryFlags[ebN]+1] += force_v_y*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netForces_v[3*boundaryFlags[ebN]+2] += force_v_z*dS*(1.0-ebqe_vf_ext[ebNE_kb]); + netForces_v.data()[3*boundaryFlags.data()[ebN]+0] += force_v_x*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netForces_v.data()[3*boundaryFlags.data()[ebN]+1] += force_v_y*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netForces_v.data()[3*boundaryFlags.data()[ebN]+2] += force_v_z*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); - netMoments[3*boundaryFlags[ebN]+0] += (r_y*force_z - r_z*force_y)*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netMoments[3*boundaryFlags[ebN]+1] += (r_z*force_x - r_x*force_z)*dS*(1.0-ebqe_vf_ext[ebNE_kb]); - netMoments[3*boundaryFlags[ebN]+2] += (r_x*force_y - r_y*force_x)*dS*(1.0-ebqe_vf_ext[ebNE_kb]); + netMoments.data()[3*boundaryFlags.data()[ebN]+0] += (r_y*force_z - r_z*force_y)*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netMoments.data()[3*boundaryFlags.data()[ebN]+1] += (r_z*force_x - r_x*force_z)*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); + netMoments.data()[3*boundaryFlags.data()[ebN]+2] += (r_x*force_y - r_y*force_x)*dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]); } // //update residuals @@ -3399,68 +3403,68 @@ namespace proteus ck.ExteriorElementBoundaryFlux(flux_mom_uu_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_uv_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_uw_diff_ext,vel_test_dS[i])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], eb_adjoint_sigma, u_ext, bc_u_ext, normal, - sdInfo_u_u_rowptr, - sdInfo_u_u_colind, + sdInfo_u_u_rowptr.data(), + sdInfo_u_u_colind.data(), mom_uu_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], eb_adjoint_sigma, v_ext, bc_v_ext, normal, - sdInfo_u_v_rowptr, - sdInfo_u_v_colind, + sdInfo_u_v_rowptr.data(), + sdInfo_u_v_colind.data(), mom_uv_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_u[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_u.data()[ebNE_kb], eb_adjoint_sigma, w_ext, bc_w_ext, normal, - sdInfo_u_w_rowptr, - sdInfo_u_w_colind, + sdInfo_u_w_rowptr.data(), + sdInfo_u_w_colind.data(), mom_uw_diff_ten_ext, &vel_grad_test_dS[i*nSpace]); elementResidual_v[i] += ck.ExteriorElementBoundaryFlux(flux_mom_v_adv_ext,vel_test_dS[i]) + ck.ExteriorElementBoundaryFlux(flux_mom_vu_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_vv_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_vw_diff_ext,vel_test_dS[i])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], eb_adjoint_sigma, u_ext, bc_u_ext, normal, - sdInfo_v_u_rowptr, - sdInfo_v_u_colind, + sdInfo_v_u_rowptr.data(), + sdInfo_v_u_colind.data(), mom_vu_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], eb_adjoint_sigma, v_ext, bc_v_ext, normal, - sdInfo_v_v_rowptr, - sdInfo_v_v_colind, + sdInfo_v_v_rowptr.data(), + sdInfo_v_v_colind.data(), mom_vv_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_v[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_v.data()[ebNE_kb], eb_adjoint_sigma, w_ext, bc_w_ext, normal, - sdInfo_v_w_rowptr, - sdInfo_v_w_colind, + sdInfo_v_w_rowptr.data(), + sdInfo_v_w_colind.data(), mom_vw_diff_ten_ext, &vel_grad_test_dS[i*nSpace]); @@ -3468,34 +3472,34 @@ namespace proteus ck.ExteriorElementBoundaryFlux(flux_mom_wu_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_wv_diff_ext,vel_test_dS[i])+ ck.ExteriorElementBoundaryFlux(flux_mom_ww_diff_ext,vel_test_dS[i])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], eb_adjoint_sigma, u_ext, bc_u_ext, normal, - sdInfo_w_u_rowptr, - sdInfo_w_u_colind, + sdInfo_w_u_rowptr.data(), + sdInfo_w_u_colind.data(), mom_wu_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], eb_adjoint_sigma, v_ext, bc_v_ext, normal, - sdInfo_w_v_rowptr, - sdInfo_w_v_colind, + sdInfo_w_v_rowptr.data(), + sdInfo_w_v_colind.data(), mom_wv_diff_ten_ext, &vel_grad_test_dS[i*nSpace])+ - ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], - isDiffusiveFluxBoundary_w[ebNE_kb], + ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb], + isDiffusiveFluxBoundary_w.data()[ebNE_kb], eb_adjoint_sigma, w_ext, bc_w_ext, normal, - sdInfo_w_w_rowptr, - sdInfo_w_w_colind, + sdInfo_w_w_rowptr.data(), + sdInfo_w_w_colind.data(), mom_ww_diff_ten_ext, &vel_grad_test_dS[i*nSpace]); }//i @@ -3507,50 +3511,50 @@ namespace proteus { int eN_i = eN*nDOF_test_element+i; - elementResidual_p_save[eN_i] += elementResidual_p[i]; + elementResidual_p_save.data()[eN_i] += elementResidual_p[i]; - globalResidual[offset_p+stride_p*p_l2g[eN_i]]+=elementResidual_p[i]; - globalResidual[offset_u+stride_u*vel_l2g[eN_i]]+=elementResidual_u[i]; - globalResidual[offset_v+stride_v*vel_l2g[eN_i]]+=elementResidual_v[i]; - globalResidual[offset_w+stride_w*vel_l2g[eN_i]]+=elementResidual_w[i]; + globalResidual.data()[offset_p+stride_p*p_l2g.data()[eN_i]]+=elementResidual_p[i]; + globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i]; + globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i]; + globalResidual.data()[offset_w+stride_w*vel_l2g.data()[eN_i]]+=elementResidual_w[i]; }//i }//ebNE } void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -3570,116 +3574,116 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, // - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, - int* csrRowIndeces_p_p,int* csrColumnOffsets_p_p, - int* csrRowIndeces_p_u,int* csrColumnOffsets_p_u, - int* csrRowIndeces_p_v,int* csrColumnOffsets_p_v, - int* csrRowIndeces_p_w,int* csrColumnOffsets_p_w, - int* csrRowIndeces_u_p,int* csrColumnOffsets_u_p, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v,int* csrColumnOffsets_u_v, - int* csrRowIndeces_u_w,int* csrColumnOffsets_u_w, - int* csrRowIndeces_v_p,int* csrColumnOffsets_v_p, - int* csrRowIndeces_v_u,int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v,int* csrColumnOffsets_v_v, - int* csrRowIndeces_v_w,int* csrColumnOffsets_v_w, - int* csrRowIndeces_w_p,int* csrColumnOffsets_w_p, - int* csrRowIndeces_w_u,int* csrColumnOffsets_w_u, - int* csrRowIndeces_w_v,int* csrColumnOffsets_w_v, - int* csrRowIndeces_w_w,int* csrColumnOffsets_w_w, - double* globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p,xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u,xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v,xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w,xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p,xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v,xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w,xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p,xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u,xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v,xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w,xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p,xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u,xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v,xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w,xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, // - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3) + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -3831,54 +3835,54 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //xt=0.0;yt=0.0;zt=0.0; //std::cout<<"xt "<= 3) { @@ -4736,12 +4740,12 @@ namespace proteus rho_1, nu_1, useVF, - ebqe_vf_ext[ebNE_kb], - ebqe_phi_ext[ebNE_kb], + ebqe_vf_ext.data()[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], porosity_ext, c_mu, //mwf hack - ebqe_turb_var_0[ebNE_kb], - ebqe_turb_var_1[ebNE_kb], + ebqe_turb_var_0.data()[ebNE_kb], + ebqe_turb_var_1.data()[ebNE_kb], turb_var_grad_0_dummy, //not needed mom_uu_diff_ten_ext, mom_vv_diff_ten_ext, @@ -4764,12 +4768,12 @@ namespace proteus rho_1, nu_1, useVF, - ebqe_vf_ext[ebNE_kb], - ebqe_phi_ext[ebNE_kb], + ebqe_vf_ext.data()[ebNE_kb], + ebqe_phi_ext.data()[ebNE_kb], porosity_ext, c_mu, //mwf hack - ebqe_turb_var_0[ebNE_kb], - ebqe_turb_var_1[ebNE_kb], + ebqe_turb_var_0.data()[ebNE_kb], + ebqe_turb_var_1.data()[ebNE_kb], turb_var_grad_0_dummy, //not needed bc_mom_uu_diff_ten_ext, bc_mom_vv_diff_ten_ext, @@ -4827,14 +4831,14 @@ namespace proteus // //calculate the numerical fluxes // - exteriorNumericalAdvectiveFluxDerivatives(isDOFBoundary_p[ebNE_kb], - isDOFBoundary_u[ebNE_kb], - isDOFBoundary_v[ebNE_kb], - isDOFBoundary_w[ebNE_kb], - isAdvectiveFluxBoundary_p[ebNE_kb], - isAdvectiveFluxBoundary_u[ebNE_kb], - isAdvectiveFluxBoundary_v[ebNE_kb], - isAdvectiveFluxBoundary_w[ebNE_kb], + exteriorNumericalAdvectiveFluxDerivatives(isDOFBoundary_p.data()[ebNE_kb], + isDOFBoundary_u.data()[ebNE_kb], + isDOFBoundary_v.data()[ebNE_kb], + isDOFBoundary_w.data()[ebNE_kb], + isAdvectiveFluxBoundary_p.data()[ebNE_kb], + isAdvectiveFluxBoundary_u.data()[ebNE_kb], + isAdvectiveFluxBoundary_v.data()[ebNE_kb], + isAdvectiveFluxBoundary_w.data()[ebNE_kb], dmom_u_ham_grad_p_ext[0],//=1/rho normal, bc_p_ext, @@ -4842,10 +4846,10 @@ namespace proteus bc_mom_u_adv_ext, bc_mom_v_adv_ext, bc_mom_w_adv_ext, - ebqe_bc_flux_mass_ext[ebNE_kb], - ebqe_bc_flux_mom_u_adv_ext[ebNE_kb], - ebqe_bc_flux_mom_v_adv_ext[ebNE_kb], - ebqe_bc_flux_mom_w_adv_ext[ebNE_kb], + ebqe_bc_flux_mass_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb], + ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb], p_ext, mass_adv_ext, mom_u_adv_ext, @@ -4885,128 +4889,128 @@ namespace proteus //calculate the flux jacobian // ck.calculateGScale(G,normal,h_penalty); - penalty = useMetrics*C_b*h_penalty + (1.0-useMetrics)*ebqe_penalty_ext[ebNE_kb]; + penalty = useMetrics*C_b*h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb]; for (int j=0;j& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage) + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage) { int permutations[nQuadraturePoints_elementBoundary]; double xArray_left[nQuadraturePoints_elementBoundary*3], @@ -5151,23 +5155,23 @@ namespace proteus permutations[i]=i;//just to initialize for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; for (int kb=0;kb& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -5323,76 +5327,76 @@ namespace proteus double Cd_sge, double C_dc, double C_b, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, - double* rho_init, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, + xt::pyarray& rho_init, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* cg, double* force,double* moment, + xt::pyarray& cg, xt::pyarray& force,xt::pyarray& moment, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* forceExtractionFaces, int nForceExtractionFaces, - double* ebqe_vf_ext, - double* ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& forceExtractionFaces, int nForceExtractionFaces, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save) { // //loop over exterior element boundaries to calculate surface integrals and load into element and global residuals @@ -5405,12 +5409,12 @@ namespace proteus for (int fef = 0; fef < nForceExtractionFaces; fef++) { - int ebNE = forceExtractionFaces[fef]; + int ebNE = forceExtractionFaces.data()[fef]; //std::cout<& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -5666,120 +5670,120 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* phi_solid, - const double* q_velocity_solid, - const double* q_porosity, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, + const xt::pyarray& eps_solid, + const xt::pyarray& phi_solid, + const xt::pyarray& q_velocity_solid, + const xt::pyarray& q_porosity, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, // - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_porosity_ext, - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_porosity_ext, + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* q_dragBeam1, - double* q_dragBeam2, - double* q_dragBeam3, - double* ebqe_dragBeam1, - double* ebqe_dragBeam2, - double* ebqe_dragBeam3, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& q_dragBeam1, + xt::pyarray& q_dragBeam2, + xt::pyarray& q_dragBeam3, + xt::pyarray& ebqe_dragBeam1, + xt::pyarray& ebqe_dragBeam2, + xt::pyarray& ebqe_dragBeam3, int nBeams, int nBeamElements, int beam_quadOrder, double beam_Cd, - double* beamRadius, - double* xq, - double* yq, - double* zq, - double* Beam_h, - double* dV_beam, - double* q1, - double* q2, - double* q3, - double* vel_avg, - double* netBeamDrag) + xt::pyarray& beamRadius, + xt::pyarray& xq, + xt::pyarray& yq, + xt::pyarray& zq, + xt::pyarray& Beam_h, + xt::pyarray& dV_beam, + xt::pyarray& q1, + xt::pyarray& q2, + xt::pyarray& q3, + xt::pyarray& vel_avg, + xt::pyarray& netBeamDrag) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -5883,60 +5887,60 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //xt=0.0;yt=0.0;zt=0.0; //std::cout<<"xt "< a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppRANS3PSed_base; +using proteus::cppRANS3PSed2D_base; + +PYBIND11_MODULE(RANS3PSed, m) +{ + xt::import_numpy(); + + py::class_(m, "RANS3PSed") + .def(py::init(&proteus::newRANS3PSed)) + .def("calculateResidual", &cppRANS3PSed_base::calculateResidual) + .def("calculateJacobian", &cppRANS3PSed_base::calculateJacobian) + .def("calculateVelocityAverage", &cppRANS3PSed_base::calculateVelocityAverage); +} + +PYBIND11_MODULE(RANS3PSed2D, m) +{ + xt::import_numpy(); + + py::class_(m, "RANS3PSed2D") + .def(py::init(&proteus::newRANS3PSed2D)) + .def("calculateResidual", &cppRANS3PSed2D_base::calculateResidual) + .def("calculateJacobian", &cppRANS3PSed2D_base::calculateJacobian) + .def("calculateVelocityAverage", &cppRANS3PSed2D_base::calculateVelocityAverage); +} diff --git a/proteus/mprans/RANS3PSed.h b/proteus/mprans/RANS3PSed.h index ee9ec22657..4272d9bfc7 100644 --- a/proteus/mprans/RANS3PSed.h +++ b/proteus/mprans/RANS3PSed.h @@ -5,6 +5,10 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "SedClosure.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + const double DM=0.0;//1-mesh conservation and divergence, 0 - weak div(v) only const double DM2=0.0;//1-point-wise mesh volume strong-residual, 0 - div(v) only const double DM3=1.0;//1-point-wise divergence, 0-point-wise rate of volume change @@ -31,42 +35,42 @@ namespace proteus double angFriction, double vos_limiter, double mu_fr_limiter){} - virtual void calculateResidual(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + virtual void calculateResidual(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& q_p, + xt::pyarray& q_grad_p, + xt::pyarray& ebqe_p, + xt::pyarray& ebqe_grad_p, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -87,67 +91,67 @@ namespace proteus double Cd_sge, double C_dc, double C_b, - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - double * q_eddy_viscosity, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + const xt::pyarray& eps_solid, + const xt::pyarray& q_velocity_fluid, + const xt::pyarray& q_velocityStar_fluid, + const xt::pyarray& q_vos,//sed fraction - gco check + const xt::pyarray& q_dvos_dt, + const xt::pyarray& q_grad_vos, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& q_eddy_viscosity, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double *vf, - double *phi, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc, - double *q_mom_v_acc, - double *q_mom_w_acc, - double *q_mass_adv, - double *q_mom_u_acc_beta_bdf, - double *q_mom_v_acc_beta_bdf, - double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *ebqe_velocity_star, - double *q_cfl, - double *q_numDiff_u, - double *q_numDiff_v, - double *q_numDiff_w, - double *q_numDiff_u_last, - double *q_numDiff_v_last, - double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, - int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, - int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, - int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, - int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, - int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, - int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, - int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, - int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, - int *sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& ebqe_velocity_star, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_v, + xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr, + xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr, + xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr, + xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr, + xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr, + xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, @@ -156,98 +160,98 @@ namespace proteus int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* ncDrag, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, + const xt::pyarray& ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& ncDrag, double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr)=0; + xt::pyarray& q_mu_fr_last, + xt::pyarray& q_mu_fr)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& q_p, + xt::pyarray& q_grad_p, + xt::pyarray& ebqe_p, + xt::pyarray& ebqe_grad_p, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -268,140 +272,140 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* g, + const xt::pyarray& eps_solid, + const xt::pyarray& q_velocity_fluid, + const xt::pyarray& q_velocityStar_fluid, + const xt::pyarray& q_vos,//sed fraction - gco check + const xt::pyarray& q_dvos_dt, + const xt::pyarray& q_grad_vos, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, xt::pyarray& u_dof, xt::pyarray& v_dof, xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double *vf, - double *phi, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *ebqe_velocity_star, - double *q_cfl, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, - int *csrRowIndeces_p_p, int *csrColumnOffsets_p_p, - int *csrRowIndeces_p_u, int *csrColumnOffsets_p_u, - int *csrRowIndeces_p_v, int *csrColumnOffsets_p_v, - int *csrRowIndeces_p_w, int *csrColumnOffsets_p_w, - int *csrRowIndeces_u_p, int *csrColumnOffsets_u_p, - int *csrRowIndeces_u_u, int *csrColumnOffsets_u_u, - int *csrRowIndeces_u_v, int *csrColumnOffsets_u_v, - int *csrRowIndeces_u_w, int *csrColumnOffsets_u_w, - int *csrRowIndeces_v_p, int *csrColumnOffsets_v_p, - int *csrRowIndeces_v_u, int *csrColumnOffsets_v_u, - int *csrRowIndeces_v_v, int *csrColumnOffsets_v_v, - int *csrRowIndeces_v_w, int *csrColumnOffsets_v_w, - int *csrRowIndeces_w_p, int *csrColumnOffsets_w_p, - int *csrRowIndeces_w_u, int *csrColumnOffsets_w_u, - int *csrRowIndeces_w_v, int *csrColumnOffsets_w_v, - int *csrRowIndeces_w_w, int *csrColumnOffsets_w_w, - double *globalJacobian, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& ebqe_velocity_star, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr, xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr, xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr, xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr, xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr, xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr, xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr, xt::pyarray& sdInfo_w_v_colind, + xt::pyarray& csrRowIndeces_p_p, xt::pyarray& csrColumnOffsets_p_p, + xt::pyarray& csrRowIndeces_p_u, xt::pyarray& csrColumnOffsets_p_u, + xt::pyarray& csrRowIndeces_p_v, xt::pyarray& csrColumnOffsets_p_v, + xt::pyarray& csrRowIndeces_p_w, xt::pyarray& csrColumnOffsets_p_w, + xt::pyarray& csrRowIndeces_u_p, xt::pyarray& csrColumnOffsets_u_p, + xt::pyarray& csrRowIndeces_u_u, xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_u_w, xt::pyarray& csrColumnOffsets_u_w, + xt::pyarray& csrRowIndeces_v_p, xt::pyarray& csrColumnOffsets_v_p, + xt::pyarray& csrRowIndeces_v_u, xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& csrRowIndeces_v_w, xt::pyarray& csrColumnOffsets_v_w, + xt::pyarray& csrRowIndeces_w_p, xt::pyarray& csrColumnOffsets_w_p, + xt::pyarray& csrRowIndeces_w_u, xt::pyarray& csrColumnOffsets_w_u, + xt::pyarray& csrRowIndeces_w_v, xt::pyarray& csrColumnOffsets_w_v, + xt::pyarray& csrRowIndeces_w_w, xt::pyarray& csrColumnOffsets_w_w, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - int* elementFlags, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& csrColumnOffsets_eb_p_p, + xt::pyarray& csrColumnOffsets_eb_p_u, + xt::pyarray& csrColumnOffsets_eb_p_v, + xt::pyarray& csrColumnOffsets_eb_p_w, + xt::pyarray& csrColumnOffsets_eb_u_p, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_u_w, + xt::pyarray& csrColumnOffsets_eb_v_p, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v, + xt::pyarray& csrColumnOffsets_eb_v_w, + xt::pyarray& csrColumnOffsets_eb_w_p, + xt::pyarray& csrColumnOffsets_eb_w_u, + xt::pyarray& csrColumnOffsets_eb_w_v, + xt::pyarray& csrColumnOffsets_eb_w_w, + xt::pyarray& elementFlags, double mu_fr, - double* q_mu_fr_last, - double* q_mu_fr)=0; + xt::pyarray& q_mu_fr_last, + xt::pyarray& q_mu_fr)=0; virtual void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, + xt::pyarray& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int *interiorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, //0 or 1 - int *mesh_l2g, - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *normal_ref, - double *boundaryJac_ref, - int *vel_l2g, - double *u_dof, - double *v_dof, - double *w_dof, - double *vos_dof, - double *vel_trial_trace_ref, - double *ebqe_velocity, - double *velocityAverage) = 0; + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vos_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage) = 0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& p_trial_ref, + xt::pyarray& p_grad_trial_ref, + xt::pyarray& p_test_ref, + xt::pyarray& p_grad_test_ref, + xt::pyarray& q_p, + xt::pyarray& q_grad_p, + xt::pyarray& ebqe_p, + xt::pyarray& ebqe_grad_p, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& p_trial_trace_ref, + xt::pyarray& p_grad_trial_trace_ref, + xt::pyarray& p_test_trace_ref, + xt::pyarray& p_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -1524,110 +1528,110 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - double * q_eddy_viscosity, + const xt::pyarray& eps_solid, + const xt::pyarray& q_velocity_fluid, + const xt::pyarray& q_velocityStar_fluid, + const xt::pyarray& q_vos,//sed fraction - gco check + const xt::pyarray& q_dvos_dt, + const xt::pyarray& q_grad_vos, + const xt::pyarray& q_dragAlpha, + const xt::pyarray& q_dragBeta, + const xt::pyarray& q_mass_source, + const xt::pyarray& q_turb_var_0, + const xt::pyarray& q_turb_var_1, + const xt::pyarray& q_turb_var_grad_0, + xt::pyarray& q_eddy_viscosity, // - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + xt::pyarray& p_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& p_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* ebqe_velocity_star, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray& vf, + xt::pyarray& phi, + xt::pyarray& normal_phi, + xt::pyarray& kappa_phi, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mom_w_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mom_u_acc_beta_bdf, xt::pyarray& q_mom_v_acc_beta_bdf, xt::pyarray& q_mom_w_acc_beta_bdf, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& q_velocity_sge, + xt::pyarray& ebqe_velocity_star, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, xt::pyarray& q_numDiff_v, xt::pyarray& q_numDiff_w, + xt::pyarray& q_numDiff_u_last, xt::pyarray& q_numDiff_v_last, xt::pyarray& q_numDiff_w_last, + xt::pyarray& sdInfo_u_u_rowptr,xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr,xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_u_w_rowptr,xt::pyarray& sdInfo_u_w_colind, + xt::pyarray& sdInfo_v_v_rowptr,xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr,xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& sdInfo_v_w_rowptr,xt::pyarray& sdInfo_v_w_colind, + xt::pyarray& sdInfo_w_w_rowptr,xt::pyarray& sdInfo_w_w_colind, + xt::pyarray& sdInfo_w_u_rowptr,xt::pyarray& sdInfo_w_u_colind, + xt::pyarray& sdInfo_w_v_rowptr,xt::pyarray& sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_vf_ext, + xt::pyarray& bc_ebqe_vf_ext, + xt::pyarray& ebqe_phi_ext, + xt::pyarray& bc_ebqe_phi_ext, + xt::pyarray& ebqe_normal_phi_ext, + xt::pyarray& ebqe_kappa_phi_ext, //VRANS - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray& ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray& ebqe_turb_var_0, + const xt::pyarray& ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* ncDrag, + xt::pyarray& isDOFBoundary_p, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isDOFBoundary_w, + xt::pyarray& isAdvectiveFluxBoundary_p, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_w, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_w, + xt::pyarray& ebqe_bc_p_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& ebqe_bc_w_ext, + xt::pyarray& ebqe_bc_flux_w_diff_ext, + xt::pyarray& q_x, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_p_save, + xt::pyarray& elementFlags, + xt::pyarray& boundaryFlags, + xt::pyarray& barycenters, + xt::pyarray& wettedAreas, + xt::pyarray& netForces_p, + xt::pyarray& netForces_v, + xt::pyarray& netMoments, + xt::pyarray& ncDrag, double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) + xt::pyarray& q_mu_fr_last, + xt::pyarray& q_mu_fr) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -1646,7 +1650,7 @@ namespace proteus for (int i=0;i& exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& interiorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vos_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage) + xt::pyarray& mesh_l2g, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + xt::pyarray& vel_l2g, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& w_dof, + xt::pyarray& vos_dof, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& ebqe_velocity, + xt::pyarray& velocityAverage) { int permutations[nQuadraturePoints_elementBoundary]; double xArray_left[nQuadraturePoints_elementBoundary*3], @@ -4683,23 +4687,23 @@ namespace proteus permutations[i]=i;//just to initialize for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; for (int kb=0;kb mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray p_trial_ref, + xt::pyarray p_grad_trial_ref, + xt::pyarray p_test_ref, + xt::pyarray p_grad_test_ref, + xt::pyarray q_p, + xt::pyarray q_grad_p, + xt::pyarray ebqe_p, + xt::pyarray ebqe_grad_p, + xt::pyarray vel_trial_ref, + xt::pyarray vel_grad_trial_ref, + xt::pyarray vel_test_ref, + xt::pyarray vel_grad_test_ref, + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray p_trial_trace_ref, + xt::pyarray p_grad_trial_trace_ref, + xt::pyarray p_test_trace_ref, + xt::pyarray p_grad_test_trace_ref, + xt::pyarray vel_trial_trace_ref, + xt::pyarray vel_grad_trial_trace_ref, + xt::pyarray vel_test_trace_ref, + xt::pyarray vel_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -86,67 +90,67 @@ namespace proteus double Cd_sge, double C_dc, double C_b, - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - double * q_eddy_viscosity, - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + const xt::pyarray eps_solid, + const xt::pyarray q_velocity_fluid, + const xt::pyarray q_velocityStar_fluid, + const xt::pyarray q_vos,//sed fraction - gco check + const xt::pyarray q_dvos_dt, + const xt::pyarray q_grad_vos, + const xt::pyarray q_dragAlpha, + const xt::pyarray q_dragBeta, + const xt::pyarray q_mass_source, + const xt::pyarray q_turb_var_0, + const xt::pyarray q_turb_var_1, + const xt::pyarray q_turb_var_grad_0, + xt::pyarray q_eddy_viscosity, + xt::pyarray p_l2g, + xt::pyarray vel_l2g, + xt::pyarray p_dof, + xt::pyarray u_dof, + xt::pyarray v_dof, + xt::pyarray w_dof, + xt::pyarray g, const double useVF, - double *vf, - double *phi, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc, - double *q_mom_v_acc, - double *q_mom_w_acc, - double *q_mass_adv, - double *q_mom_u_acc_beta_bdf, - double *q_mom_v_acc_beta_bdf, - double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *ebqe_velocity_star, - double *q_cfl, - double *q_numDiff_u, - double *q_numDiff_v, - double *q_numDiff_w, - double *q_numDiff_u_last, - double *q_numDiff_v_last, - double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, - int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, - int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, - int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, - int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, - int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, - int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, - int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, - int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, - int *sdInfo_w_v_colind, + xt::pyarray vf, + xt::pyarray phi, + xt::pyarray normal_phi, + xt::pyarray kappa_phi, + xt::pyarray q_mom_u_acc, + xt::pyarray q_mom_v_acc, + xt::pyarray q_mom_w_acc, + xt::pyarray q_mass_adv, + xt::pyarray q_mom_u_acc_beta_bdf, + xt::pyarray q_mom_v_acc_beta_bdf, + xt::pyarray q_mom_w_acc_beta_bdf, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray q_velocity_sge, + xt::pyarray ebqe_velocity_star, + xt::pyarray q_cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_v, + xt::pyarray q_numDiff_w, + xt::pyarray q_numDiff_u_last, + xt::pyarray q_numDiff_v_last, + xt::pyarray q_numDiff_w_last, + xt::pyarray sdInfo_u_u_rowptr, + xt::pyarray sdInfo_u_u_colind, + xt::pyarray sdInfo_u_v_rowptr, + xt::pyarray sdInfo_u_v_colind, + xt::pyarray sdInfo_u_w_rowptr, + xt::pyarray sdInfo_u_w_colind, + xt::pyarray sdInfo_v_v_rowptr, + xt::pyarray sdInfo_v_v_colind, + xt::pyarray sdInfo_v_u_rowptr, + xt::pyarray sdInfo_v_u_colind, + xt::pyarray sdInfo_v_w_rowptr, + xt::pyarray sdInfo_v_w_colind, + xt::pyarray sdInfo_w_w_rowptr, + xt::pyarray sdInfo_w_w_colind, + xt::pyarray sdInfo_w_u_rowptr, + xt::pyarray sdInfo_w_u_colind, + xt::pyarray sdInfo_w_v_rowptr, + xt::pyarray sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, @@ -155,98 +159,98 @@ namespace proteus int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* ncDrag, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_vf_ext, + xt::pyarray bc_ebqe_vf_ext, + xt::pyarray ebqe_phi_ext, + xt::pyarray bc_ebqe_phi_ext, + xt::pyarray ebqe_normal_phi_ext, + xt::pyarray ebqe_kappa_phi_ext, + const xt::pyarray ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray ebqe_turb_var_0, + const xt::pyarray ebqe_turb_var_1, + xt::pyarray isDOFBoundary_p, + xt::pyarray isDOFBoundary_u, + xt::pyarray isDOFBoundary_v, + xt::pyarray isDOFBoundary_w, + xt::pyarray isAdvectiveFluxBoundary_p, + xt::pyarray isAdvectiveFluxBoundary_u, + xt::pyarray isAdvectiveFluxBoundary_v, + xt::pyarray isAdvectiveFluxBoundary_w, + xt::pyarray isDiffusiveFluxBoundary_u, + xt::pyarray isDiffusiveFluxBoundary_v, + xt::pyarray isDiffusiveFluxBoundary_w, + xt::pyarray ebqe_bc_p_ext, + xt::pyarray ebqe_bc_flux_mass_ext, + xt::pyarray ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_bc_flux_u_diff_ext, + xt::pyarray ebqe_penalty_ext, + xt::pyarray ebqe_bc_v_ext, + xt::pyarray ebqe_bc_flux_v_diff_ext, + xt::pyarray ebqe_bc_w_ext, + xt::pyarray ebqe_bc_flux_w_diff_ext, + xt::pyarray q_x, + xt::pyarray q_velocity, + xt::pyarray ebqe_velocity, + xt::pyarray flux, + xt::pyarray elementResidual_p, + xt::pyarray elementFlags, + xt::pyarray boundaryFlags, + xt::pyarray barycenters, + xt::pyarray wettedAreas, + xt::pyarray netForces_p, + xt::pyarray netForces_v, + xt::pyarray netMoments, + xt::pyarray ncDrag, double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr)=0; + xt::pyarray q_mu_fr_last, + xt::pyarray q_mu_fr)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, double MOVING_DOMAIN, double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray p_trial_ref, + xt::pyarray p_grad_trial_ref, + xt::pyarray p_test_ref, + xt::pyarray p_grad_test_ref, + xt::pyarray q_p, + xt::pyarray q_grad_p, + xt::pyarray ebqe_p, + xt::pyarray ebqe_grad_p, + xt::pyarray vel_trial_ref, + xt::pyarray vel_grad_trial_ref, + xt::pyarray vel_test_ref, + xt::pyarray vel_grad_test_ref, //element boundary - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *dS_ref, - double *p_trial_trace_ref, - double *p_grad_trial_trace_ref, - double *p_test_trace_ref, - double *p_grad_test_trace_ref, - double *vel_trial_trace_ref, - double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, - double *vel_grad_test_trace_ref, - double *normal_ref, - double *boundaryJac_ref, + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray p_trial_trace_ref, + xt::pyarray p_grad_trial_trace_ref, + xt::pyarray p_test_trace_ref, + xt::pyarray p_grad_test_trace_ref, + xt::pyarray vel_trial_trace_ref, + xt::pyarray vel_grad_trial_trace_ref, + xt::pyarray vel_test_trace_ref, + xt::pyarray vel_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, //physics double eb_adjoint_sigma, - double *elementDiameter, - double *nodeDiametersArray, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, double hFactor, int nElements_global, double useRBLES, @@ -267,140 +271,140 @@ namespace proteus double C_dg, double C_b, //VRANS - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - int* p_l2g, - int* vel_l2g, - double* p_dof, double* u_dof, double* v_dof, double* w_dof, - double* g, + const xt::pyarray eps_solid, + const xt::pyarray q_velocity_fluid, + const xt::pyarray q_velocityStar_fluid, + const xt::pyarray q_vos,//sed fraction - gco check + const xt::pyarray q_dvos_dt, + const xt::pyarray q_grad_vos, + const xt::pyarray q_dragAlpha, + const xt::pyarray q_dragBeta, + const xt::pyarray q_mass_source, + const xt::pyarray q_turb_var_0, + const xt::pyarray q_turb_var_1, + const xt::pyarray q_turb_var_grad_0, + xt::pyarray p_l2g, + xt::pyarray vel_l2g, + xt::pyarray p_dof, xt::pyarray u_dof, xt::pyarray v_dof, xt::pyarray w_dof, + xt::pyarray g, const double useVF, - double *vf, - double *phi, - double *normal_phi, - double *kappa_phi, - double *q_mom_u_acc_beta_bdf, double *q_mom_v_acc_beta_bdf, double *q_mom_w_acc_beta_bdf, - double *q_dV, - double *q_dV_last, - double *q_velocity_sge, - double *ebqe_velocity_star, - double *q_cfl, - double *q_numDiff_u_last, double *q_numDiff_v_last, double *q_numDiff_w_last, - int *sdInfo_u_u_rowptr, int *sdInfo_u_u_colind, - int *sdInfo_u_v_rowptr, int *sdInfo_u_v_colind, - int *sdInfo_u_w_rowptr, int *sdInfo_u_w_colind, - int *sdInfo_v_v_rowptr, int *sdInfo_v_v_colind, - int *sdInfo_v_u_rowptr, int *sdInfo_v_u_colind, - int *sdInfo_v_w_rowptr, int *sdInfo_v_w_colind, - int *sdInfo_w_w_rowptr, int *sdInfo_w_w_colind, - int *sdInfo_w_u_rowptr, int *sdInfo_w_u_colind, - int *sdInfo_w_v_rowptr, int *sdInfo_w_v_colind, - int *csrRowIndeces_p_p, int *csrColumnOffsets_p_p, - int *csrRowIndeces_p_u, int *csrColumnOffsets_p_u, - int *csrRowIndeces_p_v, int *csrColumnOffsets_p_v, - int *csrRowIndeces_p_w, int *csrColumnOffsets_p_w, - int *csrRowIndeces_u_p, int *csrColumnOffsets_u_p, - int *csrRowIndeces_u_u, int *csrColumnOffsets_u_u, - int *csrRowIndeces_u_v, int *csrColumnOffsets_u_v, - int *csrRowIndeces_u_w, int *csrColumnOffsets_u_w, - int *csrRowIndeces_v_p, int *csrColumnOffsets_v_p, - int *csrRowIndeces_v_u, int *csrColumnOffsets_v_u, - int *csrRowIndeces_v_v, int *csrColumnOffsets_v_v, - int *csrRowIndeces_v_w, int *csrColumnOffsets_v_w, - int *csrRowIndeces_w_p, int *csrColumnOffsets_w_p, - int *csrRowIndeces_w_u, int *csrColumnOffsets_w_u, - int *csrRowIndeces_w_v, int *csrColumnOffsets_w_v, - int *csrRowIndeces_w_w, int *csrColumnOffsets_w_w, - double *globalJacobian, + xt::pyarray vf, + xt::pyarray phi, + xt::pyarray normal_phi, + xt::pyarray kappa_phi, + xt::pyarray q_mom_u_acc_beta_bdf, xt::pyarray q_mom_v_acc_beta_bdf, xt::pyarray q_mom_w_acc_beta_bdf, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray q_velocity_sge, + xt::pyarray ebqe_velocity_star, + xt::pyarray q_cfl, + xt::pyarray q_numDiff_u_last, xt::pyarray q_numDiff_v_last, xt::pyarray q_numDiff_w_last, + xt::pyarray sdInfo_u_u_rowptr, xt::pyarray sdInfo_u_u_colind, + xt::pyarray sdInfo_u_v_rowptr, xt::pyarray sdInfo_u_v_colind, + xt::pyarray sdInfo_u_w_rowptr, xt::pyarray sdInfo_u_w_colind, + xt::pyarray sdInfo_v_v_rowptr, xt::pyarray sdInfo_v_v_colind, + xt::pyarray sdInfo_v_u_rowptr, xt::pyarray sdInfo_v_u_colind, + xt::pyarray sdInfo_v_w_rowptr, xt::pyarray sdInfo_v_w_colind, + xt::pyarray sdInfo_w_w_rowptr, xt::pyarray sdInfo_w_w_colind, + xt::pyarray sdInfo_w_u_rowptr, xt::pyarray sdInfo_w_u_colind, + xt::pyarray sdInfo_w_v_rowptr, xt::pyarray sdInfo_w_v_colind, + xt::pyarray csrRowIndeces_p_p, xt::pyarray csrColumnOffsets_p_p, + xt::pyarray csrRowIndeces_p_u, xt::pyarray csrColumnOffsets_p_u, + xt::pyarray csrRowIndeces_p_v, xt::pyarray csrColumnOffsets_p_v, + xt::pyarray csrRowIndeces_p_w, xt::pyarray csrColumnOffsets_p_w, + xt::pyarray csrRowIndeces_u_p, xt::pyarray csrColumnOffsets_u_p, + xt::pyarray csrRowIndeces_u_u, xt::pyarray csrColumnOffsets_u_u, + xt::pyarray csrRowIndeces_u_v, xt::pyarray csrColumnOffsets_u_v, + xt::pyarray csrRowIndeces_u_w, xt::pyarray csrColumnOffsets_u_w, + xt::pyarray csrRowIndeces_v_p, xt::pyarray csrColumnOffsets_v_p, + xt::pyarray csrRowIndeces_v_u, xt::pyarray csrColumnOffsets_v_u, + xt::pyarray csrRowIndeces_v_v, xt::pyarray csrColumnOffsets_v_v, + xt::pyarray csrRowIndeces_v_w, xt::pyarray csrColumnOffsets_v_w, + xt::pyarray csrRowIndeces_w_p, xt::pyarray csrColumnOffsets_w_p, + xt::pyarray csrRowIndeces_w_u, xt::pyarray csrColumnOffsets_w_u, + xt::pyarray csrRowIndeces_w_v, xt::pyarray csrColumnOffsets_w_v, + xt::pyarray csrRowIndeces_w_w, xt::pyarray csrColumnOffsets_w_w, + xt::pyarray globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *ebqe_vf_ext, - double *bc_ebqe_vf_ext, - double *ebqe_phi_ext, - double *bc_ebqe_phi_ext, - double *ebqe_normal_phi_ext, - double *ebqe_kappa_phi_ext, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_vf_ext, + xt::pyarray bc_ebqe_vf_ext, + xt::pyarray ebqe_phi_ext, + xt::pyarray bc_ebqe_phi_ext, + xt::pyarray ebqe_normal_phi_ext, + xt::pyarray ebqe_kappa_phi_ext, //VRANS - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray ebqe_turb_var_0, + const xt::pyarray ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - int* csrColumnOffsets_eb_p_p, - int* csrColumnOffsets_eb_p_u, - int* csrColumnOffsets_eb_p_v, - int* csrColumnOffsets_eb_p_w, - int* csrColumnOffsets_eb_u_p, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_u_w, - int* csrColumnOffsets_eb_v_p, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v, - int* csrColumnOffsets_eb_v_w, - int* csrColumnOffsets_eb_w_p, - int* csrColumnOffsets_eb_w_u, - int* csrColumnOffsets_eb_w_v, - int* csrColumnOffsets_eb_w_w, - int* elementFlags, + xt::pyarray isDOFBoundary_p, + xt::pyarray isDOFBoundary_u, + xt::pyarray isDOFBoundary_v, + xt::pyarray isDOFBoundary_w, + xt::pyarray isAdvectiveFluxBoundary_p, + xt::pyarray isAdvectiveFluxBoundary_u, + xt::pyarray isAdvectiveFluxBoundary_v, + xt::pyarray isAdvectiveFluxBoundary_w, + xt::pyarray isDiffusiveFluxBoundary_u, + xt::pyarray isDiffusiveFluxBoundary_v, + xt::pyarray isDiffusiveFluxBoundary_w, + xt::pyarray ebqe_bc_p_ext, + xt::pyarray ebqe_bc_flux_mass_ext, + xt::pyarray ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_bc_flux_u_diff_ext, + xt::pyarray ebqe_penalty_ext, + xt::pyarray ebqe_bc_v_ext, + xt::pyarray ebqe_bc_flux_v_diff_ext, + xt::pyarray ebqe_bc_w_ext, + xt::pyarray ebqe_bc_flux_w_diff_ext, + xt::pyarray csrColumnOffsets_eb_p_p, + xt::pyarray csrColumnOffsets_eb_p_u, + xt::pyarray csrColumnOffsets_eb_p_v, + xt::pyarray csrColumnOffsets_eb_p_w, + xt::pyarray csrColumnOffsets_eb_u_p, + xt::pyarray csrColumnOffsets_eb_u_u, + xt::pyarray csrColumnOffsets_eb_u_v, + xt::pyarray csrColumnOffsets_eb_u_w, + xt::pyarray csrColumnOffsets_eb_v_p, + xt::pyarray csrColumnOffsets_eb_v_u, + xt::pyarray csrColumnOffsets_eb_v_v, + xt::pyarray csrColumnOffsets_eb_v_w, + xt::pyarray csrColumnOffsets_eb_w_p, + xt::pyarray csrColumnOffsets_eb_w_u, + xt::pyarray csrColumnOffsets_eb_w_v, + xt::pyarray csrColumnOffsets_eb_w_w, + xt::pyarray elementFlags, double mu_fr, - double* q_mu_fr_last, - double* q_mu_fr)=0; + xt::pyarray q_mu_fr_last, + xt::pyarray q_mu_fr)=0; virtual void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, + xt::pyarray exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int *interiorElementBoundariesArray, - int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, - double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray interiorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, double MOVING_DOMAIN, //0 or 1 - int *mesh_l2g, - double *mesh_trial_trace_ref, - double *mesh_grad_trial_trace_ref, - double *normal_ref, - double *boundaryJac_ref, - int *vel_l2g, - double *u_dof, - double *v_dof, - double *w_dof, - double *vos_dof, - double *vel_trial_trace_ref, - double *ebqe_velocity, - double *velocityAverage) = 0; + xt::pyarray mesh_l2g, + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + xt::pyarray vel_l2g, + xt::pyarray u_dof, + xt::pyarray v_dof, + xt::pyarray w_dof, + xt::pyarray vos_dof, + xt::pyarray vel_trial_trace_ref, + xt::pyarray ebqe_velocity, + xt::pyarray velocityAverage) = 0; }; template mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, double MOVING_DOMAIN, double PSTAB, - int* mesh_l2g, - double* dV_ref, - double* p_trial_ref, - double* p_grad_trial_ref, - double* p_test_ref, - double* p_grad_test_ref, - double* q_p, - double* q_grad_p, - double* ebqe_p, - double* ebqe_grad_p, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray p_trial_ref, + xt::pyarray p_grad_trial_ref, + xt::pyarray p_test_ref, + xt::pyarray p_grad_test_ref, + xt::pyarray q_p, + xt::pyarray q_grad_p, + xt::pyarray ebqe_p, + xt::pyarray ebqe_grad_p, + xt::pyarray vel_trial_ref, + xt::pyarray vel_grad_trial_ref, + xt::pyarray vel_test_ref, + xt::pyarray vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* p_trial_trace_ref, - double* p_grad_trial_trace_ref, - double* p_test_trace_ref, - double* p_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray p_trial_trace_ref, + xt::pyarray p_grad_trial_trace_ref, + xt::pyarray p_test_trace_ref, + xt::pyarray p_grad_test_trace_ref, + xt::pyarray vel_trial_trace_ref, + xt::pyarray vel_grad_trial_trace_ref, + xt::pyarray vel_test_trace_ref, + xt::pyarray vel_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, //physics double eb_adjoint_sigma, - double* elementDiameter, - double* nodeDiametersArray, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, double hFactor, int nElements_global, int nElementBoundaries_owned, @@ -1532,110 +1536,110 @@ namespace proteus double C_dc, double C_b, //VRANS - const double* eps_solid, - const double* q_velocity_fluid, - const double* q_velocityStar_fluid, - const double* q_vos,//sed fraction - gco check - const double* q_dvos_dt, - const double* q_grad_vos, - const double* q_dragAlpha, - const double* q_dragBeta, - const double* q_mass_source, - const double* q_turb_var_0, - const double* q_turb_var_1, - const double* q_turb_var_grad_0, - double * q_eddy_viscosity, + const xt::pyarray eps_solid, + const xt::pyarray q_velocity_fluid, + const xt::pyarray q_velocityStar_fluid, + const xt::pyarray q_vos,//sed fraction - gco check + const xt::pyarray q_dvos_dt, + const xt::pyarray q_grad_vos, + const xt::pyarray q_dragAlpha, + const xt::pyarray q_dragBeta, + const xt::pyarray q_mass_source, + const xt::pyarray q_turb_var_0, + const xt::pyarray q_turb_var_1, + const xt::pyarray q_turb_var_grad_0, + xt::pyarray q_eddy_viscosity, // - int* p_l2g, - int* vel_l2g, - double* p_dof, - double* u_dof, - double* v_dof, - double* w_dof, - double* g, + xt::pyarray p_l2g, + xt::pyarray vel_l2g, + xt::pyarray p_dof, + xt::pyarray u_dof, + xt::pyarray v_dof, + xt::pyarray w_dof, + xt::pyarray g, const double useVF, - double* vf, - double* phi, - double* normal_phi, - double* kappa_phi, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mom_w_acc, - double* q_mass_adv, - double* q_mom_u_acc_beta_bdf, double* q_mom_v_acc_beta_bdf, double* q_mom_w_acc_beta_bdf, - double* q_dV, - double* q_dV_last, - double* q_velocity_sge, - double* ebqe_velocity_star, - double* q_cfl, - double* q_numDiff_u, double* q_numDiff_v, double* q_numDiff_w, - double* q_numDiff_u_last, double* q_numDiff_v_last, double* q_numDiff_w_last, - int* sdInfo_u_u_rowptr,int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr,int* sdInfo_u_v_colind, - int* sdInfo_u_w_rowptr,int* sdInfo_u_w_colind, - int* sdInfo_v_v_rowptr,int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr,int* sdInfo_v_u_colind, - int* sdInfo_v_w_rowptr,int* sdInfo_v_w_colind, - int* sdInfo_w_w_rowptr,int* sdInfo_w_w_colind, - int* sdInfo_w_u_rowptr,int* sdInfo_w_u_colind, - int* sdInfo_w_v_rowptr,int* sdInfo_w_v_colind, + xt::pyarray vf, + xt::pyarray phi, + xt::pyarray normal_phi, + xt::pyarray kappa_phi, + xt::pyarray q_mom_u_acc, + xt::pyarray q_mom_v_acc, + xt::pyarray q_mom_w_acc, + xt::pyarray q_mass_adv, + xt::pyarray q_mom_u_acc_beta_bdf, xt::pyarray q_mom_v_acc_beta_bdf, xt::pyarray q_mom_w_acc_beta_bdf, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray q_velocity_sge, + xt::pyarray ebqe_velocity_star, + xt::pyarray q_cfl, + xt::pyarray q_numDiff_u, xt::pyarray q_numDiff_v, xt::pyarray q_numDiff_w, + xt::pyarray q_numDiff_u_last, xt::pyarray q_numDiff_v_last, xt::pyarray q_numDiff_w_last, + xt::pyarray sdInfo_u_u_rowptr,xt::pyarray sdInfo_u_u_colind, + xt::pyarray sdInfo_u_v_rowptr,xt::pyarray sdInfo_u_v_colind, + xt::pyarray sdInfo_u_w_rowptr,xt::pyarray sdInfo_u_w_colind, + xt::pyarray sdInfo_v_v_rowptr,xt::pyarray sdInfo_v_v_colind, + xt::pyarray sdInfo_v_u_rowptr,xt::pyarray sdInfo_v_u_colind, + xt::pyarray sdInfo_v_w_rowptr,xt::pyarray sdInfo_v_w_colind, + xt::pyarray sdInfo_w_w_rowptr,xt::pyarray sdInfo_w_w_colind, + xt::pyarray sdInfo_w_u_rowptr,xt::pyarray sdInfo_w_u_colind, + xt::pyarray sdInfo_w_v_rowptr,xt::pyarray sdInfo_w_v_colind, int offset_p, int offset_u, int offset_v, int offset_w, int stride_p, int stride_u, int stride_v, int stride_w, - double* globalResidual, + xt::pyarray globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_vf_ext, - double* bc_ebqe_vf_ext, - double* ebqe_phi_ext, - double* bc_ebqe_phi_ext, - double* ebqe_normal_phi_ext, - double* ebqe_kappa_phi_ext, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_vf_ext, + xt::pyarray bc_ebqe_vf_ext, + xt::pyarray ebqe_phi_ext, + xt::pyarray bc_ebqe_phi_ext, + xt::pyarray ebqe_normal_phi_ext, + xt::pyarray ebqe_kappa_phi_ext, //VRANS - const double* ebqe_vos_ext,//sed fraction - gco check - const double* ebqe_turb_var_0, - const double* ebqe_turb_var_1, + const xt::pyarray ebqe_vos_ext,//sed fraction - gco check + const xt::pyarray ebqe_turb_var_0, + const xt::pyarray ebqe_turb_var_1, //VRANS end - int* isDOFBoundary_p, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isDOFBoundary_w, - int* isAdvectiveFluxBoundary_p, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isAdvectiveFluxBoundary_w, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_w, - double* ebqe_bc_p_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_flux_mom_w_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* ebqe_bc_w_ext, - double* ebqe_bc_flux_w_diff_ext, - double* q_x, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_p_save, - int* elementFlags, - int* boundaryFlags, - double* barycenters, - double* wettedAreas, - double* netForces_p, - double* netForces_v, - double* netMoments, - double* ncDrag, + xt::pyarray isDOFBoundary_p, + xt::pyarray isDOFBoundary_u, + xt::pyarray isDOFBoundary_v, + xt::pyarray isDOFBoundary_w, + xt::pyarray isAdvectiveFluxBoundary_p, + xt::pyarray isAdvectiveFluxBoundary_u, + xt::pyarray isAdvectiveFluxBoundary_v, + xt::pyarray isAdvectiveFluxBoundary_w, + xt::pyarray isDiffusiveFluxBoundary_u, + xt::pyarray isDiffusiveFluxBoundary_v, + xt::pyarray isDiffusiveFluxBoundary_w, + xt::pyarray ebqe_bc_p_ext, + xt::pyarray ebqe_bc_flux_mass_ext, + xt::pyarray ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray ebqe_bc_flux_mom_w_adv_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_bc_flux_u_diff_ext, + xt::pyarray ebqe_penalty_ext, + xt::pyarray ebqe_bc_v_ext, + xt::pyarray ebqe_bc_flux_v_diff_ext, + xt::pyarray ebqe_bc_w_ext, + xt::pyarray ebqe_bc_flux_w_diff_ext, + xt::pyarray q_x, + xt::pyarray q_velocity, + xt::pyarray ebqe_velocity, + xt::pyarray flux, + xt::pyarray elementResidual_p_save, + xt::pyarray elementFlags, + xt::pyarray boundaryFlags, + xt::pyarray barycenters, + xt::pyarray wettedAreas, + xt::pyarray netForces_p, + xt::pyarray netForces_v, + xt::pyarray netMoments, + xt::pyarray ncDrag, double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) + xt::pyarray q_mu_fr_last, + xt::pyarray q_mu_fr) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -1750,61 +1754,61 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateH_element(eN, k, - nodeDiametersArray, - mesh_l2g, - mesh_trial_ref, + nodeDiametersArray.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), h_phi); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //xt=0.0;yt=0.0;zt=0.0; //std::cout<<"xt "< exteriorElementBoundariesArray, int nInteriorElementBoundaries_global, - int* interiorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray interiorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int* vel_l2g, - double* u_dof, - double* v_dof, - double* w_dof, - double* vos_dof, - double* vel_trial_trace_ref, - double* ebqe_velocity, - double* velocityAverage) + xt::pyarray mesh_l2g, + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + xt::pyarray vel_l2g, + xt::pyarray u_dof, + xt::pyarray v_dof, + xt::pyarray w_dof, + xt::pyarray vos_dof, + xt::pyarray vel_trial_trace_ref, + xt::pyarray ebqe_velocity, + xt::pyarray velocityAverage) { int permutations[nQuadraturePoints_elementBoundary]; double xArray_left[nQuadraturePoints_elementBoundary*2], @@ -4661,22 +4665,22 @@ namespace proteus permutations[i]=i;//just to initialize for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) { - register int ebN = exteriorElementBoundariesArray[ebNE]; + register int ebN = exteriorElementBoundariesArray.data()[ebNE]; for (int kb=0;kb a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::RDLS_base; +using pybind11::return_value_policy; + +PYBIND11_MODULE(cRDLS, m) +{ + xt::import_numpy(); + + py::class_(m, "cRDLS_base") + .def(py::init(&proteus::newRDLS)) + .def("calculateResidual" , &RDLS_base::calculateResidual ) + .def("calculateJacobian" , &RDLS_base::calculateJacobian ) + .def("calculateResidual_ellipticRedist" , &RDLS_base::calculateResidual_ellipticRedist ) + .def("calculateJacobian_ellipticRedist" , &RDLS_base::calculateJacobian_ellipticRedist ) + .def("normalReconstruction" , &RDLS_base::normalReconstruction ) + .def("calculateMetricsAtEOS" , &RDLS_base::calculateMetricsAtEOS, return_value_policy::take_ownership); +} diff --git a/proteus/mprans/RDLS.h b/proteus/mprans/RDLS.h index c7e7a6dc65..908ae15984 100644 --- a/proteus/mprans/RDLS.h +++ b/proteus/mprans/RDLS.h @@ -6,6 +6,10 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "equivalent_polynomials.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + #define SINGLE_POTENTIAL 1 namespace proteus @@ -25,26 +29,26 @@ namespace proteus std::valarray weighted_lumped_mass_matrix; virtual ~RDLS_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -59,63 +63,63 @@ namespace proteus //1 dH lagged in tau //2 dH lagged in tau and Residual, adjoint calculations double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* phi_ls, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* u_weak_internal_bc_dofs,//for freezing level set - double* q_m_betaBDF, - double* q_dH_last,//for lagging subgrid error - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* weakDirichletConditionFlags, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& phi_ls, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last,//for lagging subgrid error + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_n, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz, + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz, double alpha, bool useExact)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -128,55 +132,55 @@ namespace proteus int lag_shockCapturing, int lag_subgridError, double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* u_weak_internal_bc_dofs,//for freezing level set - double* phi_ls, - double* q_m_betaBDF, - double* q_dH_last, - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int * weakDirichletConditionFlags, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& phi_ls, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, double alpha, bool useExact)=0; virtual void calculateResidual_ellipticRedist(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -191,63 +195,63 @@ namespace proteus //1 dH lagged in tau //2 dH lagged in tau and Residual, adjoint calculations double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* phi_ls, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* u_weak_internal_bc_dofs,//for freezing level set - double* q_m_betaBDF, - double* q_dH_last,//for lagging subgrid error - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* weakDirichletConditionFlags, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& phi_ls, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last,//for lagging subgrid error + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_n, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz, + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz, double alpha, bool useExact)=0; virtual void calculateJacobian_ellipticRedist(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* x_ref, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -260,73 +264,70 @@ namespace proteus int lag_shockCapturing, int lag_subgridError, double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* u_weak_internal_bc_dofs,//for freezing level set - double* phi_ls, - double* q_m_betaBDF, - double* q_dH_last, - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int * weakDirichletConditionFlags, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& phi_ls, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, double alpha, bool useExact)=0; - virtual void normalReconstruction(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + virtual void normalReconstruction(xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, int nElements_global, - int* u_l2g, - double* elementDiameter, - double* phi_dof, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& phi_dof, int offset_u, int stride_u, int numDOFs, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz)=0; - virtual void calculateMetricsAtEOS( //EOS=End Of Simulation - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz)=0; + virtual std::tuple calculateMetricsAtEOS( //EOS=End Of Simulation + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global, - int* u_l2g, - double* elementDiameter, - //double* nodeDiametersArray, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + //xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFact_redist, - double* u_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_V_err, - double* global_D_err)=0; + xt::pyarray& u_dof, + xt::pyarray& u_exact, + int offset_u, int stride_u)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -448,40 +449,40 @@ namespace proteus //1 dH lagged in tau //2 dH lagged in tau and Residual, adjoint calculations double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* phi_ls, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* u_weak_internal_bc_dofs,//for freezing level set - double* q_m_betaBDF, - double* q_dH_last,//for lagging subgrid error - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* weakDirichletConditionFlags, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& phi_ls, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last,//for lagging subgrid error + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_n, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz, + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz, double alpha, bool useExact) { @@ -523,7 +524,7 @@ namespace proteus { register int eN_i=eN*nDOF_trial_element+i; elementResidual_u[i]=0.0; - element_phi[i] = phi_dof[u_l2g[eN_i]]; + element_phi[i] = phi_dof.data()[u_l2g.data()[eN_i]]; dummy_l2g[i] = i; }//i double element_nodes[nDOF_mesh_trial_element*3]; @@ -531,18 +532,18 @@ namespace proteus { register int eN_i=eN*nDOF_mesh_trial_element+i; for(int I=0;I<3;I++) - element_nodes[i*3 + I] = mesh_dof[mesh_l2g[eN_i]*3 + I]; + element_nodes[i*3 + I] = mesh_dof.data()[mesh_l2g.data()[eN_i]*3 + I]; }//i - gf.calculate(element_phi, element_nodes, x_ref); + gf.calculate(element_phi, element_nodes, x_ref.data()); /* for (int i=0;i 1) { for (int I=0; I < nSpace; I++) { - dH_strong[I] = q_dH_last[eN_k_nSpace+I]; + dH_strong[I] = q_dH_last.data()[eN_k_nSpace+I]; } } //save mass for time history and dH for subgrid error //save solution for other models // - q_m[eN_k] = m; - q_u[eN_k] = u; + q_m.data()[eN_k] = m; + q_u.data()[eN_k] = u; for (int I=0;I epsilon_background_diffusion) */ /* nu_sc += backgroundDiffusionFactor*h_phi; */ - double epsilon_background_diffusion = 2.0*epsFact_redist*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - if (fabs(phi_ls[eN_k]) > epsilon_background_diffusion) - nu_sc += backgroundDiffusionFactor*elementDiameter[eN]; // + double epsilon_background_diffusion = 2.0*epsFact_redist*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + if (fabs(phi_ls.data()[eN_k]) > epsilon_background_diffusion) + nu_sc += backgroundDiffusionFactor*elementDiameter.data()[eN]; // //update element residual // for(int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -927,29 +928,29 @@ namespace proteus int lag_shockCapturing, int lag_subgridError, double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* u_weak_internal_bc_dofs,//for freezing level set - double* phi_ls, - double* q_m_betaBDF, - double* q_dH_last, - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int * weakDirichletConditionFlags, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& phi_ls, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, @@ -975,7 +976,7 @@ namespace proteus for (int i=0;i 1) { for (int I=0; I < nSpace; I++) { - dH_strong[I] = q_dH_last[eN_k_nSpace+I]; + dH_strong[I] = q_dH_last.data()[eN_k_nSpace+I]; } } // @@ -1125,7 +1126,7 @@ namespace proteus //calculate time derivatives // ck.bdf(alphaBDF, - q_m_betaBDF[eN_k], + q_m_betaBDF.data()[eN_k], m, dm, m_t, @@ -1152,37 +1153,37 @@ namespace proteus //int eN_k_j=eN_k*nDOF_trial_element+j; //int eN_k_j_nSpace = eN_k_j*nSpace; int j_nSpace = j*nSpace; - dpdeResidual_u_u[j]=ck.MassJacobian_strong(dm_t,u_trial_ref[k*nDOF_trial_element+j]) + + dpdeResidual_u_u[j]=ck.MassJacobian_strong(dm_t,u_trial_ref.data()[k*nDOF_trial_element+j]) + ck.HamiltonianJacobian_strong(dH_strong,&u_grad_trial[j_nSpace]); } //tau and tau*Res - calculateSubgridError_tau(elementDiameter[eN], + calculateSubgridError_tau(elementDiameter.data()[eN], dm_t, dH_tau, - q_cfl[eN_k], + q_cfl.data()[eN_k], tau0); calculateSubgridError_tau(G, dH_tau, tau1, - q_cfl[eN_k]); + q_cfl.data()[eN_k]); tau = useMetrics*tau1+(1.0-useMetrics)*tau0; for (int j=0;j epsilon_background_diffusion) */ /* nu_sc += backgroundDiffusionFactor*h_phi; */ - double epsilon_background_diffusion = 2.0*epsFact_redist*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]); - if (fabs(phi_ls[eN_k]) > epsilon_background_diffusion) - nu_sc += backgroundDiffusionFactor*elementDiameter[eN]; // + double epsilon_background_diffusion = 2.0*epsFact_redist*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]); + if (fabs(phi_ls.data()[eN_k]) > epsilon_background_diffusion) + nu_sc += backgroundDiffusionFactor*elementDiameter.data()[eN]; // for(int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1424,40 +1425,40 @@ namespace proteus //1 dH lagged in tau //2 dH lagged in tau and Residual, adjoint calculations double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* phi_ls, - double* q_m, - double* q_u, - double* q_n, - double* q_dH, - double* u_weak_internal_bc_dofs,//for freezing level set - double* q_m_betaBDF, - double* q_dH_last,//for lagging subgrid error - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int* weakDirichletConditionFlags, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& phi_ls, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_n, + xt::pyarray& q_dH, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last,//for lagging subgrid error + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - double* ebqe_u, - double* ebqe_n, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_n, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz, + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz, double alpha, bool useExact) { @@ -1481,16 +1482,16 @@ namespace proteus { register int eN_i=eN*nDOF_trial_element+i; elementResidual_u[i]=0.0; - element_phi[i] = phi_dof[u_l2g[eN_i]]; + element_phi[i] = phi_dof.data()[u_l2g.data()[eN_i]]; }//i double element_nodes[nDOF_mesh_trial_element*3]; for (int i=0;i 1) { // use linear elliptic re-distancing via C0 normal reconstruction - ck.valFromDOF(lumped_qx, - &u_l2g[eN_nDOF_trial_element], - &u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(lumped_qx.data(), + &u_l2g.data()[eN_nDOF_trial_element], + &u_trial_ref.data()[k*nDOF_trial_element], qx); - ck.valFromDOF(lumped_qy, - &u_l2g[eN_nDOF_trial_element], - &u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(lumped_qy.data(), + &u_l2g.data()[eN_nDOF_trial_element], + &u_trial_ref.data()[k*nDOF_trial_element], qy); - ck.valFromDOF(lumped_qz, - &u_l2g[eN_nDOF_trial_element], - &u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(lumped_qz.data(), + &u_l2g.data()[eN_nDOF_trial_element], + &u_trial_ref.data()[k*nDOF_trial_element], qz); normalReconstruction[0] = qx; normalReconstruction[1] = qy; @@ -1563,7 +1564,7 @@ namespace proteus //precalculate test function products with integration weights for (int j=0;j 1) // (NON)LINEAR VIA C0 NORMAL RECONSTRUCTION { @@ -1613,7 +1614,7 @@ namespace proteus -ck.NumericalDiffusion(1.0, normalReconstruction, &u_grad_test_dV[i_nSpace]) - +alpha*(u_dof[gi]-phi_dof[gi])*delta*u_test_dV[i]; // BCs + +alpha*(u_dof.data()[gi]-phi_dof.data()[gi])*delta*u_test_dV[i]; // BCs } else // =1. Nonlinear via single or double pot. { @@ -1622,7 +1623,7 @@ namespace proteus +ck.NumericalDiffusion(coeff+backgroundDissipation, grad_u, &u_grad_test_dV[i_nSpace]) - + alpha*(u_dof[gi]-phi_dof[gi])*delta*u_test_dV[i]; // BCs + + alpha*(u_dof.data()[gi]-phi_dof.data()[gi])*delta*u_test_dV[i]; // BCs } }//i }//k @@ -1632,7 +1633,7 @@ namespace proteus for(int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_l2g, + xt::pyarray& x_ref, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1740,29 +1741,29 @@ namespace proteus int lag_shockCapturing, int lag_subgridError, double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double* u_dof, - double* phi_dof, - double* u_weak_internal_bc_dofs,//for freezing level set - double* phi_ls, - double* q_m_betaBDF, - double* q_dH_last, - double* q_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int * weakDirichletConditionFlags, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& nodeDiametersArray, + xt::pyarray& u_dof, + xt::pyarray& phi_dof, + xt::pyarray& u_weak_internal_bc_dofs,//for freezing level set + xt::pyarray& phi_ls, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dH_last, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& weakDirichletConditionFlags, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_phi_ls_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_phi_ls_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, // elliptic redistancing int ELLIPTIC_REDISTANCING, double backgroundDissipationEllipticRedist, @@ -1780,7 +1781,7 @@ namespace proteus for (int i=0;i& mesh_trial_ref,// + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, // + xt::pyarray& mesh_l2g,// + xt::pyarray& dV_ref,// + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, //physics int nElements_global,// - int* u_l2g, // - double* elementDiameter,// - double* u_dof,// + xt::pyarray& u_l2g, // + xt::pyarray& elementDiameter,// + xt::pyarray& u_dof,// int offset_u, int stride_u, // PARAMETERS FOR EDGE VISCOSITY int numDOFs, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz) + xt::pyarray& lumped_qx, + xt::pyarray& lumped_qy, + xt::pyarray& lumped_qz) { weighted_lumped_mass_matrix.resize(numDOFs,0.0); for (int i=0; i calculateMetricsAtEOS( //EOS=End Of Simulation + xt::pyarray& mesh_trial_ref, // + xt::pyarray& mesh_grad_trial_ref, // + xt::pyarray& mesh_dof, // + xt::pyarray& mesh_l2g, // + xt::pyarray& dV_ref, // + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, // //physics int nElements_global, // - int* u_l2g, // - double* elementDiameter, - //double* nodeDiametersArray, + xt::pyarray& u_l2g, // + xt::pyarray& elementDiameter, + //xt::pyarray& nodeDiametersArray, double degree_polynomial, double epsFact_redist, - double* u_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_V_err, - double* global_D_err) + xt::pyarray& u_dof, + xt::pyarray& u_exact, + int offset_u, int stride_u) { double global_V = 0.; double global_V0 = 0.; - *global_I_err = 0.0; - *global_V_err = 0.0; - *global_D_err = 0.0; + double global_I_err = 0.0; + double global_V_err = 0.0; + double global_D_err = 0.0; ////////////////////// // ** LOOP IN CELLS // ////////////////////// @@ -2101,27 +2099,27 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; // get functions at quad points - ck.valFromDOF(u_dof, - &u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element], + ck.valFromDOF(u_dof.data(), + &u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element], uh); - u = u_exact[eN_k]; + u = u_exact.data()[eN_k]; // get gradients - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace], + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace], jacInv, u_grad_trial); - ck.gradFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_uh); + ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_uh); - double epsHeaviside = epsFact_redist*elementDiameter[eN]/degree_polynomial; + double epsHeaviside = epsFact_redist*elementDiameter.data()[eN]/degree_polynomial; // compute (smoothed) heaviside functions // double Hu = heaviside(u); double Huh = heaviside(uh); @@ -2138,11 +2136,12 @@ namespace proteus global_V += cell_V; global_V0 += cell_V0; // metrics // - *global_I_err += cell_I_err; - *global_D_err += cell_D_err; + global_I_err += cell_I_err; + global_D_err += cell_D_err; }//elements - *global_V_err = fabs(global_V0 - global_V)/global_V0; - *global_D_err *= 0.5; + global_V_err = fabs(global_V0 - global_V)/global_V0; + global_D_err *= 0.5; + return std::tuple(global_I_err, global_V_err, global_D_err); } };//RDLS diff --git a/proteus/mprans/RDLS.py b/proteus/mprans/RDLS.py index 41fa8e46d1..d3ad208967 100644 --- a/proteus/mprans/RDLS.py +++ b/proteus/mprans/RDLS.py @@ -4,6 +4,10 @@ import proteus from proteus.mprans.cRDLS import * from proteus.Comm import globalMax +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class SubgridError(proteus.SubgridError.SGE_base): def __init__(self, coefficients, nd): @@ -1164,8 +1168,8 @@ def getJacobianNew(self, jacobian): self.freezeLevelSet, useTimeIntegration, self.shockCapturing.lag, - self.stabilization.lag, - self.shockCapturing.shockCapturingFactor, + int(self.stabilization.lag), + int(self.shockCapturing.shockCapturingFactor), self.u[0].femSpace.dofMap.l2g, self.elementDiameter, # self.mesh.elementDiametersArray, self.mesh.nodeDiametersArray, @@ -1180,7 +1184,7 @@ def getJacobianNew(self, jacobian): self.shockCapturing.numDiff_last[0], self.weakDirichletConditionFlags, self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, @@ -1192,7 +1196,7 @@ def getJacobianNew(self, jacobian): # elliptic re-distancing self.coefficients.ELLIPTIC_REDISTANCING, self.coefficients.backgroundDissipationEllipticRedist, - self.coefficients.alpha/self.elementDiameter.min(), + float(self.coefficients.alpha/self.elementDiameter.min()), self.coefficients.useExact) # FREEZING INTERFACE # diff --git a/proteus/mprans/SW2D.cpp b/proteus/mprans/SW2D.cpp new file mode 100644 index 0000000000..5bb8580112 --- /dev/null +++ b/proteus/mprans/SW2D.cpp @@ -0,0 +1,31 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "SW2D.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::SW2D_base; + +PYBIND11_MODULE(cSW2D, m) +{ + xt::import_numpy(); + + py::class_(m, "cSW2D_base") + .def(py::init(&proteus::newSW2D)) + .def("calculateResidual" , &SW2D_base::calculateResidual) + .def("calculateJacobian" , &SW2D_base::calculateJacobian) + .def("calculateResidual_supg" , &SW2D_base::calculateResidual_supg) + .def("calculateJacobian_supg" , &SW2D_base::calculateJacobian_supg); +} diff --git a/proteus/mprans/SW2D.h b/proteus/mprans/SW2D.h index d04ce5c4b4..d086549968 100644 --- a/proteus/mprans/SW2D.h +++ b/proteus/mprans/SW2D.h @@ -4,6 +4,10 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; + //cek todo //2. Get stabilization right //3. Add Riemann solvers for external flux @@ -16,37 +20,37 @@ namespace proteus public: virtual ~SW2D_base(){} virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, @@ -54,214 +58,214 @@ namespace proteus double nu, double g, double shockCapturingCoefficient, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mass_adv, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h, - double* q_numDiff_u, - double* q_numDiff_v, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_v, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, int offset_h, int offset_u, int offset_v, int stride_h, int stride_u, int stride_v, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_h)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_h)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, double alphaBDF, double nu, double g, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, - int* csrRowIndeces_h_h, - int* csrColumnOffsets_h_h, - int* csrRowIndeces_h_u, - int* csrColumnOffsets_h_u, - int* csrRowIndeces_h_v, - int* csrColumnOffsets_h_v, - int* csrRowIndeces_u_h, - int* csrColumnOffsets_u_h, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v, - int* csrColumnOffsets_u_v, - int* csrRowIndeces_v_h, - int* csrColumnOffsets_v_h, - int* csrRowIndeces_v_u, - int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - double* globalJacobian, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_u, + xt::pyarray& csrColumnOffsets_h_u, + xt::pyarray& csrRowIndeces_h_v, + xt::pyarray& csrColumnOffsets_h_v, + xt::pyarray& csrRowIndeces_u_h, + xt::pyarray& csrColumnOffsets_u_h, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, + xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_v_h, + xt::pyarray& csrColumnOffsets_v_h, + xt::pyarray& csrRowIndeces_v_u, + xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - int* csrColumnOffsets_eb_h_h, - int* csrColumnOffsets_eb_h_u, - int* csrColumnOffsets_eb_h_v, - int* csrColumnOffsets_eb_u_h, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_v_h, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, + xt::pyarray& csrColumnOffsets_eb_h_u, + xt::pyarray& csrColumnOffsets_eb_h_v, + xt::pyarray& csrColumnOffsets_eb_u_h, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_v_h, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v)=0; virtual void calculateResidual_supg(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN,//0 or 1 - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, @@ -269,182 +273,182 @@ namespace proteus double nu, double g, double shockCapturingCoefficient, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mass_adv, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h, - double* q_numDiff_u, - double* q_numDiff_v, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_v, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, int offset_h, int offset_u, int offset_v, int stride_h, int stride_u, int stride_v, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_h)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_h)=0; virtual void calculateJacobian_supg(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, double alphaBDF, double nu, double g, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, - int* csrRowIndeces_h_h, - int* csrColumnOffsets_h_h, - int* csrRowIndeces_h_u, - int* csrColumnOffsets_h_u, - int* csrRowIndeces_h_v, - int* csrColumnOffsets_h_v, - int* csrRowIndeces_u_h, - int* csrColumnOffsets_u_h, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v, - int* csrColumnOffsets_u_v, - int* csrRowIndeces_v_h, - int* csrColumnOffsets_v_h, - int* csrRowIndeces_v_u, - int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - double* globalJacobian, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_u, + xt::pyarray& csrColumnOffsets_h_u, + xt::pyarray& csrRowIndeces_h_v, + xt::pyarray& csrColumnOffsets_h_v, + xt::pyarray& csrRowIndeces_u_h, + xt::pyarray& csrColumnOffsets_u_h, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, + xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_v_h, + xt::pyarray& csrColumnOffsets_v_h, + xt::pyarray& csrRowIndeces_v_u, + xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - int* csrColumnOffsets_eb_h_h, - int* csrColumnOffsets_eb_h_u, - int* csrColumnOffsets_eb_h_v, - int* csrColumnOffsets_eb_u_h, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_v_h, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v)=0; + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, + xt::pyarray& csrColumnOffsets_eb_h_u, + xt::pyarray& csrColumnOffsets_eb_h_v, + xt::pyarray& csrColumnOffsets_eb_u_h, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_v_h, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, @@ -1188,70 +1192,70 @@ namespace proteus double nu, double g, double shockCapturingCoefficient, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mass_adv, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h, - double* q_numDiff_u, - double* q_numDiff_v, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_v, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, int offset_h, int offset_u, int offset_v, int stride_h, int stride_u, int stride_v, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_h_save) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_h_save) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -1266,7 +1270,7 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, @@ -2127,70 +2131,70 @@ namespace proteus double nu, double g, double shockCapturingCoefficient, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc, - double* q_mom_u_acc, - double* q_mom_v_acc, - double* q_mass_adv, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h, - double* q_numDiff_u, - double* q_numDiff_v, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc, + xt::pyarray& q_mom_u_acc, + xt::pyarray& q_mom_v_acc, + xt::pyarray& q_mass_adv, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_v, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, int offset_h, int offset_u, int offset_v, int stride_h, int stride_u, int stride_v, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - double* q_velocity, - double* ebqe_velocity, - double* flux, - double* elementResidual_h_save) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& q_velocity, + xt::pyarray& ebqe_velocity, + xt::pyarray& flux, + xt::pyarray& elementResidual_h_save) { // //loop over elements to compute volume integrals and load them into element and global residual @@ -2205,7 +2209,7 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, double alphaBDF, double nu, double g, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, - int* csrRowIndeces_h_h, - int* csrColumnOffsets_h_h, - int* csrRowIndeces_h_u, - int* csrColumnOffsets_h_u, - int* csrRowIndeces_h_v, - int* csrColumnOffsets_h_v, - int* csrRowIndeces_u_h, - int* csrColumnOffsets_u_h, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v, - int* csrColumnOffsets_u_v, - int* csrRowIndeces_v_h, - int* csrColumnOffsets_v_h, - int* csrRowIndeces_v_u, - int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - double* globalJacobian, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_u, + xt::pyarray& csrColumnOffsets_h_u, + xt::pyarray& csrRowIndeces_h_v, + xt::pyarray& csrColumnOffsets_h_v, + xt::pyarray& csrRowIndeces_u_h, + xt::pyarray& csrColumnOffsets_u_h, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, + xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_v_h, + xt::pyarray& csrColumnOffsets_v_h, + xt::pyarray& csrRowIndeces_v_u, + xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - int* csrColumnOffsets_eb_h_h, - int* csrColumnOffsets_eb_h_u, - int* csrColumnOffsets_eb_h_v, - int* csrColumnOffsets_eb_u_h, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_v_h, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, + xt::pyarray& csrColumnOffsets_eb_h_u, + xt::pyarray& csrColumnOffsets_eb_h_v, + xt::pyarray& csrColumnOffsets_eb_u_h, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_v_h, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v) { double tauSum=0.0; // @@ -2837,44 +2841,44 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; //get the trial function gradients - ck.gradTrialFromRef(&h_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); //get the solution - ck.valFromDOF(b_dof,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],b); - ck.valFromDOF(h_dof,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],h); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(h_dof_sge,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],h_sge); - ck.valFromDOF(u_dof_sge,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u_sge); - ck.valFromDOF(v_dof_sge,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v_sge); + ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b); + ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge); + ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge); + ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge); //get the solution gradients - ck.gradFromDOF(b_dof,&h_l2g[eN_nDOF_trial_element],h_grad_trial,grad_b); - ck.gradFromDOF(h_dof,&h_l2g[eN_nDOF_trial_element],h_grad_trial,grad_h); - ck.gradFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v); + ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b); + ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h); + ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v); //precalculate test function products with integration weights for (int j=0;j& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* h_trial_ref, - double* h_grad_trial_ref, - double* h_test_ref, - double* h_grad_test_ref, - double* vel_trial_ref, - double* vel_grad_trial_ref, - double* vel_test_ref, - double* vel_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, + xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, + xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* h_trial_trace_ref, - double* h_grad_trial_trace_ref, - double* h_test_trace_ref, - double* h_grad_test_trace_ref, - double* vel_trial_trace_ref, - double* vel_grad_trial_trace_ref, - double* vel_test_trace_ref, - double* vel_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& h_trial_trace_ref, + xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, + xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, + xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, + xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics - double* elementDiameter, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, double useMetrics, double alphaBDF, double nu, double g, - int* h_l2g, - int* vel_l2g, - double* b_dof, - double* h_dof, - double* u_dof, - double* v_dof, - double* h_dof_sge, - double* u_dof_sge, - double* v_dof_sge, - double* q_mass_acc_beta_bdf, - double* q_mom_u_acc_beta_bdf, - double* q_mom_v_acc_beta_bdf, - double* q_velocity_sge, - double* q_cfl, - double* q_numDiff_h_last, - double* q_numDiff_u_last, - double* q_numDiff_v_last, - int* sdInfo_u_u_rowptr, - int* sdInfo_u_u_colind, - int* sdInfo_u_v_rowptr, - int* sdInfo_u_v_colind, - int* sdInfo_v_v_rowptr, - int* sdInfo_v_v_colind, - int* sdInfo_v_u_rowptr, - int* sdInfo_v_u_colind, - int* csrRowIndeces_h_h, - int* csrColumnOffsets_h_h, - int* csrRowIndeces_h_u, - int* csrColumnOffsets_h_u, - int* csrRowIndeces_h_v, - int* csrColumnOffsets_h_v, - int* csrRowIndeces_u_h, - int* csrColumnOffsets_u_h, - int* csrRowIndeces_u_u, - int* csrColumnOffsets_u_u, - int* csrRowIndeces_u_v, - int* csrColumnOffsets_u_v, - int* csrRowIndeces_v_h, - int* csrColumnOffsets_v_h, - int* csrRowIndeces_v_u, - int* csrColumnOffsets_v_u, - int* csrRowIndeces_v_v, - int* csrColumnOffsets_v_v, - double* globalJacobian, + xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, + xt::pyarray& b_dof, + xt::pyarray& h_dof, + xt::pyarray& u_dof, + xt::pyarray& v_dof, + xt::pyarray& h_dof_sge, + xt::pyarray& u_dof_sge, + xt::pyarray& v_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_u_acc_beta_bdf, + xt::pyarray& q_mom_v_acc_beta_bdf, + xt::pyarray& q_velocity_sge, + xt::pyarray& q_cfl, + xt::pyarray& q_numDiff_h_last, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& q_numDiff_v_last, + xt::pyarray& sdInfo_u_u_rowptr, + xt::pyarray& sdInfo_u_u_colind, + xt::pyarray& sdInfo_u_v_rowptr, + xt::pyarray& sdInfo_u_v_colind, + xt::pyarray& sdInfo_v_v_rowptr, + xt::pyarray& sdInfo_v_v_colind, + xt::pyarray& sdInfo_v_u_rowptr, + xt::pyarray& sdInfo_v_u_colind, + xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, + xt::pyarray& csrRowIndeces_h_u, + xt::pyarray& csrColumnOffsets_h_u, + xt::pyarray& csrRowIndeces_h_v, + xt::pyarray& csrColumnOffsets_h_v, + xt::pyarray& csrRowIndeces_u_h, + xt::pyarray& csrColumnOffsets_u_h, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& csrRowIndeces_u_v, + xt::pyarray& csrColumnOffsets_u_v, + xt::pyarray& csrRowIndeces_v_h, + xt::pyarray& csrColumnOffsets_v_h, + xt::pyarray& csrRowIndeces_v_u, + xt::pyarray& csrColumnOffsets_v_u, + xt::pyarray& csrRowIndeces_v_v, + xt::pyarray& csrColumnOffsets_v_v, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - int* isDOFBoundary_h, - int* isDOFBoundary_u, - int* isDOFBoundary_v, - int* isAdvectiveFluxBoundary_h, - int* isAdvectiveFluxBoundary_u, - int* isAdvectiveFluxBoundary_v, - int* isDiffusiveFluxBoundary_u, - int* isDiffusiveFluxBoundary_v, - double* ebqe_bc_h_ext, - double* ebqe_bc_flux_mass_ext, - double* ebqe_bc_flux_mom_u_adv_ext, - double* ebqe_bc_flux_mom_v_adv_ext, - double* ebqe_bc_u_ext, - double* ebqe_bc_flux_u_diff_ext, - double* ebqe_penalty_ext, - double* ebqe_bc_v_ext, - double* ebqe_bc_flux_v_diff_ext, - int* csrColumnOffsets_eb_h_h, - int* csrColumnOffsets_eb_h_u, - int* csrColumnOffsets_eb_h_v, - int* csrColumnOffsets_eb_u_h, - int* csrColumnOffsets_eb_u_u, - int* csrColumnOffsets_eb_u_v, - int* csrColumnOffsets_eb_v_h, - int* csrColumnOffsets_eb_v_u, - int* csrColumnOffsets_eb_v_v) + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& isDOFBoundary_v, + xt::pyarray& isAdvectiveFluxBoundary_h, + xt::pyarray& isAdvectiveFluxBoundary_u, + xt::pyarray& isAdvectiveFluxBoundary_v, + xt::pyarray& isDiffusiveFluxBoundary_u, + xt::pyarray& isDiffusiveFluxBoundary_v, + xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, + xt::pyarray& ebqe_bc_flux_mom_u_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_v_adv_ext, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& ebqe_bc_flux_u_diff_ext, + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_v_ext, + xt::pyarray& ebqe_bc_flux_v_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, + xt::pyarray& csrColumnOffsets_eb_h_u, + xt::pyarray& csrColumnOffsets_eb_h_v, + xt::pyarray& csrColumnOffsets_eb_u_h, + xt::pyarray& csrColumnOffsets_eb_u_u, + xt::pyarray& csrColumnOffsets_eb_u_v, + xt::pyarray& csrColumnOffsets_eb_v_h, + xt::pyarray& csrColumnOffsets_eb_v_u, + xt::pyarray& csrColumnOffsets_eb_v_v) { // //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian @@ -3961,44 +3965,44 @@ namespace proteus //get jacobian, etc for mapping reference element ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt); //get the physical integration weight - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; //get the trial function gradients - ck.gradTrialFromRef(&h_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial); - ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); + ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial); + ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial); //get the solution - ck.valFromDOF(b_dof,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],b); - ck.valFromDOF(h_dof,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],h); - ck.valFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u); - ck.valFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v); - ck.valFromDOF(h_dof_sge,&h_l2g[eN_nDOF_trial_element],&h_trial_ref[k*nDOF_trial_element],h_sge); - ck.valFromDOF(u_dof_sge,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u_sge); - ck.valFromDOF(v_dof_sge,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v_sge); + ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b); + ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h); + ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u); + ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v); + ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge); + ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge); + ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge); //get the solution gradients - ck.gradFromDOF(b_dof,&h_l2g[eN_nDOF_trial_element],h_grad_trial,grad_b); - ck.gradFromDOF(h_dof,&h_l2g[eN_nDOF_trial_element],h_grad_trial,grad_h); - ck.gradFromDOF(u_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u); - ck.gradFromDOF(v_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v); + ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b); + ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h); + ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u); + ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v); //precalculate test function products with integration weights for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::SW2DCV_base; +using pybind11::return_value_policy; + +PYBIND11_MODULE(cSW2DCV, m) +{ + xt::import_numpy(); + + py::class_(m, "cSW2DCV_base") + .def(py::init(&proteus::newSW2DCV)) + .def("FCTStep" , &SW2DCV_base::FCTStep ) + .def("convexLimiting" , &SW2DCV_base::convexLimiting ) + .def("calculateEdgeBasedCFL" , &SW2DCV_base::calculateEdgeBasedCFL, return_value_policy::take_ownership) + .def("calculateResidual" , &SW2DCV_base::calculateResidual ) + .def("calculateMassMatrix" , &SW2DCV_base::calculateMassMatrix ) + .def("calculateLumpedMassMatrix", &SW2DCV_base::calculateLumpedMassMatrix); +} diff --git a/proteus/mprans/SW2DCV.h b/proteus/mprans/SW2DCV.h index a610b68ce1..d13864563d 100644 --- a/proteus/mprans/SW2DCV.h +++ b/proteus/mprans/SW2DCV.h @@ -6,6 +6,9 @@ #include #include #include +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; // cek todo // 2. Get stabilization right @@ -135,212 +138,212 @@ class SW2DCV_base { FCTStep(double dt, int NNZ, // number on non-zero entries on sparsity pattern int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *limited_hnp1, double *limited_hunp1, double *limited_hvnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, xt::pyarray& limited_hvnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, xt::pyarray& hReg, int LUMPED_MASS_MATRIX, // LOCAL LIMITING - double *dLow, double *hBT, double *huBT, double *hvBT) = 0; + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT) = 0; virtual void convexLimiting(double dt, int NNZ, // number on non-zero entries on sparsity pattern int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *limited_hnp1, double *limited_hunp1, - double *limited_hvnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, - double *hReg, int LUMPED_MASS_MATRIX, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, // LOCAL LIMITING - double *dLow, double *hBT, double *huBT, double *hvBT) = 0; + xt::pyarray& dLow, xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT) = 0; virtual double calculateEdgeBasedCFL( double g, int numDOFsPerEqn, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *b_dof, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double hEps, double *hReg, double *Cx, double *Cy, double *CTx, - double *CTy, double *dLow, double run_cfl, double *edge_based_cfl, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, int debug) = 0; virtual void calculateResidual( // last EDGE BASED version - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, // 0 or 1 - int *mesh_l2g, double *dV_ref, double *h_trial_ref, - double *h_grad_trial_ref, double *h_test_ref, double *h_grad_test_ref, - double *vel_trial_ref, double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_l2g, xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, + xt::pyarray& h_grad_trial_ref, xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, + xt::pyarray& vel_trial_ref, xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *h_dof_old, double *hu_dof_old, double *hv_dof_old, - double *b_dof, double *h_dof, double *hu_dof, double *hv_dof, - double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc, double *q_mom_hu_acc, double *q_mom_hv_acc, - double *q_mass_adv, double *q_mass_acc_beta_bdf, - double *q_mom_hu_acc_beta_bdf, double *q_mom_hv_acc_beta_bdf, - double *q_cfl, int *sdInfo_hu_hu_rowptr, int *sdInfo_hu_hu_colind, - int *sdInfo_hu_hv_rowptr, int *sdInfo_hu_hv_colind, - int *sdInfo_hv_hv_rowptr, int *sdInfo_hv_hv_colind, - int *sdInfo_hv_hu_rowptr, int *sdInfo_hv_hu_colind, int offset_h, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, xt::pyarray& hv_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc, xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, + xt::pyarray& q_mass_adv, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, int stride_h, int stride_hu, int stride_hv, - double *globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - double *q_velocity, double *ebqe_velocity, double *flux, - double *elementResidual_h, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h, // C matrices - double *Cx, double *Cy, double *CTx, double *CTy, + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, // PARAMETERS FOR EDGE BASED STABILIZATION - int numDOFsPerEqn, int NNZ, int *csrRowIndeces_DofLoops, - int *csrColumnOffsets_DofLoops, + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, // LUMPED MASS MATRIX - double *lumped_mass_matrix, double cfl_run, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, // SAVE SOLUTION (mql) - double *hnp1_at_quad_point, double *hunp1_at_quad_point, - double *hvnp1_at_quad_point, + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, // TO COMPUTE LOW ORDER - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, // FOR FCT - double *dH_minus_dL, double *muH_minus_muL, double cE, + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, // Quant of interests - double *quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, // NORMAL COMPONENTS - int COMPUTE_NORMALS, double *normalx, double *normaly, double *dLow, - double *hBT, double *huBT, double *hvBT, int lstage) = 0; + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, int lstage) = 0; virtual void calculateMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int *csrRowIndeces_h_h, - int *csrColumnOffsets_h_h, int *csrRowIndeces_h_hu, - int *csrColumnOffsets_h_hu, int *csrRowIndeces_h_hv, - int *csrColumnOffsets_h_hv, int *csrRowIndeces_hu_h, - int *csrColumnOffsets_hu_h, int *csrRowIndeces_hu_hu, - int *csrColumnOffsets_hu_hu, int *csrRowIndeces_hu_hv, - int *csrColumnOffsets_hu_hv, int *csrRowIndeces_hv_h, - int *csrColumnOffsets_hv_h, int *csrRowIndeces_hv_hu, - int *csrColumnOffsets_hv_hu, int *csrRowIndeces_hv_hv, - int *csrColumnOffsets_hv_hv, double *globalJacobian, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, xt::pyarray& csrRowIndeces_h_hu, + xt::pyarray& csrColumnOffsets_h_hu, xt::pyarray& csrRowIndeces_h_hv, + xt::pyarray& csrColumnOffsets_h_hv, xt::pyarray& csrRowIndeces_hu_h, + xt::pyarray& csrColumnOffsets_hu_h, xt::pyarray& csrRowIndeces_hu_hu, + xt::pyarray& csrColumnOffsets_hu_hu, xt::pyarray& csrRowIndeces_hu_hv, + xt::pyarray& csrColumnOffsets_hu_hv, xt::pyarray& csrRowIndeces_hv_h, + xt::pyarray& csrColumnOffsets_hv_h, xt::pyarray& csrRowIndeces_hv_hu, + xt::pyarray& csrColumnOffsets_hv_hu, xt::pyarray& csrRowIndeces_hv_hv, + xt::pyarray& csrColumnOffsets_hv_hv, xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) = 0; + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; virtual void calculateLumpedMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int *csrRowIndeces_h_h, - int *csrColumnOffsets_h_h, int *csrRowIndeces_h_hu, - int *csrColumnOffsets_h_hu, int *csrRowIndeces_h_hv, - int *csrColumnOffsets_h_hv, int *csrRowIndeces_hu_h, - int *csrColumnOffsets_hu_h, int *csrRowIndeces_hu_hu, - int *csrColumnOffsets_hu_hu, int *csrRowIndeces_hu_hv, - int *csrColumnOffsets_hu_hv, int *csrRowIndeces_hv_h, - int *csrColumnOffsets_hv_h, int *csrRowIndeces_hv_hu, - int *csrColumnOffsets_hv_hu, int *csrRowIndeces_hv_hv, - int *csrColumnOffsets_hv_hv, double *globalJacobian, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, xt::pyarray& csrRowIndeces_h_hu, + xt::pyarray& csrColumnOffsets_h_hu, xt::pyarray& csrRowIndeces_h_hv, + xt::pyarray& csrColumnOffsets_h_hv, xt::pyarray& csrRowIndeces_hu_h, + xt::pyarray& csrColumnOffsets_hu_h, xt::pyarray& csrRowIndeces_hu_hu, + xt::pyarray& csrColumnOffsets_hu_hu, xt::pyarray& csrRowIndeces_hu_hv, + xt::pyarray& csrColumnOffsets_hu_hv, xt::pyarray& csrRowIndeces_hv_h, + xt::pyarray& csrColumnOffsets_hv_h, xt::pyarray& csrRowIndeces_hv_hu, + xt::pyarray& csrColumnOffsets_hv_hu, xt::pyarray& csrRowIndeces_hv_hv, + xt::pyarray& csrColumnOffsets_hv_hv, xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) = 0; + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) = 0; }; template & lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, xt::pyarray& dLow, xt::pyarray& hBT, + xt::pyarray& huBT, xt::pyarray& hvBT) { Rneg.resize(numDOFs, 0.0); Rpos.resize(numDOFs, 0.0); hLow.resize(numDOFs, 0.0); @@ -864,20 +867,20 @@ class SW2DCV : public SW2DCV_base { convexLimiting(double dt, int NNZ, // number on non-zero entries on sparsity pattern int numDOFs, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector)) - double *h_old, // DOFs of solution at last stage - double *hu_old, double *hv_old, double *b_dof, - double *high_order_hnp1, // DOFs of high order solution at tnp1 - double *high_order_hunp1, double *high_order_hvnp1, - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, - double *limited_hnp1, double *limited_hunp1, - double *limited_hvnp1, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double *MassMatrix, // mass matrix - double *dH_minus_dL, double *muH_minus_muL, double hEps, - double *hReg, int LUMPED_MASS_MATRIX, double *dLow, - double *hBT, double *huBT, double *hvBT) { + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_old, // DOFs of solution at last stage + xt::pyarray& hu_old, xt::pyarray& hv_old, xt::pyarray& b_dof, + xt::pyarray& high_order_hnp1, // DOFs of high order solution at tnp1 + xt::pyarray& high_order_hunp1, xt::pyarray& high_order_hvnp1, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, + xt::pyarray& limited_hnp1, xt::pyarray& limited_hunp1, + xt::pyarray& limited_hvnp1, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + xt::pyarray& MassMatrix, // mass matrix + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double hEps, + xt::pyarray& hReg, int LUMPED_MASS_MATRIX, xt::pyarray& dLow, + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT) { Rneg.resize(numDOFs, 0.0); Rpos.resize(numDOFs, 0.0); hLow.resize(numDOFs, 0.0); @@ -1147,13 +1150,13 @@ class SW2DCV : public SW2DCV_base { double calculateEdgeBasedCFL( double g, int numDOFsPerEqn, // number of DOFs - double *lumped_mass_matrix, // lumped mass matrix (as vector)) - double *h_dof_old, // DOFs of solution at last stage - double *hu_dof_old, double *hv_dof_old, double *b_dof, - int *csrRowIndeces_DofLoops, // csr row indeces - int *csrColumnOffsets_DofLoops, // csr column offsets - double hEps, double *hReg, double *Cx, double *Cy, double *CTx, - double *CTy, double *dLow, double run_cfl, double *edge_based_cfl, + xt::pyarray& lumped_mass_matrix, // lumped mass matrix (as vector)) + xt::pyarray& h_dof_old, // DOFs of solution at last stage + xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, xt::pyarray& b_dof, + xt::pyarray& csrRowIndeces_DofLoops, // csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, // csr column offsets + double hEps, xt::pyarray& hReg, xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, + xt::pyarray& CTy, xt::pyarray& dLow, double run_cfl, xt::pyarray& edge_based_cfl, int debug) { std::valarray psi(numDOFsPerEqn); double max_edge_based_cfl = 0.; @@ -1305,67 +1308,67 @@ class SW2DCV : public SW2DCV_base { } void calculateResidual( // last EDGE BASED version - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *h_dof_old, double *hu_dof_old, double *hv_dof_old, - double *b_dof, double *h_dof, double *hu_dof, double *hv_dof, - double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc, double *q_mom_hu_acc, double *q_mom_hv_acc, - double *q_mass_adv, double *q_mass_acc_beta_bdf, - double *q_mom_hu_acc_beta_bdf, double *q_mom_hv_acc_beta_bdf, - double *q_cfl, int *sdInfo_hu_hu_rowptr, int *sdInfo_hu_hu_colind, - int *sdInfo_hu_hv_rowptr, int *sdInfo_hu_hv_colind, - int *sdInfo_hv_hv_rowptr, int *sdInfo_hv_hv_colind, - int *sdInfo_hv_hu_rowptr, int *sdInfo_hv_hu_colind, int offset_h, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& h_dof_old, xt::pyarray& hu_dof_old, xt::pyarray& hv_dof_old, + xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, xt::pyarray& hv_dof, + xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc, xt::pyarray& q_mom_hu_acc, xt::pyarray& q_mom_hv_acc, + xt::pyarray& q_mass_adv, xt::pyarray& q_mass_acc_beta_bdf, + xt::pyarray& q_mom_hu_acc_beta_bdf, xt::pyarray& q_mom_hv_acc_beta_bdf, + xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, xt::pyarray& sdInfo_hu_hu_colind, + xt::pyarray& sdInfo_hu_hv_rowptr, xt::pyarray& sdInfo_hu_hv_colind, + xt::pyarray& sdInfo_hv_hv_rowptr, xt::pyarray& sdInfo_hv_hv_colind, + xt::pyarray& sdInfo_hv_hu_rowptr, xt::pyarray& sdInfo_hv_hu_colind, int offset_h, int offset_hu, int offset_hv, int stride_h, int stride_hu, int stride_hv, - double *globalResidual, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - double *q_velocity, double *ebqe_velocity, double *flux, - double *elementResidual_h_save, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& q_velocity, xt::pyarray& ebqe_velocity, xt::pyarray& flux, + xt::pyarray& elementResidual_h_save, // C matrices - double *Cx, double *Cy, double *CTx, double *CTy, + xt::pyarray& Cx, xt::pyarray& Cy, xt::pyarray& CTx, xt::pyarray& CTy, // PARAMETERS FOR EDGE BASED STABILIZATION - int numDOFsPerEqn, int NNZ, int *csrRowIndeces_DofLoops, - int *csrColumnOffsets_DofLoops, + int numDOFsPerEqn, int NNZ, xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, // LUMPED MASS MATRIX - double *lumped_mass_matrix, double cfl_run, double hEps, double *hReg, + xt::pyarray& lumped_mass_matrix, double cfl_run, double hEps, xt::pyarray& hReg, // SAVE SOLUTION (mql) - double *hnp1_at_quad_point, double *hunp1_at_quad_point, - double *hvnp1_at_quad_point, + xt::pyarray& hnp1_at_quad_point, xt::pyarray& hunp1_at_quad_point, + xt::pyarray& hvnp1_at_quad_point, // TO COMPUTE LOW ORDER - double *extendedSourceTerm_hu, double *extendedSourceTerm_hv, + xt::pyarray& extendedSourceTerm_hu, xt::pyarray& extendedSourceTerm_hv, // FOR FCT - double *dH_minus_dL, double *muH_minus_muL, double cE, + xt::pyarray& dH_minus_dL, xt::pyarray& muH_minus_muL, double cE, int LUMPED_MASS_MATRIX, double dt, int LINEAR_FRICTION, double mannings, // Quant of interests - double *quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, + xt::pyarray& quantDOFs, int SECOND_CALL_CALCULATE_RESIDUAL, // NORMAL COMPONENTS - int COMPUTE_NORMALS, double *normalx, double *normaly, double *dLow, + int COMPUTE_NORMALS, xt::pyarray& normalx, xt::pyarray& normaly, xt::pyarray& dLow, // LOCAL LIMITING - double *hBT, double *huBT, double *hvBT, int lstage) { + xt::pyarray& hBT, xt::pyarray& huBT, xt::pyarray& hvBT, int lstage) { // FOR FRICTION// double n2 = std::pow(mannings, 2.); double gamma = 4. / 3; @@ -1405,27 +1408,27 @@ class SW2DCV : public SW2DCV_base { jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace], h_test_dV[nDOF_trial_element], dV, x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; // get the solution at current time - ck.valFromDOF(h_dof, &h_l2g[eN_nDOF_trial_element], - &h_trial_ref[k * nDOF_trial_element], h); - ck.valFromDOF(hu_dof, &vel_l2g[eN_nDOF_trial_element], - &vel_trial_ref[k * nDOF_trial_element], hu); - ck.valFromDOF(hv_dof, &vel_l2g[eN_nDOF_trial_element], - &vel_trial_ref[k * nDOF_trial_element], hv); + ck.valFromDOF(h_dof.data(), &h_l2g.data()[eN_nDOF_trial_element], + &h_trial_ref.data()[k * nDOF_trial_element], h); + ck.valFromDOF(hu_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref.data()[k * nDOF_trial_element], hu); + ck.valFromDOF(hv_dof.data(), &vel_l2g[eN_nDOF_trial_element], + &vel_trial_ref.data()[k * nDOF_trial_element], hv); // get the solution at the lstage - ck.valFromDOF(h_dof_old, &h_l2g[eN_nDOF_trial_element], - &h_trial_ref[k * nDOF_trial_element], h_old); - ck.valFromDOF(hu_dof_old, &vel_l2g[eN_nDOF_trial_element], - &vel_trial_ref[k * nDOF_trial_element], hu_old); - ck.valFromDOF(hv_dof_old, &vel_l2g[eN_nDOF_trial_element], - &vel_trial_ref[k * nDOF_trial_element], hv_old); + ck.valFromDOF(h_dof_old.data(), &h_l2g.data()[eN_nDOF_trial_element], + &h_trial_ref.data()[k * nDOF_trial_element], h_old); + ck.valFromDOF(hu_dof_old.data(), &vel_l2g.data()[eN_nDOF_trial_element], + &vel_trial_ref.data()[k * nDOF_trial_element], hu_old); + ck.valFromDOF(hv_dof_old.data(), &vel_l2g.data()[eN_nDOF_trial_element], + &vel_trial_ref.data()[k * nDOF_trial_element], hv_old); // calculate cell based CFL to keep a reference - calculateCFL(elementDiameter[eN], g, h_old, hu_old, hv_old, hEps, + calculateCFL(elementDiameter.data()[eN], g, h_old, hu_old, hv_old, hEps, q_cfl[eN_k]); // precalculate test function products with integration weights for (int j = 0; j < nDOF_trial_element; j++) @@ -1826,10 +1829,10 @@ class SW2DCV : public SW2DCV_base { /* compute information about mapping from reference element to * physical element */ ck.calculateMapping_elementBoundary( - eN, ebN_local, kb, ebN_local_kb, mesh_dof, mesh_l2g, - mesh_trial_trace_ref, mesh_grad_trial_trace_ref, boundaryJac_ref, + eN, ebN_local, kb, ebN_local_kb, mesh_dof.data(), mesh_l2g.data(), + mesh_trial_trace_ref.data(), mesh_grad_trial_trace_ref.data(), boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext, boundaryJac, metricTensor, - metricTensorDetSqrt, normal_ref, normal, x_ext, y_ext); + metricTensorDetSqrt, normal_ref.data(), normal, x_ext, y_ext); } // distribute the normal vectors for (int i = 0; i < nDOF_test_element; i++) { @@ -1853,55 +1856,55 @@ class SW2DCV : public SW2DCV_base { } void calculateMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int *csrRowIndeces_h_h, - int *csrColumnOffsets_h_h, int *csrRowIndeces_h_hu, - int *csrColumnOffsets_h_hu, int *csrRowIndeces_h_hv, - int *csrColumnOffsets_h_hv, int *csrRowIndeces_hu_h, - int *csrColumnOffsets_hu_h, int *csrRowIndeces_hu_hu, - int *csrColumnOffsets_hu_hu, int *csrRowIndeces_hu_hv, - int *csrColumnOffsets_hu_hv, int *csrRowIndeces_hv_h, - int *csrColumnOffsets_hv_h, int *csrRowIndeces_hv_hu, - int *csrColumnOffsets_hv_hu, int *csrRowIndeces_hv_hv, - int *csrColumnOffsets_hv_hv, double *globalJacobian, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, xt::pyarray& csrRowIndeces_h_hu, + xt::pyarray& csrColumnOffsets_h_hu, xt::pyarray& csrRowIndeces_h_hv, + xt::pyarray& csrColumnOffsets_h_hv, xt::pyarray& csrRowIndeces_hu_h, + xt::pyarray& csrColumnOffsets_hu_h, xt::pyarray& csrRowIndeces_hu_hu, + xt::pyarray& csrColumnOffsets_hu_hu, xt::pyarray& csrRowIndeces_hu_hv, + xt::pyarray& csrColumnOffsets_hu_hv, xt::pyarray& csrRowIndeces_hv_h, + xt::pyarray& csrColumnOffsets_hv_h, xt::pyarray& csrRowIndeces_hv_hu, + xt::pyarray& csrColumnOffsets_hv_hu, xt::pyarray& csrRowIndeces_hv_hv, + xt::pyarray& csrColumnOffsets_hv_hv, xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) { + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { // // loop over elements to compute volume integrals and load them into the // element Jacobians and global Jacobian @@ -1930,8 +1933,8 @@ class SW2DCV : public SW2DCV_base { dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; @@ -1975,55 +1978,55 @@ class SW2DCV : public SW2DCV_base { } void calculateLumpedMassMatrix( // element - double *mesh_trial_ref, double *mesh_grad_trial_ref, double *mesh_dof, - double *mesh_velocity_dof, double MOVING_DOMAIN, int *mesh_l2g, - double *dV_ref, double *h_trial_ref, double *h_grad_trial_ref, - double *h_test_ref, double *h_grad_test_ref, double *vel_trial_ref, - double *vel_grad_trial_ref, double *vel_test_ref, - double *vel_grad_test_ref, + xt::pyarray& mesh_trial_ref, xt::pyarray& mesh_grad_trial_ref, xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, xt::pyarray& h_trial_ref, xt::pyarray& h_grad_trial_ref, + xt::pyarray& h_test_ref, xt::pyarray& h_grad_test_ref, xt::pyarray& vel_trial_ref, + xt::pyarray& vel_grad_trial_ref, xt::pyarray& vel_test_ref, + xt::pyarray& vel_grad_test_ref, // element boundary - double *mesh_trial_trace_ref, double *mesh_grad_trial_trace_ref, - double *dS_ref, double *h_trial_trace_ref, double *h_grad_trial_trace_ref, - double *h_test_trace_ref, double *h_grad_test_trace_ref, - double *vel_trial_trace_ref, double *vel_grad_trial_trace_ref, - double *vel_test_trace_ref, double *vel_grad_test_trace_ref, - double *normal_ref, double *boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, xt::pyarray& h_trial_trace_ref, xt::pyarray& h_grad_trial_trace_ref, + xt::pyarray& h_test_trace_ref, xt::pyarray& h_grad_test_trace_ref, + xt::pyarray& vel_trial_trace_ref, xt::pyarray& vel_grad_trial_trace_ref, + xt::pyarray& vel_test_trace_ref, xt::pyarray& vel_grad_test_trace_ref, + xt::pyarray& normal_ref, xt::pyarray& boundaryJac_ref, // physics - double *elementDiameter, int nElements_global, double useRBLES, - double useMetrics, double alphaBDF, double nu, double g, int *h_l2g, - int *vel_l2g, double *b_dof, double *h_dof, double *hu_dof, - double *hv_dof, double *h_dof_sge, double *hu_dof_sge, double *hv_dof_sge, - double *q_mass_acc_beta_bdf, double *q_mom_hu_acc_beta_bdf, - double *q_mom_hv_acc_beta_bdf, double *q_cfl, int *sdInfo_hu_hu_rowptr, - int *sdInfo_hu_hu_colind, int *sdInfo_hu_hv_rowptr, - int *sdInfo_hu_hv_colind, int *sdInfo_hv_hv_rowptr, - int *sdInfo_hv_hv_colind, int *sdInfo_hv_hu_rowptr, - int *sdInfo_hv_hu_colind, int *csrRowIndeces_h_h, - int *csrColumnOffsets_h_h, int *csrRowIndeces_h_hu, - int *csrColumnOffsets_h_hu, int *csrRowIndeces_h_hv, - int *csrColumnOffsets_h_hv, int *csrRowIndeces_hu_h, - int *csrColumnOffsets_hu_h, int *csrRowIndeces_hu_hu, - int *csrColumnOffsets_hu_hu, int *csrRowIndeces_hu_hv, - int *csrColumnOffsets_hu_hv, int *csrRowIndeces_hv_h, - int *csrColumnOffsets_hv_h, int *csrRowIndeces_hv_hu, - int *csrColumnOffsets_hv_hu, int *csrRowIndeces_hv_hv, - int *csrColumnOffsets_hv_hv, double *globalJacobian, + xt::pyarray& elementDiameter, int nElements_global, double useRBLES, + double useMetrics, double alphaBDF, double nu, double g, xt::pyarray& h_l2g, + xt::pyarray& vel_l2g, xt::pyarray& b_dof, xt::pyarray& h_dof, xt::pyarray& hu_dof, + xt::pyarray& hv_dof, xt::pyarray& h_dof_sge, xt::pyarray& hu_dof_sge, xt::pyarray& hv_dof_sge, + xt::pyarray& q_mass_acc_beta_bdf, xt::pyarray& q_mom_hu_acc_beta_bdf, + xt::pyarray& q_mom_hv_acc_beta_bdf, xt::pyarray& q_cfl, xt::pyarray& sdInfo_hu_hu_rowptr, + xt::pyarray& sdInfo_hu_hu_colind, xt::pyarray& sdInfo_hu_hv_rowptr, + xt::pyarray& sdInfo_hu_hv_colind, xt::pyarray& sdInfo_hv_hv_rowptr, + xt::pyarray& sdInfo_hv_hv_colind, xt::pyarray& sdInfo_hv_hu_rowptr, + xt::pyarray& sdInfo_hv_hu_colind, xt::pyarray& csrRowIndeces_h_h, + xt::pyarray& csrColumnOffsets_h_h, xt::pyarray& csrRowIndeces_h_hu, + xt::pyarray& csrColumnOffsets_h_hu, xt::pyarray& csrRowIndeces_h_hv, + xt::pyarray& csrColumnOffsets_h_hv, xt::pyarray& csrRowIndeces_hu_h, + xt::pyarray& csrColumnOffsets_hu_h, xt::pyarray& csrRowIndeces_hu_hu, + xt::pyarray& csrColumnOffsets_hu_hu, xt::pyarray& csrRowIndeces_hu_hv, + xt::pyarray& csrColumnOffsets_hu_hv, xt::pyarray& csrRowIndeces_hv_h, + xt::pyarray& csrColumnOffsets_hv_h, xt::pyarray& csrRowIndeces_hv_hu, + xt::pyarray& csrColumnOffsets_hv_hu, xt::pyarray& csrRowIndeces_hv_hv, + xt::pyarray& csrColumnOffsets_hv_hv, xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int *exteriorElementBoundariesArray, int *elementBoundaryElementsArray, - int *elementBoundaryLocalElementBoundariesArray, int *isDOFBoundary_h, - int *isDOFBoundary_hu, int *isDOFBoundary_hv, - int *isAdvectiveFluxBoundary_h, int *isAdvectiveFluxBoundary_hu, - int *isAdvectiveFluxBoundary_hv, int *isDiffusiveFluxBoundary_hu, - int *isDiffusiveFluxBoundary_hv, double *ebqe_bc_h_ext, - double *ebqe_bc_flux_mass_ext, double *ebqe_bc_flux_mom_hu_adv_ext, - double *ebqe_bc_flux_mom_hv_adv_ext, double *ebqe_bc_hu_ext, - double *ebqe_bc_flux_hu_diff_ext, double *ebqe_penalty_ext, - double *ebqe_bc_hv_ext, double *ebqe_bc_flux_hv_diff_ext, - int *csrColumnOffsets_eb_h_h, int *csrColumnOffsets_eb_h_hu, - int *csrColumnOffsets_eb_h_hv, int *csrColumnOffsets_eb_hu_h, - int *csrColumnOffsets_eb_hu_hu, int *csrColumnOffsets_eb_hu_hv, - int *csrColumnOffsets_eb_hv_h, int *csrColumnOffsets_eb_hv_hu, - int *csrColumnOffsets_eb_hv_hv, double dt) { + xt::pyarray& exteriorElementBoundariesArray, xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, xt::pyarray& isDOFBoundary_h, + xt::pyarray& isDOFBoundary_hu, xt::pyarray& isDOFBoundary_hv, + xt::pyarray& isAdvectiveFluxBoundary_h, xt::pyarray& isAdvectiveFluxBoundary_hu, + xt::pyarray& isAdvectiveFluxBoundary_hv, xt::pyarray& isDiffusiveFluxBoundary_hu, + xt::pyarray& isDiffusiveFluxBoundary_hv, xt::pyarray& ebqe_bc_h_ext, + xt::pyarray& ebqe_bc_flux_mass_ext, xt::pyarray& ebqe_bc_flux_mom_hu_adv_ext, + xt::pyarray& ebqe_bc_flux_mom_hv_adv_ext, xt::pyarray& ebqe_bc_hu_ext, + xt::pyarray& ebqe_bc_flux_hu_diff_ext, xt::pyarray& ebqe_penalty_ext, + xt::pyarray& ebqe_bc_hv_ext, xt::pyarray& ebqe_bc_flux_hv_diff_ext, + xt::pyarray& csrColumnOffsets_eb_h_h, xt::pyarray& csrColumnOffsets_eb_h_hu, + xt::pyarray& csrColumnOffsets_eb_h_hv, xt::pyarray& csrColumnOffsets_eb_hu_h, + xt::pyarray& csrColumnOffsets_eb_hu_hu, xt::pyarray& csrColumnOffsets_eb_hu_hv, + xt::pyarray& csrColumnOffsets_eb_hv_h, xt::pyarray& csrColumnOffsets_eb_hv_hu, + xt::pyarray& csrColumnOffsets_eb_hv_hv, double dt) { // // loop over elements to compute volume integrals and load them into the // element Jacobians and global Jacobian @@ -2052,8 +2055,8 @@ class SW2DCV : public SW2DCV_base { dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x, y, xt, yt; // get jacobian, etc for mapping reference element - ck.calculateMapping_element(eN, k, mesh_dof, mesh_l2g, mesh_trial_ref, - mesh_grad_trial_ref, jac, jacDet, jacInv, x, + ck.calculateMapping_element(eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y); // get the physical integration weight dV = fabs(jacDet) * dV_ref[k]; diff --git a/proteus/mprans/SW2DCV.py b/proteus/mprans/SW2DCV.py index 51c853b15d..9eb8c5b9b8 100644 --- a/proteus/mprans/SW2DCV.py +++ b/proteus/mprans/SW2DCV.py @@ -5,6 +5,10 @@ from past.utils import old_div import proteus from proteus.mprans.cSW2DCV import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class NumericalFlux(proteus.NumericalFlux.ShallowWater_2D): hasInterior = False @@ -1387,7 +1391,7 @@ def getJacobian(self, jacobian): self.csrRowIndeces[(2, 0)], self.csrColumnOffsets[(2, 0)], self.csrRowIndeces[(2, 1)], self.csrColumnOffsets[(2, 1)], self.csrRowIndeces[(2, 2)], self.csrColumnOffsets[(2, 2)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/mprans/SedClosure.cpp b/proteus/mprans/SedClosure.cpp new file mode 100644 index 0000000000..586e5d3a1e --- /dev/null +++ b/proteus/mprans/SedClosure.cpp @@ -0,0 +1,70 @@ +#define FORCE_IMPORT_ARRAY +#include "SedClosure.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; + +PYBIND11_MODULE(SedClosure, m) +{ + using proteus::cppHsuSedStress2D; + + xt::import_numpy(); + + py::class_(m, "HsuSedStress") + .def(py::init()) + .def_readonly("aDarcy", &cppHsuSedStress2D::aDarcy_) + .def_readonly("betaForch", &cppHsuSedStress2D::betaForch_) + .def_readonly("grain", &cppHsuSedStress2D::grain_) + .def_readonly("packFraction", &cppHsuSedStress2D::packFraction_) + .def_readonly("packMargin", &cppHsuSedStress2D::packMargin_) + .def_readonly("maxFraction", &cppHsuSedStress2D::maxFraction_) + .def_readonly("frFraction", &cppHsuSedStress2D::frFraction_) + .def_readonly("sigmaC", &cppHsuSedStress2D::sigmaC_) + .def_readonly("C3e", &cppHsuSedStress2D::C3e_) + .def_readonly("C4e", &cppHsuSedStress2D::C4e_) + .def_readonly("eR", &cppHsuSedStress2D::eR_) + .def_readonly("fContact", &cppHsuSedStress2D::fContact_) + .def_readonly("mContact", &cppHsuSedStress2D::mContact_) + .def_readonly("nContact", &cppHsuSedStress2D::nContact_) + .def_readonly("angFriction", &cppHsuSedStress2D::angFriction_) + .def_readonly("vos_limiter", &cppHsuSedStress2D::vos_limiter_) + .def_readonly("mu_fr_limiter", &cppHsuSedStress2D::mu_fr_limiter_) + .def("betaCoeff", &cppHsuSedStress2D::xt_betaCoeff) + .def("gs0", &cppHsuSedStress2D::gs0) + .def("kappa_sed1", &cppHsuSedStress2D::xt_kappa_sed1) + .def("dkappa_sed1_dk", &cppHsuSedStress2D::xt_dkappa_sed1_dk) + .def("deps_sed_deps", &cppHsuSedStress2D::xt_deps_sed_deps) + .def("psc", &cppHsuSedStress2D::psc) + .def("psc_term", &cppHsuSedStress2D::psc_term) + .def("dpsc_term_dtheta", &cppHsuSedStress2D::dpsc_term_dtheta) + .def("mu_sc", &cppHsuSedStress2D::mu_sc) + .def("mu_fr", &cppHsuSedStress2D::mu_fr) + .def("l_sc", &cppHsuSedStress2D::l_sc) + .def("tausc_term_theta", &cppHsuSedStress2D::tausc_term_theta) + .def("gamma_s", &cppHsuSedStress2D::gamma_s) + .def("dgamma_s_dtheta", &cppHsuSedStress2D::dgamma_s_dtheta) + .def("jint1", &cppHsuSedStress2D::xt_jint1) + .def("jint2", &cppHsuSedStress2D::xt_jint2) + .def("djint2_dtheta", &cppHsuSedStress2D::xt_djint2_dtheta) + .def("k_diff", &cppHsuSedStress2D::k_diff) + .def("p_friction", &cppHsuSedStress2D::p_friction) + .def("gradp_friction", &cppHsuSedStress2D::gradp_friction) + .def("mIntFluid", &cppHsuSedStress2D::xt_mIntFluid) + .def("mIntSolid", &cppHsuSedStress2D::xt_mIntSolid) + .def("mIntgradC", &cppHsuSedStress2D::xt_mIntgradC) + .def("dmInt_duFluid", &cppHsuSedStress2D::xt_dmInt_duFluid) + .def("dmInt_duSolid", &cppHsuSedStress2D::xt_dmInt_duSolid) + .def("p_s", &cppHsuSedStress2D::p_s); +} diff --git a/proteus/mprans/SedClosure.h b/proteus/mprans/SedClosure.h index c06e918d96..833cec88cd 100644 --- a/proteus/mprans/SedClosure.h +++ b/proteus/mprans/SedClosure.h @@ -3,6 +3,8 @@ #include #include +#include "xtensor-python/pyarray.hpp" + namespace proteus { template @@ -54,11 +56,23 @@ namespace proteus {} + inline double xt_betaCoeff( + double sedF, // Sediment fraction + double rhoFluid, + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + double nu //Kinematic viscosity + ) + { + return betaCoeff(sedF, rhoFluid, uFluid.data(), uSolid.data(), nu); + } + + inline double betaCoeff( double sedF, // Sediment fraction double rhoFluid, - double uFluid[nSpace], //Fluid velocity - double uSolid[nSpace], //Sediment velocity + const double uFluid[nSpace], //Fluid velocity + const double uSolid[nSpace], //Sediment velocity double nu //Kinematic viscosity ) { @@ -116,20 +130,49 @@ namespace proteus return g0; } + inline double xt_deps_sed_deps( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const xt::pyarray& g) + { + return deps_sed_deps(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + gradC.data(), + nu, + theta_n, + kappa_n, + epsilon_n, + nuT_n, + g.data()); + + } + inline double deps_sed_deps( double sedF, // Sediment fraction double rhoFluid, double rhoSolid, - double uFluid[nSpace], - double uSolid[nSpace], - double gradC[nSpace], //Sediment velocity + const double uFluid[nSpace], + const double uSolid[nSpace], + const double gradC[nSpace], //Sediment velocity double nu, //Kinematic viscosity double theta_n, double kappa_n, double epsilon_n, double nuT_n, - double g[nSpace]) - + const double g[nSpace]) + { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; @@ -156,22 +199,49 @@ namespace proteus } - inline double kappa_sed1( + inline double xt_kappa_sed1( double sedF, // Sediment fraction double rhoFluid, double rhoSolid, - double uFluid[nSpace], - double uSolid[nSpace], - double gradC[nSpace], + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, double nu, double theta_n, double kappa_n, double epsilon_n, double nuT_n, - double g[nSpace]) - - { + const xt::pyarray& g) + { + return kappa_sed1(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + gradC.data(), + nu, + theta_n, + kappa_n, + epsilon_n, + nuT_n, + g.data()); + } + + inline double kappa_sed1( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const double uFluid[nSpace], + const double uSolid[nSpace], + const double gradC[nSpace], + double nu, + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const double g[nSpace]) + { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; double gs = gs0(sedF)+small_; @@ -195,19 +265,46 @@ namespace proteus return es_1 + es_2; } - inline double dkappa_sed1_dk( + + inline double xt_dkappa_sed1_dk( double sedF, // Sediment fraction double rhoFluid, double rhoSolid, - double uFluid[nSpace], //Fluid velocity - double uSolid[nSpace], //Sediment velocity - double gradC[nSpace], //Sediment velocity + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + const xt::pyarray& gradC, //Sediment velocity double nu, //Kinematic viscosity double theta_n, double kappa_n, double epsilon_n, double nuT_n) - + { + return dkappa_sed1_dk(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + gradC.data(), + nu, + theta_n, + kappa_n, + epsilon_n, + nuT_n); + + } + + inline double dkappa_sed1_dk( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const double uFluid[nSpace], //Fluid velocity + const double uSolid[nSpace], //Sediment velocity + const double gradC[nSpace], //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n) { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; double gs = gs0(sedF)+small_; @@ -373,17 +470,36 @@ namespace proteus return gamma_s; } - inline double jint1( double sedF, + inline double xt_jint1( double sedF, double rhoFluid, double rhoSolid, - double uFluid[nSpace], - double uSolid[nSpace], + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, double kappa, double epsilon, double theta, double nu) - - + { + return jint1(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + kappa, + epsilon, + theta, + nu); + } + + inline double jint1( double sedF, + double rhoFluid, + double rhoSolid, + const double uFluid[nSpace], + const double uSolid[nSpace], + double kappa, + double epsilon, + double theta, + double nu) { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; @@ -398,16 +514,32 @@ namespace proteus double Jint1 = 4. * alpha * beta * kappa /( 3.* rhoSolid) ; return Jint1; - } - inline double jint2( double sedF, + } + inline double xt_jint2( double sedF, double rhoFluid, double rhoSolid, - double uFluid[nSpace], - double uSolid[nSpace], + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, double theta, double nu) - + { + return jint2(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + theta, + nu); + } + + inline double jint2( double sedF, + double rhoFluid, + double rhoSolid, + const double uFluid[nSpace], + const double uSolid[nSpace], + double theta, + double nu) { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; @@ -415,14 +547,27 @@ namespace proteus } - inline double djint2_dtheta( double sedF, + inline double xt_djint2_dtheta( double sedF, double rhoFluid, double rhoSolid, - double uFluid[nSpace], - double uSolid[nSpace], + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, double nu) + { + return djint2_dtheta(sedF, + rhoFluid, + rhoSolid, + uFluid.data(), + uSolid.data(), + nu); + } - + inline double djint2_dtheta( double sedF, + double rhoFluid, + double rhoSolid, + const double uFluid[nSpace], + const double uSolid[nSpace], + double nu) { double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; @@ -563,14 +708,37 @@ namespace proteus + inline xt::pyarray xt_mIntFluid(double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uFluid_np1, //Fluid velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + auto mint2 = xt::pyarray::from_shape({2}); + mIntFluid(mint2.data(), + sedF, + rhoFluid, + uFluid_n.data(), + uSolid_n.data(), + uFluid_np1.data(), + nu, + nuT, + gradc.data()); + return mint2; + } + inline void mIntFluid( double * mint2, double sedF, double rhoFluid, - double uFluid_n[nSpace], //Fluid velocity - double uSolid_n[nSpace], //Sediment velocity - double uFluid_np1[nSpace], //Fluid velocity + const double uFluid_n[nSpace], //Fluid velocity + const double uSolid_n[nSpace], //Sediment velocity + const double uFluid_np1[nSpace], //Fluid velocity double nu, //Kinematic viscosity double nuT, //Turbulent viscosity - double gradc[nSpace] + const double gradc[nSpace] ) { @@ -582,14 +750,37 @@ namespace proteus } + inline xt::pyarray xt_mIntSolid(double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uSolid_np1, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + auto mint2 = xt::pyarray::from_shape({2}); + mIntSolid(mint2.data(), + sedF, + rhoFluid, + uFluid_n.data(), + uSolid_n.data(), + uSolid_np1.data(), + nu, + nuT, + gradc.data()); + return mint2; + } + inline void mIntSolid( double * mint2, double sedF, double rhoFluid, - double uFluid_n[nSpace], //Fluid velocity - double uSolid_n[nSpace], //Sediment velocity - double uSolid_np1[nSpace], //Sediment velocity + const double uFluid_n[nSpace], //Fluid velocity + const double uSolid_n[nSpace], //Sediment velocity + const double uSolid_np1[nSpace], //Sediment velocity double nu, //Kinematic viscosity double nuT, //Turbulent viscosity - double gradc[nSpace] + const double gradc[nSpace] ) { @@ -600,14 +791,37 @@ namespace proteus } } + inline xt::pyarray xt_mIntgradC(double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + + auto mint2 = xt::pyarray::from_shape({2}); + mIntgradC(mint2.data(), + sedF, + rhoFluid, + uFluid_n.data(), + uSolid_n.data(), + nu, + nuT, + gradc.data()); + return mint2; + } + inline void mIntgradC(double * mint2, double sedF, double rhoFluid, - double uFluid_n[nSpace], //Fluid velocity - double uSolid_n[nSpace], //Sediment velocity + const double uFluid_n[nSpace], //Fluid velocity + const double uSolid_n[nSpace], //Sediment velocity double nu, //Kinematic viscosity double nuT, //Turbulent viscosity - double gradc[nSpace] + const double gradc[nSpace] ) + { double beta = betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu); @@ -621,11 +835,27 @@ namespace proteus + inline double xt_dmInt_duFluid + ( double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + + ) + { + return dmInt_duFluid(sedF, + rhoFluid, + uFluid_n.data(), + uSolid_n.data(), + nu); + } + inline double dmInt_duFluid ( double sedF, double rhoFluid, - double uFluid_n[nSpace], //Fluid velocity - double uSolid_n[nSpace], //Sediment velocity + const double uFluid_n[nSpace], //Fluid velocity + const double uSolid_n[nSpace], //Sediment velocity double nu //Kinematic viscosity ) @@ -635,11 +865,27 @@ namespace proteus } + inline double xt_dmInt_duSolid + ( double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + + ) + { + return dmInt_duSolid(sedF, + rhoFluid, + uFluid_n.data(), + uSolid_n.data(), + nu); + } + inline double dmInt_duSolid ( double sedF, double rhoFluid, - double uFluid_n[nSpace], //Fluid velocity - double uSolid_n[nSpace], //Sediment velocity + const double uFluid_n[nSpace], //Fluid velocity + const double uSolid_n[nSpace], //Sediment velocity double nu //Kinematic viscosity ) diff --git a/proteus/mprans/SedClosure.pyx b/proteus/mprans/SedClosure.pyx deleted file mode 100644 index 50a27ae147..0000000000 --- a/proteus/mprans/SedClosure.pyx +++ /dev/null @@ -1,639 +0,0 @@ -import numpy -import cython -cimport numpy -from cpython cimport array -#pull in C++ definitions and declare interface -cdef extern from "mprans/SedClosure.h" namespace "proteus": - - cdef cppclass cppHsuSedStress2D: - double aDarcy_; - double betaForch_; - double grain_; - double packFraction_; - double packMargin_; - double frFraction_; - double maxFraction_; - double sigmaC_; - double C3e_; - double C4e_; - double eR_; - double fContact_; - double mContact_; - double nContact_; - double angFriction_; - double small_; - double notSoLarge_; - double large_; - double vos_limiter_; - double mu_fr_limiter_; - - cppHsuSedStress2D( - double aDarcy, # darcy parameter for drag term. Default value from Ergun (1952) is 150 - double betaForch, # forchheimer parameter for drag term. Default value from Ergun (1952) is 1.75 - double grain, # Grain size, default assumed as d50 - double packFraction, #Critical volume fraction for switching the drag relation 0.2 by default, see Chen and Hsu 2014 - double packMargin, # - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter, - ) - double betaCoeff( - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid, #Fluid velocity - double* uSolid, #Sediment velocity - double nu #Kinematic viscosity - ) - double gs0( - double sedF # Sediment fraction - ) - double kappa_sed1(double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double* gradC, - double nu, - double theta_n, - double kappa_n, - double epsilon_n, - double nuT_n, - double * g) - double dkappa_sed1_dk(double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double* gradC, - double nu, - double theta_n, - double kappa_n, - double epsilon_n, - double nuT_n) - double deps_sed_deps(double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double* gradC, - double nu, - double theta_n, - double kappa_n, - double epsilon_n, - double nuT_n, - double* g) - - double psc( - double sedF, - double rhoSolid, - double theta_n) - double psc_term( - double sedF, - double rhoSolid, - double theta_np1, - double du_dx, - double dv_dy, - double dw_dz) - - double dpsc_term_dtheta( double sedF, - double rhoSolid, - double du_dx, - double dv_dy, - double dw_dz) - - double mu_sc( double sedF, - double rhoSolid, - double theta ) - double l_sc( double sedF, - double rhoSolid, - double theta ) - - double tausc_term_theta( - double sedF, - double rhoSolid, - double theta_n, - double du_dx, - double du_dy, - double du_dz, - double dv_dx, - double dv_dy, - double dv_dz, - double dw_dx, - double dw_dy, - double dw_dz) - - double gamma_s( double sedF, - double rhoSolid, - double theta_n, - double theta_np1, - double du_dx, - double dv_dy, - double dw_dz) - - double dgamma_s_dtheta( double sedF, - double rhoSolid, - double theta_np1, - double du_dx, - double dv_dy, - double dw_dz) - double jint1( double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double kappa, - double epsilon, - double theta_n, - double nu) - - double jint2( double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double theta, - double nu) - - double djint2_dtheta( double sedF, - double rhoFluid, - double rhoSolid, - double* uFluid, - double* uSolid, - double nu) - - - double k_diff(double sedF, double rhoSolid, double theta ) - - - double p_friction(double sedF) - - double gradp_friction(double sedF) - - double mu_fr(double sedF, - double du_dx, - double du_dy, - double du_dz, - double dv_dx, - double dv_dy, - double dv_dz, - double dw_dx, - double dw_dy, - double dw_dz) - - void mIntFluid(double * mint2, - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid_n, #Fluid velocity - double* uSolid_n, #Sediment velocity - double* uFluid_np1, #Fluid - double nu, #Kinematic viscosity - double nuT, - double* gradc - ) - void mIntSolid(double * mint2, - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid_n, #Fluid velocity - double* uSolid_n, #Sediment velocity - double* uFluid_np1, #Fluid - double nu, #Kinematic viscosity - double nuT, - double* gradc - ) - - void mIntgradC(double * mint2, - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid_n, #Fluid velocity - double* uSolid_n, #Sediment velocity - double nu, #Kinematic viscosity - double nuT, - double* gradc - ) - - double dmInt_duFluid( - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid_n, #Fluid velocity - double* uSolid_n, #Sediment velocity - double nu #Kinematic viscosity - ) - double dmInt_duSolid( - double sedF, # Sediment fraction - double rhoFluid, - double* uFluid_n, #Fluid velocity - double* uSolid_n, #Sediment velocity - double nu #Kinematic viscosity - ) - double p_s( double sedF, - double rhoSolid, - double theta, - double du_dx, - double du_dy, - double du_dz, - double dv_dx, - double dv_dy, - double dv_dz, - double dw_dx, - double dw_dy, - double dw_dz) - -#define the way we want to present to Python -cdef class HsuSedStress: - cdef cppHsuSedStress2D* thisptr - def __cinit__(self, aDarcy, betaForch, grain, packFraction,packMargin, maxFraction, frFraction,sigmaC, C3e, C4e, eR,fContact, mContact, nContact, angFriction, vos_limiter, mu_fr_limiter): - """ Class for caclulating sediment / fluid momentum transfer, see Chen and Hsu, CACR 14-08, A Multidimensional TwoPhase Eulerian Model for Sediment Transport TwoPhaseEulerSedFoam (Version 1.0) - http://www.coastal.udel.edu/~thsu/simulation_data_files/CACR-14-08.pdf - param: aDarcy: Darcy parameter for drag term [-]. Default value from Ergun (1952) is 150 - param: betaForch: Forchheimer parameter for drag term [-]. Default value from Ergun (1952) is 1.75 - param: grain: Grain size, default assumed as d50 [L] - param: packFraction : Critical sediment fraction [-] for switching the drag relation 0.2 by default, see Chen and Hsu 2014, equation (7) - param: packMargin : [-] For packFraction \pm packMargin where the two braches in equation (7) are blended with linear weighting. Currently no information on the default value of this """ - self.thisptr = new cppHsuSedStress2D( aDarcy, betaForch, grain, packFraction, packMargin, maxFraction, frFraction,sigmaC, C3e, C4e, eR, fContact, mContact, nContact, angFriction, vos_limiter, mu_fr_limiter) - @property - def aDarcy(self): - return self.thisptr.aDarcy_ - @property - def betaForch(self): - return self.thisptr.betaForch_ - @property - def grain(self): - return self.thisptr.grain_ - @property - def packFraction(self): - return self.thisptr.packFraction_ - @property - def packMargin(self): - return self.thisptr.packMargin_ - @property - def maxFraction(self): - return self.thisptr.maxFraction_ - @property - def frFraction(self): - return self.thisptr.frFraction_ - @property - def sigmaC(self): - return self.thisptr.sigmaC_ - @property - def C3e(self): - return self.thisptr.C3e_ - @property - def C4e(self): - return self.thisptr.C4e_ - @property - def eR(self): - return self.thisptr.eR_ - @property - def fContact(self): - return self.thisptr.fContact_ - @property - def mContact(self): - return self.thisptr.mContact_ - @property - def nContact(self): - return self.thisptr.nContact_ - @property - def angFriction(self): - return self.thisptr.angFriction_ - @property - def vos_limiter(self): - return self.thisptr.vos_limiter_ - @property - def mu_fr_limiter(self): - return self.thisptr.mu_fr_limiter_ - def __dealloc__(self): - del self.thisptr - def betaCoeff(self, - sedF, - rhoFluid, - uFluid, - uSolid, - nu): - """ Function for calculating equation (7) from Chen and Hsu, CACR 14-08, A Multidimensional TwoPhase Eulerian Model for Sediment Transport TwoPhaseEulerSedFoam (Version 1.0) - http://www.coastal.udel.edu/~thsu/simulation_data_files/CACR-14-08.pdf - param: sedF: Sediment fraction [-] - param: uFluid: Fluid velocity vector [L/T] - param: uSolid: Solid velocity vector [L/T] - param: nu : Fluid kinematic viscosity [L^2/T] - """ - - cython.declare(UF=double[2]) - cython.declare(US=double[2]) - for ii in range(2): - UF[ii] = uFluid[ii] - US[ii] = uSolid[ii] - beta = self.thisptr.betaCoeff(sedF,rhoFluid,UF,US,nu) - return beta - - def gs0(self,sedF): - """ Radial distribution function for collision closure, equation (2.31) from Hsu et al 2004 'On two-phase sediment transport: - sheet flow of massive particles', Proc. Royal Soc. Lond A 460, pp 2223-2250 - http://www.coastal.udel.edu/~thsu/simulation_data_files/CACR-14-08.pdf - param: sedF: Sediment fraction [-] - """ - return self.thisptr.gs0(sedF) - def kappa_sed1(self, - sedF, - rhoFluid, - rhoSolid, - numpy.ndarray uFluid, - numpy.ndarray uSolid, - numpy.ndarray gradC, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n, - numpy.ndarray g): - return self.thisptr.kappa_sed1(sedF, - rhoFluid, - rhoSolid, - < double *> uFluid.data, - < double *> uSolid.data, - < double *> gradC.data, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n, - < double *> g.data) - - def dkappa_sed1_dk(self, - sedF, - rhoFluid, - rhoSolid, - numpy.ndarray uFluid, - numpy.ndarray uSolid, - numpy.ndarray gradC, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n): - return self.thisptr.dkappa_sed1_dk(sedF, - rhoFluid, - rhoSolid, - < double *> uFluid.data, - < double *> uSolid.data, - < double *> gradC.data, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n) - - - def deps_sed_deps(self, - sedF, - rhoFluid, - rhoSolid, - numpy.ndarray uFluid, - numpy.ndarray uSolid, - numpy.ndarray gradC, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n, - numpy.ndarray g): - return self.thisptr.deps_sed_deps(sedF, - rhoFluid, - rhoSolid, - < double *> uFluid.data, - < double *> uSolid.data, - < double *> gradC.data, - nu, - theta_n, - kappa_n, - epsilon_n, - nuT_n, - < double *> g.data) - - def psc(self, - sedF, - rhoSolid, - theta): - return self.thisptr.psc(sedF, rhoSolid, theta) - - def psc_term(self, - sedF, - rhoSolid, - theta_np1, - du_dx, - dv_dy, - dw_dz): - - return self.thisptr.psc_term( - sedF, - rhoSolid, - theta_np1, - du_dx, - dv_dy, - dw_dz) - - def dpsc_term_dtheta(self, - sedF, - rhoSolid, - du_dx, - dv_dy, - dw_dz): - - - return self.thisptr.dpsc_term_dtheta( - sedF, - rhoSolid, - du_dx, - dv_dy, - dw_dz) - - def mu_sc(self, - sedF, - rhoSolid, - theta ): - return self.thisptr.mu_sc(sedF, rhoSolid, theta) - def mu_fr(self, sedF, du_dx, du_dy, du_dz, dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz): - return self.thisptr.mu_fr(sedF, du_dx, du_dy, du_dz, dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz) - - def l_sc(self, - sedF, - rhoSolid, - theta ): - return self.thisptr.l_sc(sedF, rhoSolid, theta) - - def tausc_term_theta(self, - sedF, - rhoSolid, - theta_n, - du_dx, - du_dy, - du_dz, - dv_dx, - dv_dy, - dv_dz, - dw_dx, - dw_dy, - dw_dz): - return self.thisptr.tausc_term_theta(sedF,rhoSolid,theta_n,du_dx,du_dy,du_dz,dv_dx,dv_dy,dv_dz,dw_dx,dw_dy,dw_dz) - def gamma_s( self, sedF, - rhoSolid, - theta_n, - theta_np1, - du_dx, - dv_dy, - dw_dz): - return self.thisptr.gamma_s( sedF, rhoSolid, theta_n, theta_np1, du_dx, dv_dy, dw_dz) - - def dgamma_s_dtheta( self, sedF, - rhoSolid, - theta_n, - du_dx, - dv_dy, - dw_dz): - return self.thisptr.dgamma_s_dtheta( sedF, rhoSolid, theta_n, du_dx, dv_dy, dw_dz) - - - def jint1(self, sedF, rhoFluid ,rhoSolid, numpy.ndarray uFluid, numpy.ndarray uSolid, kappa, epsilon, theta_n, nu): - return self.thisptr.jint1(sedF, rhoFluid ,rhoSolid, < double * > uFluid.data, < double * > uSolid.data, kappa, epsilon, theta_n, nu) - - def jint2( self, sedF, rhoFluid ,rhoSolid, numpy.ndarray uFluid ,numpy.ndarray uSolid, theta,nu): - return self.thisptr.jint2(sedF, rhoFluid ,rhoSolid,< double * > uFluid.data, < double * > uSolid.data, theta, nu) - def djint2_dtheta( self, sedF, rhoFluid ,rhoSolid, numpy.ndarray uFluid ,numpy.ndarray uSolid, nu): - return self.thisptr.djint2_dtheta(sedF, rhoFluid ,rhoSolid,< double * > uFluid.data, < double * > uSolid.data, nu) - - - def k_diff(self, sedF, rhoSolid, theta ): - return self.thisptr.k_diff( sedF, rhoSolid, theta) - - def p_friction(self, sedF): - return self.thisptr.p_friction(sedF) - - def gradp_friction(self, sedF): - return self.thisptr.gradp_friction(sedF) - - - def mIntFluid(self, - sedF, - rhoFluid , - numpy.ndarray uFluid_n, - numpy.ndarray uSolid_n, - numpy.ndarray uFluid_np1, - nu, - nuT, - numpy.ndarray gradc - ): - - - - cython.declare(xx=cython.double[2]) - for ii in range(2): - xx[ii] = 0. - - self.thisptr.mIntFluid(xx, sedF,rhoFluid , - - < double * > uFluid_n.data, - < double * > uSolid_n.data, - < double * > uFluid_np1.data, - nu, - nuT, - < double * > gradc.data) - mint = numpy.zeros(2,) - for ii in range(2): - mint[ii] = xx[ii] - return mint - - def mIntSolid(self, - sedF, - rhoFluid , - numpy.ndarray uFluid_n, - numpy.ndarray uSolid_n, - numpy.ndarray uSolid_np1, - nu, - nuT, - numpy.ndarray gradc - ): - - - cython.declare(xx=cython.double[2]) - for ii in range(2): - xx[ii] = 0. - - self.thisptr.mIntSolid(xx, sedF,rhoFluid , - < double * > uFluid_n.data, - < double * > uSolid_n.data, - < double * > uSolid_np1.data, - nu, - nuT, - < double * > gradc.data) - mint = numpy.zeros(2,) - for ii in range(2): - mint[ii] = xx[ii] - return mint - - def mIntgradC(self, - sedF, - rhoFluid , - numpy.ndarray uFluid_n, - numpy.ndarray uSolid_n, - nu, - nuT, - numpy.ndarray gradc - ): - - - cython.declare(xx=cython.double[2]) - for ii in range(2): - xx[ii] = 0. - - - self.thisptr.mIntgradC(xx,sedF, rhoFluid , - < double * > uFluid_n.data, - < double * > uSolid_n.data, - nu, - nuT, - < double * > gradc.data) - mint = numpy.zeros(2,) - for ii in range(2): - mint[ii] = xx[ii] - return mint - - - - - def dmInt_duFluid(self, - sedF, # Sediment fraction - rhoFluid , - numpy.ndarray uFluid_n, #Fluid velocity - numpy.ndarray uSolid_n, #Sediment velocity - nu): #Kinematic viscosity - - return self.thisptr.dmInt_duFluid(sedF, rhoFluid , - < double * > uFluid_n.data, - < double * > uSolid_n.data, - nu) - - - - def dmInt_duSolid(self, - sedF, # Sediment fraction - rhoFluid , - numpy.ndarray uFluid_n, #Fluid velocity - numpy.ndarray uSolid_n, #Sediment velocity - nu): #Kinematic viscosity - - - return self.thisptr.dmInt_duSolid(sedF, rhoFluid , - < double * > uFluid_n.data, - < double * > uSolid_n.data, - nu) - def p_s( self, sedF, rhoSolid, theta, du_dx, du_dy, du_dz, dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz): - return self.thisptr.p_s( sedF, rhoSolid, theta, du_dx, du_dy, du_dz, dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz) - diff --git a/proteus/mprans/VOF.cpp b/proteus/mprans/VOF.cpp new file mode 100644 index 0000000000..7b38487904 --- /dev/null +++ b/proteus/mprans/VOF.cpp @@ -0,0 +1,31 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "VOF.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::VOF_base; + +PYBIND11_MODULE(cVOF, m) +{ + xt::import_numpy(); + + py::class_(m, "cVOF_base") + .def(py::init(&proteus::newVOF)) + .def("calculateResidualElementBased" , &VOF_base::calculateResidualElementBased ) + .def("calculateJacobian" , &VOF_base::calculateJacobian ) + .def("FCTStep" , &VOF_base::FCTStep ) + .def("calculateResidualEdgeBased" , &VOF_base::calculateResidualEdgeBased ); +} diff --git a/proteus/mprans/VOF.h b/proteus/mprans/VOF.h index e553289391..7d41669afb 100644 --- a/proteus/mprans/VOF.h +++ b/proteus/mprans/VOF.h @@ -5,6 +5,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; #define POWER_SMOOTHNESS_INDICATOR 2 #define IS_BETAij_ONE 0 @@ -50,27 +53,27 @@ namespace proteus virtual ~VOF_base(){} virtual void calculateResidualElementBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -80,45 +83,45 @@ namespace proteus double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // TAYLOR GALERKIN int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR ENTROPY VISCOSITY double cE, double cMax, @@ -129,46 +132,46 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -176,73 +179,73 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int STABILIZATION_TYPE)=0; virtual void FCTStep(double dt, int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* lumped_mass_matrix, //lumped mass matrix (as vector) - double* soln, //DOFs of solution at time tn - double* solH, //DOFs of high order solution at tnp1 - double* uLow, - double* dLow, - double* limited_solution, - int* csrRowIndeces_DofLoops, //csr row indeces - int* csrColumnOffsets_DofLoops, //csr column offsets - double* MassMatrix, //mass matrix - double* dt_times_dH_minus_dL, //low minus high order dissipative matrices - double* min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 - double* max_u_bc, + xt::pyarray& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE )=0; virtual void calculateResidualEdgeBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -252,45 +255,45 @@ namespace proteus double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -301,24 +304,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -541,45 +544,45 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -590,24 +593,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { double meanEntropy = 0., meanOmega = 0., maxEntropy = -1E10, minEntropy = 1E10; maxVel.resize(nElements_global, 0.0); @@ -675,73 +678,73 @@ namespace proteus // int eN_j=eN*nDOF_trial_element+j; // int eN_k_j=eN_k*nDOF_trial_element+j; // int eN_k_j_nSpace = eN_k_j*nSpace; - // u += valFromDOF_c(u_dof[u_l2g[eN_j]],u_trial[eN_k_j]); + // u += valFromDOF_c(u_dof.data()[u_l2g.data()[eN_j]],u_trial[eN_k_j]); // for (int I=0;I=0.0) - ebqe_u[ebNE_kb] = u_ext; + ebqe_u.data()[ebNE_kb] = u_ext; else - ebqe_u[ebNE_kb] = bc_u_ext; + ebqe_u.data()[ebNE_kb] = bc_u_ext; if (STABILIZATION_TYPE==1) if (stage==1) @@ -1132,7 +1135,7 @@ namespace proteus for (int i=0;i& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1183,34 +1186,34 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int STABILIZATION_TYPE) { - //std::cout<<"ndjaco address "<& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE ) @@ -1646,12 +1649,12 @@ namespace proteus for (int i=0; i0) ? fmin(Rposi,Rneg[j]) : fmin(Rnegi,Rpos[j])); ith_Limiter_times_FluxCorrectionMatrix += Lij * FluxCorrectionMatrix[ij]; //update ij ij+=1; } - limited_solution[i] = uLow[i] + 1./lumped_mass_matrix[i]*ith_Limiter_times_FluxCorrectionMatrix; + limited_solution.data()[i] = uLow.data()[i] + 1./lumped_mass_matrix.data()[i]*ith_Limiter_times_FluxCorrectionMatrix; } } void calculateResidualEdgeBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1763,45 +1766,45 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -1812,24 +1815,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { // NOTE: This function follows a different (but equivalent) implementation of the smoothness based indicator than NCLS.h // Allocate space for the transport matrices @@ -1847,7 +1850,7 @@ namespace proteus // NODAL ENTROPY // if (STABILIZATION_TYPE==2) //EV stab { - double porosity_times_solni = porosity_dof[i]*u_dof_old[i]; + double porosity_times_solni = porosity_dof.data()[i]*u_dof_old.data()[i]; eta[i] = ENTROPY_TYPE == 0 ? ENTROPY(porosity_times_solni,uL,uR) : ENTROPY_LOG(porosity_times_solni,uL,uR); global_entropy_residual[i]=0.; } @@ -1903,43 +1906,43 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); - dV = fabs(jacDet)*dV_ref[k]; + dV = fabs(jacDet)*dV_ref.data()[k]; //get the solution (of Newton's solver). To compute time derivative term - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u); //get the solution at quad point at tn and tnm1 for entropy viscosity - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); + ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],un); //get the solution gradients at tn for entropy viscosity - ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_un); + ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); + ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_un); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j Dissipation matrices as well. - double solni = u_dof_old[i]; // solution at time tn for the ith DOF - double porosityi = porosity_dof[i]; + double solni = u_dof_old.data()[i]; // solution at time tn for the ith DOF + double porosityi = porosity_dof.data()[i]; double ith_dissipative_term = 0; double ith_low_order_dissipative_term = 0; double ith_flux_term = 0; double dLii = 0.; // loop over the sparsity pattern of the i-th DOF - for (int offset=csrRowIndeces_DofLoops[i]; offset ai; + std::allocator ad; + } + } +#endif +} + +PYBIND11_MODULE(cVOF3P, m) +{ + using proteus::cppVOF3P_base; + using proteus::newVOF3P; + + xt::import_numpy(); + + py::class_(m, "cppVOF3P_base") + .def("calculateResidualElementBased", &cppVOF3P_base::calculateResidualElementBased) + .def("calculateJacobian", &cppVOF3P_base::calculateJacobian) + .def("FCTStep", &cppVOF3P_base::FCTStep) + .def("calculateResidualEdgeBased", &cppVOF3P_base::calculateResidualEdgeBased); + + m.def("newVOF3P", newVOF3P); +} + diff --git a/proteus/mprans/VOF3P.h b/proteus/mprans/VOF3P.h index 35549b72c4..1115d383ec 100644 --- a/proteus/mprans/VOF3P.h +++ b/proteus/mprans/VOF3P.h @@ -6,6 +6,8 @@ #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + #define POWER_SMOOTHNESS_INDICATOR 2 #define IS_BETAij_ONE 0 #define GLOBAL_FCT 0 @@ -49,27 +51,27 @@ namespace proteus virtual ~cppVOF3P_base(){} virtual void calculateResidualElementBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -79,45 +81,45 @@ namespace proteus double sc_uref, double sc_alpha, //VRANS - const double* q_vos, - const double* vos_dof, + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // TAYLOR GALERKIN int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR ENTROPY VISCOSITY double cE, double cMax, @@ -128,46 +130,46 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -175,73 +177,73 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int STABILIZATION_TYPE)=0; virtual void FCTStep(double dt, int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* lumped_mass_matrix, //lumped mass matrix (as vector) - double* soln, //DOFs of solution at time tn - double* solH, //DOFs of high order solution at tnp1 - double* uLow, - double* dLow, - double* limited_solution, - int* csrRowIndeces_DofLoops, //csr row indeces - int* csrColumnOffsets_DofLoops, //csr column offsets - double* MassMatrix, //mass matrix - double* dt_times_dH_minus_dL, //low minus high order dissipative matrices - double* min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 - double* max_u_bc, + xt::pyarray& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE )=0; virtual void calculateResidualEdgeBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -251,45 +253,45 @@ namespace proteus double sc_uref, double sc_alpha, //VRANS - const double* q_vos, - const double* vos_dof, + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -300,24 +302,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; }; template& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -540,45 +542,45 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_vos, - const double* vos_dof, + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -589,24 +591,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { double meanEntropy = 0., meanOmega = 0., maxEntropy = -1E10, minEntropy = 1E10; register double maxVel[nElements_global], maxEntRes[nElements_global]; @@ -684,19 +686,19 @@ namespace proteus // } ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); //get the physical integration weight dV = fabs(jacDet)*dV_ref[k]; @@ -706,24 +708,24 @@ namespace proteus jacInv, u_grad_trial); //get the solution - ck.valFromDOF(u_dof, + ck.valFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_ref[k*nDOF_trial_element], u); - ck.valFromDOF(u_dof_old, + ck.valFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], &u_trial_ref[k*nDOF_trial_element], un); //get the solution gradients - ck.gradFromDOF(u_dof, + ck.gradFromDOF(u_dof.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_u); - ck.gradFromDOF(u_dof_old, + ck.gradFromDOF(u_dof_old.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_u_old); - ck.gradFromDOF(uTilde_dof, + ck.gradFromDOF(uTilde_dof.data(), &u_l2g[eN_nDOF_trial_element], u_grad_trial, grad_uTilde); @@ -982,37 +984,38 @@ namespace proteus //calculate the solution and gradients at quadrature points // //compute information about mapping from reference element to physical element - ck.calculateMapping_elementBoundary(eN, - ebN_local, - kb, - ebN_local_kb, - mesh_dof, - mesh_l2g, - mesh_trial_trace_ref, - mesh_grad_trial_trace_ref, - boundaryJac_ref, - jac_ext, - jacDet_ext, - jacInv_ext, - boundaryJac, - metricTensor, - metricTensorDetSqrt, - normal_ref, - normal, - x_ext,y_ext,z_ext); - ck.calculateMappingVelocity_elementBoundary(eN, - ebN_local, - kb, - ebN_local_kb, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_trace_ref, - xt_ext,yt_ext,zt_ext, - normal, - boundaryJac, - metricTensor, - integralScaling); - //std::cout<<"metricTensorDetSqrt "<& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1184,31 +1187,31 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_vos, + const xt::pyarray& q_vos, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int STABILIZATION_TYPE) { //std::cout<<"ndjaco address "<& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE ) @@ -1734,27 +1737,27 @@ namespace proteus void calculateResidualEdgeBased(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1763,45 +1766,45 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_vos, - const double* vos_dof, + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, double degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_vos_ext, + const xt::pyarray& ebqe_vos_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, //EXPLICIT METHODS int stage, - double * uTilde_dof, + xt::pyarray& uTilde_dof, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cMax, @@ -1812,24 +1815,24 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, - double* ML, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, + xt::pyarray& ML, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* uLow, - double* dLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { // NOTE: This function follows a different (but equivalent) implementation of the smoothness based indicator than NCLS.h // Allocate space for the transport matrices @@ -1907,28 +1910,28 @@ namespace proteus //get the physical integration weight ck.calculateMapping_element(eN, k, - mesh_dof, - mesh_l2g, - mesh_trial_ref, - mesh_grad_trial_ref, + mesh_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x,y,z); ck.calculateMappingVelocity_element(eN, k, - mesh_velocity_dof, - mesh_l2g, - mesh_trial_ref, + mesh_velocity_dof.data(), + mesh_l2g.data(), + mesh_trial_ref.data(), xt,yt,zt); dV = fabs(jacDet)*dV_ref[k]; //get the solution (of Newton's solver). To compute time derivative term - ck.valFromDOF(u_dof,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); + ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u); //get the solution at quad point at tn and tnm1 for entropy viscosity - ck.valFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); + ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],un); //get the solution gradients at tn for entropy viscosity ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial); - ck.gradFromDOF(u_dof_old,&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_un); + ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_un); //precalculate test function products with integration weights for mass matrix terms for (int j=0;j a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::cppVOS3P_base; + +PYBIND11_MODULE(cVOS3P, m) +{ + xt::import_numpy(); + + py::class_(m, "VOS3P") + .def(py::init(&proteus::newVOS3P)) + .def("calculateResidual", &cppVOS3P_base::calculateResidual) + .def("calculateJacobian", &cppVOS3P_base::calculateJacobian) + .def("FCTStep", &cppVOS3P_base::FCTStep) + .def("kth_FCT_step", &cppVOS3P_base::kth_FCT_step) + .def("calculateResidual_entropy_viscosity", &cppVOS3P_base::calculateResidual_entropy_viscosity) + .def("calculateMassMatrix", &cppVOS3P_base::calculateMassMatrix); +} diff --git a/proteus/mprans/VOS3P.h b/proteus/mprans/VOS3P.h index 2f27e86638..977f0c941e 100644 --- a/proteus/mprans/VOS3P.h +++ b/proteus/mprans/VOS3P.h @@ -5,6 +5,9 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" + +namespace py = pybind11; #define POWER_SMOOTHNESS_INDICATOR 2 #define IS_BETAij_ONE 0 @@ -44,27 +47,27 @@ namespace proteus virtual ~cppVOS3P_base(){} virtual void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -73,44 +76,44 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, - double* q_dvos_dt, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, + xt::pyarray& q_dvos_dt, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cK, @@ -120,57 +123,57 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // C matrices - double* Cx, - double* Cy, - double* Cz, - double* CTx, - double* CTy, - double* CTz, - double* ML, - double* delta_x_ij, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& CTx, + xt::pyarray& CTy, + xt::pyarray& CTz, + xt::pyarray& ML, + xt::pyarray& delta_x_ij, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* dLow, - double* fluxMatrix, - double* uDotLow, - double* uLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& dLow, + xt::pyarray& fluxMatrix, + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; virtual void calculateJacobian(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -178,91 +181,91 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - double* delta_x_ij, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + xt::pyarray& delta_x_ij, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int LUMPED_MASS_MATRIX)=0; virtual void FCTStep(int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* lumped_mass_matrix, //lumped mass matrix (as vector) - double* soln, //DOFs of solution at time tn - double* solH, //DOFs of high order solution at tnp1 - double* uLow, - double* limited_solution, - int* csrRowIndeces_DofLoops, //csr row indeces - int* csrColumnOffsets_DofLoops, //csr column offsets - double* MassMatrix, //mass matrix - double* dt_times_dH_minus_dL, //low minus high order dissipative matrices - double* min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 - double* max_u_bc, + xt::pyarray& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX )=0; virtual void kth_FCT_step(double dt, int num_fct_iter, int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* MC, - double* ML, - double* soln, - double* solLim, //DOFs of high order solution at tnp1 - double* uDotLow, - double* uLow, - double* dLow, - double* FluxMatrix, - double* limitedFlux, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& MC, + xt::pyarray& ML, + xt::pyarray& soln, + xt::pyarray& solLim, //DOFs of high order solution at tnp1 + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& FluxMatrix, + xt::pyarray& limitedFlux, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, double global_min_u, double global_max_u, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops)=0; + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops)=0; virtual void calculateResidual_entropy_viscosity(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -272,44 +275,44 @@ namespace proteus double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, - double* q_dvos_dt, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, + xt::pyarray& q_dvos_dt, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cK, @@ -319,57 +322,57 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // C matrices - double* Cx, - double* Cy, - double* Cz, - double* CTx, - double* CTy, - double* CTz, - double* ML, - double* delta_x_ij, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& CTx, + xt::pyarray& CTy, + xt::pyarray& CTz, + xt::pyarray& ML, + xt::pyarray& delta_x_ij, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* dLow, - double* fluxMatrix, - double* uDotLow, - double* uLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& dLow, + xt::pyarray& fluxMatrix, + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs)=0; + xt::pyarray& quantDOFs)=0; virtual void calculateMassMatrix(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -377,33 +380,33 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - double* delta_x_ij, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + xt::pyarray& delta_x_ij, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int LUMPED_MASS_MATRIX)=0; }; @@ -601,27 +604,27 @@ namespace proteus void calculateResidual(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -630,44 +633,44 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, - double* q_dvos_dt, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, + xt::pyarray& q_dvos_dt, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cK, @@ -677,37 +680,37 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // C matrices - double* Cx, - double* Cy, - double* Cz, - double* CTx, - double* CTy, - double* CTz, - double* ML, - double* delta_x_ij, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& CTx, + xt::pyarray& CTy, + xt::pyarray& CTz, + xt::pyarray& ML, + xt::pyarray& delta_x_ij, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* dLow, - double* fluxMatrix, - double* uDotLow, - double* uLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& dLow, + xt::pyarray& fluxMatrix, + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { - //std::cout<<"numDiff address "<=0.0) - ebqe_u[ebNE_kb] = u_ext; + ebqe_u.data()[ebNE_kb] = u_ext; else - ebqe_u[ebNE_kb] = bc_u_ext; + ebqe_u.data()[ebNE_kb] = bc_u_ext; // //update residuals // @@ -1110,34 +1113,34 @@ namespace proteus { int eN_i = eN*nDOF_test_element+i; - globalResidual[offset_u+stride_u*r_l2g[eN_i]] += elementResidual_u[i]; + globalResidual.data()[offset_u+stride_u*r_l2g.data()[eN_i]] += elementResidual_u[i]; }//i }//ebNE } void calculateJacobian(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1145,36 +1148,36 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - double* delta_x_ij, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + xt::pyarray& delta_x_ij, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int LUMPED_MASS_MATRIX) { - //std::cout<<"ndjaco address "<& lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray& soln, //DOFs of solution at time tn + xt::pyarray& solH, //DOFs of high order solution at tnp1 + xt::pyarray& uLow, + xt::pyarray& limited_solution, + xt::pyarray& csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray& csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray& MassMatrix, //mass matrix + xt::pyarray& dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray& min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray& max_u_bc, int LUMPED_MASS_MATRIX ) { @@ -1594,14 +1597,14 @@ namespace proteus for (int i=0; i0) ? fmin(Rposi,Rneg[j]) : fmin(Rnegi,Rpos[j])) * FluxCorrectionMatrix[ij]; @@ -1667,7 +1670,7 @@ namespace proteus //update ij ij+=1; } - limited_solution[i] = solL[i] + 1./lumped_mass_matrix[i]*ith_Limiter_times_FluxCorrectionMatrix; + limited_solution.data()[i] = solL[i] + 1./lumped_mass_matrix.data()[i]*ith_Limiter_times_FluxCorrectionMatrix; } } @@ -1675,21 +1678,21 @@ namespace proteus int num_fct_iter, int NNZ, //number on non-zero entries on sparsity pattern int numDOFs, //number of DOFs - double* MC, - double* ML, - double* soln, - double* solLim, // INPUT/OUTPUT - double* uDotLow, - double* uLow, - double* dLow, - double* FluxMatrix, - double* limitedFlux, // INPUT/OUTPUT - double* min_u_bc, - double* max_u_bc, + xt::pyarray& MC, + xt::pyarray& ML, + xt::pyarray& soln, + xt::pyarray& solLim, // INPUT/OUTPUT + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dLow, + xt::pyarray& FluxMatrix, + xt::pyarray& limitedFlux, // INPUT/OUTPUT + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, double global_min_u, double global_max_u, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops) + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops) { Rpos.resize(numDOFs,0.0), Rneg.resize(numDOFs,0.0); int ij=0; @@ -1701,7 +1704,7 @@ namespace proteus { // No FCT for global bounds for (int i=0; i 0) ? 1. : 0.); Pnegi += Fluxij*((Fluxij < 0) ? 1. : 0.); // update ij ij+=1; } // compute Q vectors - double mi = ML[i]; - double solLimi = solLim[i]; + double mi = ML.data()[i]; + double solLimi = solLim.data()[i]; double Qposi = mi*(global_max_u-solLimi); double Qnegi = mi*(global_min_u-solLimi); // compute R vectors @@ -1737,12 +1740,12 @@ namespace proteus { double ith_Limiter_times_FluxCorrectionMatrix = 0.; double Rposi = Rpos[i], Rnegi = Rneg[i]; - for (int offset=csrRowIndeces_DofLoops[i]; - offset0 ? Rposi : Rpos[j]); @@ -1752,17 +1755,17 @@ namespace proteus // ***** UPDATE VECTORS FOR NEXT FCT ITERATION ***** // // update limited flux - limitedFlux[ij] = Lij*Fluxij; + limitedFlux.data()[ij] = Lij*Fluxij; //update FluxMatrix - FluxMatrix[ij] = Fluxij; + FluxMatrix.data()[ij] = Fluxij; //update ij ij+=1; } //update limited solution - double mi = ML[i]; - solLim[i] += 1.0/mi*ith_Limiter_times_FluxCorrectionMatrix; + double mi = ML.data()[i]; + solLim.data()[i] += 1.0/mi*ith_Limiter_times_FluxCorrectionMatrix; } } } @@ -1773,26 +1776,26 @@ namespace proteus ij=0; for (int i=0; i 0. ? 1. : 0.); Pnegi += fij * (fij < 0. ? 1. : 0.); //update ij ij+=1; } // compute Q vectors // - double mi = ML[i]; - double Qposi = mi*(maxi-solLim[i]); - double Qnegi = mi*(mini-solLim[i]); + double mi = ML.data()[i]; + double Qposi = mi*(maxi-solLim.data()[i]); + double Qnegi = mi*(mini-solLim.data()[i]); // compute R vectors // Rpos[i] = ((Pposi==0) ? 1. : fmin(1.0,Qposi/Pposi)); @@ -1806,11 +1809,11 @@ namespace proteus double ith_limited_flux_correction = 0; double Rposi = Rpos[i]; double Rnegi = Rneg[i]; - for (int offset=csrRowIndeces_DofLoops[i]; offset 0. ? fmin(Rposi,Rneg[j]) : fmin(Rnegi,Rpos[j]); @@ -1818,48 +1821,48 @@ namespace proteus ith_limited_flux_correction += Lij*fij; ij+=1; } - double mi = ML[i]; - solLim[i] += 1./mi*ith_limited_flux_correction; + double mi = ML.data()[i]; + solLim.data()[i] += 1./mi*ith_limited_flux_correction; // clean round off error - if (solLim[i] > 1.0+1E-13) + if (solLim.data()[i] > 1.0+1E-13) { - std::cout << "upper bound violated... " << 1.0-solLim[i] << std::endl; + std::cout << "upper bound violated... " << 1.0-solLim.data()[i] << std::endl; abort(); } - else if (solLim[i] < -1E-13) + else if (solLim.data()[i] < -1E-13) { - std::cout << "lower bound violated... " << solLim[i] << std::endl; + std::cout << "lower bound violated... " << solLim.data()[i] << std::endl; abort(); } else - solLim[i] = fmax(0.,fmin(solLim[i],1.0)); + solLim.data()[i] = fmax(0.,fmin(solLim.data()[i],1.0)); } } void calculateResidual_entropy_viscosity(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -1868,44 +1871,44 @@ namespace proteus double shockCapturingDiffusion, double sc_uref, double sc_alpha, //VRANS - const double* q_porosity, - const double* porosity_dof, - double* q_dvos_dt, + const xt::pyarray& q_porosity, + const xt::pyarray& porosity_dof, + xt::pyarray& q_dvos_dt, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_grad_u, - double* q_m_betaBDF, - double* q_dV, - double* q_dV_last, - double* cfl, - double* edge_based_cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_grad_u, + xt::pyarray& q_m_betaBDF, + xt::pyarray& q_dV, + xt::pyarray& q_dV_last, + xt::pyarray& cfl, + xt::pyarray& edge_based_cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, int offset_u, int stride_u, - double* globalResidual, + xt::pyarray& globalResidual, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi,double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux, // PARAMETERS FOR EDGE BASED STABILIZATION double cE, double cK, @@ -1915,34 +1918,34 @@ namespace proteus // PARAMETERS FOR EDGE VISCOSITY int numDOFs, int NNZ, - int* csrRowIndeces_DofLoops, - int* csrColumnOffsets_DofLoops, - int* csrRowIndeces_CellLoops, - int* csrColumnOffsets_CellLoops, - int* csrColumnOffsets_eb_CellLoops, + xt::pyarray& csrRowIndeces_DofLoops, + xt::pyarray& csrColumnOffsets_DofLoops, + xt::pyarray& csrRowIndeces_CellLoops, + xt::pyarray& csrColumnOffsets_CellLoops, + xt::pyarray& csrColumnOffsets_eb_CellLoops, // C matrices - double* Cx, - double* Cy, - double* Cz, - double* CTx, - double* CTy, - double* CTz, - double* ML, - double* delta_x_ij, + xt::pyarray& Cx, + xt::pyarray& Cy, + xt::pyarray& Cz, + xt::pyarray& CTx, + xt::pyarray& CTy, + xt::pyarray& CTz, + xt::pyarray& ML, + xt::pyarray& delta_x_ij, // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD int LUMPED_MASS_MATRIX, int STABILIZATION_TYPE, int ENTROPY_TYPE, // FOR FCT - double* dLow, - double* fluxMatrix, - double* uDotLow, - double* uLow, - double* dt_times_dH_minus_dL, - double* min_u_bc, - double* max_u_bc, + xt::pyarray& dLow, + xt::pyarray& fluxMatrix, + xt::pyarray& uDotLow, + xt::pyarray& uLow, + xt::pyarray& dt_times_dH_minus_dL, + xt::pyarray& min_u_bc, + xt::pyarray& max_u_bc, // AUX QUANTITIES OF INTEREST - double* quantDOFs) + xt::pyarray& quantDOFs) { Rpos.resize(numDOFs,0.0), Rneg.resize(numDOFs,0.0); //register double FluxCorrectionMatrix[NNZ]; @@ -1955,8 +1958,8 @@ namespace proteus for (int j=0;j= 0 && isFluxBoundary_u[ebNE_kb] != 1 ) //outflow. This is handled via the transport matrices. Then flux_ext=0 and dflux_ext!=0 + if (flow >= 0 && isFluxBoundary_u.data()[ebNE_kb] != 1 ) //outflow. This is handled via the transport matrices. Then flux_ext=0 and dflux_ext!=0 { /* if (x_ext > 1.0e-8) */ /* std::cout<<"Outflow boundary VOS3P "< 0.0) - // assert( (xi[I] - xj[I]) == delta_x_ij[offset*3+I]); + //if (delta_x_ij.data()[offset*3+I] > 0.0) + // assert( (xi[I] - xj[I]) == delta_x_ij.data()[offset*3+I]); //gi_times_x += gi[I]*(xi[I]-xj[I]); - gi_times_x += gi[I]*delta_x_ij[offset*3+I]; + gi_times_x += gi[I]*delta_x_ij.data()[offset*3+I]; } // compute the positive and negative part of gi*(xi-xj) SumPos += gi_times_x > 0 ? gi_times_x : 0; @@ -2418,7 +2421,7 @@ namespace proteus alpha_deni = alpha_denominator_pos + alpha_denominator_neg; } double alphai = alpha_numi/(alpha_deni+1E-15); - quantDOFs[i] = alphai; + quantDOFs.data()[i] = alphai; if (POWER_SMOOTHNESS_INDICATOR==0) psi[i] = 1.0; @@ -2440,9 +2443,9 @@ namespace proteus double dLii = 0.; // loop over the sparsity pattern of the i-th DOF - for (int offset=csrRowIndeces_DofLoops[i]; offset 0) ? 1. : 0.); // Pnegi += FluxCorrectionMatrix[ij]*((FluxCorrectionMatrix[ij] < 0) ? 1. : 0.); // ij+=1; // } - // double mi = ML[i]; - // double solni = u_dof_old[i]; + // double mi = ML.data()[i]; + // double solni = u_dof_old.data()[i]; // double Qposi = mi*(maxi-solni); // double Qnegi = mi*(mini-solni); @@ -2570,10 +2573,10 @@ namespace proteus //std::cout << "Rnegi: " << Rnegi << std::endl; // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// - // for (int offset=csrRowIndeces_DofLoops[i]; - // offset0) ? fmin(Rposi,Rneg[j]) : fmin(Rnegi,Rpos[j])); // //Lij=0.0; @@ -2581,36 +2584,36 @@ namespace proteus // //update ij // ij+=1; // } - // double mi = ML[i]; - // double solni = u_dof_old[i]; - // globalResidual[i] = solni + 1.0/mi*ith_Limiter_times_FluxCorrectionMatrix; + // double mi = ML.data()[i]; + // double solni = u_dof_old.data()[i]; + // globalResidual.data()[i] = solni + 1.0/mi*ith_Limiter_times_FluxCorrectionMatrix; //} } void calculateMassMatrix(//element double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, //physics int nElements_global, double useMetrics, @@ -2618,36 +2621,36 @@ namespace proteus int lag_shockCapturing,/*mwf not used yet*/ double shockCapturingDiffusion, //VRANS - const double* q_porosity, + const xt::pyarray& q_porosity, // - int* u_l2g, - int* r_l2g, - double* elementDiameter, + xt::pyarray& u_l2g, + xt::pyarray& r_l2g, + xt::pyarray& elementDiameter, int degree_polynomial, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - double* delta_x_ij, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + xt::pyarray& delta_x_ij, int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, //VRANS - const double* ebqe_porosity_ext, + const xt::pyarray& ebqe_porosity_ext, // - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u, int LUMPED_MASS_MATRIX) { - //std::cout<<"ndjaco address "< mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - nElementBoundaries_owned, - < int * > u_l2g.data, - < double * > u_dof.data, - < double * > q_rho.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int *> elementBoundaryMaterialTypesArray.data, - < double* > Aij.data, - added_mass_i, - < double *> barycenters.data, - < int *> flags_rigidbody.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - numpy.ndarray q_rho, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray csrColumnOffsets_eb_u_u): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - < int * > u_l2g.data, - < double * > u_dof.data, - < double * > q_rho.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > csrColumnOffsets_eb_u_u.data) diff --git a/proteus/mprans/cCLSVOF.pyx b/proteus/mprans/cCLSVOF.pyx deleted file mode 100644 index aff9a9413f..0000000000 --- a/proteus/mprans/cCLSVOF.pyx +++ /dev/null @@ -1,886 +0,0 @@ -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "CLSVOF.h" namespace "proteus": - cdef cppclass CLSVOF_base: - void calculateResidual(double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - int nElements_owned, - double useMetrics, - double* q_vos, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* velocity_old, - double* q_m, - double* q_u, - double* q_n, - double* q_H, - double* q_mH, - double* q_dV, - double* q_dV_last, - double* cfl, - int offset_u, int stride_u, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - double* ebqe_vos_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_u, - double* ebqe_n, - double* ebqe_H, - double* ebqe_flux, - int timeOrder, - int timeStage, - double epsFactHeaviside, - double epsFactDirac, - double epsFactRedist, - double lambdaFact, - double* min_distance, - double* max_distance, - double* mean_distance, - double* volume_domain, - double norm_factor_lagged, - double VelMax, - double* projected_qx_tn, - double* projected_qy_tn, - double* projected_qz_tn, - double* projected_qx_tStar, - double* projected_qy_tStar, - double* projected_qz_tStar, - int numDOFs, - double* lumped_mass_matrix, - double* H_dof, - int preRedistancingStage, - double* interface_locator, - double alpha) - void calculateJacobian(double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - double useMetrics, - double* q_vos, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - int degree_polynomial, - double* u_dof, - double* u_dof_old, - double* velocity, - double* cfl, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - double* ebqe_vos_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u, - int timeOrder, - int timeStage, - double epsFactHeaviside, - double epsFactDirac, - double epsFactRedist, - double lambdaFact, - int preRedistancingStage, - double norm_factor_lagged, - double alpha) - void calculateMetricsAtEOS(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int nElements_owned, - int useMetrics, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double degree_polynomial, - double epsFactHeaviside, - double* u_dof, - double* u0_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_sI_err, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err, - double* global_L2_err, - double* global_L2Banded_err, - double* global_area_band, - double* global_sH_L2_err) - void calculateMetricsAtETS(double dt, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int nElements_owned, - int useMetrics, - double* q_vos, - int* u_l2g, - double* elementDiameter, - double* nodeDiametersArray, - double degree_polynomial, - double epsFactHeaviside, - double* u_dof, - double* u_dof_old, - double* u0_dof, - double* velocity, - int offset_u, int stride_u, - int numDOFs, - double* R_vector, - double* sR_vector, - double* global_V, - double* global_V0, - double* global_sV, - double* global_sV0, - double* global_D_err) - void normalReconstruction(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* elementDiameter, - double* u_dof, - int offset_u, int stride_u, - int numDOFs, - double* weighted_lumped_mass_matrix, - double* rhs_qx, - double* rhs_qy, - double* rhs_qz, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* weighted_mass_matrix) - void calculateRhsL2Proj(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* elementDiameter, - double he_for_disc_ICs, - double* u_dof, - int offset_u, int stride_u, - int numDOFs, - double* rhs_l2_proj) - void calculateLumpedMassMatrix(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* elementDiameter, - double* lumped_mass_matrix, - int offset_u, int stride_u) - void assembleSpinUpSystem(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* uInitial, - int offset_u, int stride_u, - double* globalResidual, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalMassMatrix) - void FCTStep(int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * soln, - double * solH, - double * solL, - double * limited_solution, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix) - CLSVOF_base* newCLSVOF(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cCLSVOF_base: - cdef CLSVOF_base* thisptr - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newCLSVOF(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - def __dealloc__(self): - del self.thisptr - def calculateResidual(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - int nElements_owned, - double useMetrics, - numpy.ndarray q_vos, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray velocity_old, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_H, - numpy.ndarray q_mH, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_vos_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray ebqe_H, - numpy.ndarray ebqe_flux, - int timeOrder, - int timeStage, - double epsFactHeaviside, - double epsFactDirac, - double epsFactRedist, - double lambdaFact, - numpy.ndarray min_distance, - numpy.ndarray max_distance, - numpy.ndarray mean_distance, - numpy.ndarray volume_domain, - double norm_factor_lagged, - double VelMax, - numpy.ndarray projected_qx_tn, - numpy.ndarray projected_qy_tn, - numpy.ndarray projected_qz_tn, - numpy.ndarray projected_qx_tStar, - numpy.ndarray projected_qy_tStar, - numpy.ndarray projected_qz_tStar, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray H_dof, - int preRedistancingStage, - numpy.ndarray interface_locator, - double alpha): - self.thisptr.calculateResidual(dt, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - nElements_owned, - useMetrics, - q_vos.data, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - degree_polynomial, - u_dof.data, - u_dof_old.data, - velocity.data, - velocity_old.data, - q_m.data, - q_u.data, - q_n.data, - q_H.data, - q_mH.data, - q_dV.data, - q_dV_last.data, - cfl.data, - offset_u, stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_velocity_ext.data, - ebqe_vos_ext.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - ebqe_u.data, - ebqe_n.data, - ebqe_H.data, - ebqe_flux.data, - timeOrder, - timeStage, - epsFactHeaviside, - epsFactDirac, - epsFactRedist, - lambdaFact, - min_distance.data, - max_distance.data, - mean_distance.data, - volume_domain.data, - norm_factor_lagged, - VelMax, - projected_qx_tn.data, - projected_qy_tn.data, - projected_qz_tn.data, - projected_qx_tStar.data, - projected_qy_tStar.data, - projected_qz_tStar.data, - numDOFs, - lumped_mass_matrix.data, - H_dof.data, - preRedistancingStage, - interface_locator.data, - alpha) - def calculateJacobian(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - numpy.ndarray q_vos, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray cfl, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_vos_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int timeOrder, - int timeStage, - double epsFactHeaviside, - double epsFactDirac, - double epsFactRedist, - double lambdaFact, - int preRedistancingStage, - double norm_factor_lagged, - double alpha): - cdef numpy.ndarray rowptr,colind,globalJacobian_a - (rowptr,colind,globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(dt, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - q_vos.data, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - degree_polynomial, - u_dof.data, - u_dof_old.data, - velocity.data, - cfl.data, - csrRowIndeces_u_u.data, - csrColumnOffsets_u_u.data, - globalJacobian_a.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_velocity_ext.data, - ebqe_vos_ext.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - csrColumnOffsets_eb_u_u.data, - timeOrder, - timeStage, - epsFactHeaviside, - epsFactDirac, - epsFactRedist, - lambdaFact, - preRedistancingStage, - norm_factor_lagged, - alpha) - def calculateMetricsAtEOS(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - int nElements_owned, - int useMetrics, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double degree_polynomial, - double epsFactHeaviside, - numpy.ndarray u_dof, - numpy.ndarray u0_dof, - numpy.ndarray u_exact, - int offset_u, int stride_u): - cdef double global_I_err - cdef double global_sI_err - cdef double global_V - cdef double global_V0 - cdef double global_sV - cdef double global_sV0 - cdef double global_D_err - cdef double global_L2_err - cdef double global_L2Banded_err - cdef double global_area_band - cdef double global_sH_L2_err - self.thisptr.calculateMetricsAtEOS(mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - nElements_owned, - useMetrics, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - degree_polynomial, - epsFactHeaviside, - u_dof.data, - u0_dof.data, - u_exact.data, - offset_u, - stride_u, - &global_I_err, - &global_sI_err, - &global_V, - &global_V0, - &global_sV, - &global_sV0, - &global_D_err, - &global_L2_err, - &global_L2Banded_err, - &global_area_band, - &global_sH_L2_err) - return(global_I_err, - global_sI_err, - global_V, - global_V0, - global_sV, - global_sV0, - global_D_err, - global_L2_err, - global_L2Banded_err, - global_area_band, - global_sH_L2_err) - def calculateMetricsAtETS(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - int nElements_owned, - int useMetrics, - numpy.ndarray q_vos, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double degree_polynomial, - double epsFactHeaviside, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray u0_dof, - numpy.ndarray velocity, - int offset_u, int stride_u, - int numDOFs, - numpy.ndarray R_vector, - numpy.ndarray sR_vector): - cdef double global_V - cdef double global_V0 - cdef double global_sV - cdef double global_sV0 - cdef double global_D_err - self.thisptr.calculateMetricsAtETS(dt, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - nElements_owned, - useMetrics, - q_vos.data, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - degree_polynomial, - epsFactHeaviside, - u_dof.data, - u_dof_old.data, - u0_dof.data, - velocity.data, - offset_u, - stride_u, - numDOFs, - R_vector.data, - sR_vector.data, - &global_V, - &global_V0, - &global_sV, - &global_sV0, - &global_D_err) - return(global_V, - global_V0, - global_sV, - global_sV0, - global_D_err) - def normalReconstruction(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - int offset_u, int stride_u, - int numDOFs, - numpy.ndarray weighted_lumped_mass_matrix, - numpy.ndarray rhs_qx, - numpy.ndarray rhs_qy, - numpy.ndarray rhs_qz, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - weighted_mass_matrix): - cdef numpy.ndarray rowptr,colind,weighted_mass_matrix_a - (rowptr,colind,weighted_mass_matrix_a) = weighted_mass_matrix.getCSRrepresentation() - self.thisptr.normalReconstruction( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - elementDiameter.data, - u_dof.data, - offset_u, stride_u, - numDOFs, - weighted_lumped_mass_matrix.data, - rhs_qx.data, - rhs_qy.data, - rhs_qz.data, - csrRowIndeces_u_u.data, - csrColumnOffsets_u_u.data, - weighted_mass_matrix_a.data) - def calculateRhsL2Proj(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - double he_for_disc_ICs, - numpy.ndarray u_dof, - int offset_u, int stride_u, - int numDOFs, - numpy.ndarray rhs_l2_proj): - self.thisptr.calculateRhsL2Proj( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - elementDiameter.data, - he_for_disc_ICs, - u_dof.data, - offset_u, stride_u, - numDOFs, - rhs_l2_proj.data) - def calculateLumpedMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray lumped_mass_matrix, - int offset_u, int stride_u): - self.thisptr.calculateLumpedMassMatrix( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - elementDiameter.data, - lumped_mass_matrix.data, - offset_u, stride_u) - def assembleSpinUpSystem(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray uInitial, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalMassMatrix): - cdef numpy.ndarray rowptr,colind,globalMassMatrix_a - (rowptr,colind,globalMassMatrix_a) = globalMassMatrix.getCSRrepresentation() - self.thisptr.assembleSpinUpSystem( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - uInitial.data, - offset_u, stride_u, - globalResidual.data, - csrRowIndeces_u_u.data, - csrColumnOffsets_u_u.data, - globalMassMatrix_a.data) - def FCTStep(self, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray soln, - numpy.ndarray solH, - numpy.ndarray solL, - numpy.ndarray limited_solution, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - MassMatrix): - cdef numpy.ndarray rowptr,colind,MassMatrix_a - (rowptr,colind,MassMatrix_a) = MassMatrix.getCSRrepresentation() - self.thisptr.FCTStep(NNZ, - numDOFs, - lumped_mass_matrix.data, - soln.data, - solH.data, - solL.data, - limited_solution.data, - csrRowIndeces_DofLoops.data, - csrColumnOffsets_DofLoops.data, - MassMatrix_a.data) diff --git a/proteus/mprans/cDissipation.pyx b/proteus/mprans/cDissipation.pyx deleted file mode 100644 index ef16a46a0d..0000000000 --- a/proteus/mprans/cDissipation.pyx +++ /dev/null @@ -1,616 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "Dissipation.h" namespace "proteus": - cdef cppclass Dissipation_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_kappa, # kinetic energy variable - double * q_grad_kappa, - double * q_porosity, # VRANS - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_kappa, # kinetic energy - double * ebqe_porosity, # VRANS - double * ebqe_u, - double * ebqe_flux) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffuion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_kappa, # kinetic energy - double * q_grad_kappa, - double * q_porosity, # VRANS -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - int * csrColumnOffsets_eb_u_u, - double * ebqe_phi, double epsFact, - double * ebqe_kappa, # kinetic energy - double * ebqe_porosity) # VRANS - Dissipation_base * newDissipation(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter) - -cdef class cDissipation_base: - cdef Dissipation_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter): - - self.thisptr = newDissipation(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter) - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_kappa, # kinetic energy - numpy.ndarray q_grad_kappa, - numpy.ndarray q_porosity, # VRANS - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_kappa, # kinetic energy - numpy.ndarray ebqe_porosity, # VRANS - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - c_1, - c_2, - c_e, - rho_0, - rho_1, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - dissipation_model_flag, - # end diffuion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_kappa.data, # kinetic energy - < double * > q_grad_kappa.data, # kinetic energy - < double * > q_porosity.data, # kinetic energy - # velocity dof - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dof - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_kappa.data, # kinetic energy on boundary - < double * > ebqe_porosity.data, # VRANS - < double * > ebqe_u.data, - < double * > ebqe_flux.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_kappa, # kinetic energy - numpy.ndarray q_grad_kappa, # kinetic energy - numpy.ndarray q_porosity, # VRANS - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray ebqe_phi, - double epsFact, - numpy.ndarray ebqe_kappa, # kinetic energy - numpy.ndarray ebqe_porosity): # VRANS - - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - c_1, - c_2, - c_e, - rho_0, - rho_1, - dissipation_model_flag, - # end diffusion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_kappa.data, - < double * > q_grad_kappa.data, - < double * > q_porosity.data, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - # velocity dofs - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dofs - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - < double * > ebqe_phi.data, epsFact, - < double * > ebqe_kappa.data, - < double * > ebqe_porosity.data) diff --git a/proteus/mprans/cDissipation2D.pyx b/proteus/mprans/cDissipation2D.pyx deleted file mode 100644 index 50cd43d522..0000000000 --- a/proteus/mprans/cDissipation2D.pyx +++ /dev/null @@ -1,617 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "Dissipation2D.h" namespace "proteus": - cdef cppclass Dissipation2D_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_kappa, # kinetic energy variable - double * q_grad_kappa, - double * q_porosity, # VRANS - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_kappa, # kinetic energy - double * ebqe_porosity, # VRANS - double * ebqe_u, - double * ebqe_flux) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffuion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_kappa, # kinetic energy - double * q_grad_kappa, - double * q_porosity, # VRANS -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - int * csrColumnOffsets_eb_u_u, - double * ebqe_phi, double epsFact, - double * ebqe_kappa, # kinetic energy - double * ebqe_porosity) # VRANS - Dissipation2D_base * newDissipation2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter) - - -cdef class cDissipation2D_base: - cdef Dissipation2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter): - - self.thisptr = newDissipation2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter) - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_kappa, # kinetic energy - numpy.ndarray q_grad_kappa, - numpy.ndarray q_porosity, # VRANS - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_kappa, # kinetic energy - numpy.ndarray ebqe_porosity, # VRANS - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - c_1, - c_2, - c_e, - rho_0, - rho_1, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - dissipation_model_flag, - # end diffuion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_kappa.data, # kinetic energy - < double * > q_grad_kappa.data, # kinetic energy - < double * > q_porosity.data, # kinetic energy - # velocity dof - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dof - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_kappa.data, # kinetic energy on boundary - < double * > ebqe_porosity.data, # VRANS - < double * > ebqe_u.data, - < double * > ebqe_flux.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double c_1, - double c_2, - double c_e, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_kappa, # kinetic energy - numpy.ndarray q_grad_kappa, # kinetic energy - numpy.ndarray q_porosity, # VRANS - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray ebqe_phi, - double epsFact, - numpy.ndarray ebqe_kappa, # kinetic energy - numpy.ndarray ebqe_porosity): # VRANS - - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - c_1, - c_2, - c_e, - rho_0, - rho_1, - dissipation_model_flag, - # end diffusion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_kappa.data, - < double * > q_grad_kappa.data, - < double * > q_porosity.data, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - # velocity dofs - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dofs - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - < double * > ebqe_phi.data, epsFact, - < double * > ebqe_kappa.data, - < double * > ebqe_porosity.data) diff --git a/proteus/mprans/cGN_SW2DCV.pyx b/proteus/mprans/cGN_SW2DCV.pyx deleted file mode 100644 index 5262eaecc9..0000000000 --- a/proteus/mprans/cGN_SW2DCV.pyx +++ /dev/null @@ -1,1639 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "GN_SW2DCV.h" namespace "proteus": - cdef cppclass GN_SW2DCV_base: - void FCTStep(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * heta_old, - double * hw_old, - double * b_dof, - double * high_order_hnp1, - double * high_order_hunp1, - double * high_order_hvnp1, - double* high_order_hetanp1, - double* high_order_hwnp1, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * extendedSourceTerm_heta, - double * extendedSourceTerm_hw, - double * limited_hnp1, - double * limited_hunp1, - double * limited_hvnp1, - double * limited_hetanp1, - double * limited_hwnp1, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dH_minus_dL, - double * muH_minus_muL, - double hEps, - double * hReg, - int LUMPED_MASS_MATRIX, - double * dLow, - double * hBT, - double * huBT, - double * hvBT, - double * hetaBT, - double * hwBT) - void convexLimiting(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * heta_old, - double * hw_old, - double * b_dof, - double * high_order_hnp1, - double * high_order_hunp1, - double * high_order_hvnp1, - double * high_order_hetanp1, - double * high_order_hwnp1, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * extendedSourceTerm_heta, - double * extendedSourceTerm_hw, - double * limited_hnp1, - double * limited_hunp1, - double * limited_hvnp1, - double * limited_hetanp1, - double * limited_hwnp1, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dH_minus_dL, - double * muH_minus_muL, - double hEps, - double * hReg, - int LUMPED_MASS_MATRIX, - double * dLow, - double * hBT, - double * huBT, - double * hvBT, - double * hetaBT, - double * hwBT, - double * new_SourceTerm_hu, - double * new_SourceTerm_hv, - double * new_SourceTerm_heta, - double * new_SourceTerm_hw) - double calculateEdgeBasedCFL( - double g, - int numDOFsPerEqn, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * heta_old, - double * b_dof, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double hEps, - double * hReg, - double * Cx, - double * Cy, - double * CTx, - double * CTy, - double * dLow, - double run_cfl, - double * edge_based_cfl, - int debug) - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * h_dof_old, - double * hu_dof_old, - double * hv_dof_old, - double * heta_dof_old, - double * hw_dof_old, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * heta_dof, - double * hw_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * heta_dof_sge, - double * hw_dof_sge, - double * q_mass_acc, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mass_adv, - double * q_mass_acc_beta_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int offset_eta, - int offset_w, - int stride_h, - int stride_u, - int stride_v, - int stride_eta, - int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_h, - double * Cx, - double * Cy, - double * CTx, - double * CTy, - int numDOFsPerEqn, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * lumped_mass_matrix, - double cfl_run, - double hEps, - double * hReg, - double * hnp1_at_quad_point, - double * hunp1_at_quad_point, - double * hvnp1_at_quad_point, - double * hetanp1_at_quad_point, - double * hwnp1_at_quad_point, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * extendedSourceTerm_heta, - double * extendedSourceTerm_hw, - double * dH_minus_dL, - double * muH_minus_muL, - double cE, - int LUMPED_MASS_MATRIX, - double dt, - int LINEAR_FRICTION, - double mannings, - double * quantDOFs, - int SECOND_CALL_CALCULATE_RESIDUAL, - int COMPUTE_NORMALS, - double * normalx, - double * normaly, - double * dLow, - double * hBT, - double * huBT, - double * hvBT, - double * hetaBT, - double * hwBT, - int lstage, - double * new_SourceTerm_hu, - double * new_SourceTerm_hv, - double * new_SourceTerm_heta, - double * new_SourceTerm_hw) - void calculateMassMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * heta_dof, - double * hw_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * heta_dof_sge, - double * hw_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_h_eta, - int * csrColumnOffsets_h_eta, - int * csrRowIndeces_h_w, - int * csrColumnOffsets_h_w, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_eta, - int * csrColumnOffsets_u_eta, - int * csrRowIndeces_u_w, - int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_eta, - int * csrColumnOffsets_v_eta, - int * csrRowIndeces_v_w, - int * csrColumnOffsets_v_w, - int * csrRowIndeces_eta_h, - int * csrColumnOffsets_eta_h, - int * csrRowIndeces_eta_u, - int * csrColumnOffsets_eta_u, - int * csrRowIndeces_eta_v, - int * csrColumnOffsets_eta_v, - int * csrRowIndeces_eta_eta, - int * csrColumnOffsets_eta_eta, - int * csrRowIndeces_eta_w, - int * csrColumnOffsets_eta_w, - int * csrRowIndeces_w_h, - int * csrColumnOffsets_w_h, - int * csrRowIndeces_w_u, - int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, - int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_eta, - int * csrColumnOffsets_w_eta, - int * csrRowIndeces_w_w, - int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - double dt) - void calculateLumpedMassMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_h_eta, - int * csrColumnOffsets_h_eta, - int * csrRowIndeces_h_w, - int * csrColumnOffsets_h_w, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_eta, - int * csrColumnOffsets_u_eta, - int * csrRowIndeces_u_w, - int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_eta, - int * csrColumnOffsets_v_eta, - int * csrRowIndeces_v_w, - int * csrColumnOffsets_v_w, - int * csrRowIndeces_eta_h, - int * csrColumnOffsets_eta_h, - int * csrRowIndeces_eta_u, - int * csrColumnOffsets_eta_u, - int * csrRowIndeces_eta_v, - int * csrColumnOffsets_eta_v, - int * csrRowIndeces_eta_eta, - int * csrColumnOffsets_eta_eta, - int * csrRowIndeces_eta_w, - int * csrColumnOffsets_eta_w, - int * csrRowIndeces_w_h, - int * csrColumnOffsets_w_h, - int * csrRowIndeces_w_u, - int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, - int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_eta, - int * csrColumnOffsets_w_eta, - int * csrRowIndeces_w_w, - int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - double dt) - GN_SW2DCV_base * newGN_SW2DCV(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cGN_SW2DCV_base: - cdef GN_SW2DCV_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newGN_SW2DCV(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def FCTStep(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray heta_old, - numpy.ndarray hw_old, - numpy.ndarray b_dof, - numpy.ndarray high_order_hnp1, - numpy.ndarray high_order_hunp1, - numpy.ndarray high_order_hvnp1, - numpy.ndarray high_order_hetanp1, - numpy.ndarray high_order_hwnp1, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray extendedSourceTerm_heta, - numpy.ndarray extendedSourceTerm_hw, - numpy.ndarray limited_hnp1, - numpy.ndarray limited_hunp1, - numpy.ndarray limited_hvnp1, - numpy.ndarray limited_hetanp1, - numpy.ndarray limited_hwnp1, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double hEps, - numpy.ndarray hReg, - int LUMPED_MASS_MATRIX, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT, - numpy.ndarray hetaBT, - numpy.ndarray hwBT): - self.thisptr.FCTStep(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > heta_old.data, - < double * > hw_old.data, - < double * > b_dof.data, - < double * > high_order_hnp1.data, - < double * > high_order_hunp1.data, - < double * > high_order_hvnp1.data, - < double * > high_order_hetanp1.data, - < double * > high_order_hwnp1.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > extendedSourceTerm_heta.data, - < double * > extendedSourceTerm_hw.data, - < double * > limited_hnp1.data, - < double * > limited_hunp1.data, - < double * > limited_hvnp1.data, - < double * > limited_hetanp1.data, - < double * > limited_hwnp1.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - hEps, - < double * > hReg.data, - LUMPED_MASS_MATRIX, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data, - < double * > hetaBT.data, - < double * > hwBT.data) - def convexLimiting(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray heta_old, - numpy.ndarray hw_old, - numpy.ndarray b_dof, - numpy.ndarray high_order_hnp1, - numpy.ndarray high_order_hunp1, - numpy.ndarray high_order_hvnp1, - numpy.ndarray high_order_hetanp1, - numpy.ndarray high_order_hwnp1, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray extendedSourceTerm_heta, - numpy.ndarray extendedSourceTerm_hw, - numpy.ndarray limited_hnp1, - numpy.ndarray limited_hunp1, - numpy.ndarray limited_hvnp1, - numpy.ndarray limited_hetanp1, - numpy.ndarray limited_hwnp1, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double hEps, - numpy.ndarray hReg, - int LUMPED_MASS_MATRIX, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT, - numpy.ndarray hetaBT, - numpy.ndarray hwBT, - numpy.ndarray new_SourceTerm_hu, - numpy.ndarray new_SourceTerm_hv, - numpy.ndarray new_SourceTerm_heta, - numpy.ndarray new_SourceTerm_hw): - self.thisptr.convexLimiting(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > heta_old.data, - < double * > hw_old.data, - < double * > b_dof.data, - < double * > high_order_hnp1.data, - < double * > high_order_hunp1.data, - < double * > high_order_hvnp1.data, - < double * > high_order_hetanp1.data, - < double * > high_order_hwnp1.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > extendedSourceTerm_heta.data, - < double * > extendedSourceTerm_hw.data, - < double * > limited_hnp1.data, - < double * > limited_hunp1.data, - < double * > limited_hvnp1.data, - < double * > limited_hetanp1.data, - < double * > limited_hwnp1.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - hEps, - < double * > hReg.data, - LUMPED_MASS_MATRIX, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data, - < double * > hetaBT.data, - < double * > hwBT.data, - < double * > new_SourceTerm_hu.data, - < double * > new_SourceTerm_hv.data, - < double * > new_SourceTerm_heta.data, - < double * > new_SourceTerm_hw.data) - def calculateEdgeBasedCFL(self, - double g, - int numDOFsPerEqn, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray heta_old, - numpy.ndarray b_dof, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - double hEps, - numpy.ndarray hReg, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray CTx, - numpy.ndarray CTy, - numpy.ndarray dLow, - double run_cfl, - numpy.ndarray edge_based_cfl, - int debug): - return self.thisptr.calculateEdgeBasedCFL( - g, - numDOFsPerEqn, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > heta_old.data, - < double * > b_dof.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - hEps, - < double * > hReg.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > CTx.data, - < double * > CTy.data, - < double * > dLow.data, - run_cfl, - < double * > edge_based_cfl.data, - debug) - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray h_dof_old, - numpy.ndarray hu_dof_old, - numpy.ndarray hv_dof_old, - numpy.ndarray heta_dof_old, - numpy.ndarray hw_dof_old, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray heta_dof, - numpy.ndarray hw_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray heta_dof_sge, - numpy.ndarray hw_dof_sge, - numpy.ndarray q_mass_acc, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int offset_eta, - int offset_w, - int stride_h, - int stride_u, - int stride_v, - int stride_eta, - int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_h, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray CTx, - numpy.ndarray CTy, - int numDOFsPerEqn, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray lumped_mass_matrix, - double cfl_run, - double hEps, - numpy.ndarray hReg, - numpy.ndarray hnp1_at_quad_point, - numpy.ndarray hunp1_at_quad_point, - numpy.ndarray hvnp1_at_quad_point, - numpy.ndarray hetanp1_at_quad_point, - numpy.ndarray hwnp1_at_quad_point, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray extendedSourceTerm_heta, - numpy.ndarray extendedSourceTerm_hw, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double cE, - int LUMPED_MASS_MATRIX, - double dt, - int LINEAR_FRICTION, - double mannings, - numpy.ndarray quantDOFs, - int SECOND_CALL_CALCULATE_RESIDUAL, - int COMPUTE_NORMALS, - numpy.ndarray normalx, - numpy.ndarray normaly, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT, - numpy.ndarray hetaBT, - numpy.ndarray hwBT, - int lstage, - numpy.ndarray new_SourceTerm_hu, - numpy.ndarray new_SourceTerm_hv, - numpy.ndarray new_SourceTerm_heta, - numpy.ndarray new_SourceTerm_hw): - self.thisptr.calculateResidual(< double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > h_dof_old.data, - < double * > hu_dof_old.data, - < double * > hv_dof_old.data, - < double * > heta_dof_old.data, - < double * > hw_dof_old.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > heta_dof.data, - < double * > hw_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > heta_dof_sge.data, - < double * > hw_dof_sge.data, - < double * > q_mass_acc.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mass_adv.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - offset_h, - offset_u, - offset_v, - offset_eta, - offset_w, - stride_h, - stride_u, - stride_v, - stride_eta, - stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_h.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > CTx.data, - < double * > CTy.data, - numDOFsPerEqn, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > lumped_mass_matrix.data, - cfl_run, - hEps, - < double * > hReg.data, - < double * > hnp1_at_quad_point.data, - < double * > hunp1_at_quad_point.data, - < double * > hvnp1_at_quad_point.data, - < double * > hetanp1_at_quad_point.data, - < double * > hwnp1_at_quad_point.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > extendedSourceTerm_heta.data, - < double * > extendedSourceTerm_hw.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - cE, - LUMPED_MASS_MATRIX, - dt, - LINEAR_FRICTION, - mannings, - < double * > quantDOFs.data, - SECOND_CALL_CALCULATE_RESIDUAL, - COMPUTE_NORMALS, - < double * > normalx.data, - < double * > normaly.data, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data, - < double * > hetaBT.data, - < double * > hwBT.data, - lstage, - < double * > new_SourceTerm_hu.data, - < double * > new_SourceTerm_hv.data, - < double * > new_SourceTerm_heta.data, - < double * > new_SourceTerm_hw.data) - def calculateMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray heta_dof, - numpy.ndarray hw_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray heta_dof_sge, - numpy.ndarray hw_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_h_eta, - numpy.ndarray csrColumnOffsets_h_eta, - numpy.ndarray csrRowIndeces_h_w, - numpy.ndarray csrColumnOffsets_h_w, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_eta, - numpy.ndarray csrColumnOffsets_u_eta, - numpy.ndarray csrRowIndeces_u_w, - numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_eta, - numpy.ndarray csrColumnOffsets_v_eta, - numpy.ndarray csrRowIndeces_v_w, - numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_eta_h, - numpy.ndarray csrColumnOffsets_eta_h, - numpy.ndarray csrRowIndeces_eta_u, - numpy.ndarray csrColumnOffsets_eta_u, - numpy.ndarray csrRowIndeces_eta_v, - numpy.ndarray csrColumnOffsets_eta_v, - numpy.ndarray csrRowIndeces_eta_eta, - numpy.ndarray csrColumnOffsets_eta_eta, - numpy.ndarray csrRowIndeces_eta_w, - numpy.ndarray csrColumnOffsets_eta_w, - numpy.ndarray csrRowIndeces_w_h, - numpy.ndarray csrColumnOffsets_w_h, - numpy.ndarray csrRowIndeces_w_u, - numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, - numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_eta, - numpy.ndarray csrColumnOffsets_w_eta, - numpy.ndarray csrRowIndeces_w_w, - numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - double dt): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateMassMatrix(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > heta_dof.data, - < double * > hw_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > heta_dof_sge.data, - < double * > hw_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_h_eta.data, - < int * > csrColumnOffsets_h_eta.data, - < int * > csrRowIndeces_h_w.data, - < int * > csrColumnOffsets_h_w.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_eta.data, - < int * > csrColumnOffsets_u_eta.data, - < int * > csrRowIndeces_u_w.data, - < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_eta.data, - < int * > csrColumnOffsets_v_eta.data, - < int * > csrRowIndeces_v_w.data, - < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_eta_h.data, - < int * > csrColumnOffsets_eta_h.data, - < int * > csrRowIndeces_eta_u.data, - < int * > csrColumnOffsets_eta_u.data, - < int * > csrRowIndeces_eta_v.data, - < int * > csrColumnOffsets_eta_v.data, - < int * > csrRowIndeces_eta_eta.data, - < int * > csrColumnOffsets_eta_eta.data, - < int * > csrRowIndeces_eta_w.data, - < int * > csrColumnOffsets_eta_w.data, - < int * > csrRowIndeces_w_h.data, - < int * > csrColumnOffsets_w_h.data, - < int * > csrRowIndeces_w_u.data, - < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, - < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_eta.data, - < int * > csrColumnOffsets_w_eta.data, - < int * > csrRowIndeces_w_w.data, - < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - dt) - - def calculateLumpedMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_h_eta, - numpy.ndarray csrColumnOffsets_h_eta, - numpy.ndarray csrRowIndeces_h_w, - numpy.ndarray csrColumnOffsets_h_w, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_eta, - numpy.ndarray csrColumnOffsets_u_eta, - numpy.ndarray csrRowIndeces_u_w, - numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_eta, - numpy.ndarray csrColumnOffsets_v_eta, - numpy.ndarray csrRowIndeces_v_w, - numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_eta_h, - numpy.ndarray csrColumnOffsets_eta_h, - numpy.ndarray csrRowIndeces_eta_u, - numpy.ndarray csrColumnOffsets_eta_u, - numpy.ndarray csrRowIndeces_eta_v, - numpy.ndarray csrColumnOffsets_eta_v, - numpy.ndarray csrRowIndeces_eta_eta, - numpy.ndarray csrColumnOffsets_eta_eta, - numpy.ndarray csrRowIndeces_eta_w, - numpy.ndarray csrColumnOffsets_eta_w, - numpy.ndarray csrRowIndeces_w_h, - numpy.ndarray csrColumnOffsets_w_h, - numpy.ndarray csrRowIndeces_w_u, - numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, - numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_eta, - numpy.ndarray csrColumnOffsets_w_eta, - numpy.ndarray csrRowIndeces_w_w, - numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - double dt): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateLumpedMassMatrix(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_h_eta.data, - < int * > csrColumnOffsets_h_eta.data, - < int * > csrRowIndeces_h_w.data, - < int * > csrColumnOffsets_h_w.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_eta.data, - < int * > csrColumnOffsets_u_eta.data, - < int * > csrRowIndeces_u_w.data, - < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_eta.data, - < int * > csrColumnOffsets_v_eta.data, - < int * > csrRowIndeces_v_w.data, - < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_eta_h.data, - < int * > csrColumnOffsets_eta_h.data, - < int * > csrRowIndeces_eta_u.data, - < int * > csrColumnOffsets_eta_u.data, - < int * > csrRowIndeces_eta_v.data, - < int * > csrColumnOffsets_eta_v.data, - < int * > csrRowIndeces_eta_eta.data, - < int * > csrColumnOffsets_eta_eta.data, - < int * > csrRowIndeces_eta_w.data, - < int * > csrColumnOffsets_eta_w.data, - < int * > csrRowIndeces_w_h.data, - < int * > csrColumnOffsets_w_h.data, - < int * > csrRowIndeces_w_u.data, - < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, - < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_eta.data, - < int * > csrColumnOffsets_w_eta.data, - < int * > csrRowIndeces_w_w.data, - < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - dt) diff --git a/proteus/mprans/cKappa.pyx b/proteus/mprans/cKappa.pyx deleted file mode 100644 index 230c121465..0000000000 --- a/proteus/mprans/cKappa.pyx +++ /dev/null @@ -1,598 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "Kappa.h" namespace "proteus": - cdef cppclass Kappa_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_dissipation, # dissipation rate variable - double * q_grad_dissipation, - double * q_porosity, # VRANS - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_dissipation, # dissipation rate - double * ebqe_porosity, # VRANS - double * ebqe_u, - double * ebqe_flux) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffuion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_dissipation, # dissipation rate - double * q_grad_dissipation, - double * q_porosity, # VRANS -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - int * csrColumnOffsets_eb_u_u, - double * ebqe_phi, double epsFact, - double * ebqe_dissipation, # dissipation rate - double * ebqe_porosity) # VRANS - Kappa_base * newKappa(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter) - -cdef class cKappa_base: - cdef Kappa_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter): - - self.thisptr = newKappa(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter) - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_dissipation, # dissipation rate - numpy.ndarray q_grad_dissipation, # VRANS - numpy.ndarray q_porosity, # VRANS - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_dissipation, # dissipation rate - numpy.ndarray ebqe_porosity, # VRANS - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - rho_0, - rho_1, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - dissipation_model_flag, - # end diffuion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_dissipation.data, # dissipation rate - < double * > q_grad_dissipation.data, # VRANS - < double * > q_porosity.data, # VRANS - # velocity dof - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dof - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_dissipation.data, # dissipation rate on boundary - < double * > ebqe_porosity.data, # VRANS - < double * > ebqe_u.data, - < double * > ebqe_flux.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_dissipation, # dissipation rate - numpy.ndarray q_grad_dissipation, # VRANS - numpy.ndarray q_porosity, # VRANS - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray ebqe_phi, - double epsFact, - numpy.ndarray ebqe_dissipation, # dissipation rate - numpy.ndarray ebqe_porosity): # VRANS - - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - rho_0, - rho_1, - dissipation_model_flag, - # end diffusion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_dissipation.data, - < double * > q_grad_dissipation.data, - < double * > q_porosity.data, # VRANS - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - # velocity dofs - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dofs - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - < double * > ebqe_phi.data, epsFact, - < double * > ebqe_dissipation.data, - < double * > ebqe_porosity.data) # VRANS diff --git a/proteus/mprans/cKappa2D.pyx b/proteus/mprans/cKappa2D.pyx deleted file mode 100644 index c8ed52f4d8..0000000000 --- a/proteus/mprans/cKappa2D.pyx +++ /dev/null @@ -1,598 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "Kappa2D.h" namespace "proteus": - cdef cppclass Kappa2D_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_dissipation, # dissipation rate variable - double * q_grad_dissipation, - double * q_porosity, # VRANS - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_dissipation, # dissipation rate - double * ebqe_porosity, # VRANS - double * ebqe_u, - double * ebqe_flux) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffuion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * phi_ls, # level set variable - double * q_dissipation, # dissipation rate - double * q_grad_dissipation, - double * q_porosity, # VRANS -#Sediment model - double sedFlag, - double* q_vos, - double *q_vos_gradc, - double* ebqe_q_vos, - double *ebqe_q_vos_gradc, - double rho_f, - double rho_s, - double* vs, - double* ebqe_vs, - double* g, -#end Sediment - # velocity dof - double * velocity_dof_u, - double * velocity_dof_v, - double * velocity_dof_w, - # end velocity dof - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - double * ebqe_penalty_ext, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isAdvectiveFluxBoundary_u, - double * ebqe_bc_advectiveFlux_u_ext, - int * isDiffusiveFluxBoundary_u, - double * ebqe_bc_diffusiveFlux_u_ext, - int * csrColumnOffsets_eb_u_u, - double * ebqe_phi, double epsFact, - double * ebqe_dissipation, # dissipation rate - double * ebqe_porosity) # VRANS - Kappa2D_base * newKappa2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter) - -cdef class cKappa2D_base: - cdef Kappa2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter): - - self.thisptr = newKappa2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter) - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion terms - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_dissipation, # dissipation rate - numpy.ndarray q_grad_dissipation, # VRANS - numpy.ndarray q_porosity, # VRANS - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_dissipation, # dissipation rate - numpy.ndarray ebqe_porosity, # VRANS - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - rho_0, - rho_1, - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - dissipation_model_flag, - # end diffuion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_dissipation.data, # dissipation rate - < double * > q_grad_dissipation.data, # VRANS - < double * > q_porosity.data, # VRANS - # velocity dof - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dof - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_dissipation.data, # dissipation rate on boundary - < double * > ebqe_porosity.data, # VRANS - < double * > ebqe_u.data, - < double * > ebqe_flux.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - # diffusion - double nu_0, - double nu_1, - double sigma_k, - double c_mu, - double rho_0, - double rho_1, - int dissipation_model_flag, - # end diffusion - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray phi_ls, # level set variable - numpy.ndarray q_dissipation, # dissipation rate - numpy.ndarray q_grad_dissipation, # VRANS - numpy.ndarray q_porosity, # VRANS - # Argumentlist for sediment - double sedFlag, - numpy.ndarray q_vos, - numpy.ndarray q_vos_gradc, - numpy.ndarray ebqe_q_vos, - numpy.ndarray ebqe_q_vos_gradc, - double rho_f, - double rho_s, - numpy.ndarray vs, - numpy.ndarray ebqe_vs, - numpy.ndarray g, - # end for sediment - # velocity dof - numpy.ndarray velocity_dof_u, - numpy.ndarray velocity_dof_v, - numpy.ndarray velocity_dof_w, - # end velocity dof - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray ebqe_bc_advectiveFlux_u_ext, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray ebqe_bc_diffusiveFlux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray ebqe_phi, - double epsFact, - numpy.ndarray ebqe_dissipation, # dissipation rate - numpy.ndarray ebqe_porosity): # VRANS - - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - # diffusion - nu_0, - nu_1, - sigma_k, - c_mu, - rho_0, - rho_1, - dissipation_model_flag, - # end diffusion - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, < double * > u_dof_old.data, - < double * > velocity.data, - < double * > phi_ls.data, - < double * > q_dissipation.data, - < double * > q_grad_dissipation.data, - < double * > q_porosity.data, # VRANS - # Argumentlist for sediment - sedFlag, - < double * > q_vos.data, - < double * > q_vos_gradc.data, - < double * > ebqe_q_vos.data, - < double * > ebqe_q_vos_gradc.data, - rho_f, - rho_s, - < double * > vs.data, - < double * > ebqe_vs.data, - < double * > g.data, - # end for sediment - # velocity dofs - < double * > velocity_dof_u.data, - < double * > velocity_dof_v.data, - < double * > velocity_dof_w.data, - # end velocity dofs - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < double * > ebqe_penalty_ext.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isAdvectiveFluxBoundary_u.data, - < double * > ebqe_bc_advectiveFlux_u_ext.data, - < int * > isDiffusiveFluxBoundary_u.data, - < double * > ebqe_bc_diffusiveFlux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - < double * > ebqe_phi.data, epsFact, - < double * > ebqe_dissipation.data, - < double * > ebqe_porosity.data) # VRANS diff --git a/proteus/mprans/cMCorr.pyx b/proteus/mprans/cMCorr.pyx deleted file mode 100644 index 888347416d..0000000000 --- a/proteus/mprans/cMCorr.pyx +++ /dev/null @@ -1,1314 +0,0 @@ -# A type of -*- python -*- file -from libcpp cimport bool -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "MCorr.h" namespace "proteus": - cdef cppclass MCorr_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - bool useExact) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * q_H, - double * q_porosity, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - bool useExact) - void elementSolve(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol) - void elementConstantSolve(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol) - void globalConstantRJ(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol, - double constant_u, - double * constantResidual, - double * consdtantJacobian) - void calculateMass(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * globalMass, - bool useExact) - void setMassQuadrature(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * phi_l2g, - double * elementDiameter, - double * nodeDiamaetersArray, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * H_dof, - bool useExact) - void FCTStep(int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * solH, - double * solL, - double * limited_solution, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix) - void calculateMassMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * q_H, - double * q_porosity, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalMassMatrix, - double * globalLumpedMassMatrix) - void setMassQuadratureEdgeBasedStabilizationMethods(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double* x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * phi_l2g, - double * elementDiameter, - double * nodeDiamaetersArray, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_porosity, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * rhs_mass_correction, - double * lumped_L2p_vof_mass_correction, - double * lumped_mass_matrix, - int numDOFs, - bool useExact) - MCorr_base * newMCorr(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cMCorr_base: - cdef MCorr_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newMCorr(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - bool useExact): - self.thisptr.calculateResidual( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_porosity.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - useExact) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_porosity, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - bool useExact): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > q_H.data, - < double * > q_porosity.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - useExact) - def elementSolve(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol): - self.thisptr.elementSolve( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - u_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol) - def elementConstantSolve(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol): - self.thisptr.elementConstantSolve( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - u_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol) - def globalConstantRJ(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol, - double constant_u): - cdef double constantResidual - cdef double constantJacobian - self.thisptr.globalConstantRJ( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_owned, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - u_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol, - constant_u, - &constantResidual, - &constantJacobian) - return (constantResidual,constantJacobian) - def calculateMass(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - bool useExact): - cdef double globalMass - self.thisptr.calculateMass( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - x_ref.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_owned, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - u_dof.data, - phi_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - &globalMass, - useExact) - return globalMass - def setMassQuadrature(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray phi_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray H_dof, - bool useExact): - self.thisptr.setMassQuadrature( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - x_ref.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - phi_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - phi_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - H_dof.data, - useExact) - def FCTStep(self, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray solH, - numpy.ndarray solL, - numpy.ndarray limited_solution, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix): - self.thisptr.FCTStep(NNZ, - numDOFs, - lumped_mass_matrix.data, - solH.data, - solL.data, - limited_solution.data, - csrRowIndeces_DofLoops.data, - csrColumnOffsets_DofLoops.data, - MassMatrix.data) - def calculateMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_porosity, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalMassMatrix, - numpy.ndarray globalLumpedMassMatrix): - cdef numpy.ndarray rowptr,colind,globalMassMatrix_a - (rowptr,colind,globalMassMatrix_a) = globalMassMatrix.getCSRrepresentation() - self.thisptr.calculateMassMatrix( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - u_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - u_dof.data, - q_phi.data, - q_normal_phi.data, - q_H.data, - q_porosity.data, - csrRowIndeces_u_u.data, - csrColumnOffsets_u_u.data, - globalMassMatrix_a.data, - globalLumpedMassMatrix.data) - def setMassQuadratureEdgeBasedStabilizationMethods(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray phi_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_porosity, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray rhs_mass_correction, - numpy.ndarray lumped_L2p_vof_mass_correction, - numpy.ndarray lumped_mass_matrix, - int numDOFs, - bool useExact): - self.thisptr.setMassQuadratureEdgeBasedStabilizationMethods( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - x_ref.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - phi_l2g.data, - elementDiameter.data, - nodeDiametersArray.data, - phi_dof.data, - q_phi.data, - q_normal_phi.data, - ebqe_phi.data, - ebqe_normal_phi.data, - q_H.data, - q_u.data, - q_n.data, - ebqe_u.data, - ebqe_n.data, - q_r.data, - q_porosity.data, - offset_u, - stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - rhs_mass_correction.data, - lumped_L2p_vof_mass_correction.data, - lumped_mass_matrix.data, - numDOFs, - useExact) diff --git a/proteus/mprans/cMCorr3P.pyx b/proteus/mprans/cMCorr3P.pyx deleted file mode 100644 index c1872dbd87..0000000000 --- a/proteus/mprans/cMCorr3P.pyx +++ /dev/null @@ -1,1056 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy - -cdef extern from "mprans/MCorr3P.h" namespace "proteus": - cdef cppclass cppMCorr3P_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * interface_lumpedMassMatrix) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * q_H, - double * q_vos, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int numDOFs, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * stiffness_matrix, - double * interface_lumpedMassMatrix) - void elementSolve(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol) - void elementConstantSolve(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol) - void globalConstantRJ(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol, - double constant_u, - double * constantResidual, - double * consdtantJacobian) - void calculateMass(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * globalMass) - void setMassQuadrature(double * mesh_trial_ip, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * phi_l2g, - double * elementDiameter, - double * nodeDiamaetersArray, - double * phi_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * H_dof) - void calculateStiffnessMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_grad_trial_ref, - int nElements_global, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - double useMetrics, - double epsFactDiffusion, - double * elementDiameter, - double * nodeDiametersArray) - cppMCorr3P_base * newMCorr3P(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class MCorr3P: - cdef cppMCorr3P_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newMCorr3P(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray interface_lumpedMassMatrix): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > interface_lumpedMassMatrix.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_vos, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int numDOFs, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray stiffness_matrix, - numpy.ndarray interface_lumpedMassMatrix): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > q_H.data, - < double * > q_vos.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - numDOFs, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > stiffness_matrix.data, - < double * > interface_lumpedMassMatrix.data) - - def elementSolve(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol): - self.thisptr.elementSolve(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol) - - def elementConstantSolve(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol): - self.thisptr.elementConstantSolve(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol) - - def globalConstantRJ(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int maxIts, - double atol, - double constant_u): - cdef double constantResidual - cdef double constantJacobian - self.thisptr.globalConstantRJ(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_owned, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - maxIts, - atol, - constant_u, - & constantResidual, - & constantJacobian) - return (constantResidual, constantJacobian) - - def calculateMass(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_owned, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray): - cdef double globalMass - self.thisptr.calculateMass(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_owned, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - & globalMass) - return globalMass - - def setMassQuadrature(self, - numpy.ndarray mesh_trial_ip, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray phi_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray phi_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray H_dof): - self.thisptr.setMassQuadrature(< double*> mesh_trial_ip.data, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > phi_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > phi_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > H_dof.data) - def calculateStiffnessMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_grad_trial_ref, - int nElements_global, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - double useMetrics, - double epsFactDiffusion, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateStiffnessMatrix(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_grad_trial_ref.data, - nElements_global, - < int*> csrRowIndeces_u_u.data, - < int*> csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - useMetrics, - epsFactDiffusion, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data) diff --git a/proteus/mprans/cMoveMesh.pyx b/proteus/mprans/cMoveMesh.pyx deleted file mode 100644 index ab3e4d1f7c..0000000000 --- a/proteus/mprans/cMoveMesh.pyx +++ /dev/null @@ -1,346 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "MoveMesh.h" namespace "proteus": - cdef cppclass MoveMesh_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * disp_trial_ref, - double * disp_grad_trial_ref, - double * disp_test_ref, - double * disp_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * disp_trial_trace_ref, - double * disp_grad_trial_trace_ref, - double * disp_test_trace_ref, - double * disp_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * materialTypes, - int nMaterialProperties, - double * materialProperties, - int * disp_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isStressFluxBoundary_u, - int * isStressFluxBoundary_v, - int * isStressFluxBoundary_w, - double * ebqe_bc_u_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_stressFlux_u_ext, - double * ebqe_bc_stressFlux_v_ext, - double * ebqe_bc_stressFlux_w_ext) - - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * disp_trial_ref, - double * disp_grad_trial_ref, - double * disp_test_ref, - double * disp_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * disp_trial_trace_ref, - double * disp_grad_trial_trace_ref, - double * disp_test_trace_ref, - double * disp_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * materialTypes, - int nMaterialProperties, - double * materialProperties, - int * disp_l2g, - double * u_dof, double * v_dof, double * w_dof, - double * bodyForce, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isStressFluxBoundary_u, - int * isStressFluxBoundary_v, - int * isStressFluxBoundary_w, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w) - - MoveMesh_base * newMoveMesh(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cMoveMesh_base: - cdef MoveMesh_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newMoveMesh(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_stressFlux_u_ext, - numpy.ndarray ebqe_bc_stressFlux_v_ext, - numpy.ndarray ebqe_bc_stressFlux_w_ext): - self.thisptr.calculateResidual(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >disp_trial_ref.data, - < double * >disp_grad_trial_ref.data, - < double * >disp_test_ref.data, - < double * >disp_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >disp_trial_trace_ref.data, - < double * >disp_grad_trial_trace_ref.data, - < double * >disp_test_trace_ref.data, - < double * >disp_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - < int * >materialTypes.data, - nMaterialProperties, - < double * >materialProperties.data, - < int * >disp_l2g.data, - < double * >u_dof.data, - < double * >v_dof.data, - < double * >w_dof.data, - < double * >bodyForce.data, - offset_u, offset_v, offset_w, - stride_u, stride_v, stride_w, - < double * >globalResidual.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >isDOFBoundary_u.data, - < int * >isDOFBoundary_v.data, - < int * >isDOFBoundary_w.data, - < int * >isStressFluxBoundary_u.data, - < int * >isStressFluxBoundary_v.data, - < int * >isStressFluxBoundary_w.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_bc_v_ext.data, - < double * >ebqe_bc_w_ext.data, - < double * >ebqe_bc_stressFlux_u_ext.data, - < double * >ebqe_bc_stressFlux_v_ext.data, - < double * >ebqe_bc_stressFlux_w_ext.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray bodyForce, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >disp_trial_ref.data, - < double * >disp_grad_trial_ref.data, - < double * >disp_test_ref.data, - < double * >disp_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >disp_trial_trace_ref.data, - < double * >disp_grad_trial_trace_ref.data, - < double * >disp_test_trace_ref.data, - < double * >disp_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - < int * >materialTypes.data, - nMaterialProperties, - < double * >materialProperties.data, - < int * >disp_l2g.data, - < double*>u_dof.data, < double*>v_dof.data, < double*>w_dof.data, - < double * >bodyForce.data, - < int*>csrRowIndeces_u_u.data, < int*>csrColumnOffsets_u_u.data, - < int*>csrRowIndeces_u_v.data, < int*>csrColumnOffsets_u_v.data, - < int*>csrRowIndeces_u_w.data, < int*>csrColumnOffsets_u_w.data, - < int*>csrRowIndeces_v_u.data, < int*>csrColumnOffsets_v_u.data, - < int*>csrRowIndeces_v_v.data, < int*>csrColumnOffsets_v_v.data, - < int*>csrRowIndeces_v_w.data, < int*>csrColumnOffsets_v_w.data, - < int*>csrRowIndeces_w_u.data, < int*>csrColumnOffsets_w_u.data, - < int*>csrRowIndeces_w_v.data, < int*>csrColumnOffsets_w_v.data, - < int*>csrRowIndeces_w_w.data, < int*>csrColumnOffsets_w_w.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >isDOFBoundary_u.data, - < int * >isDOFBoundary_v.data, - < int * >isDOFBoundary_w.data, - < int * >isStressFluxBoundary_u.data, - < int * >isStressFluxBoundary_v.data, - < int * >isStressFluxBoundary_w.data, - < int * >csrColumnOffsets_eb_u_u.data, - < int * >csrColumnOffsets_eb_u_v.data, - < int * >csrColumnOffsets_eb_u_w.data, - < int * >csrColumnOffsets_eb_v_u.data, - < int * >csrColumnOffsets_eb_v_v.data, - < int * >csrColumnOffsets_eb_v_w.data, - < int * >csrColumnOffsets_eb_w_u.data, - < int * >csrColumnOffsets_eb_w_v.data, - < int * >csrColumnOffsets_eb_w_w.data) diff --git a/proteus/mprans/cMoveMesh2D.pyx b/proteus/mprans/cMoveMesh2D.pyx deleted file mode 100644 index 9ebdc1aa1a..0000000000 --- a/proteus/mprans/cMoveMesh2D.pyx +++ /dev/null @@ -1,346 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "MoveMesh2D.h" namespace "proteus": - cdef cppclass MoveMesh2D_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * disp_trial_ref, - double * disp_grad_trial_ref, - double * disp_test_ref, - double * disp_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * disp_trial_trace_ref, - double * disp_grad_trial_trace_ref, - double * disp_test_trace_ref, - double * disp_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * materialTypes, - int nMaterialProperties, - double * materialProperties, - int * disp_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isStressFluxBoundary_u, - int * isStressFluxBoundary_v, - int * isStressFluxBoundary_w, - double * ebqe_bc_u_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_stressFlux_u_ext, - double * ebqe_bc_stressFlux_v_ext, - double * ebqe_bc_stressFlux_w_ext) - - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * disp_trial_ref, - double * disp_grad_trial_ref, - double * disp_test_ref, - double * disp_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * disp_trial_trace_ref, - double * disp_grad_trial_trace_ref, - double * disp_test_trace_ref, - double * disp_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * materialTypes, - int nMaterialProperties, - double * materialProperties, - int * disp_l2g, - double * u_dof, double * v_dof, double * w_dof, - double * bodyForce, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isStressFluxBoundary_u, - int * isStressFluxBoundary_v, - int * isStressFluxBoundary_w, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w) - - MoveMesh2D_base * newMoveMesh2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cMoveMesh2D_base: - cdef MoveMesh2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newMoveMesh2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray bodyForce, - int offset_u, int offset_v, int offset_w, - int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_stressFlux_u_ext, - numpy.ndarray ebqe_bc_stressFlux_v_ext, - numpy.ndarray ebqe_bc_stressFlux_w_ext): - self.thisptr.calculateResidual(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >disp_trial_ref.data, - < double * >disp_grad_trial_ref.data, - < double * >disp_test_ref.data, - < double * >disp_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >disp_trial_trace_ref.data, - < double * >disp_grad_trial_trace_ref.data, - < double * >disp_test_trace_ref.data, - < double * >disp_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - < int * >materialTypes.data, - nMaterialProperties, - < double * >materialProperties.data, - < int * >disp_l2g.data, - < double * >u_dof.data, - < double * >v_dof.data, - < double * >w_dof.data, - < double * >bodyForce.data, - offset_u, offset_v, offset_w, - stride_u, stride_v, stride_w, - < double * >globalResidual.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >isDOFBoundary_u.data, - < int * >isDOFBoundary_v.data, - < int * >isDOFBoundary_w.data, - < int * >isStressFluxBoundary_u.data, - < int * >isStressFluxBoundary_v.data, - < int * >isStressFluxBoundary_w.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_bc_v_ext.data, - < double * >ebqe_bc_w_ext.data, - < double * >ebqe_bc_stressFlux_u_ext.data, - < double * >ebqe_bc_stressFlux_v_ext.data, - < double * >ebqe_bc_stressFlux_w_ext.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray disp_trial_ref, - numpy.ndarray disp_grad_trial_ref, - numpy.ndarray disp_test_ref, - numpy.ndarray disp_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray disp_trial_trace_ref, - numpy.ndarray disp_grad_trial_trace_ref, - numpy.ndarray disp_test_trace_ref, - numpy.ndarray disp_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray materialTypes, - int nMaterialProperties, - numpy.ndarray materialProperties, - numpy.ndarray disp_l2g, - numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray bodyForce, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isStressFluxBoundary_u, - numpy.ndarray isStressFluxBoundary_v, - numpy.ndarray isStressFluxBoundary_w, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >disp_trial_ref.data, - < double * >disp_grad_trial_ref.data, - < double * >disp_test_ref.data, - < double * >disp_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >disp_trial_trace_ref.data, - < double * >disp_grad_trial_trace_ref.data, - < double * >disp_test_trace_ref.data, - < double * >disp_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - < int * >materialTypes.data, - nMaterialProperties, - < double * >materialProperties.data, - < int * >disp_l2g.data, - < double*>u_dof.data, < double*>v_dof.data, < double*>w_dof.data, - < double * >bodyForce.data, - < int*>csrRowIndeces_u_u.data, < int*>csrColumnOffsets_u_u.data, - < int*>csrRowIndeces_u_v.data, < int*>csrColumnOffsets_u_v.data, - < int*>csrRowIndeces_u_w.data, < int*>csrColumnOffsets_u_w.data, - < int*>csrRowIndeces_v_u.data, < int*>csrColumnOffsets_v_u.data, - < int*>csrRowIndeces_v_v.data, < int*>csrColumnOffsets_v_v.data, - < int*>csrRowIndeces_v_w.data, < int*>csrColumnOffsets_v_w.data, - < int*>csrRowIndeces_w_u.data, < int*>csrColumnOffsets_w_u.data, - < int*>csrRowIndeces_w_v.data, < int*>csrColumnOffsets_w_v.data, - < int*>csrRowIndeces_w_w.data, < int*>csrColumnOffsets_w_w.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >isDOFBoundary_u.data, - < int * >isDOFBoundary_v.data, - < int * >isDOFBoundary_w.data, - < int * >isStressFluxBoundary_u.data, - < int * >isStressFluxBoundary_v.data, - < int * >isStressFluxBoundary_w.data, - < int * >csrColumnOffsets_eb_u_u.data, - < int * >csrColumnOffsets_eb_u_v.data, - < int * >csrColumnOffsets_eb_u_w.data, - < int * >csrColumnOffsets_eb_v_u.data, - < int * >csrColumnOffsets_eb_v_v.data, - < int * >csrColumnOffsets_eb_v_w.data, - < int * >csrColumnOffsets_eb_w_u.data, - < int * >csrColumnOffsets_eb_w_v.data, - < int * >csrColumnOffsets_eb_w_w.data) diff --git a/proteus/mprans/cNCLS.pyx b/proteus/mprans/cNCLS.pyx deleted file mode 100644 index 4912482ca2..0000000000 --- a/proteus/mprans/cNCLS.pyx +++ /dev/null @@ -1,1294 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "NCLS.h" namespace "proteus": - cdef cppclass NCLS_base: - void calculateResidual(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * nodeDiametersArray, - int degree_polynomial, - double * u_dof, - double * u_dof_old, - double * uStar_dof, - double * velocity, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - double * ebqe_u, - double * ebqe_grad_u, - double * interface_locator, - int PURE_BDF, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - int LUMPED_MASS_MATRIX, - double * quantDOFs, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - int COUPEZ, - int SATURATED_LEVEL_SET, - double * Cx, - double * Cy, - double * Cz, - double * ML, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double cE - ) - void calculateJacobian(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - int PURE_BDF, - int LUMPED_MASS_MATRIX) - void calculateWaterline(int * wlc, - double * waterline, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * elementBoundaryMaterialTypes, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - double * ebqe_u) - double calculateRedistancingResidual(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - int nElements_global, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * u_dof_old, - double * uStar_dof, - int offset_u, int stride_u, - double * globalResidual, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - double * edge_based_cfl, - int SATURATED_LEVEL_SET, - double * Cx, - double * Cy, - double * Cz, - double * ML) - double calculateRhsSmoothing(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - int nElements_global, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof_old, - int offset_u, int stride_u, - double * globalResidual) - void calculateResidual_entropy_viscosity(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * nodeDiametersArray, - int degree_polynomial, - double * u_dof, - double * u_dof_old, - double * uStar_dof, - double * velocity, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - double * ebqe_u, - double * ebqe_grad_u, - double * interface_locator, - int PURE_BDF, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - int LUMPED_MASS_MATRIX, - double * quantDOFs, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - int COUPEZ, - int SATURATED_LEVEL_SET, - double * Cx, - double * Cy, - double * Cz, - double * ML, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double cE - ) - void calculateMassMatrix(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - int PURE_BDF, - int LUMPED_MASS_MATRIX) - void calculateSmoothingMatrix(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - double he) - - NCLS_base * newNCLS(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cNCLS_base: - cdef NCLS_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newNCLS(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray uStar_dof, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_grad_u, - numpy.ndarray interface_locator, - int PURE_BDF, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - int LUMPED_MASS_MATRIX, - numpy.ndarray quantDOFs, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - int COUPEZ, - int SATURATED_LEVEL_SET, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray Cz, - numpy.ndarray ML, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double cE): - self.thisptr.calculateResidual(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - < double * >nodeDiametersArray.data, - degree_polynomial, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >uStar_dof.data, - < double * >velocity.data, - < double * >q_m.data, - < double * >q_u.data, - < double * >q_n.data, - < double * >q_dH.data, - < double * >q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * >cfl.data, - < double * >edge_based_cfl.data, - < double * >q_numDiff_u.data, - < double * >q_numDiff_u_last.data, - offset_u, - stride_u, - < double * >globalResidual.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_u.data, - < double * >ebqe_grad_u.data, - < double * >interface_locator.data, - PURE_BDF, - numDOFs, - NNZ, - < int * >csrRowIndeces_DofLoops.data, - < int * >csrColumnOffsets_DofLoops.data, - < int * >csrRowIndeces_CellLoops.data, - < int * >csrColumnOffsets_CellLoops.data, - < int * >csrColumnOffsets_eb_CellLoops.data, - LUMPED_MASS_MATRIX, - < double * > quantDOFs.data, - lambda_coupez, - epsCoupez, - epsFactRedistancing, - COUPEZ, - SATURATED_LEVEL_SET, - < double * > Cx.data, - < double * > Cy.data, - < double * > Cz.data, - < double * > ML.data, - STABILIZATION_TYPE, - ENTROPY_TYPE, - cE) - - def calculateJacobian(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int PURE_BDF, - int LUMPED_MASS_MATRIX): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - degree_polynomial, - < double * >u_dof.data, - < double * >velocity.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u_last.data, - < int * >csrRowIndeces_u_u.data, < int * >csrColumnOffsets_u_u.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < int * >csrColumnOffsets_eb_u_u.data, - PURE_BDF, - LUMPED_MASS_MATRIX) - - def calculateWaterline(self, - numpy.ndarray wlc, - numpy.ndarray waterline, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray elementBoundaryMaterialTypes, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u): - self.thisptr.calculateWaterline(< int*>wlc.data, - < double * >waterline.data, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >velocity.data, - < double * >q_m.data, - < double * >q_u.data, - < double * >q_n.data, - < double * >q_dH.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u.data, - < double * >q_numDiff_u_last.data, - offset_u, - stride_u, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >elementBoundaryMaterialTypes.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_u.data) - - def calculateRedistancingResidual(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray uStar_dof, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - numpy.ndarray edge_based_cfl, - int SATURATED_LEVEL_SET, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray Cz, - numpy.ndarray ML): - return self.thisptr.calculateRedistancingResidual(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - nElements_global, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - < double * >nodeDiametersArray.data, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >uStar_dof.data, - offset_u, - stride_u, - < double * >globalResidual.data, - numDOFs, - NNZ, - < int * >csrRowIndeces_DofLoops.data, - < int * >csrColumnOffsets_DofLoops.data, - < int * >csrRowIndeces_CellLoops.data, - < int * >csrColumnOffsets_CellLoops.data, - lambda_coupez, - epsCoupez, - epsFactRedistancing, - < double * >edge_based_cfl.data, - SATURATED_LEVEL_SET, - < double * >Cx.data, - < double * >Cy.data, - < double * >Cz.data, - < double * >ML.data) - - def calculateRhsSmoothing(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof_old, - int offset_u, int stride_u, - numpy.ndarray globalResidual): - return self.thisptr.calculateRhsSmoothing(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - nElements_global, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - < double * >nodeDiametersArray.data, - < double * >u_dof_old.data, - offset_u, - stride_u, - < double * >globalResidual.data) - - def calculateResidual_entropy_viscosity(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray uStar_dof, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_grad_u, - numpy.ndarray interface_locator, - int PURE_BDF, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - int LUMPED_MASS_MATRIX, - numpy.ndarray quantDOFs, - double lambda_coupez, - double epsCoupez, - double epsFactRedistancing, - int COUPEZ, - int SATURATED_LEVEL_SET, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray Cz, - numpy.ndarray ML, - int STABILIZATION_TYPE, - ENTROPY_TYPE, - double cE): - self.thisptr.calculateResidual_entropy_viscosity(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - < double * >nodeDiametersArray.data, - degree_polynomial, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >uStar_dof.data, - < double * >velocity.data, - < double * >q_m.data, - < double * >q_u.data, - < double * >q_n.data, - < double * >q_dH.data, - < double * >q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * >cfl.data, - < double * >edge_based_cfl.data, - < double * >q_numDiff_u.data, - < double * >q_numDiff_u_last.data, - offset_u, - stride_u, - < double * >globalResidual.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_u.data, - < double * >ebqe_grad_u.data, - < double * >interface_locator.data, - PURE_BDF, - numDOFs, - NNZ, - < int * >csrRowIndeces_DofLoops.data, - < int * >csrColumnOffsets_DofLoops.data, - < int * >csrRowIndeces_CellLoops.data, - < int * >csrColumnOffsets_CellLoops.data, - < int * >csrColumnOffsets_eb_CellLoops.data, - LUMPED_MASS_MATRIX, - < double * > quantDOFs.data, - lambda_coupez, - epsCoupez, - epsFactRedistancing, - COUPEZ, - SATURATED_LEVEL_SET, - < double * > Cx.data, - < double * > Cy.data, - < double * > Cz.data, - < double * > ML.data, - STABILIZATION_TYPE, - ENTROPY_TYPE, - cE) - - def calculateMassMatrix(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int PURE_BDF, - int LUMPED_MASS_MATRIX): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateMassMatrix(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - degree_polynomial, - < double * >u_dof.data, - < double * >velocity.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u_last.data, - < int * >csrRowIndeces_u_u.data, < int * >csrColumnOffsets_u_u.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < int * >csrColumnOffsets_eb_u_u.data, - PURE_BDF, - LUMPED_MASS_MATRIX) - - def calculateSmoothingMatrix(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - double he): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateSmoothingMatrix(dt, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * >u_l2g.data, - < int * >r_l2g.data, - < double * >elementDiameter.data, - degree_polynomial, - < double * >u_dof.data, - < double * >velocity.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u_last.data, - < int * >csrRowIndeces_u_u.data, < int * >csrColumnOffsets_u_u.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < int * >csrColumnOffsets_eb_u_u.data, - he) diff --git a/proteus/mprans/cNCLS3P.pyx b/proteus/mprans/cNCLS3P.pyx deleted file mode 100644 index 4256a42b8e..0000000000 --- a/proteus/mprans/cNCLS3P.pyx +++ /dev/null @@ -1,512 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy - -cdef extern from "mprans/NCLS3P.h" namespace "proteus": - cdef cppclass cppNCLS3P_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - double * ebqe_u, - double * cell_interface_locator, - double * interface_locator, - int EXPLICIT_METHOD, - double degree_polynomial, - int stage, - double * uTilde_dof, - double dt, - int PURE_BDF) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_rd_u_ext, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - int EXPLICIT_METHOD, - int PURE_BDF) - void calculateWaterline(int * wlc, - double * waterline, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int * u_l2g, - double * elementDiameter, - double * u_dof, double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * elementBoundaryMaterialTypes, - double * ebqe_velocity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - double * ebqe_u) - - cppNCLS3P_base * newNCLS3P(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class NCLS3P: - cdef cppNCLS3P_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newNCLS3P(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray cell_interface_locator, - numpy.ndarray interface_locator, - int EXPLICIT_METHOD, - double degree_polynomial, - int stage, - numpy.ndarray uTilde_dof, - double dt, - int PURE_BDF): - self.thisptr.calculateResidual(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * >u_l2g.data, - < double * >elementDiameter.data, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >velocity.data, - < double * >q_m.data, - < double * >q_u.data, - < double * >q_n.data, - < double * >q_dH.data, - < double * >q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * >cfl.data, - < double * >q_numDiff_u.data, - < double * >q_numDiff_u_last.data, - offset_u, - stride_u, - < double * >globalResidual.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_u.data, - < double * >cell_interface_locator.data, - < double * >interface_locator.data, - EXPLICIT_METHOD, - degree_polynomial, - stage, - < double * >uTilde_dof.data, - dt, - PURE_BDF) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_rd_u_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int EXPLICIT_METHOD, - int PURE_BDF): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*>mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < int * >u_l2g.data, - < double * >elementDiameter.data, - < double * >u_dof.data, - < double * >velocity.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u_last.data, - < int*>csrRowIndeces_u_u.data, < int*>csrColumnOffsets_u_u.data, - < double * >globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_rd_u_ext.data, - < double * >ebqe_bc_u_ext.data, - < int * >csrColumnOffsets_eb_u_u.data, - EXPLICIT_METHOD, - PURE_BDF) - - def calculateWaterline(self, - numpy.ndarray wlc, - numpy.ndarray waterline, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray elementBoundaryMaterialTypes, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u): - self.thisptr.calculateWaterline(< int*>wlc.data, - < double * >waterline.data, - < double * >mesh_trial_ref.data, - < double * >mesh_grad_trial_ref.data, - < double * >mesh_dof.data, - < double * >mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * >mesh_l2g.data, - < double * >dV_ref.data, - < double * >u_trial_ref.data, - < double * >u_grad_trial_ref.data, - < double * >u_test_ref.data, - < double * >u_grad_test_ref.data, - < double * >mesh_trial_trace_ref.data, - < double * >mesh_grad_trial_trace_ref.data, - < double * >dS_ref.data, - < double * >u_trial_trace_ref.data, - < double * >u_grad_trial_trace_ref.data, - < double * >u_test_trace_ref.data, - < double * >u_grad_test_trace_ref.data, - < double * >normal_ref.data, - < double * >boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < int * >u_l2g.data, - < double * >elementDiameter.data, - < double * >u_dof.data, - < double * >u_dof_old.data, - < double * >velocity.data, - < double * >q_m.data, - < double * >q_u.data, - < double * >q_n.data, - < double * >q_dH.data, - < double * >q_m_betaBDF.data, - < double * >cfl.data, - < double * >q_numDiff_u.data, - < double * >q_numDiff_u_last.data, - offset_u, - stride_u, - nExteriorElementBoundaries_global, - < int * >exteriorElementBoundariesArray.data, - < int * >elementBoundaryElementsArray.data, - < int * >elementBoundaryLocalElementBoundariesArray.data, - < int * >elementBoundaryMaterialTypes.data, - < double * >ebqe_velocity_ext.data, - < int * >isDOFBoundary_u.data, - < double * >ebqe_bc_u_ext.data, - < double * >ebqe_u.data) diff --git a/proteus/mprans/cPres.pyx b/proteus/mprans/cPres.pyx deleted file mode 100644 index a5f6510ac9..0000000000 --- a/proteus/mprans/cPres.pyx +++ /dev/null @@ -1,213 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy - -cdef extern from "mprans/Pres.h" namespace "proteus": - cdef cppclass cppPres_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * u_l2g, - double * u_dof, - double * q_u, - double * q_grad_u, - double * q_p_last, - double * q_p_inc, - double * q_massFlux, - double * ebqe_massFlux, - double * ebqe_u, - double * ebqe_grad_u, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian) - cppPres_base * newPres(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class Pres: - cdef cppPres_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newPres(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_p_last, - numpy.ndarray q_p_inc, - numpy.ndarray q_massFlux, - numpy.ndarray ebqe_massFlux, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_grad_u, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - < int * > u_l2g.data, - < double * > u_dof.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_p_last.data, - < double * > q_p_inc.data, - < double * > q_massFlux.data, - < double * > ebqe_massFlux.data, - < double * > ebqe_u.data, - < double * > ebqe_grad_u.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data) diff --git a/proteus/mprans/cPresInc.pyx b/proteus/mprans/cPresInc.pyx deleted file mode 100644 index 5988e012bd..0000000000 --- a/proteus/mprans/cPresInc.pyx +++ /dev/null @@ -1,337 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy - -cdef extern from "mprans/PresInc.h" namespace "proteus": - cdef cppclass cppPresInc_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * isDOFBoundary, - int * isFluxBoundary, - int * u_l2g, - double * u_dof, - double alphaBDF, - double * q_vf, - double * q_divU, - double * q_vs, - double * q_vos, - double rho_s, - double * q_rho_f, - double rho_s_min, - double rho_f_min, - double * ebqe_vf, - double * ebqe_vs, - double * ebqe_vos, - double * ebqe_rho_f, - double * q_p, - double * q_grad_p, - double * ebqe_p, - double * ebqe_grad_p, - double * ebqe_bc_u_ext, - double * ebqe_adv_flux, - double * ebqe_diff_flux, - double * bc_adv_flux, - double * bc_diff_flux, - int offset_u, - int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int INTEGRATE_BY_PARTS_DIV_U, - double* q_a, - double* ebqe_a) - - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - int * isDOFBoundary, - int * isFluxBoundary, - int * u_l2g, - double * u_dof, - double alphaBDF, - double * q_vf, - double * q_vs, - double * q_vos, - double rho_s, - double * q_rho_f, - double rho_s_min, - double rho_f_min, - double * ebqe_vf, - double * ebqe_vs, - double * ebqe_vos, - double * ebqe_rho_f, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * csrColumnOffsets_eb_u_u) - cppPresInc_base * newPresInc(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class PresInc: - cdef cppPresInc_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newPresInc(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray isDOFBoundary, - numpy.ndarray isFluxBoundary, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - double alphaBDF, - numpy.ndarray q_vf, - numpy.ndarray q_divU, - numpy.ndarray q_vs, - numpy.ndarray q_vos, - double rho_s, - numpy.ndarray q_rho_f, - double rho_s_min, - double rho_f_min, - numpy.ndarray ebqe_vf, - numpy.ndarray ebqe_vs, - numpy.ndarray ebqe_vos, - numpy.ndarray ebqe_rho_f, - numpy.ndarray q_p, - numpy.ndarray q_grad_p, - numpy.ndarray ebqe_p, - numpy.ndarray ebqe_grad_p, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_adv_flux, - numpy.ndarray ebqe_diff_flux, - numpy.ndarray bc_adv_flux, - numpy.ndarray bc_diff_flux, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - int INTEGRATE_BY_PARTS_DIV_U, - numpy.ndarray q_a, - numpy.ndarray ebqe_a): - self.thisptr.calculateResidual( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - isDOFBoundary.data, - isFluxBoundary.data, - < int * > u_l2g.data, - < double * > u_dof.data, - alphaBDF, - < double * > q_vf.data, - < double * > q_divU.data, - < double * > q_vs.data, - < double * > q_vos.data, - rho_s, - < double * > q_rho_f.data, - rho_s_min, - rho_f_min, - < double * > ebqe_vf.data, - < double * > ebqe_vs.data, - < double * > ebqe_vos.data, - < double * > ebqe_rho_f.data, - < double * > q_p.data, - < double * > q_grad_p.data, - < double * > ebqe_p.data, - < double * > ebqe_grad_p.data, - < double* > ebqe_bc_u_ext.data, - < double* > ebqe_adv_flux.data, - < double* > ebqe_diff_flux.data, - < double* > bc_adv_flux.data, - < double* > bc_diff_flux.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - INTEGRATE_BY_PARTS_DIV_U, - q_a.data, - ebqe_a.data) - - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray isDOFBoundary, - numpy.ndarray isFluxBoundary, - numpy.ndarray u_l2g, - numpy.ndarray u_dof, - double alphaBDF, - numpy.ndarray q_vf, - numpy.ndarray q_vs, - numpy.ndarray q_vos, - double rho_s, - numpy.ndarray q_rho_f, - double rho_s_min, - double rho_f_min, - numpy.ndarray ebqe_vf, - numpy.ndarray ebqe_vs, - numpy.ndarray ebqe_vos, - numpy.ndarray ebqe_rho_f, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray csrColumnOffsets_eb_u_u): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - < int * > isDOFBoundary.data, - < int * > isFluxBoundary.data, - < int * > u_l2g.data, - < double * > u_dof.data, - alphaBDF, - < double * > q_vf.data, - < double * > q_vs.data, - < double * > q_vos.data, - rho_s, - < double * > q_rho_f.data, - rho_s_min, - rho_f_min, - < double * > ebqe_vf.data, - < double * > ebqe_vs.data, - < double * > ebqe_vos.data, - < double * > ebqe_rho_f.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > csrColumnOffsets_eb_u_u.data) diff --git a/proteus/mprans/cPresInit.pyx b/proteus/mprans/cPresInit.pyx deleted file mode 100644 index 749b94a71f..0000000000 --- a/proteus/mprans/cPresInit.pyx +++ /dev/null @@ -1,276 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy - -cdef extern from "mprans/PresInit.h" namespace "proteus": - cdef cppclass cppPresInit_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * ebqe_phi, - double * ebqe_normal_phi, - double * q_H, - double * q_u, - double * q_n, - double * ebqe_u, - double * ebqe_n, - double * q_r, - double * q_vos, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * q_phi, - double * q_normal_phi, - double * q_H, - double * q_vos, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian) - cppPresInit_base * newPresInit(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class PresInit: - cdef cppPresInit_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newPresInit(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray ebqe_phi, - numpy.ndarray ebqe_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - numpy.ndarray q_r, - numpy.ndarray q_vos, - int offset_u, - int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > ebqe_phi.data, - < double * > ebqe_normal_phi.data, - < double * > q_H.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - < double * > q_r.data, - < double * > q_vos.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double epsFactHeaviside, - double epsFactDirac, - double epsFactDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray q_phi, - numpy.ndarray q_normal_phi, - numpy.ndarray q_H, - numpy.ndarray q_vos, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - epsFactHeaviside, - epsFactDirac, - epsFactDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > q_phi.data, - < double * > q_normal_phi.data, - < double * > q_H.data, - < double * > q_vos.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data) diff --git a/proteus/mprans/cRANS2P.pyx b/proteus/mprans/cRANS2P.pyx deleted file mode 100644 index 27ba912411..0000000000 --- a/proteus/mprans/cRANS2P.pyx +++ /dev/null @@ -1,1614 +0,0 @@ -# A type of -*- python -*- file -from libcpp cimport bool -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "RANS2P.h" namespace "proteus": - cdef cppclass RANS2P_base: - void calculateResidual(double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - double* numerical_viscosity, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double LAG_LES, - double * q_eddy_viscosity, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity, - double * ebqe_eddy_viscosity_last, - # VRANS end - int * p_l2g, - int * vel_l2g, - int * rp_l2g, - int * rvel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * p_old_dof, - double * u_old_dof, - double * v_old_dof, - double * w_old_dof, - double * g, - double useVF, - double * rho, - double * vf, - double * phi, - double * phi_nodes, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * elementFlags, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * velocityError, - double * velocityErrorNodal, - double* forcex, - double* forcey, - double* forcez, - int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, - int use_pseudo_penalty, - bool useExact) - void calculateJacobian(double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double LAG_LES, - double * q_eddy_viscosity, - double * ebqe_eddy_viscosity, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - double * p_old_dof, - double * u_old_dof, - double * v_old_dof, - double * w_old_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * phi_nodes, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_p_u, int * csrColumnOffsets_p_u, - int * csrRowIndeces_p_v, int * csrColumnOffsets_p_v, - int * csrRowIndeces_p_w, int * csrColumnOffsets_p_w, - int * csrRowIndeces_u_p, int * csrColumnOffsets_u_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_p, int * csrColumnOffsets_v_p, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_p, int * csrColumnOffsets_w_p, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - int * csrColumnOffsets_eb_p_p, - int * csrColumnOffsets_eb_p_u, - int * csrColumnOffsets_eb_p_v, - int * csrColumnOffsets_eb_p_w, - int * csrColumnOffsets_eb_u_p, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_p, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_p, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w, - int * elementFlags, - int * boundaryFlags, - int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, - int nParticles, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - int use_pseudo_penalty, - bool useExact) - void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - int * interiorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int * vel_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * vel_trial_trace_ref, - double * ebqe_velocity, - double * velocityAverage) - void getTwoPhaseAdvectionOperator(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * vel_trail_ref, - double * vel_grad_trial_ref, - double * elementDiameter, - double * nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * vel_l2g, - double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * advection_matrix) - void getTwoPhaseInvScaledLaplaceOperator(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_grad_trial_ref, - double * vel_grad_trial_ref, - double * elementDiameter, - double * nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * sdInfo_p_p_rowptr, int * sdInfo_p_p_colind, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * laplace_matrix) - void getTwoPhaseScaledMassOperator(int scale_type, - int use_numerical_viscosity, - int lumped, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_test_ref, - double * vel_trial_ref, - double * vel_test_ref, - double * elementDiameter, - double * nodeDiametersArray, - double * numerical_viscosity, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * csrRowIndeces_p_p, - int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, - int * csrColumnOffsets_w_w, - double * mass_matrix) - RANS2P_base * newRANS2P(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nDOF_v_trial_elementIn, - int nDOF_v_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cRANS2P_base: - cdef RANS2P_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nDOF_v_trial_elementIn, - int nDOF_v_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newRANS2P(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nDOF_v_trial_elementIn, - nDOF_v_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - numpy.ndarray numerical_viscosity, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - double LAG_LES, - numpy.ndarray q_eddy_viscosity, - numpy.ndarray q_eddy_viscosity_last, - numpy.ndarray ebqe_eddy_viscosity, - numpy.ndarray ebqe_eddy_viscosity_last, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray rp_l2g, - numpy.ndarray rvel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray p_old_dof, - numpy.ndarray u_old_dof, - numpy.ndarray v_old_dof, - numpy.ndarray w_old_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray rho, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray phi_nodes, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray velocityError, - numpy.ndarray velocityErrorNodal, - numpy.ndarray forcex, - numpy.ndarray forcey, - numpy.ndarray forcez, - int use_ball_as_particle, - numpy.ndarray ball_center, - numpy.ndarray ball_radius, - numpy.ndarray ball_velocity, - numpy.ndarray ball_angular_velocity, - numpy.ndarray ball_center_acceleration, - numpy.ndarray ball_angular_acceleration, - numpy.ndarray ball_density, - numpy.ndarray particle_signed_distances, - numpy.ndarray particle_signed_distance_normals, - numpy.ndarray particle_velocities, - numpy.ndarray particle_centroids, - numpy.ndarray ebq_global_phi_s, - numpy.ndarray ebq_global_grad_phi_s, - numpy.ndarray ebq_particle_velocity_s, - int nParticles, - numpy.ndarray particle_netForces, - numpy.ndarray particle_netMoments, - numpy.ndarray particle_surfaceArea, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - numpy.ndarray phi_solid_nodes, - numpy.ndarray distance_to_solids, - int use_pseudo_penalty, - bool useExact): - self.thisptr.calculateResidual(NONCONSERVATIVE_FORM, - MOMENTUM_SGE, - PRESSURE_SGE, - VELOCITY_SGE, - PRESSURE_PROJECTION_STABILIZATION, - numerical_viscosity.data, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - LAG_LES, - < double * > q_eddy_viscosity.data, - < double * > q_eddy_viscosity_last.data, - < double * > ebqe_eddy_viscosity.data, - < double * > ebqe_eddy_viscosity_last.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < int * > rp_l2g.data, - < int * > rvel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > p_old_dof.data, - < double * > u_old_dof.data, - < double * > v_old_dof.data, - < double * > w_old_dof.data, - < double * > g.data, - useVF, - < double * > rho.data, - < double * > vf.data, - < double * > phi.data, - < double * > phi_nodes.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > velocityError.data, - < double * > velocityErrorNodal.data, - < double * > forcex.data, - < double * > forcey.data, - < double * > forcez.data, - use_ball_as_particle, - < double * > ball_center.data, - < double * > ball_radius.data, - < double * > ball_velocity.data, - < double * > ball_angular_velocity.data, - < double * > ball_center_acceleration.data, - < double * > ball_angular_acceleration.data, - < double * > ball_density.data, - < double * > particle_signed_distances.data, - < double * > particle_signed_distance_normals.data, - < double * > particle_velocities.data, - < double * > particle_centroids.data, - < double * > ebq_global_phi_s.data, - < double * > ebq_global_grad_phi_s.data, - < double * > ebq_particle_velocity_s.data, - nParticles, - < double * > particle_netForces.data, - < double * > particle_netMoments.data, - < double * > particle_surfaceArea.data, - nElements_owned, - particle_nitsche, - particle_epsFact, - particle_alpha, - particle_beta, - particle_penalty_constant, - < double * > phi_solid_nodes.data, - < double * > distance_to_solids.data, - use_pseudo_penalty, - useExact) - - def calculateJacobian(self, - double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - double LAG_LES, - numpy.ndarray q_eddy_viscosity_last, - numpy.ndarray ebqe_eddy_viscosity_last, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray p_old_dof, - numpy.ndarray u_old_dof, - numpy.ndarray v_old_dof, - numpy.ndarray w_old_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray phi_nodes, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_p_u, numpy.ndarray csrColumnOffsets_p_u, - numpy.ndarray csrRowIndeces_p_v, numpy.ndarray csrColumnOffsets_p_v, - numpy.ndarray csrRowIndeces_p_w, numpy.ndarray csrColumnOffsets_p_w, - numpy.ndarray csrRowIndeces_u_p, numpy.ndarray csrColumnOffsets_u_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_p, numpy.ndarray csrColumnOffsets_v_p, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_p, numpy.ndarray csrColumnOffsets_w_p, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray csrColumnOffsets_eb_p_p, - numpy.ndarray csrColumnOffsets_eb_p_u, - numpy.ndarray csrColumnOffsets_eb_p_v, - numpy.ndarray csrColumnOffsets_eb_p_w, - numpy.ndarray csrColumnOffsets_eb_u_p, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_p, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_p, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - int use_ball_as_particle, - numpy.ndarray ball_center, - numpy.ndarray ball_radius, - numpy.ndarray ball_velocity, - numpy.ndarray ball_angular_velocity, - numpy.ndarray ball_center_acceleration, - numpy.ndarray ball_angular_acceleration, - numpy.ndarray ball_density, - numpy.ndarray particle_signed_distances, - numpy.ndarray particle_signed_distance_normals, - numpy.ndarray particle_velocities, - numpy.ndarray particle_centroids, - numpy.ndarray ebq_global_phi_s, - numpy.ndarray ebq_global_grad_phi_s, - numpy.ndarray ebq_particle_velocity_s, - numpy.ndarray phi_solid_nodes, - numpy.ndarray distance_to_solids, - int nParticles, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - int use_pseudo_penalty, - bool useExact): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(NONCONSERVATIVE_FORM, - MOMENTUM_SGE, - PRESSURE_SGE, - VELOCITY_SGE, - PRESSURE_PROJECTION_STABILIZATION, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dg, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - LAG_LES, - < double * > q_eddy_viscosity_last.data, - < double * > ebqe_eddy_viscosity_last.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - < double * > p_old_dof.data, - < double * > u_old_dof.data, - < double * > v_old_dof.data, - < double * > w_old_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > phi_nodes.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_p_u.data, < int * > csrColumnOffsets_p_u.data, - < int * > csrRowIndeces_p_v.data, < int * > csrColumnOffsets_p_v.data, - < int * > csrRowIndeces_p_w.data, < int * > csrColumnOffsets_p_w.data, - < int * > csrRowIndeces_u_p.data, < int * > csrColumnOffsets_u_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_w.data, < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_p.data, < int * > csrColumnOffsets_v_p.data, - < int * > csrRowIndeces_v_u.data, < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_w.data, < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_w_p.data, < int * > csrColumnOffsets_w_p.data, - < int * > csrRowIndeces_w_u.data, < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < int * > csrColumnOffsets_eb_p_p.data, - < int * > csrColumnOffsets_eb_p_u.data, - < int * > csrColumnOffsets_eb_p_v.data, - < int * > csrColumnOffsets_eb_p_w.data, - < int * > csrColumnOffsets_eb_u_p.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_u_w.data, - < int * > csrColumnOffsets_eb_v_p.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - < int * > csrColumnOffsets_eb_v_w.data, - < int * > csrColumnOffsets_eb_w_p.data, - < int * > csrColumnOffsets_eb_w_u.data, - < int * > csrColumnOffsets_eb_w_v.data, - < int * > csrColumnOffsets_eb_w_w.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - use_ball_as_particle, - < double * > ball_center.data, - < double * > ball_radius.data, - < double * > ball_velocity.data, - < double * > ball_angular_velocity.data, - < double * > ball_center_acceleration.data, - < double * > ball_angular_acceleration.data, - < double * > ball_density.data, - < double * > particle_signed_distances.data, - < double * > particle_signed_distance_normals.data, - < double * > particle_velocities.data, - < double * > particle_centroids.data, - < double * > ebq_global_phi_s.data, - < double * > ebq_global_grad_phi_s.data, - < double * > ebq_particle_velocity_s.data, - < double * > phi_solid_nodes.data, - < double * > distance_to_solids.data, - nParticles, - nElements_owned, - particle_nitsche, - particle_epsFact, - particle_alpha, - particle_beta, - particle_penalty_constant, - use_pseudo_penalty, - useExact) - - def calculateVelocityAverage(self, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - numpy.ndarray interiorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray ebqe_velocity, - numpy.ndarray velocityAverage): - self.thisptr.calculateVelocityAverage(nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - nInteriorElementBoundaries_global, - < int * > interiorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < int * > vel_l2g.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > vel_trial_trace_ref.data, - < double * > ebqe_velocity.data, - < double * > velocityAverage.data) - - def getTwoPhaseAdvectionOperator(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - advection_matrix): - cdef numpy.ndarray rowptr, colind, advection_matrix_vals - (rowptr, colind, advection_matrix_vals) = advection_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseAdvectionOperator( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > vel_l2g.data, - < double*> u_dof.data, < double*> v_dof.data, < double*> w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int*> csrRowIndeces_p_p.data, < int*> csrColumnOffsets_p_p.data, - < int*> csrRowIndeces_u_u.data, < int*> csrColumnOffsets_u_u.data, - < int*> csrRowIndeces_v_v.data, < int*> csrColumnOffsets_v_v.data, - < int*> csrRowIndeces_w_w.data, < int*> csrColumnOffsets_w_w.data, - < double * > advection_matrix_vals.data) - - def getTwoPhaseInvScaledLaplaceOperator(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray sdInfo_p_p_rowptr, numpy.ndarray sdInfo_p_p_colind, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - laplace_matrix): - cdef numpy.ndarray rowptr, colind, laplace_matrix_vals - (rowptr, colind, laplace_matrix_vals) = laplace_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseInvScaledLaplaceOperator( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_grad_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int*> sdInfo_p_p_rowptr.data, < int*> sdInfo_p_p_colind.data, - < int*> sdInfo_u_u_rowptr.data, < int*> sdInfo_u_u_colind.data, - < int*> sdInfo_v_v_rowptr.data, < int*> sdInfo_v_v_colind.data, - < int*> sdInfo_w_w_rowptr.data, < int*> sdInfo_w_w_colind.data, - < int*> csrRowIndeces_p_p.data, < int*> csrColumnOffsets_p_p.data, - < int*> csrRowIndeces_u_u.data, < int*> csrColumnOffsets_u_u.data, - < int*> csrRowIndeces_v_v.data, < int*> csrColumnOffsets_v_v.data, - < int*> csrRowIndeces_w_w.data, < int*> csrColumnOffsets_w_w.data, - < double * > laplace_matrix_vals.data) - - def getTwoPhaseScaledMassOperator(self, - int scale_type, - int use_numerical_viscosity, - int lumped, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray numerical_viscosity, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - mass_matrix): - cdef numpy.ndarray rowptr, colind, mass_matrix_vals - (rowptr, colind, mass_matrix_vals) = mass_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseScaledMassOperator(scale_type, - use_numerical_viscosity, - lumped, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_test_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > numerical_viscosity.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > mass_matrix_vals.data) diff --git a/proteus/mprans/cRANS2P2D.pyx b/proteus/mprans/cRANS2P2D.pyx deleted file mode 100644 index 0636996113..0000000000 --- a/proteus/mprans/cRANS2P2D.pyx +++ /dev/null @@ -1,1614 +0,0 @@ -# A type of -*- python -*- file -from libcpp cimport bool -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "RANS2P2D.h" namespace "proteus": - cdef cppclass RANS2P2D_base: - void calculateResidual(double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - double* numerical_viscosity, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double LAG_LES, - double * q_eddy_viscosity, - double * q_eddy_viscosity_last, - double * ebqe_eddy_viscosity, - double * ebqe_eddy_viscosity_last, - # VRANS end - int * p_l2g, - int * vel_l2g, - int * rp_l2g, - int * rvel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * p_old_dof, - double * u_old_dof, - double * v_old_dof, - double * w_old_dof, - double * g, - double useVF, - double * rho, - double * vf, - double * phi, - double * phi_nodes, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * elementFlags, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * velocityError, - double * velocityErrorNodal, - double* forcex, - double* forcey, - double* forcez, - int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - int nParticles, - double *particle_netForces, - double *particle_netMoments, - double *particle_surfaceArea, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - double* phi_solid_nodes, - double* distance_to_solids, - int use_pseudo_penalty, - bool useExact) - void calculateJacobian(double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double LAG_LES, - double * q_eddy_viscosity, - double * ebqe_eddy_viscosity, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - double * p_old_dof, - double * u_old_dof, - double * v_old_dof, - double * w_old_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * phi_nodes, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_p_u, int * csrColumnOffsets_p_u, - int * csrRowIndeces_p_v, int * csrColumnOffsets_p_v, - int * csrRowIndeces_p_w, int * csrColumnOffsets_p_w, - int * csrRowIndeces_u_p, int * csrColumnOffsets_u_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_p, int * csrColumnOffsets_v_p, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_p, int * csrColumnOffsets_w_p, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - int * csrColumnOffsets_eb_p_p, - int * csrColumnOffsets_eb_p_u, - int * csrColumnOffsets_eb_p_v, - int * csrColumnOffsets_eb_p_w, - int * csrColumnOffsets_eb_u_p, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_p, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_p, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w, - int * elementFlags, - int * boundaryFlags, - int use_ball_as_particle, - double* ball_center, - double* ball_radius, - double* ball_velocity, - double* ball_angular_velocity, - double* ball_center_acceleration, - double* ball_angular_acceleration, - double* ball_density, - double* particle_signed_distances, - double* particle_signed_distance_normals, - double* particle_velocities, - double* particle_centroids, - double* ebq_global_phi_s, - double* ebq_global_grad_phi_s, - double* ebq_particle_velocity_s, - double* phi_solid_nodes, - double* distance_to_solids, - int nParticles, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - int use_pseudo_penalty, - bool useExact) - void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - int * interiorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int * vel_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * vel_trial_trace_ref, - double * ebqe_velocity, - double * velocityAverage) - void getTwoPhaseAdvectionOperator(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * vel_trail_ref, - double * vel_grad_trial_ref, - double * elementDiameter, - double * nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * vel_l2g, - double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * advection_matrix) - void getTwoPhaseInvScaledLaplaceOperator(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_grad_trial_ref, - double * vel_grad_trial_ref, - double * elementDiameter, - double * nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * sdInfo_p_p_rowptr, int * sdInfo_p_p_colind, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * laplace_matrix) - void getTwoPhaseScaledMassOperator(int scale_type, - int use_numerical_viscosity, - int lumped, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_test_ref, - double * vel_trial_ref, - double * vel_test_ref, - double * elementDiameter, - double * nodeDiametersArray, - double * numerical_viscosity, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - const double useVF, - double * vf, - double * phi, - int * csrRowIndeces_p_p, - int * csrColumnOffsets_p_p, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - int * csrRowIndeces_w_w, - int * csrColumnOffsets_w_w, - double * mass_matrix) - RANS2P2D_base * newRANS2P2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nDOF_v_trial_elementIn, - int nDOF_v_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cRANS2P2D_base: - cdef RANS2P2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nDOF_v_trial_elementIn, - int nDOF_v_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newRANS2P2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nDOF_v_trial_elementIn, - nDOF_v_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - numpy.ndarray numerical_viscosity, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - double LAG_LES, - numpy.ndarray q_eddy_viscosity, - numpy.ndarray q_eddy_viscosity_last, - numpy.ndarray ebqe_eddy_viscosity, - numpy.ndarray ebqe_eddy_viscosity_last, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray rp_l2g, - numpy.ndarray rvel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray p_old_dof, - numpy.ndarray u_old_dof, - numpy.ndarray v_old_dof, - numpy.ndarray w_old_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray rho, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray phi_nodes, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray velocityError, - numpy.ndarray velocityErrorNodal, - numpy.ndarray forcex, - numpy.ndarray forcey, - numpy.ndarray forcez, - int use_ball_as_particle, - numpy.ndarray ball_center, - numpy.ndarray ball_radius, - numpy.ndarray ball_velocity, - numpy.ndarray ball_angular_velocity, - numpy.ndarray ball_center_acceleration, - numpy.ndarray ball_angular_acceleration, - numpy.ndarray ball_density, - numpy.ndarray particle_signed_distances, - numpy.ndarray particle_signed_distance_normals, - numpy.ndarray particle_velocities, - numpy.ndarray particle_centroids, - numpy.ndarray ebq_global_phi_s, - numpy.ndarray ebq_global_grad_phi_s, - numpy.ndarray ebq_particle_velocity_s, - int nParticles, - numpy.ndarray particle_netForces, - numpy.ndarray particle_netMoments, - numpy.ndarray particle_surfaceArea, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - numpy.ndarray phi_solid_nodes, - numpy.ndarray distance_to_solids, - int use_pseudo_penalty, - bool useExact): - self.thisptr.calculateResidual(NONCONSERVATIVE_FORM, - MOMENTUM_SGE, - PRESSURE_SGE, - VELOCITY_SGE, - PRESSURE_PROJECTION_STABILIZATION, - numerical_viscosity.data, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - LAG_LES, - < double * > q_eddy_viscosity.data, - < double * > q_eddy_viscosity_last.data, - < double * > ebqe_eddy_viscosity.data, - < double * > ebqe_eddy_viscosity_last.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < int * > rp_l2g.data, - < int * > rvel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > p_old_dof.data, - < double * > u_old_dof.data, - < double * > v_old_dof.data, - < double * > w_old_dof.data, - < double * > g.data, - useVF, - < double * > rho.data, - < double * > vf.data, - < double * > phi.data, - < double * > phi_nodes.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > velocityError.data, - < double * > velocityErrorNodal.data, - < double * > forcex.data, - < double * > forcey.data, - < double * > forcez.data, - use_ball_as_particle, - < double * > ball_center.data, - < double * > ball_radius.data, - < double * > ball_velocity.data, - < double * > ball_angular_velocity.data, - < double * > ball_center_acceleration.data, - < double * > ball_angular_acceleration.data, - < double * > ball_density.data, - < double * > particle_signed_distances.data, - < double * > particle_signed_distance_normals.data, - < double * > particle_velocities.data, - < double * > particle_centroids.data, - < double * > ebq_global_phi_s.data, - < double * > ebq_global_grad_phi_s.data, - < double * > ebq_particle_velocity_s.data, - nParticles, - < double * > particle_netForces.data, - < double * > particle_netMoments.data, - < double * > particle_surfaceArea.data, - nElements_owned, - particle_nitsche, - particle_epsFact, - particle_alpha, - particle_beta, - particle_penalty_constant, - < double * > phi_solid_nodes.data, - < double * > distance_to_solids.data, - use_pseudo_penalty, - useExact) - - def calculateJacobian(self, - double NONCONSERVATIVE_FORM, - double MOMENTUM_SGE, - double PRESSURE_SGE, - double VELOCITY_SGE, - double PRESSURE_PROJECTION_STABILIZATION, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - double LAG_LES, - numpy.ndarray q_eddy_viscosity_last, - numpy.ndarray ebqe_eddy_viscosity_last, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray p_old_dof, - numpy.ndarray u_old_dof, - numpy.ndarray v_old_dof, - numpy.ndarray w_old_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray phi_nodes, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_p_u, numpy.ndarray csrColumnOffsets_p_u, - numpy.ndarray csrRowIndeces_p_v, numpy.ndarray csrColumnOffsets_p_v, - numpy.ndarray csrRowIndeces_p_w, numpy.ndarray csrColumnOffsets_p_w, - numpy.ndarray csrRowIndeces_u_p, numpy.ndarray csrColumnOffsets_u_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_p, numpy.ndarray csrColumnOffsets_v_p, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_p, numpy.ndarray csrColumnOffsets_w_p, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray csrColumnOffsets_eb_p_p, - numpy.ndarray csrColumnOffsets_eb_p_u, - numpy.ndarray csrColumnOffsets_eb_p_v, - numpy.ndarray csrColumnOffsets_eb_p_w, - numpy.ndarray csrColumnOffsets_eb_u_p, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_p, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_p, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - int use_ball_as_particle, - numpy.ndarray ball_center, - numpy.ndarray ball_radius, - numpy.ndarray ball_velocity, - numpy.ndarray ball_angular_velocity, - numpy.ndarray ball_center_acceleration, - numpy.ndarray ball_angular_acceleration, - numpy.ndarray ball_density, - numpy.ndarray particle_signed_distances, - numpy.ndarray particle_signed_distance_normals, - numpy.ndarray particle_velocities, - numpy.ndarray particle_centroids, - numpy.ndarray ebq_global_phi_s, - numpy.ndarray ebq_global_grad_phi_s, - numpy.ndarray ebq_particle_velocity_s, - numpy.ndarray phi_solid_nodes, - numpy.ndarray distance_to_solids, - int nParticles, - int nElements_owned, - double particle_nitsche, - double particle_epsFact, - double particle_alpha, - double particle_beta, - double particle_penalty_constant, - int use_pseudo_penalty, - bool useExact): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(NONCONSERVATIVE_FORM, - MOMENTUM_SGE, - PRESSURE_SGE, - VELOCITY_SGE, - PRESSURE_PROJECTION_STABILIZATION, - mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dg, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - LAG_LES, - < double * > q_eddy_viscosity_last.data, - < double * > ebqe_eddy_viscosity_last.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - < double * > p_old_dof.data, - < double * > u_old_dof.data, - < double * > v_old_dof.data, - < double * > w_old_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > phi_nodes.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_p_u.data, < int * > csrColumnOffsets_p_u.data, - < int * > csrRowIndeces_p_v.data, < int * > csrColumnOffsets_p_v.data, - < int * > csrRowIndeces_p_w.data, < int * > csrColumnOffsets_p_w.data, - < int * > csrRowIndeces_u_p.data, < int * > csrColumnOffsets_u_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_w.data, < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_p.data, < int * > csrColumnOffsets_v_p.data, - < int * > csrRowIndeces_v_u.data, < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_w.data, < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_w_p.data, < int * > csrColumnOffsets_w_p.data, - < int * > csrRowIndeces_w_u.data, < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < int * > csrColumnOffsets_eb_p_p.data, - < int * > csrColumnOffsets_eb_p_u.data, - < int * > csrColumnOffsets_eb_p_v.data, - < int * > csrColumnOffsets_eb_p_w.data, - < int * > csrColumnOffsets_eb_u_p.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_u_w.data, - < int * > csrColumnOffsets_eb_v_p.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - < int * > csrColumnOffsets_eb_v_w.data, - < int * > csrColumnOffsets_eb_w_p.data, - < int * > csrColumnOffsets_eb_w_u.data, - < int * > csrColumnOffsets_eb_w_v.data, - < int * > csrColumnOffsets_eb_w_w.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - use_ball_as_particle, - < double * > ball_center.data, - < double * > ball_radius.data, - < double * > ball_velocity.data, - < double * > ball_angular_velocity.data, - < double * > ball_center_acceleration.data, - < double * > ball_angular_acceleration.data, - < double * > ball_density.data, - < double * > particle_signed_distances.data, - < double * > particle_signed_distance_normals.data, - < double * > particle_velocities.data, - < double * > particle_centroids.data, - < double * > ebq_global_phi_s.data, - < double * > ebq_global_grad_phi_s.data, - < double * > ebq_particle_velocity_s.data, - < double * > phi_solid_nodes.data, - < double * > distance_to_solids.data, - nParticles, - nElements_owned, - particle_nitsche, - particle_epsFact, - particle_alpha, - particle_beta, - particle_penalty_constant, - use_pseudo_penalty, - useExact) - - def calculateVelocityAverage(self, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - numpy.ndarray interiorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray ebqe_velocity, - numpy.ndarray velocityAverage): - self.thisptr.calculateVelocityAverage(nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - nInteriorElementBoundaries_global, - < int * > interiorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < int * > vel_l2g.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > vel_trial_trace_ref.data, - < double * > ebqe_velocity.data, - < double * > velocityAverage.data) - - def getTwoPhaseAdvectionOperator(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - advection_matrix): - cdef numpy.ndarray rowptr, colind, advection_matrix_vals - (rowptr, colind, advection_matrix_vals) = advection_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseAdvectionOperator( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > vel_l2g.data, - < double*> u_dof.data, < double*> v_dof.data, < double*> w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int*> csrRowIndeces_p_p.data, < int*> csrColumnOffsets_p_p.data, - < int*> csrRowIndeces_u_u.data, < int*> csrColumnOffsets_u_u.data, - < int*> csrRowIndeces_v_v.data, < int*> csrColumnOffsets_v_v.data, - < int*> csrRowIndeces_w_w.data, < int*> csrColumnOffsets_w_w.data, - < double * > advection_matrix_vals.data) - - def getTwoPhaseInvScaledLaplaceOperator(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray sdInfo_p_p_rowptr, numpy.ndarray sdInfo_p_p_colind, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - laplace_matrix): - cdef numpy.ndarray rowptr, colind, laplace_matrix_vals - (rowptr, colind, laplace_matrix_vals) = laplace_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseInvScaledLaplaceOperator( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_grad_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int*> sdInfo_p_p_rowptr.data, < int*> sdInfo_p_p_colind.data, - < int*> sdInfo_u_u_rowptr.data, < int*> sdInfo_u_u_colind.data, - < int*> sdInfo_v_v_rowptr.data, < int*> sdInfo_v_v_colind.data, - < int*> sdInfo_w_w_rowptr.data, < int*> sdInfo_w_w_colind.data, - < int*> csrRowIndeces_p_p.data, < int*> csrColumnOffsets_p_p.data, - < int*> csrRowIndeces_u_u.data, < int*> csrColumnOffsets_u_u.data, - < int*> csrRowIndeces_v_v.data, < int*> csrColumnOffsets_v_v.data, - < int*> csrRowIndeces_w_w.data, < int*> csrColumnOffsets_w_w.data, - < double * > laplace_matrix_vals.data) - - def getTwoPhaseScaledMassOperator(self, - int scale_type, - int use_numerical_viscosity, - int lumped, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray numerical_viscosity, - int nElements_global, - double useMetrics, - double epsFact_rho, - double epsFact_mu, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - mass_matrix): - cdef numpy.ndarray rowptr, colind, mass_matrix_vals - (rowptr, colind, mass_matrix_vals) = mass_matrix.getCSRrepresentation() - self.thisptr.getTwoPhaseScaledMassOperator(scale_type, - use_numerical_viscosity, - lumped, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_test_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > numerical_viscosity.data, - nElements_global, - useMetrics, - epsFact_rho, - epsFact_mu, - rho_0, - nu_0, - rho_1, - nu_1, - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > mass_matrix_vals.data) diff --git a/proteus/mprans/cRANS2P_IB.pyx b/proteus/mprans/cRANS2P_IB.pyx deleted file mode 100644 index 2629e5f35f..0000000000 --- a/proteus/mprans/cRANS2P_IB.pyx +++ /dev/null @@ -1,1880 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "RANS2P_IB.h" namespace "proteus": - cdef cppclass RANS2P_IB_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * q_dragBeam1, - double * q_dragBeam2, - double * q_dragBeam3, - double * ebqe_dragBeam1, - double * ebqe_dragBeam2, - double * ebqe_dragBeam3) - void calculateBeams(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * q_dragBeam1, - double * q_dragBeam2, - double * q_dragBeam3, - double * ebqe_dragBeam1, - double * ebqe_dragBeam2, - double * ebqe_dragBeam3, - int nBeams, - int nBeamElements, - int beam_quadOrder, - double beam_Cd, - double * beamRadius, - double * xq, - double * yq, - double * zq, - double * Beam_h, - double * dV_beam, - double * q1, - double * q2, - double * q3, - double * vel_avg, - double * netBeamDrag) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - double * eps_solid, - double * phi_solid, - double * q_velocity_solid, - double * q_porosity, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_p_u, int * csrColumnOffsets_p_u, - int * csrRowIndeces_p_v, int * csrColumnOffsets_p_v, - int * csrRowIndeces_p_w, int * csrColumnOffsets_p_w, - int * csrRowIndeces_u_p, int * csrColumnOffsets_u_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_p, int * csrColumnOffsets_v_p, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_p, int * csrColumnOffsets_w_p, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_porosity_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - int * csrColumnOffsets_eb_p_p, - int * csrColumnOffsets_eb_p_u, - int * csrColumnOffsets_eb_p_v, - int * csrColumnOffsets_eb_p_w, - int * csrColumnOffsets_eb_u_p, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_p, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_p, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w, - double * q_dragBeam1, - double * q_dragBeam2, - double * q_dragBeam3, - double * ebqe_dragBeam1, - double * ebqe_dragBeam2, - double * ebqe_dragBeam3) - void calculateForce(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_B, - int * p_l2g, - int * vel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * g, - double * rho_init, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * cg, double * force, double * moment, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * forceExtractionFaces, int nForceExtractionFaces, - double * ebqe_vf_ext, - double * ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p) - void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - int * interiorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * mesh_dof, - int * mesh_l2g, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int * vel_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * vel_trial_trace_ref, - double * ebqe_velocity, - double * velocityAverage) - RANS2P_IB_base * newRANS2P_IB(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cRANS2P_IB_base: - cdef RANS2P_IB_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newRANS2P_IB(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray q_dragBeam1, - numpy.ndarray q_dragBeam2, - numpy.ndarray q_dragBeam3, - numpy.ndarray ebqe_dragBeam1, - numpy.ndarray ebqe_dragBeam2, - numpy.ndarray ebqe_dragBeam3): - self.thisptr.calculateResidual(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > q_dragBeam1.data, - < double * > q_dragBeam2.data, - < double * > q_dragBeam3.data, - < double * > ebqe_dragBeam1.data, - < double * > ebqe_dragBeam2.data, - < double * > ebqe_dragBeam3.data) - - def calculateBeams(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray q_dragBeam1, - numpy.ndarray q_dragBeam2, - numpy.ndarray q_dragBeam3, - numpy.ndarray ebqe_dragBeam1, - numpy.ndarray ebqe_dragBeam2, - numpy.ndarray ebqe_dragBeam3, - int nBeams, - int nBeamElements, - int beam_quadOrder, - double beam_Cd, - numpy.ndarray beamRadius, - numpy.ndarray xq, - numpy.ndarray yq, - numpy.ndarray zq, - numpy.ndarray Beam_h, - numpy.ndarray dV_beam, - numpy.ndarray q1, - numpy.ndarray q2, - numpy.ndarray q3, - numpy.ndarray vel_avg, - numpy.ndarray netBeamDrag): - self.thisptr.calculateBeams(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > q_dragBeam1.data, - < double * > q_dragBeam2.data, - < double * > q_dragBeam3.data, - < double * > ebqe_dragBeam1.data, - < double * > ebqe_dragBeam2.data, - < double * > ebqe_dragBeam3.data, - nBeams, - nBeamElements, - beam_quadOrder, - beam_Cd, - < double * > beamRadius.data, - < double * > xq.data, - < double * > yq.data, - < double * > zq.data, - < double * > Beam_h.data, - < double * > dV_beam.data, - < double * > q1.data, - < double * > q2.data, - < double * > q3.data, - < double * > vel_avg.data, - < double * > netBeamDrag.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray phi_solid, - numpy.ndarray q_velocity_solid, - numpy.ndarray q_porosity, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_p_u, numpy.ndarray csrColumnOffsets_p_u, - numpy.ndarray csrRowIndeces_p_v, numpy.ndarray csrColumnOffsets_p_v, - numpy.ndarray csrRowIndeces_p_w, numpy.ndarray csrColumnOffsets_p_w, - numpy.ndarray csrRowIndeces_u_p, numpy.ndarray csrColumnOffsets_u_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_p, numpy.ndarray csrColumnOffsets_v_p, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_p, numpy.ndarray csrColumnOffsets_w_p, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray csrColumnOffsets_eb_p_p, - numpy.ndarray csrColumnOffsets_eb_p_u, - numpy.ndarray csrColumnOffsets_eb_p_v, - numpy.ndarray csrColumnOffsets_eb_p_w, - numpy.ndarray csrColumnOffsets_eb_u_p, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_p, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_p, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w, - numpy.ndarray q_dragBeam1, - numpy.ndarray q_dragBeam2, - numpy.ndarray q_dragBeam3, - numpy.ndarray ebqe_dragBeam1, - numpy.ndarray ebqe_dragBeam2, - numpy.ndarray ebqe_dragBeam3): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dg, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > phi_solid.data, - < double * > q_velocity_solid.data, - < double * > q_porosity.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_p_u.data, < int * > csrColumnOffsets_p_u.data, - < int * > csrRowIndeces_p_v.data, < int * > csrColumnOffsets_p_v.data, - < int * > csrRowIndeces_p_w.data, < int * > csrColumnOffsets_p_w.data, - < int * > csrRowIndeces_u_p.data, < int * > csrColumnOffsets_u_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_w.data, < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_p.data, < int * > csrColumnOffsets_v_p.data, - < int * > csrRowIndeces_v_u.data, < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_w.data, < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_w_p.data, < int * > csrColumnOffsets_w_p.data, - < int * > csrRowIndeces_w_u.data, < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_porosity_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < int * > csrColumnOffsets_eb_p_p.data, - < int * > csrColumnOffsets_eb_p_u.data, - < int * > csrColumnOffsets_eb_p_v.data, - < int * > csrColumnOffsets_eb_p_w.data, - < int * > csrColumnOffsets_eb_u_p.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_u_w.data, - < int * > csrColumnOffsets_eb_v_p.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - < int * > csrColumnOffsets_eb_v_w.data, - < int * > csrColumnOffsets_eb_w_p.data, - < int * > csrColumnOffsets_eb_w_u.data, - < int * > csrColumnOffsets_eb_w_v.data, - < int * > csrColumnOffsets_eb_w_w.data, - < double * > q_dragBeam1.data, - < double * > q_dragBeam2.data, - < double * > q_dragBeam3.data, - < double * > ebqe_dragBeam1.data, - < double * > ebqe_dragBeam2.data, - < double * > ebqe_dragBeam3.data) - - def calculateForce(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray g, - numpy.ndarray rho_init, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray cg, numpy.ndarray force, numpy.ndarray moment, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray forceExtractionFaces, int nForceExtractionFaces, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p): - self.thisptr.calculateForce(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > g.data, - < double * > rho_init.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double*> q_mom_u_acc_beta_bdf.data, < double*> q_mom_v_acc_beta_bdf.data, < double*> q_mom_w_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double*> q_numDiff_u.data, < double*> q_numDiff_v.data, < double*> q_numDiff_w.data, - < double*> q_numDiff_u_last.data, < double*> q_numDiff_v_last.data, < double*> q_numDiff_w_last.data, - < int*> sdInfo_u_u_rowptr.data, < int*> sdInfo_u_u_colind.data, - < int*> sdInfo_u_v_rowptr.data, < int*> sdInfo_u_v_colind.data, - < int*> sdInfo_u_w_rowptr.data, < int*> sdInfo_u_w_colind.data, - < int*> sdInfo_v_v_rowptr.data, < int*> sdInfo_v_v_colind.data, - < int*> sdInfo_v_u_rowptr.data, < int*> sdInfo_v_u_colind.data, - < int*> sdInfo_v_w_rowptr.data, < int*> sdInfo_v_w_colind.data, - < int*> sdInfo_w_w_rowptr.data, < int*> sdInfo_w_w_colind.data, - < int*> sdInfo_w_u_rowptr.data, < int*> sdInfo_w_u_colind.data, - < int*> sdInfo_w_v_rowptr.data, < int*> sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double*> cg.data, < double*> force.data, < double*> moment.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > forceExtractionFaces.data, nForceExtractionFaces, - < double * > ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data) - - def calculateVelocityAverage(self, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - numpy.ndarray interiorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray ebqe_velocity, - numpy.ndarray velocityAverage): - self.thisptr.calculateVelocityAverage(nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - nInteriorElementBoundaries_global, - < int * > interiorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < int * > vel_l2g.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > vel_trial_trace_ref.data, - < double * > ebqe_velocity.data, - < double * > velocityAverage.data) diff --git a/proteus/mprans/cRANS3PSed.pyx b/proteus/mprans/cRANS3PSed.pyx deleted file mode 100644 index 066e1c94bd..0000000000 --- a/proteus/mprans/cRANS3PSed.pyx +++ /dev/null @@ -1,2328 +0,0 @@ -# A type of -*- python -*- file -import proteus -from proteus import Profiling -import numpy -cimport numpy - -cdef extern from "mprans/RANS3PSed.h" namespace "proteus": - cdef cppclass cppRANS3PSed_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * q_p, - double * q_grad_p, - double * ebqe_p, - double * ebqe_grad_p, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - double * eps_solid, - double * q_velocity_fluid, - double * q_velocityStar_fluid, - double * q_vos, - double * q_dvos_dt, - double * q_grad_vos, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double * q_eddy_viscosity, - int * p_l2g, - int * vel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * ebqe_velocity_star, - double * q_cfl, - double * q_numDiff_u, - double * q_numDiff_v, - double * q_numDiff_w, - double * q_numDiff_u_last, - double * q_numDiff_v_last, - double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, - int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, - int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, - int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, - int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, - int * sdInfo_w_v_colind, - int offset_p, - int offset_u, - int offset_v, - int offset_w, - int stride_p, - int stride_u, - int stride_v, - int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - double * ebqe_vos_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * elementFlags, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * ncDrag, - double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * q_p, - double * q_grad_p, - double * ebqe_p, - double * ebqe_grad_p, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - #element boundary - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - #physics - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - double * eps_solid, - double * q_velocity_fluid, - double * q_velocityStar_fluid, - double * q_vos, - double * q_dvos_dt, - double * q_grad_vos, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc_beta_bdf, double * q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * ebqe_velocity_star, - double * q_cfl, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_p_u, int * csrColumnOffsets_p_u, - int * csrRowIndeces_p_v, int * csrColumnOffsets_p_v, - int * csrRowIndeces_p_w, int * csrColumnOffsets_p_w, - int * csrRowIndeces_u_p, int * csrColumnOffsets_u_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_p, int * csrColumnOffsets_v_p, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_p, int * csrColumnOffsets_w_p, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_vos_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - int * csrColumnOffsets_eb_p_p, - int * csrColumnOffsets_eb_p_u, - int * csrColumnOffsets_eb_p_v, - int * csrColumnOffsets_eb_p_w, - int * csrColumnOffsets_eb_u_p, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_p, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_p, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w, - int * elementFlags, - double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) - void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - int * interiorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int * vel_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * vos_dof, - double * vel_trial_trace_ref, - double * ebqe_velocity, - double * velocityAverage) - cppRANS3PSed_base * newRANS3PSed(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter, - ) - -cdef class RANS3PSed: - cdef cppRANS3PSed_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter - ): - self.thisptr = newRANS3PSed(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter - ) - - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray q_p, - numpy.ndarray q_grad_p, - numpy.ndarray ebqe_p, - numpy.ndarray ebqe_grad_p, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray q_velocity_fluid, - numpy.ndarray q_velocityStar_fluid, - numpy.ndarray q_vos, - numpy.ndarray q_dvos_dt, - numpy.ndarray q_grad_vos, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - numpy.ndarray q_eddy_viscosity, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray ebqe_velocity_star, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_vos_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray ncDrag, - double LAG_MU_FR, - numpy.ndarray q_mu_fr_last, - numpy.ndarray q_mu_fr): - self.thisptr.calculateResidual( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - PSTAB, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > q_p.data, - < double * > q_grad_p.data, - < double * > ebqe_p.data, - < double * > ebqe_grad_p.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - rho_s, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > q_velocity_fluid.data, - < double * > q_velocityStar_fluid.data, - < double * > q_vos.data, - < double * > q_dvos_dt.data, - < double * > q_grad_vos.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - < double * > q_eddy_viscosity.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > ebqe_velocity_star.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_vos_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > ncDrag.data, - LAG_MU_FR, - < double * > q_mu_fr_last.data, - < double * > q_mu_fr.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray q_p, - numpy.ndarray q_grad_p, - numpy.ndarray ebqe_p, - numpy.ndarray ebqe_grad_p, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray q_velocity_fluid, - numpy.ndarray q_velocityStar_fluid, - numpy.ndarray q_vos, - numpy.ndarray q_dvos_dt, - numpy.ndarray q_grad_vos, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray ebqe_velocity_star, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_p_u, numpy.ndarray csrColumnOffsets_p_u, - numpy.ndarray csrRowIndeces_p_v, numpy.ndarray csrColumnOffsets_p_v, - numpy.ndarray csrRowIndeces_p_w, numpy.ndarray csrColumnOffsets_p_w, - numpy.ndarray csrRowIndeces_u_p, numpy.ndarray csrColumnOffsets_u_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_p, numpy.ndarray csrColumnOffsets_v_p, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_p, numpy.ndarray csrColumnOffsets_w_p, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_vos_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray csrColumnOffsets_eb_p_p, - numpy.ndarray csrColumnOffsets_eb_p_u, - numpy.ndarray csrColumnOffsets_eb_p_v, - numpy.ndarray csrColumnOffsets_eb_p_w, - numpy.ndarray csrColumnOffsets_eb_u_p, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_p, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_p, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w, - numpy.ndarray elementFlags, - LAG_MU_FR, - numpy.ndarray q_mu_fr_last, - numpy.ndarray q_mu_fr): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double *> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - PSTAB, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > q_p.data, - < double * > q_grad_p.data, - < double * > ebqe_p.data, - < double * > ebqe_grad_p.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - rho_s, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dg, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > q_velocity_fluid.data, - < double * > q_velocityStar_fluid.data, - < double * > q_vos.data, - < double * > q_dvos_dt.data, - < double * > q_grad_vos.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > ebqe_velocity_star.data, - < double * > q_cfl.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_p_u.data, < int * > csrColumnOffsets_p_u.data, - < int * > csrRowIndeces_p_v.data, < int * > csrColumnOffsets_p_v.data, - < int * > csrRowIndeces_p_w.data, < int * > csrColumnOffsets_p_w.data, - < int * > csrRowIndeces_u_p.data, < int * > csrColumnOffsets_u_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_w.data, < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_p.data, < int * > csrColumnOffsets_v_p.data, - < int * > csrRowIndeces_v_u.data, < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_w.data, < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_w_p.data, < int * > csrColumnOffsets_w_p.data, - < int * > csrRowIndeces_w_u.data, < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_vos_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < int * > csrColumnOffsets_eb_p_p.data, - < int * > csrColumnOffsets_eb_p_u.data, - < int * > csrColumnOffsets_eb_p_v.data, - < int * > csrColumnOffsets_eb_p_w.data, - < int * > csrColumnOffsets_eb_u_p.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_u_w.data, - < int * > csrColumnOffsets_eb_v_p.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - < int * > csrColumnOffsets_eb_v_w.data, - < int * > csrColumnOffsets_eb_w_p.data, - < int * > csrColumnOffsets_eb_w_u.data, - < int * > csrColumnOffsets_eb_w_v.data, - < int * > csrColumnOffsets_eb_w_w.data, - < int * > elementFlags.data, - LAG_MU_FR, - < double * > q_mu_fr_last.data, - < double * > q_mu_fr.data) - - def calculateVelocityAverage(self, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - numpy.ndarray interiorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray vos_dof, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray ebqe_velocity, - numpy.ndarray velocityAverage): - self.thisptr.calculateVelocityAverage(nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - nInteriorElementBoundaries_global, - < int * > interiorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < int * > vel_l2g.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > vos_dof.data, - < double * > vel_trial_trace_ref.data, - < double * > ebqe_velocity.data, - < double * > velocityAverage.data) - -cdef extern from "mprans/RANS3PSed2D.h" namespace "proteus": - cdef cppclass cppRANS3PSed2D_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * q_p, - double * q_grad_p, - double * ebqe_p, - double * ebqe_grad_p, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - double * eps_solid, - double * q_velocity_fluid, - double * q_velocityStar_fluid, - double * q_vos, - double * q_dvos_dt, - double * q_grad_vos, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - double * q_eddy_viscosity, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, - double * u_dof, - double * v_dof, - double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mom_w_acc, - double * q_mass_adv, - double * q_mom_u_acc_beta_bdf, double * \ - q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * ebqe_velocity_star, - double * q_cfl, - double * q_numDiff_u, double * q_numDiff_v, double * q_numDiff_w, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_vos_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - double * q_x, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_p, - int * elementFlags, - int * boundaryFlags, - double * barycenters, - double * wettedAreas, - double * netForces_p, - double * netForces_v, - double * netMoments, - double * ncDrag, - double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - int * mesh_l2g, - double * dV_ref, - double * p_trial_ref, - double * p_grad_trial_ref, - double * p_test_ref, - double * p_grad_test_ref, - double * q_p, - double * q_grad_p, - double * ebqe_p, - double * ebqe_grad_p, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * p_trial_trace_ref, - double * p_grad_trial_trace_ref, - double * p_test_trace_ref, - double * p_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double eb_adjoint_sigma, - double * elementDiameter, - double * nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - double * eps_solid, - double * q_velocity_fluid, - double * q_velocityStar_fluid, - double * q_vos, - double * q_dvos_dt, - double * q_grad_vos, - double * q_dragAlpha, - double * q_dragBeta, - double * q_mass_source, - double * q_turb_var_0, - double * q_turb_var_1, - double * q_turb_var_grad_0, - # VRANS end - int * p_l2g, - int * vel_l2g, - double * p_dof, double * u_dof, double * v_dof, double * w_dof, - double * g, - double useVF, - double * vf, - double * phi, - double * normal_phi, - double * kappa_phi, - double * q_mom_u_acc_beta_bdf, double * \ - q_mom_v_acc_beta_bdf, double * q_mom_w_acc_beta_bdf, - double * q_dV, - double * q_dV_last, - double * q_velocity_sge, - double * ebqe_velocity_star, - double * q_cfl, - double * q_numDiff_u_last, double * q_numDiff_v_last, double * q_numDiff_w_last, - int * sdInfo_u_u_rowptr, int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, int * sdInfo_u_v_colind, - int * sdInfo_u_w_rowptr, int * sdInfo_u_w_colind, - int * sdInfo_v_v_rowptr, int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, int * sdInfo_v_u_colind, - int * sdInfo_v_w_rowptr, int * sdInfo_v_w_colind, - int * sdInfo_w_w_rowptr, int * sdInfo_w_w_colind, - int * sdInfo_w_u_rowptr, int * sdInfo_w_u_colind, - int * sdInfo_w_v_rowptr, int * sdInfo_w_v_colind, - int * csrRowIndeces_p_p, int * csrColumnOffsets_p_p, - int * csrRowIndeces_p_u, int * csrColumnOffsets_p_u, - int * csrRowIndeces_p_v, int * csrColumnOffsets_p_v, - int * csrRowIndeces_p_w, int * csrColumnOffsets_p_w, - int * csrRowIndeces_u_p, int * csrColumnOffsets_u_p, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, int * csrColumnOffsets_u_v, - int * csrRowIndeces_u_w, int * csrColumnOffsets_u_w, - int * csrRowIndeces_v_p, int * csrColumnOffsets_v_p, - int * csrRowIndeces_v_u, int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, int * csrColumnOffsets_v_v, - int * csrRowIndeces_v_w, int * csrColumnOffsets_v_w, - int * csrRowIndeces_w_p, int * csrColumnOffsets_w_p, - int * csrRowIndeces_w_u, int * csrColumnOffsets_w_u, - int * csrRowIndeces_w_v, int * csrColumnOffsets_w_v, - int * csrRowIndeces_w_w, int * csrColumnOffsets_w_w, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_vf_ext, - double * bc_ebqe_vf_ext, - double * ebqe_phi_ext, - double * bc_ebqe_phi_ext, - double * ebqe_normal_phi_ext, - double * ebqe_kappa_phi_ext, - # VRANS start - double * ebqe_vos_ext, - double * ebqe_turb_var_0, - double * ebqe_turb_var_1, - # VRANS end - int * isDOFBoundary_p, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isDOFBoundary_w, - int * isAdvectiveFluxBoundary_p, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isAdvectiveFluxBoundary_w, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_w, - double * ebqe_bc_p_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_flux_mom_w_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_penalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * ebqe_bc_w_ext, - double * ebqe_bc_flux_w_diff_ext, - int * csrColumnOffsets_eb_p_p, - int * csrColumnOffsets_eb_p_u, - int * csrColumnOffsets_eb_p_v, - int * csrColumnOffsets_eb_p_w, - int * csrColumnOffsets_eb_u_p, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_u_w, - int * csrColumnOffsets_eb_v_p, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - int * csrColumnOffsets_eb_v_w, - int * csrColumnOffsets_eb_w_p, - int * csrColumnOffsets_eb_w_u, - int * csrColumnOffsets_eb_w_v, - int * csrColumnOffsets_eb_w_w, - int * elementFlags, - double LAG_MU_FR, - double* q_mu_fr_last, - double* q_mu_fr) - void calculateVelocityAverage(int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - int * interiorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int * vel_l2g, - double * u_dof, - double * v_dof, - double * w_dof, - double * vos_dof, - double * vel_trial_trace_ref, - double * ebqe_velocity, - double * velocityAverage) - cppRANS3PSed2D_base * newRANS3PSed2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter, - ) - -cdef class RANS3PSed2D: - cdef cppRANS3PSed2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag, - double aDarcy, - double betaForch, - double grain, - double packFraction, - double packMargin, - double maxFraction, - double frFraction, - double sigmaC, - double C3e, - double C4e, - double eR, - double fContact, - double mContact, - double nContact, - double angFriction, - double vos_limiter, - double mu_fr_limiter, - ): - self.thisptr = newRANS3PSed2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag, - aDarcy, - betaForch, - grain, - packFraction, - packMargin, - maxFraction, - frFraction, - sigmaC, - C3e, - C4e, - eR, - fContact, - mContact, - nContact, - angFriction, - vos_limiter, - mu_fr_limiter, - ) - - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray q_p, - numpy.ndarray q_grad_p, - numpy.ndarray ebqe_p, - numpy.ndarray ebqe_grad_p, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - int nElementBoundaries_owned, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dc, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray q_velocity_fluid, - numpy.ndarray q_velocityStar_fluid, - numpy.ndarray q_vos, - numpy.ndarray q_dvos_dt, - numpy.ndarray q_grad_vos, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - numpy.ndarray q_eddy_viscosity, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mom_w_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray ebqe_velocity_star, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, numpy.ndarray q_numDiff_v, numpy.ndarray q_numDiff_w, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - int offset_p, int offset_u, int offset_v, int offset_w, - int stride_p, int stride_u, int stride_v, int stride_w, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_vos_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray q_x, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_p, - numpy.ndarray elementFlags, - numpy.ndarray boundaryFlags, - numpy.ndarray barycenters, - numpy.ndarray wettedAreas, - numpy.ndarray netForces_p, - numpy.ndarray netForces_v, - numpy.ndarray netMoments, - numpy.ndarray ncDrag, - double LAG_MU_FR, - numpy.ndarray q_mu_fr_last, - numpy.ndarray q_mu_fr): - self.thisptr.calculateResidual( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - PSTAB, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > q_p.data, - < double * > q_grad_p.data, - < double * > ebqe_p.data, - < double * > ebqe_grad_p.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - nElementBoundaries_owned, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - rho_s, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dc, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > q_velocity_fluid.data, - < double * > q_velocityStar_fluid.data, - < double * > q_vos.data, - < double * > q_dvos_dt.data, - < double * > q_grad_vos.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - < double * > q_eddy_viscosity.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mom_w_acc.data, - < double * > q_mass_adv.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > ebqe_velocity_star.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, < double * > q_numDiff_v.data, < double * > q_numDiff_w.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - offset_p, offset_u, offset_v, offset_w, - stride_p, stride_u, stride_v, stride_w, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_vos_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < double * > q_x.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_p.data, - < int * > elementFlags.data, - < int * > boundaryFlags.data, - < double * > barycenters.data, - < double * > wettedAreas.data, - < double * > netForces_p.data, - < double * > netForces_v.data, - < double * > netMoments.data, - < double * > ncDrag.data, - LAG_MU_FR, - < double * > q_mu_fr_last.data, - < double * > q_mu_fr.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - double PSTAB, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray p_trial_ref, - numpy.ndarray p_grad_trial_ref, - numpy.ndarray p_test_ref, - numpy.ndarray p_grad_test_ref, - numpy.ndarray q_p, - numpy.ndarray q_grad_p, - numpy.ndarray ebqe_p, - numpy.ndarray ebqe_grad_p, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray p_trial_trace_ref, - numpy.ndarray p_grad_trial_trace_ref, - numpy.ndarray p_test_trace_ref, - numpy.ndarray p_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - double eb_adjoint_sigma, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - double hFactor, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double epsFact_rho, - double epsFact_mu, - double sigma, - double rho_0, - double nu_0, - double rho_1, - double nu_1, - double rho_s, - double smagorinskyConstant, - int turbulenceClosureModel, - double Ct_sge, - double Cd_sge, - double C_dg, - double C_b, - # VRANS start - numpy.ndarray eps_solid, - numpy.ndarray q_velocity_fluid, - numpy.ndarray q_velocityStar_fluid, - numpy.ndarray q_vos, - numpy.ndarray q_dvos_dt, - numpy.ndarray q_grad_vos, - numpy.ndarray q_dragAlpha, - numpy.ndarray q_dragBeta, - numpy.ndarray q_mass_source, - numpy.ndarray q_turb_var_0, - numpy.ndarray q_turb_var_1, - numpy.ndarray q_turb_var_grad_0, - # VRANS end - numpy.ndarray p_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray p_dof, numpy.ndarray u_dof, numpy.ndarray v_dof, numpy.ndarray w_dof, - numpy.ndarray g, - double useVF, - numpy.ndarray vf, - numpy.ndarray phi, - numpy.ndarray normal_phi, - numpy.ndarray kappa_phi, - numpy.ndarray q_mom_u_acc_beta_bdf, numpy.ndarray q_mom_v_acc_beta_bdf, numpy.ndarray q_mom_w_acc_beta_bdf, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray q_velocity_sge, - numpy.ndarray ebqe_velocity_star, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u_last, numpy.ndarray q_numDiff_v_last, numpy.ndarray q_numDiff_w_last, - numpy.ndarray sdInfo_u_u_rowptr, numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_u_w_rowptr, numpy.ndarray sdInfo_u_w_colind, - numpy.ndarray sdInfo_v_v_rowptr, numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray sdInfo_v_w_rowptr, numpy.ndarray sdInfo_v_w_colind, - numpy.ndarray sdInfo_w_w_rowptr, numpy.ndarray sdInfo_w_w_colind, - numpy.ndarray sdInfo_w_u_rowptr, numpy.ndarray sdInfo_w_u_colind, - numpy.ndarray sdInfo_w_v_rowptr, numpy.ndarray sdInfo_w_v_colind, - numpy.ndarray csrRowIndeces_p_p, numpy.ndarray csrColumnOffsets_p_p, - numpy.ndarray csrRowIndeces_p_u, numpy.ndarray csrColumnOffsets_p_u, - numpy.ndarray csrRowIndeces_p_v, numpy.ndarray csrColumnOffsets_p_v, - numpy.ndarray csrRowIndeces_p_w, numpy.ndarray csrColumnOffsets_p_w, - numpy.ndarray csrRowIndeces_u_p, numpy.ndarray csrColumnOffsets_u_p, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_u_w, numpy.ndarray csrColumnOffsets_u_w, - numpy.ndarray csrRowIndeces_v_p, numpy.ndarray csrColumnOffsets_v_p, - numpy.ndarray csrRowIndeces_v_u, numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, numpy.ndarray csrColumnOffsets_v_v, - numpy.ndarray csrRowIndeces_v_w, numpy.ndarray csrColumnOffsets_v_w, - numpy.ndarray csrRowIndeces_w_p, numpy.ndarray csrColumnOffsets_w_p, - numpy.ndarray csrRowIndeces_w_u, numpy.ndarray csrColumnOffsets_w_u, - numpy.ndarray csrRowIndeces_w_v, numpy.ndarray csrColumnOffsets_w_v, - numpy.ndarray csrRowIndeces_w_w, numpy.ndarray csrColumnOffsets_w_w, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_vf_ext, - numpy.ndarray bc_ebqe_vf_ext, - numpy.ndarray ebqe_phi_ext, - numpy.ndarray bc_ebqe_phi_ext, - numpy.ndarray ebqe_normal_phi_ext, - numpy.ndarray ebqe_kappa_phi_ext, - # VRANS start - numpy.ndarray ebqe_vos_ext, - numpy.ndarray ebqe_turb_var_0, - numpy.ndarray ebqe_turb_var_1, - # VRANS end - numpy.ndarray isDOFBoundary_p, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isDOFBoundary_w, - numpy.ndarray isAdvectiveFluxBoundary_p, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_w, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_w, - numpy.ndarray ebqe_bc_p_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_w_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray ebqe_bc_w_ext, - numpy.ndarray ebqe_bc_flux_w_diff_ext, - numpy.ndarray csrColumnOffsets_eb_p_p, - numpy.ndarray csrColumnOffsets_eb_p_u, - numpy.ndarray csrColumnOffsets_eb_p_v, - numpy.ndarray csrColumnOffsets_eb_p_w, - numpy.ndarray csrColumnOffsets_eb_u_p, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_u_w, - numpy.ndarray csrColumnOffsets_eb_v_p, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - numpy.ndarray csrColumnOffsets_eb_v_w, - numpy.ndarray csrColumnOffsets_eb_w_p, - numpy.ndarray csrColumnOffsets_eb_w_u, - numpy.ndarray csrColumnOffsets_eb_w_v, - numpy.ndarray csrColumnOffsets_eb_w_w, - numpy.ndarray elementFlags, - LAG_MU_FR, - numpy.ndarray q_mu_fr_last, - numpy.ndarray q_mu_fr): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double *> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - PSTAB, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > p_trial_ref.data, - < double * > p_grad_trial_ref.data, - < double * > p_test_ref.data, - < double * > p_grad_test_ref.data, - < double * > q_p.data, - < double * > q_grad_p.data, - < double * > ebqe_p.data, - < double * > ebqe_grad_p.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > p_trial_trace_ref.data, - < double * > p_grad_trial_trace_ref.data, - < double * > p_test_trace_ref.data, - < double * > p_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - eb_adjoint_sigma, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - hFactor, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - epsFact_rho, - epsFact_mu, - sigma, - rho_0, - nu_0, - rho_1, - nu_1, - rho_s, - smagorinskyConstant, - turbulenceClosureModel, - Ct_sge, - Cd_sge, - C_dg, - C_b, - # VRANS start - < double * > eps_solid.data, - < double * > q_velocity_fluid.data, - < double * > q_velocityStar_fluid.data, - < double * > q_vos.data, - < double * > q_dvos_dt.data, - < double * > q_grad_vos.data, - < double * > q_dragAlpha.data, - < double * > q_dragBeta.data, - < double * > q_mass_source.data, - < double * > q_turb_var_0.data, - < double * > q_turb_var_1.data, - < double * > q_turb_var_grad_0.data, - # VRANS end - < int * > p_l2g.data, - < int * > vel_l2g.data, - < double * > p_dof.data, < double * > u_dof.data, < double * > v_dof.data, < double * > w_dof.data, - < double * > g.data, - useVF, - < double * > vf.data, - < double * > phi.data, - < double * > normal_phi.data, - < double * > kappa_phi.data, - < double * > q_mom_u_acc_beta_bdf.data, < double * > q_mom_v_acc_beta_bdf.data, < double * > q_mom_w_acc_beta_bdf.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > q_velocity_sge.data, - < double * > ebqe_velocity_star.data, - < double * > q_cfl.data, - < double * > q_numDiff_u_last.data, < double * > q_numDiff_v_last.data, < double * > q_numDiff_w_last.data, - < int * > sdInfo_u_u_rowptr.data, < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_u_w_rowptr.data, < int * > sdInfo_u_w_colind.data, - < int * > sdInfo_v_v_rowptr.data, < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, < int * > sdInfo_v_u_colind.data, - < int * > sdInfo_v_w_rowptr.data, < int * > sdInfo_v_w_colind.data, - < int * > sdInfo_w_w_rowptr.data, < int * > sdInfo_w_w_colind.data, - < int * > sdInfo_w_u_rowptr.data, < int * > sdInfo_w_u_colind.data, - < int * > sdInfo_w_v_rowptr.data, < int * > sdInfo_w_v_colind.data, - < int * > csrRowIndeces_p_p.data, < int * > csrColumnOffsets_p_p.data, - < int * > csrRowIndeces_p_u.data, < int * > csrColumnOffsets_p_u.data, - < int * > csrRowIndeces_p_v.data, < int * > csrColumnOffsets_p_v.data, - < int * > csrRowIndeces_p_w.data, < int * > csrColumnOffsets_p_w.data, - < int * > csrRowIndeces_u_p.data, < int * > csrColumnOffsets_u_p.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_u_w.data, < int * > csrColumnOffsets_u_w.data, - < int * > csrRowIndeces_v_p.data, < int * > csrColumnOffsets_v_p.data, - < int * > csrRowIndeces_v_u.data, < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, < int * > csrColumnOffsets_v_v.data, - < int * > csrRowIndeces_v_w.data, < int * > csrColumnOffsets_v_w.data, - < int * > csrRowIndeces_w_p.data, < int * > csrColumnOffsets_w_p.data, - < int * > csrRowIndeces_w_u.data, < int * > csrColumnOffsets_w_u.data, - < int * > csrRowIndeces_w_v.data, < int * > csrColumnOffsets_w_v.data, - < int * > csrRowIndeces_w_w.data, < int * > csrColumnOffsets_w_w.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_vf_ext.data, - < double * > bc_ebqe_vf_ext.data, - < double * > ebqe_phi_ext.data, - < double * > bc_ebqe_phi_ext.data, - < double * > ebqe_normal_phi_ext.data, - < double * > ebqe_kappa_phi_ext.data, - # VRANS start - < double * > ebqe_vos_ext.data, - < double * > ebqe_turb_var_0.data, - < double * > ebqe_turb_var_1.data, - # VRANS end - < int * > isDOFBoundary_p.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isDOFBoundary_w.data, - < int * > isAdvectiveFluxBoundary_p.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isAdvectiveFluxBoundary_w.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_w.data, - < double * > ebqe_bc_p_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_flux_mom_w_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_penalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > ebqe_bc_w_ext.data, - < double * > ebqe_bc_flux_w_diff_ext.data, - < int * > csrColumnOffsets_eb_p_p.data, - < int * > csrColumnOffsets_eb_p_u.data, - < int * > csrColumnOffsets_eb_p_v.data, - < int * > csrColumnOffsets_eb_p_w.data, - < int * > csrColumnOffsets_eb_u_p.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_u_w.data, - < int * > csrColumnOffsets_eb_v_p.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - < int * > csrColumnOffsets_eb_v_w.data, - < int * > csrColumnOffsets_eb_w_p.data, - < int * > csrColumnOffsets_eb_w_u.data, - < int * > csrColumnOffsets_eb_w_v.data, - < int * > csrColumnOffsets_eb_w_w.data, - < int * > elementFlags.data, - LAG_MU_FR, - < double * > q_mu_fr_last.data, - < double * > q_mu_fr.data) - - def calculateVelocityAverage(self, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - int nInteriorElementBoundaries_global, - numpy.ndarray interiorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray vel_l2g, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray w_dof, - numpy.ndarray vos_dof, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray ebqe_velocity, - numpy.ndarray velocityAverage): - self.thisptr.calculateVelocityAverage(nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - nInteriorElementBoundaries_global, - < int * > interiorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < int * > vel_l2g.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > w_dof.data, - < double * > vos_dof.data, - < double * > vel_trial_trace_ref.data, - < double * > ebqe_velocity.data, - < double * > velocityAverage.data) diff --git a/proteus/mprans/cRDLS.pyx b/proteus/mprans/cRDLS.pyx deleted file mode 100644 index a925921210..0000000000 --- a/proteus/mprans/cRDLS.pyx +++ /dev/null @@ -1,898 +0,0 @@ -# A type of -*- python -*- file -from libcpp cimport bool -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "RDLS.h" namespace "proteus": - cdef cppclass RDLS_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * phi_ls, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * u_weak_internal_bc_dofs, - double * q_m_betaBDF, - double * q_dH_last, - double * q_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int * weakDirichletConditionFlags, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_phi_ls_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - double * ebqe_u, - double * ebqe_n, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double * lumped_qx, - double * lumped_qy, - double * lumped_qz, - double alpha, - bool useExact) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * u_weak_internal_bc_dofs, - double * phi_ls, - double * q_m_betaBDF, - double * q_dH_last, - double * q_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int * weakDirichletConditionFlags, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_phi_ls_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double alpha, - bool useExact) - void calculateResidual_ellipticRedist(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * phi_ls, - double * q_m, - double * q_u, - double * q_n, - double * q_dH, - double * u_weak_internal_bc_dofs, - double * q_m_betaBDF, - double * q_dH_last, - double * q_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int * weakDirichletConditionFlags, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_phi_ls_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - double * ebqe_u, - double * ebqe_n, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double * lumped_qx, - double * lumped_qy, - double * lumped_qz, - double alpha, - bool useExact) - void calculateJacobian_ellipticRedist(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - int * mesh_l2g, - double * x_ref, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - int * u_l2g, - double * elementDiameter, - double * nodeDiametersArray, - double * u_dof, - double * phi_dof, - double * u_weak_internal_bc_dofs, - double * phi_ls, - double * q_m_betaBDF, - double * q_dH_last, - double * q_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int * weakDirichletConditionFlags, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_phi_ls_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * csrColumnOffsets_eb_u_u, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double alpha, - bool useExact) - void normalReconstruction(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* elementDiameter, - double* phi_dof, - int offset_u, int stride_u, - int numDOFs, - double* lumped_qx, - double* lumped_qy, - double* lumped_qz) - void calculateMetricsAtEOS(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - int nElements_global, - int* u_l2g, - double* elementDiameter, - double degree_polynomial, - double epsFactHeaviside, - double* u_dof, - double* u_exact, - int offset_u, int stride_u, - double* global_I_err, - double* global_V_err, - double* global_D_err) - RDLS_base * newRDLS(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cRDLS_base: - cdef RDLS_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newRDLS(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray phi_ls, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray u_weak_internal_bc_dofs, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dH_last, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray weakDirichletConditionFlags, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_phi_ls_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - numpy.ndarray lumped_qx, - numpy.ndarray lumped_qy, - numpy.ndarray lumped_qz, - double alpha, - bool useExact): - self.thisptr.calculateResidual( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - epsFact_redist, - backgroundDiffusionFactor, - weakDirichletFactor, - freezeLevelSet, - useTimeIntegration, - lag_shockCapturing, - lag_subgridError, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > phi_ls.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > q_dH.data, - < double * > u_weak_internal_bc_dofs.data, - < double * > q_m_betaBDF.data, - < double * > q_dH_last.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < int * > weakDirichletConditionFlags.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_phi_ls_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - ELLIPTIC_REDISTANCING, - backgroundDissipationEllipticRedist, - < double * > lumped_qx.data, - < double * > lumped_qy.data, - < double * > lumped_qz.data, - alpha, - useExact) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray u_weak_internal_bc_dofs, - numpy.ndarray phi_ls, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dH_last, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray weakDirichletConditionFlags, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_phi_ls_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double alpha, - bool useExact): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - epsFact_redist, - backgroundDiffusionFactor, - weakDirichletFactor, - freezeLevelSet, - useTimeIntegration, - lag_shockCapturing, - lag_subgridError, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > u_weak_internal_bc_dofs.data, - < double * > phi_ls.data, - < double * > q_m_betaBDF.data, - < double * > q_dH_last.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < int * > weakDirichletConditionFlags.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_phi_ls_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - ELLIPTIC_REDISTANCING, - backgroundDissipationEllipticRedist, - alpha, - useExact) - - def calculateResidual_ellipticRedist(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray phi_ls, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_n, - numpy.ndarray q_dH, - numpy.ndarray u_weak_internal_bc_dofs, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dH_last, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray weakDirichletConditionFlags, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_phi_ls_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_n, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - numpy.ndarray lumped_qx, - numpy.ndarray lumped_qy, - numpy.ndarray lumped_qz, - double alpha, - bool useExact): - self.thisptr.calculateResidual_ellipticRedist( < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - epsFact_redist, - backgroundDiffusionFactor, - weakDirichletFactor, - freezeLevelSet, - useTimeIntegration, - lag_shockCapturing, - lag_subgridError, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > phi_ls.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_n.data, - < double * > q_dH.data, - < double * > u_weak_internal_bc_dofs.data, - < double * > q_m_betaBDF.data, - < double * > q_dH_last.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < int * > weakDirichletConditionFlags.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_phi_ls_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_u.data, - < double * > ebqe_n.data, - ELLIPTIC_REDISTANCING, - backgroundDissipationEllipticRedist, - < double * > lumped_qx.data, - < double * > lumped_qy.data, - < double * > lumped_qz.data, - alpha, - useExact) - - def calculateJacobian_ellipticRedist(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray x_ref, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - double epsFact_redist, - double backgroundDiffusionFactor, - double weakDirichletFactor, - int freezeLevelSet, - int useTimeIntegration, - int lag_shockCapturing, - int lag_subgridError, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray nodeDiametersArray, - numpy.ndarray u_dof, - numpy.ndarray phi_dof, - numpy.ndarray u_weak_internal_bc_dofs, - numpy.ndarray phi_ls, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dH_last, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray weakDirichletConditionFlags, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_phi_ls_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int ELLIPTIC_REDISTANCING, - double backgroundDissipationEllipticRedist, - double alpha, - bool useExact): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian_ellipticRedist(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < int * > mesh_l2g.data, - < double * > x_ref.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - epsFact_redist, - backgroundDiffusionFactor, - weakDirichletFactor, - freezeLevelSet, - useTimeIntegration, - lag_shockCapturing, - lag_subgridError, - shockCapturingDiffusion, - < int * > u_l2g.data, - < double * > elementDiameter.data, - < double * > nodeDiametersArray.data, - < double * > u_dof.data, - < double * > phi_dof.data, - < double * > u_weak_internal_bc_dofs.data, - < double * > phi_ls.data, - < double * > q_m_betaBDF.data, - < double * > q_dH_last.data, - < double * > q_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - < int * > weakDirichletConditionFlags.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_phi_ls_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - ELLIPTIC_REDISTANCING, - backgroundDissipationEllipticRedist, - alpha, - useExact) - def normalReconstruction(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray phi_dof, - int offset_u, int stride_u, - int numDOFs, - numpy.ndarray lumped_qx, - numpy.ndarray lumped_qy, - numpy.ndarray lumped_qz): - self.thisptr.normalReconstruction( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - elementDiameter.data, - phi_dof.data, - offset_u, stride_u, - numDOFs, - lumped_qx.data, - lumped_qy.data, - lumped_qz.data) - def calculateMetricsAtEOS(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - int nElements_global, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - double degree_polynomial, - double epsFactHeaviside, - numpy.ndarray u_dof, - numpy.ndarray u_exact, - int offset_u, int stride_u): - cdef double global_I_err - cdef double global_V_err - cdef double global_D_err - self.thisptr.calculateMetricsAtEOS(mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - nElements_global, - u_l2g.data, - elementDiameter.data, - degree_polynomial, - epsFactHeaviside, - u_dof.data, - u_exact.data, - offset_u, - stride_u, - &global_I_err, - &global_V_err, - &global_D_err) - return(global_I_err, - global_V_err, - global_D_err) - diff --git a/proteus/mprans/cSW2D.pyx b/proteus/mprans/cSW2D.pyx deleted file mode 100644 index 3165fb6824..0000000000 --- a/proteus/mprans/cSW2D.pyx +++ /dev/null @@ -1,1310 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "SW2D.h" namespace "proteus": - cdef cppclass SW2D_base: - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - double shockCapturingCoefficient, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * u_dof, - double * v_dof, - double * h_dof_sge, - double * u_dof_sge, - double * v_dof_sge, - double * q_mass_acc, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mass_adv, - double * q_mass_acc_beta_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_h, - double * q_numDiff_u, - double * q_numDiff_v, - double * q_numDiff_h_last, - double * q_numDiff_u_last, - double * q_numDiff_v_last, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_h) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * u_dof, - double * v_dof, - double * h_dof_sge, - double * u_dof_sge, - double * v_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_h_last, - double * q_numDiff_u_last, - double * q_numDiff_v_last, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v) - void calculateResidual_supg(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - double shockCapturingCoefficient, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * u_dof, - double * v_dof, - double * h_dof_sge, - double * u_dof_sge, - double * v_dof_sge, - double * q_mass_acc, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mass_adv, - double * q_mass_acc_beta_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_h, - double * q_numDiff_u, - double * q_numDiff_v, - double * q_numDiff_h_last, - double * q_numDiff_u_last, - double * q_numDiff_v_last, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_h) - void calculateJacobian_supg(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * u_dof, - double * v_dof, - double * h_dof_sge, - double * u_dof_sge, - double * v_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_velocity_sge, - double * q_cfl, - double * q_numDiff_h_last, - double * q_numDiff_u_last, - double * q_numDiff_v_last, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v) - SW2D_base * newSW2D(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cSW2D_base: - cdef SW2D_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newSW2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - double shockCapturingCoefficient, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray u_dof_sge, - numpy.ndarray v_dof_sge, - numpy.ndarray q_mass_acc, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_h, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_v, - numpy.ndarray q_numDiff_h_last, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray q_numDiff_v_last, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_h): - self.thisptr.calculateResidual( # element - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - # element boundary - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - # physics - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - shockCapturingCoefficient, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > h_dof_sge.data, - < double * > u_dof_sge.data, - < double * > v_dof_sge.data, - < double * > q_mass_acc.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mass_adv.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_h.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_v.data, - < double * > q_numDiff_h_last.data, - < double * > q_numDiff_u_last.data, - < double * > q_numDiff_v_last.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - offset_h, - offset_u, - offset_v, - stride_h, - stride_u, - stride_v, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_h.data) - - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray u_dof_sge, - numpy.ndarray v_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_h_last, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray q_numDiff_v_last, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > h_dof_sge.data, - < double * > u_dof_sge.data, - < double * > v_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_h_last.data, - < double * > q_numDiff_u_last.data, - < double * > q_numDiff_v_last.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data) - - def calculateResidual_supg(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - double shockCapturingCoefficient, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray u_dof_sge, - numpy.ndarray v_dof_sge, - numpy.ndarray q_mass_acc, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_h, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_v, - numpy.ndarray q_numDiff_h_last, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray q_numDiff_v_last, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_h): - self.thisptr.calculateResidual_supg( # element - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - # element boundary - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - # physics - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - shockCapturingCoefficient, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > h_dof_sge.data, - < double * > u_dof_sge.data, - < double * > v_dof_sge.data, - < double * > q_mass_acc.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mass_adv.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_h.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_v.data, - < double * > q_numDiff_h_last.data, - < double * > q_numDiff_u_last.data, - < double * > q_numDiff_v_last.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - offset_h, - offset_u, - offset_v, - stride_h, - stride_u, - stride_v, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_h.data) - - def calculateJacobian_supg(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray u_dof, - numpy.ndarray v_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray u_dof_sge, - numpy.ndarray v_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_velocity_sge, - numpy.ndarray q_cfl, - numpy.ndarray q_numDiff_h_last, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray q_numDiff_v_last, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian_supg(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > u_dof.data, - < double * > v_dof.data, - < double * > h_dof_sge.data, - < double * > u_dof_sge.data, - < double * > v_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_velocity_sge.data, - < double * > q_cfl.data, - < double * > q_numDiff_h_last.data, - < double * > q_numDiff_u_last.data, - < double * > q_numDiff_v_last.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data) diff --git a/proteus/mprans/cSW2DCV.pyx b/proteus/mprans/cSW2DCV.pyx deleted file mode 100644 index 7b98d59163..0000000000 --- a/proteus/mprans/cSW2DCV.pyx +++ /dev/null @@ -1,1300 +0,0 @@ -# A type of -*- python -*- file -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "SW2DCV.h" namespace "proteus": - cdef cppclass SW2DCV_base: - void FCTStep(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * b_dof, - double * high_order_hnp1, - double * high_order_hunp1, - double * high_order_hvnp1, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * limited_hnp1, - double * limited_hunp1, - double * limited_hvnp1, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dH_minus_dL, - double * muH_minus_muL, - double hEps, - double * hReg, - int LUMPED_MASS_MATRIX, - double * dLow, - double * hBT, - double * huBT, - double * hvBT) - void convexLimiting(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * b_dof, - double * high_order_hnp1, - double * high_order_hunp1, - double * high_order_hvnp1, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * limited_hnp1, - double * limited_hunp1, - double * limited_hvnp1, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dH_minus_dL, - double * muH_minus_muL, - double hEps, - double * hReg, - int LUMPED_MASS_MATRIX, - double * dLow, - double * hBT, - double * huBT, - double * hvBT) - double calculateEdgeBasedCFL( - double g, - int numDOFsPerEqn, - double * lumped_mass_matrix, - double * h_old, - double * hu_old, - double * hv_old, - double * b_dof, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double hEps, - double * hReg, - double * Cx, - double * Cy, - double * CTx, - double * CTy, - double * dLow, - double run_cfl, - double * edge_based_cfl, - int debug) - void calculateResidual(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * h_dof_old, - double * hu_dof_old, - double * hv_dof_old, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * q_mass_acc, - double * q_mom_u_acc, - double * q_mom_v_acc, - double * q_mass_adv, - double * q_mass_acc_beta_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - double * q_velocity, - double * ebqe_velocity, - double * flux, - double * elementResidual_h, - double * Cx, - double * Cy, - double * CTx, - double * CTy, - int numDOFsPerEqn, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * lumped_mass_matrix, - double cfl_run, - double hEps, - double * hReg, - double * hnp1_at_quad_point, - double * hunp1_at_quad_point, - double * hvnp1_at_quad_point, - double * extendedSourceTerm_hu, - double * extendedSourceTerm_hv, - double * dH_minus_dL, - double * muH_minus_muL, - double cE, - int LUMPED_MASS_MATRIX, - double dt, - int LINEAR_FRICTION, - double mannings, - double * quantDOFs, - int SECOND_CALL_CALCULATE_RESIDUAL, - int COMPUTE_NORMALS, - double * normalx, - double * normaly, - double * dLow, - double * hBT, - double * huBT, - double * hvBT, - int lstage) - void calculateMassMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - double dt) - void calculateLumpedMassMatrix(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * h_trial_ref, - double * h_grad_trial_ref, - double * h_test_ref, - double * h_grad_test_ref, - double * vel_trial_ref, - double * vel_grad_trial_ref, - double * vel_test_ref, - double * vel_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * h_trial_trace_ref, - double * h_grad_trial_trace_ref, - double * h_test_trace_ref, - double * h_grad_test_trace_ref, - double * vel_trial_trace_ref, - double * vel_grad_trial_trace_ref, - double * vel_test_trace_ref, - double * vel_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - double * elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - int * h_l2g, - int * vel_l2g, - double * b_dof, - double * h_dof, - double * hu_dof, - double * hv_dof, - double * h_dof_sge, - double * hu_dof_sge, - double * hv_dof_sge, - double * q_mass_acc_bdf, - double * q_mom_u_acc_beta_bdf, - double * q_mom_v_acc_beta_bdf, - double * q_cfl, - int * sdInfo_u_u_rowptr, - int * sdInfo_u_u_colind, - int * sdInfo_u_v_rowptr, - int * sdInfo_u_v_colind, - int * sdInfo_v_v_rowptr, - int * sdInfo_v_v_colind, - int * sdInfo_v_u_rowptr, - int * sdInfo_v_u_colind, - int * csrRowIndeces_h_h, - int * csrColumnOffsets_h_h, - int * csrRowIndeces_h_u, - int * csrColumnOffsets_h_u, - int * csrRowIndeces_h_v, - int * csrColumnOffsets_h_v, - int * csrRowIndeces_u_h, - int * csrColumnOffsets_u_h, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - int * csrRowIndeces_u_v, - int * csrColumnOffsets_u_v, - int * csrRowIndeces_v_h, - int * csrColumnOffsets_v_h, - int * csrRowIndeces_v_u, - int * csrColumnOffsets_v_u, - int * csrRowIndeces_v_v, - int * csrColumnOffsets_v_v, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - int * isDOFBoundary_h, - int * isDOFBoundary_u, - int * isDOFBoundary_v, - int * isAdvectiveFluxBoundary_h, - int * isAdvectiveFluxBoundary_u, - int * isAdvectiveFluxBoundary_v, - int * isDiffusiveFluxBoundary_u, - int * isDiffusiveFluxBoundary_v, - double * ebqe_bc_h_ext, - double * ebqe_bc_flux_mass_ext, - double * ebqe_bc_flux_mom_u_adv_ext, - double * ebqe_bc_flux_mom_v_adv_ext, - double * ebqe_bc_u_ext, - double * ebqe_bc_flux_u_diff_ext, - double * ebqe_henalty_ext, - double * ebqe_bc_v_ext, - double * ebqe_bc_flux_v_diff_ext, - int * csrColumnOffsets_eb_h_h, - int * csrColumnOffsets_eb_h_u, - int * csrColumnOffsets_eb_h_v, - int * csrColumnOffsets_eb_u_h, - int * csrColumnOffsets_eb_u_u, - int * csrColumnOffsets_eb_u_v, - int * csrColumnOffsets_eb_v_h, - int * csrColumnOffsets_eb_v_u, - int * csrColumnOffsets_eb_v_v, - double dt) - SW2DCV_base * newSW2DCV(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cSW2DCV_base: - cdef SW2DCV_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newSW2DCV(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def FCTStep(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray b_dof, - numpy.ndarray high_order_hnp1, - numpy.ndarray high_order_hunp1, - numpy.ndarray high_order_hvnp1, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray limited_hnp1, - numpy.ndarray limited_hunp1, - numpy.ndarray limited_hvnp1, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double hEps, - numpy.ndarray hReg, - int LUMPED_MASS_MATRIX, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT): - self.thisptr.FCTStep(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > b_dof.data, - < double * > high_order_hnp1.data, - < double * > high_order_hunp1.data, - < double * > high_order_hvnp1.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > limited_hnp1.data, - < double * > limited_hunp1.data, - < double * > limited_hvnp1.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - hEps, - < double * > hReg.data, - LUMPED_MASS_MATRIX, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data) - def convexLimiting(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray b_dof, - numpy.ndarray high_order_hnp1, - numpy.ndarray high_order_hunp1, - numpy.ndarray high_order_hvnp1, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray limited_hnp1, - numpy.ndarray limited_hunp1, - numpy.ndarray limited_hvnp1, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double hEps, - numpy.ndarray hReg, - int LUMPED_MASS_MATRIX, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT): - self.thisptr.convexLimiting(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > b_dof.data, - < double * > high_order_hnp1.data, - < double * > high_order_hunp1.data, - < double * > high_order_hvnp1.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > limited_hnp1.data, - < double * > limited_hunp1.data, - < double * > limited_hvnp1.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - hEps, - < double * > hReg.data, - LUMPED_MASS_MATRIX, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data) - def calculateEdgeBasedCFL(self, - double g, - int numDOFsPerEqn, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray h_old, - numpy.ndarray hu_old, - numpy.ndarray hv_old, - numpy.ndarray b_dof, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - double hEps, - numpy.ndarray hReg, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray CTx, - numpy.ndarray CTy, - numpy.ndarray dLow, - double run_cfl, - numpy.ndarray edge_based_cfl, - int debug): - return self.thisptr.calculateEdgeBasedCFL( - g, - numDOFsPerEqn, - < double * > lumped_mass_matrix.data, - < double * > h_old.data, - < double * > hu_old.data, - < double * > hv_old.data, - < double * > b_dof.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - hEps, - < double * > hReg.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > CTx.data, - < double * > CTy.data, - < double * > dLow.data, - run_cfl, - < double * > edge_based_cfl.data, - debug) - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray h_dof_old, - numpy.ndarray hu_dof_old, - numpy.ndarray hv_dof_old, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray q_mass_acc, - numpy.ndarray q_mom_u_acc, - numpy.ndarray q_mom_v_acc, - numpy.ndarray q_mass_adv, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - int offset_h, - int offset_u, - int offset_v, - int stride_h, - int stride_u, - int stride_v, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray q_velocity, - numpy.ndarray ebqe_velocity, - numpy.ndarray flux, - numpy.ndarray elementResidual_h, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray CTx, - numpy.ndarray CTy, - int numDOFsPerEqn, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray lumped_mass_matrix, - double cfl_run, - double hEps, - numpy.ndarray hReg, - numpy.ndarray hnp1_at_quad_point, - numpy.ndarray hunp1_at_quad_point, - numpy.ndarray hvnp1_at_quad_point, - numpy.ndarray extendedSourceTerm_hu, - numpy.ndarray extendedSourceTerm_hv, - numpy.ndarray dH_minus_dL, - numpy.ndarray muH_minus_muL, - double cE, - int LUMPED_MASS_MATRIX, - double dt, - int LINEAR_FRICTION, - double mannings, - numpy.ndarray quantDOFs, - int SECOND_CALL_CALCULATE_RESIDUAL, - int COMPUTE_NORMALS, - numpy.ndarray normalx, - numpy.ndarray normaly, - numpy.ndarray dLow, - numpy.ndarray hBT, - numpy.ndarray huBT, - numpy.ndarray hvBT, - int lstage): - self.thisptr.calculateResidual(< double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > h_dof_old.data, - < double * > hu_dof_old.data, - < double * > hv_dof_old.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > q_mass_acc.data, - < double * > q_mom_u_acc.data, - < double * > q_mom_v_acc.data, - < double * > q_mass_adv.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - offset_h, - offset_u, - offset_v, - stride_h, - stride_u, - stride_v, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < double * > q_velocity.data, - < double * > ebqe_velocity.data, - < double * > flux.data, - < double * > elementResidual_h.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > CTx.data, - < double * > CTy.data, - numDOFsPerEqn, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > lumped_mass_matrix.data, - cfl_run, - hEps, - < double * > hReg.data, - < double * > hnp1_at_quad_point.data, - < double * > hunp1_at_quad_point.data, - < double * > hvnp1_at_quad_point.data, - < double * > extendedSourceTerm_hu.data, - < double * > extendedSourceTerm_hv.data, - < double * > dH_minus_dL.data, - < double * > muH_minus_muL.data, - cE, - LUMPED_MASS_MATRIX, - dt, - LINEAR_FRICTION, - mannings, - < double * > quantDOFs.data, - SECOND_CALL_CALCULATE_RESIDUAL, - COMPUTE_NORMALS, - < double * > normalx.data, - < double * > normaly.data, - < double * > dLow.data, - < double * > hBT.data, - < double * > huBT.data, - < double * > hvBT.data, - lstage) - def calculateMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - double dt): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateMassMatrix(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - dt) - - def calculateLumpedMassMatrix(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray h_trial_ref, - numpy.ndarray h_grad_trial_ref, - numpy.ndarray h_test_ref, - numpy.ndarray h_grad_test_ref, - numpy.ndarray vel_trial_ref, - numpy.ndarray vel_grad_trial_ref, - numpy.ndarray vel_test_ref, - numpy.ndarray vel_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray h_trial_trace_ref, - numpy.ndarray h_grad_trial_trace_ref, - numpy.ndarray h_test_trace_ref, - numpy.ndarray h_grad_test_trace_ref, - numpy.ndarray vel_trial_trace_ref, - numpy.ndarray vel_grad_trial_trace_ref, - numpy.ndarray vel_test_trace_ref, - numpy.ndarray vel_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - numpy.ndarray elementDiameter, - int nElements_global, - double useRBLES, - double useMetrics, - double alphaBDF, - double nu, - double g, - numpy.ndarray h_l2g, - numpy.ndarray vel_l2g, - numpy.ndarray b_dof, - numpy.ndarray h_dof, - numpy.ndarray hu_dof, - numpy.ndarray hv_dof, - numpy.ndarray h_dof_sge, - numpy.ndarray hu_dof_sge, - numpy.ndarray hv_dof_sge, - numpy.ndarray q_mass_acc_beta_bdf, - numpy.ndarray q_mom_u_acc_beta_bdf, - numpy.ndarray q_mom_v_acc_beta_bdf, - numpy.ndarray q_cfl, - numpy.ndarray sdInfo_u_u_rowptr, - numpy.ndarray sdInfo_u_u_colind, - numpy.ndarray sdInfo_u_v_rowptr, - numpy.ndarray sdInfo_u_v_colind, - numpy.ndarray sdInfo_v_v_rowptr, - numpy.ndarray sdInfo_v_v_colind, - numpy.ndarray sdInfo_v_u_rowptr, - numpy.ndarray sdInfo_v_u_colind, - numpy.ndarray csrRowIndeces_h_h, - numpy.ndarray csrColumnOffsets_h_h, - numpy.ndarray csrRowIndeces_h_u, - numpy.ndarray csrColumnOffsets_h_u, - numpy.ndarray csrRowIndeces_h_v, - numpy.ndarray csrColumnOffsets_h_v, - numpy.ndarray csrRowIndeces_u_h, - numpy.ndarray csrColumnOffsets_u_h, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - numpy.ndarray csrRowIndeces_u_v, - numpy.ndarray csrColumnOffsets_u_v, - numpy.ndarray csrRowIndeces_v_h, - numpy.ndarray csrColumnOffsets_v_h, - numpy.ndarray csrRowIndeces_v_u, - numpy.ndarray csrColumnOffsets_v_u, - numpy.ndarray csrRowIndeces_v_v, - numpy.ndarray csrColumnOffsets_v_v, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray isDOFBoundary_h, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray isDOFBoundary_v, - numpy.ndarray isAdvectiveFluxBoundary_h, - numpy.ndarray isAdvectiveFluxBoundary_u, - numpy.ndarray isAdvectiveFluxBoundary_v, - numpy.ndarray isDiffusiveFluxBoundary_u, - numpy.ndarray isDiffusiveFluxBoundary_v, - numpy.ndarray ebqe_bc_h_ext, - numpy.ndarray ebqe_bc_flux_mass_ext, - numpy.ndarray ebqe_bc_flux_mom_u_adv_ext, - numpy.ndarray ebqe_bc_flux_mom_v_adv_ext, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray ebqe_bc_flux_u_diff_ext, - numpy.ndarray ebqe_henalty_ext, - numpy.ndarray ebqe_bc_v_ext, - numpy.ndarray ebqe_bc_flux_v_diff_ext, - numpy.ndarray csrColumnOffsets_eb_h_h, - numpy.ndarray csrColumnOffsets_eb_h_u, - numpy.ndarray csrColumnOffsets_eb_h_v, - numpy.ndarray csrColumnOffsets_eb_u_h, - numpy.ndarray csrColumnOffsets_eb_u_u, - numpy.ndarray csrColumnOffsets_eb_u_v, - numpy.ndarray csrColumnOffsets_eb_v_h, - numpy.ndarray csrColumnOffsets_eb_v_u, - numpy.ndarray csrColumnOffsets_eb_v_v, - double dt): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateLumpedMassMatrix(< double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > h_trial_ref.data, - < double * > h_grad_trial_ref.data, - < double * > h_test_ref.data, - < double * > h_grad_test_ref.data, - < double * > vel_trial_ref.data, - < double * > vel_grad_trial_ref.data, - < double * > vel_test_ref.data, - < double * > vel_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > h_trial_trace_ref.data, - < double * > h_grad_trial_trace_ref.data, - < double * > h_test_trace_ref.data, - < double * > h_grad_test_trace_ref.data, - < double * > vel_trial_trace_ref.data, - < double * > vel_grad_trial_trace_ref.data, - < double * > vel_test_trace_ref.data, - < double * > vel_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - < double * > elementDiameter.data, - nElements_global, - useRBLES, - useMetrics, - alphaBDF, - nu, - g, - < int * > h_l2g.data, - < int * > vel_l2g.data, - < double * > b_dof.data, - < double * > h_dof.data, - < double * > hu_dof.data, - < double * > hv_dof.data, - < double * > h_dof_sge.data, - < double * > hu_dof_sge.data, - < double * > hv_dof_sge.data, - < double * > q_mass_acc_beta_bdf.data, - < double * > q_mom_u_acc_beta_bdf.data, - < double * > q_mom_v_acc_beta_bdf.data, - < double * > q_cfl.data, - < int * > sdInfo_u_u_rowptr.data, - < int * > sdInfo_u_u_colind.data, - < int * > sdInfo_u_v_rowptr.data, - < int * > sdInfo_u_v_colind.data, - < int * > sdInfo_v_v_rowptr.data, - < int * > sdInfo_v_v_colind.data, - < int * > sdInfo_v_u_rowptr.data, - < int * > sdInfo_v_u_colind.data, - < int * > csrRowIndeces_h_h.data, - < int * > csrColumnOffsets_h_h.data, - < int * > csrRowIndeces_h_u.data, - < int * > csrColumnOffsets_h_u.data, - < int * > csrRowIndeces_h_v.data, - < int * > csrColumnOffsets_h_v.data, - < int * > csrRowIndeces_u_h.data, - < int * > csrColumnOffsets_u_h.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < int * > csrRowIndeces_u_v.data, - < int * > csrColumnOffsets_u_v.data, - < int * > csrRowIndeces_v_h.data, - < int * > csrColumnOffsets_v_h.data, - < int * > csrRowIndeces_v_u.data, - < int * > csrColumnOffsets_v_u.data, - < int * > csrRowIndeces_v_v.data, - < int * > csrColumnOffsets_v_v.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < int * > isDOFBoundary_h.data, - < int * > isDOFBoundary_u.data, - < int * > isDOFBoundary_v.data, - < int * > isAdvectiveFluxBoundary_h.data, - < int * > isAdvectiveFluxBoundary_u.data, - < int * > isAdvectiveFluxBoundary_v.data, - < int * > isDiffusiveFluxBoundary_u.data, - < int * > isDiffusiveFluxBoundary_v.data, - < double * > ebqe_bc_h_ext.data, - < double * > ebqe_bc_flux_mass_ext.data, - < double * > ebqe_bc_flux_mom_u_adv_ext.data, - < double * > ebqe_bc_flux_mom_v_adv_ext.data, - < double * > ebqe_bc_u_ext.data, - < double * > ebqe_bc_flux_u_diff_ext.data, - < double * > ebqe_henalty_ext.data, - < double * > ebqe_bc_v_ext.data, - < double * > ebqe_bc_flux_v_diff_ext.data, - < int * > csrColumnOffsets_eb_h_h.data, - < int * > csrColumnOffsets_eb_h_u.data, - < int * > csrColumnOffsets_eb_h_v.data, - < int * > csrColumnOffsets_eb_u_h.data, - < int * > csrColumnOffsets_eb_u_u.data, - < int * > csrColumnOffsets_eb_u_v.data, - < int * > csrColumnOffsets_eb_v_h.data, - < int * > csrColumnOffsets_eb_v_u.data, - < int * > csrColumnOffsets_eb_v_v.data, - dt) diff --git a/proteus/mprans/cVOF.pyx b/proteus/mprans/cVOF.pyx deleted file mode 100644 index 611dcb0553..0000000000 --- a/proteus/mprans/cVOF.pyx +++ /dev/null @@ -1,760 +0,0 @@ -# A type of -*- python -*- file -""" -An optimized volume-of-fluid transport module -""" -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "VOF.h" namespace "proteus": - cdef cppclass VOF_base: - void calculateResidualElementBased(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - double * q_porosity, - double * porosity_dof, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - int stage, - double * uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double * uLow, - double * dLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double * q_porosity, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - int * csrColumnOffsets_eb_u_u, - int STABILIZATION_TYPE) - void FCTStep(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * soln, - double * solH, - double * uLow, - double * dLow, - double * limited_solution, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE) - void calculateResidualEdgeBased(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - double * q_porosity, - double * porosity_dof, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - int stage, - double * uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double * uLow, - double * dLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - VOF_base * newVOF(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cVOF_base: - """ - Optimized VOF member functions - """ - cdef VOF_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newVOF(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidualElementBased(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_porosity, - numpy.ndarray porosity_dof, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - double degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - int stage, - numpy.ndarray uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidualElementBased(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, - sc_alpha, - < double * > q_porosity.data, - < double * > porosity_dof.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - stage, - < double * > uTilde_dof.data, - cE, - cMax, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > ML.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > uLow.data, - < double * > dLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_porosity, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int STABILIZATION_TYPE): - """ - Optimized jacobian calculation - """ - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < double * > q_porosity.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > velocity.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - STABILIZATION_TYPE) - def FCTStep(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray soln, - numpy.ndarray solH, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray limited_solution, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE): - self.thisptr.FCTStep(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > soln.data, - < double * > solH.data, - < double * > uLow.data, - < double * > dLow.data, - < double * > limited_solution.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE) - def calculateResidualEdgeBased(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_porosity, - numpy.ndarray porosity_dof, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - double degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - int stage, - numpy.ndarray uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidualEdgeBased(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < double * > q_porosity.data, - < double * > porosity_dof.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - stage, - < double * > uTilde_dof.data, - cE, - cMax, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > ML.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > uLow.data, - < double * > dLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) diff --git a/proteus/mprans/cVOF3P.pyx b/proteus/mprans/cVOF3P.pyx deleted file mode 100644 index 68a77df02a..0000000000 --- a/proteus/mprans/cVOF3P.pyx +++ /dev/null @@ -1,757 +0,0 @@ -# A type of -*- python -*- file -""" -An optimized volume-of-fluid transport module -""" -import numpy -cimport numpy - -cdef extern from "mprans/VOF3P.h" namespace "proteus": - cdef cppclass cppVOF3P_base: - void calculateResidualElementBased(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - const double * q_vos, - const double * vos_dof, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - int stage, - double * uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double * uLow, - double * dLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - void calculateJacobian(double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - const double * q_vos, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - double * globalJacobian, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - const double * ebqe_vos_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - int * csrColumnOffsets_eb_u_u, - int STABILIZATION_TYPE) - void FCTStep(double dt, - int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * soln, - double * solH, - double * uLow, - double * dLow, - double * limited_solution, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE) - void calculateResidualEdgeBased(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - double * q_vos, - double * vos_dof, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - double degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_vos_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - int stage, - double * uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double * uLow, - double * dLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - cppVOF3P_base * newVOF3P(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class VOF3P: - """ - Optimized VOF3P member functions - """ - cdef cppVOF3P_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newVOF3P(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidualElementBased(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_vos, - numpy.ndarray vos_dof, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - double degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_vos_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - int stage, - numpy.ndarray uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidualElementBased(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, - sc_alpha, - < double * > q_vos.data, - < double * > vos_dof.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_vos_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - stage, - < double * > uTilde_dof.data, - cE, - cMax, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > ML.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > uLow.data, - < double * > dLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_vos, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_vos_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int STABILIZATION_TYPE): - """ - Optimized jacobian calculation - """ - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(< double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < double * > q_vos.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - < double * > u_dof.data, - < double * > velocity.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_vos_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - STABILIZATION_TYPE) - def FCTStep(self, - double dt, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray soln, - numpy.ndarray solH, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray limited_solution, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE): - self.thisptr.FCTStep(dt, - NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > soln.data, - < double * > solH.data, - < double * > uLow.data, - < double * > dLow.data, - < double * > limited_solution.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE) - def calculateResidualEdgeBased(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_vos, - numpy.ndarray vos_dof, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - double degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_vos_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - int stage, - numpy.ndarray uTilde_dof, - double cE, - double cMax, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray ML, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidualEdgeBased(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < double * > q_vos.data, - < double * > vos_dof.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_vos_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - stage, - < double * > uTilde_dof.data, - cE, - cMax, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > ML.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > uLow.data, - < double * > dLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) diff --git a/proteus/mprans/cVOS3P.pyx b/proteus/mprans/cVOS3P.pyx deleted file mode 100644 index fdd8f5cd10..0000000000 --- a/proteus/mprans/cVOS3P.pyx +++ /dev/null @@ -1,1023 +0,0 @@ -# A type of -*- python -*- file -""" -An optimized volume-of-sediment transport module -""" -import numpy -cimport numpy - -cdef extern from "mprans/VOS3P.h" namespace "proteus": - cdef cppclass cppVOS3P_base: - void calculateResidual(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - double * q_porosity, - double * porosity_dof, - double * q_dvos_dt, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - const double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - double cE, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * Cx, - double * Cy, - double * Cz, - double * CTx, - double * CTy, - double * CTz, - double * ML, - double * delta_x_ij, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double* dLow, - double * fluxMatrix, - double * uDotLow, - double * uLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - void calculateJacobian(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - const double * q_porosity, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, - int * csrColumnOffsets_u_u, - double * globalJacobian, - double * delta_x_ij, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - const double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - int * csrColumnOffsets_eb_u_u, - int LUMPED_MASS_MATRIX) - void FCTStep(int NNZ, - int numDOFs, - double * lumped_mass_matrix, - double * soln, - double * solH, - double * uLow, - double * limited_solution, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - double * MassMatrix, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - int LUMPED_MASS_MATRIX) - void kth_FCT_step(double dt, - int num_fct_iter, - int NNZ, - int numDOFs, - double* MC, - double* ML, - double * soln, - double * solLim, - double * uDotLow, - double * uLow, - double * dLow, - double * fluxMatrix, - double * limitedFlux, - double * min_u_bc, - double * max_u_bc, - double global_min_u, - double global_max_u, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops) - void calculateResidual_entropy_viscosity(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - double * q_porosity, - double * porosity_dof, - double* q_dvos_dt, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * u_dof_old, - double * velocity, - double * q_m, - double * q_u, - double * q_grad_u, - double * q_m_betaBDF, - double * q_dV, - double * q_dV_last, - double * cfl, - double * edge_based_cfl, - double * q_numDiff_u, - double * q_numDiff_u_last, - int offset_u, int stride_u, - double * globalResidual, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - double * ebqe_phi, double epsFact, - double * ebqe_u, - double * ebqe_flux, - double cE, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - int * csrRowIndeces_DofLoops, - int * csrColumnOffsets_DofLoops, - int * csrRowIndeces_CellLoops, - int * csrColumnOffsets_CellLoops, - int * csrColumnOffsets_eb_CellLoops, - double * Cx, - double * Cy, - double * Cz, - double * CTx, - double * CTy, - double * CTz, - double * ML, - double * delta_x_ij, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - double* dLow, - double * fluxMatrix, - double * uDotLow, - double * uLow, - double * dL_minus_dC, - double * min_u_bc, - double * max_u_bc, - double * quantDOFs) - void calculateMassMatrix(double dt, - double * mesh_trial_ref, - double * mesh_grad_trial_ref, - double * mesh_dof, - double * mesh_velocity_dof, - double MOVING_DOMAIN, - int * mesh_l2g, - double * dV_ref, - double * u_trial_ref, - double * u_grad_trial_ref, - double * u_test_ref, - double * u_grad_test_ref, - double * mesh_trial_trace_ref, - double * mesh_grad_trial_trace_ref, - double * dS_ref, - double * u_trial_trace_ref, - double * u_grad_trial_trace_ref, - double * u_test_trace_ref, - double * u_grad_test_trace_ref, - double * normal_ref, - double * boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double * q_porosity, - int * u_l2g, - int * r_l2g, - double * elementDiameter, - int degree_polynomial, - double * u_dof, - double * velocity, - double * q_m_betaBDF, - double * cfl, - double * q_numDiff_u_last, - int * csrRowIndeces_u_u, int * csrColumnOffsets_u_u, - double * globalJacobian, - double * delta_x_ij, - int nExteriorElementBoundaries_global, - int * exteriorElementBoundariesArray, - int * elementBoundaryElementsArray, - int * elementBoundaryLocalElementBoundariesArray, - double * ebqe_velocity_ext, - double * ebqe_porosity_ext, - int * isDOFBoundary_u, - double * ebqe_bc_u_ext, - int * isFluxBoundary_u, - double * ebqe_bc_flux_u_ext, - int * csrColumnOffsets_eb_u_u, - int LUMPED_MASS_MATRIX) - cppVOS3P_base * newVOS3P(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class VOS3P: - """ - Optimized VOS3P member functions - """ - - cdef cppVOS3P_base * thisptr - - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newVOS3P(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - - def __dealloc__(self): - del self.thisptr - - def calculateResidual(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_porosity, - numpy.ndarray porosity_dof, - numpy.ndarray q_dvos_dt, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - double cE, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray Cz, - numpy.ndarray CTx, - numpy.ndarray CTy, - numpy.ndarray CTz, - numpy.ndarray ML, - numpy.ndarray delta_x_ij, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray dLow, - numpy.ndarray fluxMatrix, - numpy.ndarray uDotLow, - numpy.ndarray uLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidual(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, - sc_alpha, - < double * > q_porosity.data, - < double * > porosity_dof.data, - < double * > q_dvos_dt.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, - stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - cE, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > Cz.data, - < double * > CTx.data, - < double * > CTy.data, - < double * > CTz.data, - < double * > ML.data, - < double * > delta_x_ij.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > dLow.data, - < double * > fluxMatrix.data, - < double * > uDotLow.data, - < double * > uLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) - - def calculateJacobian(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_porosity, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, - numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - numpy.ndarray delta_x_ij, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int LUMPED_MASS_MATRIX): - """ - Optimized jacobian calculation - """ - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian(dt, - < double*> mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < double * > q_porosity.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > velocity.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < int * > csrRowIndeces_u_u.data, - < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - < double * > delta_x_ij.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - LUMPED_MASS_MATRIX) - - def FCTStep(self, - int NNZ, - int numDOFs, - numpy.ndarray lumped_mass_matrix, - numpy.ndarray soln, - numpy.ndarray solH, - numpy.ndarray uLow, - numpy.ndarray limited_solution, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray MassMatrix, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - int LUMPED_MASS_MATRIX): - self.thisptr.FCTStep(NNZ, - numDOFs, - < double * > lumped_mass_matrix.data, - < double * > soln.data, - < double * > solH.data, - < double * > uLow.data, - < double * > limited_solution.data, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < double * > MassMatrix.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - LUMPED_MASS_MATRIX) - def kth_FCT_step(self, - double dt, - int num_fct_iter, - int NNZ, - int numDOFs, - numpy.ndarray MC, - numpy.ndarray ML, - numpy.ndarray soln, - numpy.ndarray solLim, - numpy.ndarray uDotLow, - numpy.ndarray uLow, - numpy.ndarray dLow, - numpy.ndarray fluxMatrix, - numpy.ndarray limitedFlux, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - double global_min_u, - double global_max_u, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops): - self.thisptr.kth_FCT_step(dt, - num_fct_iter, - NNZ, - numDOFs, - < double * > MC.data, - < double * > ML.data, - < double * > soln.data, - < double * > solLim.data, - < double * > uDotLow.data, - < double * > uLow.data, - < double * > dLow.data, - < double * > fluxMatrix.data, - < double * > limitedFlux.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - global_min_u, - global_max_u, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data) - def calculateResidual_entropy_viscosity(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray q_porosity, - numpy.ndarray porosity_dof, - numpy.ndarray q_dvos_dt, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_grad_u, - numpy.ndarray q_m_betaBDF, - numpy.ndarray q_dV, - numpy.ndarray q_dV_last, - numpy.ndarray cfl, - numpy.ndarray edge_based_cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi, double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux, - double cE, - double cK, - double uL, - double uR, - int numDOFs, - int NNZ, - numpy.ndarray csrRowIndeces_DofLoops, - numpy.ndarray csrColumnOffsets_DofLoops, - numpy.ndarray csrRowIndeces_CellLoops, - numpy.ndarray csrColumnOffsets_CellLoops, - numpy.ndarray csrColumnOffsets_eb_CellLoops, - numpy.ndarray Cx, - numpy.ndarray Cy, - numpy.ndarray Cz, - numpy.ndarray CTx, - numpy.ndarray CTy, - numpy.ndarray CTz, - numpy.ndarray ML, - numpy.ndarray delta_x_ij, - int LUMPED_MASS_MATRIX, - int STABILIZATION_TYPE, - int ENTROPY_TYPE, - numpy.ndarray dLow, - numpy.ndarray fluxMatrix, - numpy.ndarray uDotLow, - numpy.ndarray uLow, - numpy.ndarray dt_times_dH_minus_dL, - numpy.ndarray min_u_bc, - numpy.ndarray max_u_bc, - numpy.ndarray quantDOFs): - self.thisptr.calculateResidual_entropy_viscosity(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - < double * > q_porosity.data, - < double * > porosity_dof.data, - < double * > q_dvos_dt.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > u_dof_old.data, - < double * > velocity.data, - < double * > q_m.data, - < double * > q_u.data, - < double * > q_grad_u.data, - < double * > q_m_betaBDF.data, - < double * > q_dV.data, - < double * > q_dV_last.data, - < double * > cfl.data, - < double * > edge_based_cfl.data, - < double * > q_numDiff_u.data, - < double * > q_numDiff_u_last.data, - offset_u, stride_u, - < double * > globalResidual.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < double * > ebqe_phi.data, - epsFact, - < double * > ebqe_u.data, - < double * > ebqe_flux.data, - cE, - cK, - uL, - uR, - numDOFs, - NNZ, - < int * > csrRowIndeces_DofLoops.data, - < int * > csrColumnOffsets_DofLoops.data, - < int * > csrRowIndeces_CellLoops.data, - < int * > csrColumnOffsets_CellLoops.data, - < int * > csrColumnOffsets_eb_CellLoops.data, - < double * > Cx.data, - < double * > Cy.data, - < double * > Cz.data, - < double * > CTx.data, - < double * > CTy.data, - < double * > CTz.data, - < double * > ML.data, - < double * > delta_x_ij.data, - LUMPED_MASS_MATRIX, - STABILIZATION_TYPE, - ENTROPY_TYPE, - < double * > dLow.data, - < double * > fluxMatrix.data, - < double * > uDotLow.data, - < double * > uLow.data, - < double * > dt_times_dH_minus_dL.data, - < double * > min_u_bc.data, - < double * > max_u_bc.data, - < double * > quantDOFs.data) - - def calculateMassMatrix(self, - double dt, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray q_porosity, - numpy.ndarray u_l2g, - numpy.ndarray r_l2g, - numpy.ndarray elementDiameter, - int degree_polynomial, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u, numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - numpy.ndarray delta_x_ij, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray ebqe_porosity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u, - int LUMPED_MASS_MATRIX): - cdef numpy.ndarray rowptr, colind, globalJacobian_a - (rowptr, colind, globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateMassMatrix(dt, - < double * > mesh_trial_ref.data, - < double * > mesh_grad_trial_ref.data, - < double * > mesh_dof.data, - < double * > mesh_velocity_dof.data, - MOVING_DOMAIN, - < int * > mesh_l2g.data, - < double * > dV_ref.data, - < double * > u_trial_ref.data, - < double * > u_grad_trial_ref.data, - < double * > u_test_ref.data, - < double * > u_grad_test_ref.data, - < double * > mesh_trial_trace_ref.data, - < double * > mesh_grad_trial_trace_ref.data, - < double * > dS_ref.data, - < double * > u_trial_trace_ref.data, - < double * > u_grad_trial_trace_ref.data, - < double * > u_test_trace_ref.data, - < double * > u_grad_test_trace_ref.data, - < double * > normal_ref.data, - < double * > boundaryJac_ref.data, - nElements_global, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - < double * > q_porosity.data, - < int * > u_l2g.data, - < int * > r_l2g.data, - < double * > elementDiameter.data, - degree_polynomial, - < double * > u_dof.data, - < double * > velocity.data, - < double * > q_m_betaBDF.data, - < double * > cfl.data, - < double * > q_numDiff_u_last.data, - < int * > csrRowIndeces_u_u.data, < int * > csrColumnOffsets_u_u.data, - < double * > globalJacobian_a.data, - < double * > delta_x_ij.data, - nExteriorElementBoundaries_global, - < int * > exteriorElementBoundariesArray.data, - < int * > elementBoundaryElementsArray.data, - < int * > elementBoundaryLocalElementBoundariesArray.data, - < double * > ebqe_velocity_ext.data, - < double * > ebqe_porosity_ext.data, - < int * > isDOFBoundary_u.data, - < double * > ebqe_bc_u_ext.data, - < int * > isFluxBoundary_u.data, - < double * > ebqe_bc_flux_u_ext.data, - < int * > csrColumnOffsets_eb_u_u.data, - LUMPED_MASS_MATRIX) diff --git a/proteus/mprans2/AddedMass.cpp b/proteus/mprans2/AddedMass.cpp new file mode 100644 index 0000000000..285b767257 --- /dev/null +++ b/proteus/mprans2/AddedMass.cpp @@ -0,0 +1,682 @@ +#include +#include + +#define FORCE_IMPORT_ARRAY +#include "AddedMass.hpp" + +#include "CompKernel.h" +#include "ModelFactory.h" + +namespace proteus +{ + /**************** + * cppAddedMass * + ****************/ + + template + class cppAddedMass : public cppAddedMass_base + { + public: + + const int nDOF_test_X_trial_element; + CompKernelType ck; + + cppAddedMass() + : nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element) + , ck() + {} + + void evaluateCoefficients(const double& rho, + double& a) + { + a = 1.0/rho; + } + + void exteriorNumericalDiffusiveFlux(const double n[nSpace], + const double a[nSpace], + int isBodyBoundary, + double& flux) + { + flux=0.0; + if (isBodyBoundary == 1) + { + for (int I=0;I mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + int nElementBoundaries_owned, + xt::pyarray u_l2g, + xt::pyarray u_dof, + xt::pyarray q_rho, + int offset_u, + int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray elementBoundaryMaterialTypesArray, + xt::pyarray Aij, + int added_mass_i, + xt::pyarray barycenters, + xt::pyarray flags_rigidbody) override + { + for(int eN=0;eN 0) + { + switch (added_mass_i) + { + case 0: + added_mass_a[0] = 1.0; + break; + case 1: + added_mass_a[1] = 1.0; + break; + case 2: + added_mass_a[2] = 1.0; + break; + case 3: + added_mass_a[1] = -rz; + added_mass_a[2] = ry; + break; + case 4: + added_mass_a[0] = rz; + added_mass_a[2] = -rx; + break; + case 5: + added_mass_a[0] = -ry; + added_mass_a[1] = rx; + break; + default: + assert(0); + } + } + // normalise unit accelerations (necessary for angular ones) + //I think we want the angular acceleration to be 1 + //but the flux uses whatever the linear acceleration works + //out to be, so I'm commenting this out for now + /* double added_mass_a_tot = sqrt(added_mass_a[0]*added_mass_a[0]+ */ + /* added_mass_a[1]*added_mass_a[1]+ */ + /* added_mass_a[2]*added_mass_a[2]); */ + /* added_mass_a[0] = added_mass_a[0]/added_mass_a_tot; */ + /* added_mass_a[1] = added_mass_a[1]/added_mass_a_tot; */ + /* added_mass_a[2] = added_mass_a[2]/added_mass_a_tot; */ + + exteriorNumericalDiffusiveFlux(normal, + added_mass_a, + flags_rigidbody[eBMT], + diff_flux_ext); + // + //update residuals + // + for (int i=0;i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray u_l2g, + xt::pyarray u_dof, + xt::pyarray q_rho, + xt::pyarray csrRowIndeces_u_u, + xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray csrColumnOffsets_eb_u_u) override + { + // + //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian + // + for(int eN=0;eN( + nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag + ); + } + else + { + return proteus::chooseAndAllocateDiscretization( + nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag + ); + } + } +} + +namespace py = pybind11; + +PYBIND11_MODULE(cAddedMass, m) +{ + using proteus::cppAddedMass_base; + using proteus::newAddedMass; + + xt::import_numpy(); + + py::class_(m, "cppAddedMass_base") + .def("calculateResidual", &cppAddedMass_base::calculateResidual) + .def("calculateJacobian", &cppAddedMass_base::calculateJacobian); + + m.def("newAddedMass", newAddedMass); +} diff --git a/proteus/mprans2/AddedMass.hpp b/proteus/mprans2/AddedMass.hpp new file mode 100644 index 0000000000..ca1d635b65 --- /dev/null +++ b/proteus/mprans2/AddedMass.hpp @@ -0,0 +1,100 @@ +#ifndef ADDEDMASS_HPP +#define ADDEDMASS_HPP + +#include "xtensor-python/pyarray.hpp" + +namespace proteus +{ + + class cppAddedMass_base + { + public: + + virtual ~cppAddedMass_base() = default; + + virtual void calculateResidual(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + int nElementBoundaries_owned, + xt::pyarray u_l2g, + xt::pyarray u_dof, + xt::pyarray q_rho, + int offset_u, + int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray elementBoundaryMaterialTypesArray, + xt::pyarray Aij, + int added_mass_i, + xt::pyarray barycenters, + xt::pyarray flags_rigidbody) = 0; + + virtual void calculateJacobian(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + xt::pyarray u_l2g, + xt::pyarray u_dof, + xt::pyarray q_rho, + xt::pyarray csrRowIndeces_u_u, + xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray csrColumnOffsets_eb_u_u) = 0; + }; + + cppAddedMass_base* newAddedMass(int nSpaceIn, + int nQuadraturePoints_elementIn, + int nDOF_mesh_trial_elementIn, + int nDOF_trial_elementIn, + int nDOF_test_elementIn, + int nQuadraturePoints_elementBoundaryIn, + int CompKernelFlag); + +} + +#endif + diff --git a/proteus/mprans2/AddedMass.py b/proteus/mprans2/AddedMass.py new file mode 100644 index 0000000000..86cfd6d709 --- /dev/null +++ b/proteus/mprans2/AddedMass.py @@ -0,0 +1,847 @@ +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 +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport +import os +from proteus import cfemIntegrals, Quadrature, Norms, Comm +from proteus.NonlinearSolvers import NonlinearEquation +from proteus.FemTools import (DOFBoundaryConditions, + FluxBoundaryConditions, + C0_AffineLinearOnSimplexWithNodalBasis) +from proteus.Comm import globalMax, globalSum +from proteus.Profiling import memory +from proteus.Profiling import logEvent +from proteus.Transport import OneLevelTransport +from proteus.TransportCoefficients import TC_base +from proteus.SubgridError import SGE_base +from proteus.ShockCapturing import ShockCapturing_base +from . import cAddedMass +from mpi4py import MPI + +class NumericalFlux(proteus.NumericalFlux.ConstantAdvection_Diffusion_SIPG_exterior): + def __init__(self, + vt, + getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions): + proteus.NumericalFlux.ConstantAdvection_Diffusion_SIPG_exterior.__init__(self, vt, getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions) + +class Coefficients(TC_base): + """ + Parameters + ---------- + nd: int + Number of space dimensions. + V_model: int + Index of Navier-Stokes model. + barycenters: array_like + List of domain barycenters. + flags_rigidbody: array_like + Array of integers of length at least as long as maximum domain flag, + with 0 at indices corresponding to flags for fixed walls, and 1 at + indices corresponding to flags for rigid bodies. + e.g. if only flag 2 is rigid body, and the max value of flag is 5, + the array will look like np.array([0,0,1,0,0,0]) + """ + + def __init__(self, + nd=2, + V_model=None, + barycenters=None, + flags_rigidbody=None, + solve_rate=0., + nullSpace="ConstantNullSpace"): + """ + TODO + """ + self.solve_rate = solve_rate + self.updated_global = False + self.next_solve = 0. + self.nullSpace = nullSpace + assert(nd in [2, 3]) + self.nd = nd + if self.nd == 2: + sdInfo = {(0, 0): (np.array([0, 1, 2], dtype='i'), + np.array([0, 1], dtype='i'))} + else: + sdInfo = {(0, 0): (np.array([0, 1, 2, 3], dtype='i'), + np.array([0, 1, 2], dtype='i'))} + TC_base.__init__(self, + nc=1, + variableNames=['am'], + diffusion={0: {0: {0: 'constant'}}}, + potential={0: {0: 'u'}}, + sparseDiffusionTensors=sdInfo, + useSparseDiffusion=True) + self.flowModelIndex=V_model + self.barycenters = barycenters + if flags_rigidbody is not None: + self.flags_rigidbody = flags_rigidbody + else: + Profiling.logEvent("Warning: flags_rigidbody was not set for"+ + "AddedMass model, using a zero array of length"+ + "1000, this sets all boundaries as fixed walls"+ + "for the added mass model and might cause"+ + " issues if the domain contains more flags") + self.flags_rigidbody = np.zeros(1000, dtype='int32') + + def attachModels(self, modelList): + """ + Attach the model for velocity and density to PresureIncrement model + """ + self.flowModel = modelList[self.flowModelIndex] + self.q_rho = self.flowModel.q['rho'] + + def initializeMesh(self, mesh): + """ + Give the TC object access to the mesh for any mesh-dependent information. + """ + self.mesh = mesh + + def initializeElementQuadrature(self, t, cq): + """ + Give the TC object access to the element quadrature storage + """ + pass + + def initializeElementBoundaryQuadrature(self, t, cebq, cebq_global): + """ + Give the TC object access to the element boundary quadrature storage + """ + pass + + def initializeGlobalExteriorElementBoundaryQuadrature(self, t, cebqe): + """ + Give the TC object access to the exterior element boundary quadrature storage + """ + pass + + def initializeGeneralizedInterpolationPointQuadrature(self, t, cip): + """ + Give the TC object access to the generalized interpolation point storage. These points are used to project nonlinear potentials (phi). + """ + pass + + def preStep(self, t, firstStep=False): + """ + Move the current values to values_last to keep cached set of values for bdf1 algorithm + """ + copyInstructions = {} + return copyInstructions + + def postStep(self, t, firstStep=False): + """ + Update the fluid velocities + """ + copyInstructions = {} + return copyInstructions + + 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) + for i in range(1, c[('a', 0, 0)].shape[-1]): + c[('a', 0, 0)][..., i] = c[('a', 0, 0)][..., 0] + +class LevelModel(proteus.Transport.OneLevelTransport): + nCalls = 0 + + def __init__(self, + uDict, + phiDict, + testSpaceDict, + matType, + dofBoundaryConditionsDict, + dofBoundaryConditionsSetterDict, + coefficients, + elementQuadrature, + elementBoundaryQuadrature, + fluxBoundaryConditionsDict=None, + advectiveFluxBoundaryConditionsSetterDict=None, + diffusiveFluxBoundaryConditionsSetterDictDict=None, + stressTraceBoundaryConditionsSetterDict=None, + stabilization=None, + shockCapturing=None, + conservativeFluxDict=None, + numericalFluxType=None, + TimeIntegrationClass=None, + massLumping=False, + reactionLumping=False, + options=None, + name='defaultName', + reuse_trial_and_test_quadrature=True, + sd=True, + movingDomain=False): + from proteus import Comm + # + # set the objects describing the method and boundary conditions + # + self.movingDomain = movingDomain + self.tLast_mesh = None + # + self.name = name + self.sd = sd + self.Hess = False + self.lowmem = True + self.timeTerm = True # allow turning off the time derivative + # self.lowmem=False + self.testIsTrial = True + self.phiTrialIsTrial = True + self.u = uDict + self.ua = {} # analytical solutions + self.phi = phiDict + self.dphi = {} + self.matType = matType + # mwf try to reuse test and trial information across components if + # spaces are the same + self.reuse_test_trial_quadrature = reuse_trial_and_test_quadrature # True#False + if self.reuse_test_trial_quadrature: + for ci in range(1, coefficients.nc): + assert self.u[ci].femSpace.__class__.__name__ == self.u[ + 0].femSpace.__class__.__name__, "to reuse_test_trial_quad all femSpaces must be the same!" + # Simplicial Mesh + # assume the same mesh for all components for now + self.mesh = self.u[0].femSpace.mesh + self.testSpace = testSpaceDict + self.dirichletConditions = dofBoundaryConditionsDict + # explicit Dirichlet conditions for now, no Dirichlet BC constraints + self.dirichletNodeSetList = None + self.coefficients = coefficients + self.coefficients.initializeMesh(self.mesh) + self.nc = self.coefficients.nc + self.stabilization = stabilization + self.shockCapturing = shockCapturing + # no velocity post-processing for now + self.conservativeFlux = conservativeFluxDict + self.fluxBoundaryConditions = fluxBoundaryConditionsDict + self.diffusiveFluxBoundaryConditionsSetterDictDict = diffusiveFluxBoundaryConditionsSetterDictDict + # determine whether the stabilization term is nonlinear + self.stabilizationIsNonlinear = False + # cek come back + if self.stabilization is not None: + for ci in range(self.nc): + if ci in coefficients.mass: + for flag in list(coefficients.mass[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.advection: + for flag in list(coefficients.advection[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.diffusion: + for diffusionDict in list(coefficients.diffusion[ci].values()): + for flag in list(diffusionDict.values()): + if flag != 'constant': + self.stabilizationIsNonlinear = True + if ci in coefficients.potential: + for flag in list(coefficients.potential[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.reaction: + for flag in list(coefficients.reaction[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.hamiltonian: + for flag in list(coefficients.hamiltonian[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + # determine if we need element boundary storage + self.elementBoundaryIntegrals = {} + for ci in range(self.nc): + self.elementBoundaryIntegrals[ci] = ( + (self.conservativeFlux is not None) or ( + numericalFluxType is not None) or ( + self.fluxBoundaryConditions[ci] == 'outFlow') or ( + self.fluxBoundaryConditions[ci] == 'mixedFlow') or ( + self.fluxBoundaryConditions[ci] == 'setFlow')) + # + # calculate some dimensions + # + # assume same space dim for all variables + self.nSpace_global = self.u[0].femSpace.nSpace_global + self.nDOF_trial_element = [ + u_j.femSpace.max_nDOF_element for u_j in list(self.u.values())] + self.nDOF_phi_trial_element = [ + phi_k.femSpace.max_nDOF_element for phi_k in list(self.phi.values())] + self.n_phi_ip_element = [ + phi_k.femSpace.referenceFiniteElement.interpolationConditions.nQuadraturePoints for phi_k in list(self.phi.values())] + self.nDOF_test_element = [ + femSpace.max_nDOF_element for femSpace in list(self.testSpace.values())] + self.nFreeDOF_global = [ + dc.nFreeDOF_global for dc in list(self.dirichletConditions.values())] + self.nVDOF_element = sum(self.nDOF_trial_element) + self.nFreeVDOF_global = sum(self.nFreeDOF_global) + # + NonlinearEquation.__init__(self, self.nFreeVDOF_global) + # + # build the quadrature point dictionaries from the input (this + # is just for convenience so that the input doesn't have to be + # complete) + # + elementQuadratureDict = {} + elemQuadIsDict = isinstance(elementQuadrature, dict) + if elemQuadIsDict: # set terms manually + for I in self.coefficients.elementIntegralKeys: + if I in elementQuadrature: + elementQuadratureDict[I] = elementQuadrature[I] + else: + elementQuadratureDict[I] = elementQuadrature['default'] + else: + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[I] = elementQuadrature + if self.stabilization is not None: + for I in self.coefficients.elementIntegralKeys: + if elemQuadIsDict: + if I in elementQuadrature: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature[I] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature['default'] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature + if self.shockCapturing is not None: + for ci in self.shockCapturing.components: + if elemQuadIsDict: + if ('numDiff', ci, ci) in elementQuadrature: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + ('numDiff', ci, ci)] + else: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + 'default'] + else: + elementQuadratureDict[ + ('numDiff', ci, ci)] = elementQuadrature + if massLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('m', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + if reactionLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('r', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + elementBoundaryQuadratureDict = {} + if isinstance(elementBoundaryQuadrature, dict): # set terms manually + for I in self.coefficients.elementBoundaryIntegralKeys: + if I in elementBoundaryQuadrature: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature[I] + else: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature['default'] + else: + for I in self.coefficients.elementBoundaryIntegralKeys: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature + # + # find the union of all element quadrature points and + # build a quadrature rule for each integral that has a + # weight at each point in the union + # mwf include tag telling me which indices are which quadrature rule? + (self.elementQuadraturePoints, self.elementQuadratureWeights, + self.elementQuadratureRuleIndeces) = Quadrature.buildUnion(elementQuadratureDict) + self.nQuadraturePoints_element = self.elementQuadraturePoints.shape[0] + self.nQuadraturePoints_global = self.nQuadraturePoints_element * \ + self.mesh.nElements_global + # + # Repeat the same thing for the element boundary quadrature + # + (self.elementBoundaryQuadraturePoints, self.elementBoundaryQuadratureWeights, + self.elementBoundaryQuadratureRuleIndeces) = Quadrature.buildUnion(elementBoundaryQuadratureDict) + self.nElementBoundaryQuadraturePoints_elementBoundary = self.elementBoundaryQuadraturePoints.shape[ + 0] + self.nElementBoundaryQuadraturePoints_global = ( + self.mesh.nElements_global * + self.mesh.nElementBoundaries_element * + self.nElementBoundaryQuadraturePoints_elementBoundary) + # + # simplified allocations for test==trial and also check if space is mixed or not + # + self.added_mass_i = 0; + self.Aij = np.zeros((self.coefficients.flags_rigidbody.shape[0], 6, 6), 'd') + self.q = {} + self.ebq = {} + self.ebq_global = {} + self.ebqe = {} + self.phi_ip = {} + # mesh + #self.q['x'] = numpy.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,3),'d') + self.ebqe['x'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + 3), + 'd') + self.q[('u', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global), + 'd') + self.ebqe[ + ('u', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebqe[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + + self.q[('v', 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nDOF_trial_element[0]), + 'd') + self.q['J'] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global, + self.nSpace_global), + 'd') + self.q['det(J)'] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element), + 'd') + self.q['inverse(J)'] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global, + self.nSpace_global), + 'd') + self.ebq[('v', 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nDOF_trial_element[0]), + 'd') + self.ebq[('w', 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nDOF_trial_element[0]), + 'd') + self.ebq['x'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + 3), + 'd') + self.ebq['hat(x)'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + 3), + 'd') + self.ebq['inverse(J)'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global, + self.nSpace_global), + 'd') + self.ebq['g'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global - 1, + self.nSpace_global - 1), + 'd') + self.ebq['sqrt(det(g))'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebq['n'] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + self.ebq[('dS_u', 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.mesh.nElementBoundaries_element, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebqe['dS'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebqe[('dS_u', 0)] = self.ebqe['dS'] + self.ebqe['n'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + self.ebqe['inverse(J)'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global, + self.nSpace_global), + 'd') + self.ebqe['g'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global - 1, + self.nSpace_global - 1), + 'd') + self.ebqe['sqrt(det(g))'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebq_global['n'] = numpy.zeros( + (self.mesh.nElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + self.ebq_global['x'] = numpy.zeros( + (self.mesh.nElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + 3), + 'd') + self.ebqe[('diffusiveFlux_bc_flag', 0, 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'i') + self.ebqe[('diffusiveFlux_bc', 0, 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + self.ebqe[('diffusiveFlux', 0, 0)] = numpy.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + self.points_elementBoundaryQuadrature = set() + self.scalars_elementBoundaryQuadrature = set( + [('u', ci) for ci in range(self.nc)]) + self.vectors_elementBoundaryQuadrature = set() + self.tensors_elementBoundaryQuadrature = set() + logEvent(memory("element and element boundary Jacobians", + "OneLevelTransport"), level=4) + self.inflowBoundaryBC = {} + self.inflowBoundaryBC_values = {} + self.inflowFlux = {} + for cj in range(self.nc): + self.inflowBoundaryBC[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global,), 'i') + self.inflowBoundaryBC_values[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nDOF_trial_element[cj]), 'd') + self.inflowFlux[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.internalNodes = set(range(self.mesh.nNodes_global)) + # identify the internal nodes this is ought to be in mesh + # \todo move this to mesh + for ebNE in range(self.mesh.nExteriorElementBoundaries_global): + ebN = self.mesh.exteriorElementBoundariesArray[ebNE] + eN_global = self.mesh.elementBoundaryElementsArray[ebN, 0] + ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[ + ebN, 0] + for i in range(self.mesh.nNodes_element): + if i != ebN_element: + I = self.mesh.elementNodesArray[eN_global, i] + self.internalNodes -= set([I]) + self.nNodes_internal = len(self.internalNodes) + self.internalNodesArray = numpy.zeros((self.nNodes_internal,), 'i') + for nI, n in enumerate(self.internalNodes): + self.internalNodesArray[nI] = n + # + del self.internalNodes + self.internalNodes = None + logEvent("Updating local to global mappings", 2) + self.updateLocal2Global() + logEvent("Building time integration object", 2) + logEvent(memory("inflowBC, internalNodes,updateLocal2Global", + "OneLevelTransport"), level=4) + # mwf for interpolating subgrid error for gradients etc + if self.stabilization and self.stabilization.usesGradientStabilization: + self.timeIntegration = TimeIntegrationClass( + self, integrateInterpolationPoints=True) + else: + self.timeIntegration = TimeIntegrationClass(self) + + if options is not None: + self.timeIntegration.setFromOptions(options) + logEvent(memory("TimeIntegration", "OneLevelTransport"), level=4) + logEvent("Calculating numerical quadrature formulas", 2) + self.calculateQuadrature() + self.setupFieldStrides() + + comm = Comm.get() + self.comm = comm + if comm.size() > 1: + assert numericalFluxType is not None and numericalFluxType.useWeakDirichletConditions, "You must use a numerical flux to apply weak boundary conditions for parallel runs" + + logEvent(memory("stride+offset", "OneLevelTransport"), level=4) + if numericalFluxType is not None: + if options is None or options.periodicDirichletConditions is None: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict) + else: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict, + options.periodicDirichletConditions) + else: + self.numericalFlux = None + # strong Dirichlet + self.dirichletConditionsForceDOF = {0: DOFBoundaryConditions(self.u[cj].femSpace, dofBoundaryConditionsSetterDict[cj], weakDirichletConditions=False)} + # set penalty terms + # cek todo move into numerical flux initialization + 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)) + # 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) + logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) + self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray + # use post processing tools to get conservative fluxes, None by default + from proteus import PostProcessingTools + self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser( + self) + logEvent(memory("velocity postprocessor", "OneLevelTransport"), level=4) + # helper for writing out data storage + from proteus import Archiver + self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.globalResidualDummy = None + compKernelFlag = 0 + self.addedMass = cAddedMass.newAddedMass( + self.nSpace_global, + self.nQuadraturePoints_element, + self.u[0].femSpace.elementMaps.localFunctionSpace.dim, + self .u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim, + self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim, + self.nElementBoundaryQuadraturePoints_elementBoundary, + compKernelFlag) + self.barycenters = self.coefficients.barycenters + self.flags_rigidbody = self.coefficients.flags_rigidbody + + def calculateCoefficients(self): + pass + + def calculateElementResidual(self): + if self.globalResidualDummy is not None: + self.getResidual(self.u[0].dof, self.globalResidualDummy) + + def getResidual(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + r.fill(0.0) + # Load the unknowns into the finite element dof + for dofN, g in list(self.dirichletConditionsForceDOF[0].DOFBoundaryConditionsDict.items()): + # load the BC valu # Load the unknowns into the finite element dof + u[self.offset[0] + self.stride[0] * dofN] = g(self.dirichletConditionsForceDOF[0].DOFBoundaryPointDict[dofN], self.timeIntegration.t) + self.setUnknowns(u) + self.Aij[:,:,self.added_mass_i]=0.0 + self.addedMass.calculateResidual( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.mesh.nElementBoundaries_owned, + self.u[0].femSpace.dofMap.l2g, + self.u[0].dof, + self.coefficients.q_rho, + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.mesh.elementBoundaryMaterialTypes, + self.Aij, + self.added_mass_i, + self.barycenters, + self.flags_rigidbody) + # sum of residual should be zero + # but it is sometimes not exactly zero with certain meshes in parallel + # hack + comm = Comm.get().comm.tompi4py() + if comm.size > 1: + r_sum_local = np.sum(r[:self.mesh.nNodes_owned]) + r_sum_global = comm.reduce(r_sum_local, op=MPI.SUM, root=0) + if comm.rank == 0: + r[0] -= r_sum_global + logEvent('R SUM: local: {r_sum_local} global: {r_sum_global}'.format(r_sum_local=r_sum_local, r_sum_global=r_sum_global)) + logEvent('ACCELERATION INDEX: {id}'.format(id=self.added_mass_i)) + # end hack + for k in range(self.Aij.shape[0]): + for j in range(self.Aij.shape[2]): + self.Aij[k,j,self.added_mass_i] = globalSum( + self.Aij[k,j,self.added_mass_i]) + for i,flag in enumerate(self.flags_rigidbody): + if flag==1: + numpy.set_printoptions(precision=2, linewidth=160) + logEvent("Added Mass Tensor for rigid body i" + repr(i)) + logEvent("Aij = \n"+str(self.Aij[i])) + for dofN, g in list(self.dirichletConditionsForceDOF[0].DOFBoundaryConditionsDict.items()): + r[self.offset[0] + self.stride[0] * dofN] = self.u[0].dof[dofN] - \ + g(self.dirichletConditionsForceDOF[0].DOFBoundaryPointDict[dofN], self.timeIntegration.t) + logEvent("Global residual", level=9, data=r) + self.nonlinear_function_evaluations += 1 + + def getJacobian(self, jacobian): + cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, jacobian) + (rowptr, colind, globalJacobian) = jacobian.getCSRrepresentation() + self.addedMass.calculateJacobian( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + self.mesh.nElements_global, + self.u[0].femSpace.dofMap.l2g, + self.u[0].dof, + self.coefficients.q_rho, + self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], + globalJacobian, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.csrColumnOffsets_eb[(0, 0)]) + for dofN in list(self.dirichletConditionsForceDOF[0].DOFBoundaryConditionsDict.keys()): + global_dofN = self.offset[0] + self.stride[0] * dofN + self.nzval[numpy.where(self.colind == global_dofN)] = 0.0 # column + self.nzval[self.rowptr[global_dofN]:self.rowptr[global_dofN + 1]] = 0.0 # row + zeroRow = True + for i in range(self.rowptr[global_dofN], self.rowptr[global_dofN + 1]): # row + if (self.colind[i] == global_dofN): + self.nzval[i] = 1.0 + zeroRow = False + if zeroRow: + raise RuntimeError("Jacobian has a zero row because sparse matrix has no diagonal entry at row " + + repr(global_dofN)+". You probably need add diagonal mass or reaction term") + logEvent("Jacobian ", level=10, data=jacobian) + self.nonlinear_function_jacobian_evaluations += 1 + return jacobian + + def calculateElementQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points. + + This function should be called only when the mesh changes. + """ + # self.u[0].femSpace.elementMaps.getValues(self.elementQuadraturePoints, + # self.q['x']) + self.u[0].femSpace.elementMaps.getBasisValuesIP( + self.u[0].femSpace.referenceFiniteElement.interpolationConditions.quadraturePointArray) + self.u[0].femSpace.elementMaps.getBasisValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.getBasisValuesRef(self.elementQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.coefficients.initializeElementQuadrature( + self.timeIntegration.t, self.q) + if self.stabilization is not None: + self.stabilization.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + self.stabilization.initializeTimeIntegration(self.timeIntegration) + if self.shockCapturing is not None: + self.shockCapturing.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + + def calculateElementBoundaryQuadrature(self): + pass + + def calculateExteriorElementBoundaryQuadrature(self): + logEvent("initalizing ebqe vectors for post-procesing velocity") + self.u[0].femSpace.elementMaps.getValuesGlobalExteriorTrace(self.elementBoundaryQuadraturePoints, + self.ebqe['x']) + self.u[0].femSpace.elementMaps.getJacobianValuesGlobalExteriorTrace(self.elementBoundaryQuadraturePoints, + self.ebqe['inverse(J)'], + self.ebqe['g'], + self.ebqe['sqrt(det(g))'], + self.ebqe['n']) + cfemIntegrals.calculateIntegrationWeights(self.ebqe['sqrt(det(g))'], + self.elementBoundaryQuadratureWeights[('u', 0)], + self.ebqe[('dS_u', 0)]) + self.u[0].femSpace.elementMaps.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + logEvent("initializing coefficients ebqe") + self.coefficients.initializeGlobalExteriorElementBoundaryQuadrature(self.timeIntegration.t, self.ebqe) + + def estimate_mt(self): + pass + + def calculateAuxiliaryQuantitiesAfterStep(self): + pass + + def calculateSolutionAtQuadrature(self): + pass + + def updateAfterMeshMotion(self): + pass diff --git a/proteus/mprans2/MCorr3P.cpp b/proteus/mprans2/MCorr3P.cpp new file mode 100644 index 0000000000..6995b8b4cc --- /dev/null +++ b/proteus/mprans2/MCorr3P.cpp @@ -0,0 +1,1810 @@ +#define FORCE_IMPORT_ARRAY +#include "MCorr3P.hpp" +#include "CompKernel.h" +#include "ModelFactory.h" +#include PROTEUS_LAPACK_H + +#define FAST_ASSEMBLY 1 + +namespace proteus +{ + template + class cppMCorr3P : public cppMCorr3P_base + { + public: + + CompKernelType ck; + cppMCorr3P(): ck() + {} + + double smoothedHeaviside(double eps, double phi) + { + double H; + if (phi > eps) + H=1.0; + else if (phi < -eps) + H=0.0; + else if (phi==0.0) + H=0.5; + else + H = 0.5*(1.0 + phi/eps + sin(M_PI*phi/eps)/M_PI); + return H; + } + + double smoothedHeaviside_integral(double eps, double phi) + { + double HI; + if (phi > eps) + { + HI= phi - eps + 0.5*(eps + 0.5*eps*eps/eps - eps*cos(M_PI*eps/eps)/(M_PI*M_PI)) - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI)); + } + else if (phi < -eps) + { + HI=0.0; + } + else + { + HI = 0.5*(phi + 0.5*phi*phi/eps - eps*cos(M_PI*phi/eps)/(M_PI*M_PI)) - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI)); + } + return HI; + } + + double smoothedDirac(double eps, double phi) + { + double d; + if (phi > eps) + d=0.0; + else if (phi < -eps) + d=0.0; + else + d = 0.5*(1.0 + cos(M_PI*phi/eps))/eps; + return d; + } + + void evaluateCoefficients(const double& epsHeaviside, + const double& epsDirac, + const double& phi, + const double& H, + const double& u, + const double& porosity, + double& r, + double& dr) + { + r = porosity*(smoothedHeaviside(epsHeaviside,phi+u) - H); + dr = porosity*smoothedDirac(epsDirac,phi+u); + } + + void calculateElementResidual(//element + double* mesh_trial_ref, + double* mesh_grad_trial_ref, + double* mesh_dof, + int* mesh_l2g, + double* dV_ref, + double* u_trial_ref, + double* u_grad_trial_ref, + double* u_test_ref, + double* u_grad_test_ref, + //element boundary + double* mesh_trial_trace_ref, + double* mesh_grad_trial_trace_ref, + double* dS_ref, + double* u_trial_trace_ref, + double* u_grad_trial_trace_ref, + double* u_test_trace_ref, + double* u_grad_test_trace_ref, + double* normal_ref, + double* boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + int* u_l2g, + double* elementDiameter, + double* nodeDiametersArray, + double* u_dof, + double* q_phi, + double* q_normal_phi, + double* ebqe_phi, + double* ebqe_normal_phi, + double* q_H, + double* q_u, + double* q_n, + double* ebqe_u, + double* ebqe_n, + double* q_r, + double* q_vos, + int offset_u, int stride_u, + double* elementResidual_u, + double* elementInterface_lumpedMassMatrix, + int nExteriorElementBoundaries_global, + int* exteriorElementBoundariesArray, + int* elementBoundaryElementsArray, + int* elementBoundaryLocalElementBoundariesArray, + double* element_u, + int eN) + { + for (int i=0;i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + // fast (jacobian) assembly + xt::pyarray interface_lumpedMassMatrix) override + { + // + //loop over elements to compute volume integrals and load them into element and global residual + // + //eN is the element index + //eN_k is the quadrature point index for a scalar + //eN_k_nSpace is the quadrature point index for a vector + //eN_i is the element test function index + //eN_j is the element trial function index + //eN_k_j is the quadrature point index for a trial function + //eN_k_i is the quadrature point index for a trial function + for(int eN=0;eN mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + // xt::pyarray u_trial, + // xt::pyarray u_grad_trial, + // xt::pyarray u_test_dV, + // xt::pyarray u_grad_test_dV, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray q_H, + xt::pyarray q_vos, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + // Fast assembly + int numDOFs, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray stiffness_matrix, + xt::pyarray interface_lumpedMassMatrix) override + { + if (FAST_ASSEMBLY==1) + { + int ij=0; + for (int i=0; i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol) override + { + // + //loop over elements to compute volume integrals and load them into element and global residual + // + //eN is the element index + //eN_k is the quadrature point index for a scalar + //eN_k_nSpace is the quadrature point index for a vector + //eN_i is the element test function index + //eN_j is the element trial function index + //eN_k_j is the quadrature point index for a trial function + //eN_k_i is the quadrature point index for a trial function + for(int eN=0;eN= atol && its < maxIts) + { + its+=1; + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), + nElements_global, + useMetrics, + epsFactHeaviside, + epsFactDirac, + epsFactDiffusion, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_vos.data(), + elementJacobian_u_u, + element_u, + eN); + for (int i=0;i 0.99*resNorm && lsIts < 100) + { + //apply correction + for (int i=0;i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol) + { + for(int eN=0;eN= atol && its < maxIts) + { + its+=1; + calculateElementJacobian(mesh_trial_ref.data(), + mesh_grad_trial_ref.data(), + mesh_dof.data(), + mesh_l2g.data(), + dV_ref.data(), + u_trial_ref.data(), + u_grad_trial_ref.data(), + u_test_ref.data(), + u_grad_test_ref.data(), + mesh_trial_trace_ref.data(), + mesh_grad_trial_trace_ref.data(), + dS_ref.data(), + u_trial_trace_ref.data(), + u_grad_trial_trace_ref.data(), + u_test_trace_ref.data(), + u_grad_test_trace_ref.data(), + normal_ref.data(), + boundaryJac_ref.data(), + nElements_global, + useMetrics, + epsFactHeaviside, + epsFactDirac, + epsFactDiffusion, + u_l2g.data(), + elementDiameter.data(), + nodeDiametersArray.data(), + u_dof.data(), + q_phi.data(), + q_normal_phi.data(), + q_H.data(), + q_vos.data(), + elementJacobian_u_u, + element_u, + eN); + elementConstantJacobian=0.0; + for (int i=0;i globalConstantRJ(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_owned, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol, + double constant_u) override + { + register double element_u[nDOF_test_element], + elementResidual_u[nDOF_test_element], + dummy[nDOF_test_element], + elementJacobian_u_u[nDOF_test_element*nDOF_trial_element]; + double constantResidual = 0.0; + double constantJacobian = 0.0; + for (int i=0;i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_owned, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray) override + { + double globalMass = 0.0; + for(int eN=0;eN mesh_trial_ip, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray phi_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray phi_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray H_dof) override + { + for(int eN=0;eN mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_grad_trial_ref, + //physics + int nElements_global, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + // for weight within stiffness matrix + double useMetrics, + double epsFactDiffusion, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray) override + { + // + //loop over elements + // + for(int eN=0;eN(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + else + { + return proteus::chooseAndAllocateDiscretization(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + } +} + +namespace py = pybind11; + +PYBIND11_MODULE(cMCorr3P, m) +{ + using proteus::cppMCorr3P_base; + using proteus::newMCorr3P; + + xt::import_numpy(); + + py::class_(m, "cppMCorr3P_base") + .def("calculateResidual", &cppMCorr3P_base::calculateResidual) + .def("calculateJacobian", &cppMCorr3P_base::calculateJacobian) + .def("elementSolve", &cppMCorr3P_base::elementSolve) + .def("elementConstantSolve", &cppMCorr3P_base::elementConstantSolve) + .def("globalConstantRJ", &cppMCorr3P_base::globalConstantRJ) + .def("calculateMass", &cppMCorr3P_base::calculateMass) + .def("setMassQuadrature", &cppMCorr3P_base::setMassQuadrature) + .def("calculateStiffnessMatrix", &cppMCorr3P_base::calculateStiffnessMatrix); + + m.def("newMCorr3P", newMCorr3P); +} diff --git a/proteus/mprans2/MCorr3P.hpp b/proteus/mprans2/MCorr3P.hpp new file mode 100644 index 0000000000..3e42e4d5b1 --- /dev/null +++ b/proteus/mprans2/MCorr3P.hpp @@ -0,0 +1,383 @@ +#ifndef MCORR3P_HPP +#define MCORR3P_HPP + +#include +#include "xtensor-python/pyarray.hpp" + +namespace proteus +{ + class cppMCorr3P_base + { + public: + virtual ~cppMCorr3P_base() = default; + + virtual void calculateResidual(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + // fast (jacobian) assembly + xt::pyarray interface_lumpedMassMatrix) = 0; + + virtual void calculateJacobian(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray q_H, + xt::pyarray q_vos, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + // Fast assembly + int numDOFs, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray stiffness_matrix, + xt::pyarray interface_lumpedMassMatrix) = 0; + + virtual void elementSolve(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol) = 0; + + virtual void elementConstantSolve(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol) = 0; + + virtual std::pair globalConstantRJ(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_owned, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + int maxIts, + double atol, + double constant_u) = 0; + + virtual double calculateMass(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_owned, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray u_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray) = 0; + + virtual void setMassQuadrature(//element + xt::pyarray mesh_trial_ip, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double epsFactHeaviside, + double epsFactDirac, + double epsFactDiffusion, + xt::pyarray phi_l2g, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray, + xt::pyarray phi_dof, + xt::pyarray q_phi, + xt::pyarray q_normal_phi, + xt::pyarray ebqe_phi, + xt::pyarray ebqe_normal_phi, + xt::pyarray q_H, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray ebqe_u, + xt::pyarray ebqe_n, + xt::pyarray q_r, + xt::pyarray q_vos, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray H_dof) = 0; + + virtual void calculateStiffnessMatrix(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_grad_trial_ref, + int nElements_global, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + double useMetrics, + double epsFactDiffusion, + xt::pyarray elementDiameter, + xt::pyarray nodeDiametersArray) = 0; + }; + + cppMCorr3P_base* newMCorr3P(int nSpaceIn, + int nQuadraturePoints_elementIn, + int nDOF_mesh_trial_elementIn, + int nDOF_trial_elementIn, + int nDOF_test_elementIn, + int nQuadraturePoints_elementBoundaryIn, + int CompKernelFlag); + +} + +#endif + diff --git a/proteus/mprans2/MCorr3P.py b/proteus/mprans2/MCorr3P.py new file mode 100644 index 0000000000..99c7933b85 --- /dev/null +++ b/proteus/mprans2/MCorr3P.py @@ -0,0 +1,1465 @@ +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 * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport +import os +from proteus import cfemIntegrals, Quadrature, Norms, Comm +from proteus.NonlinearSolvers import NonlinearEquation +from proteus.FemTools import (DOFBoundaryConditions, + FluxBoundaryConditions, + C0_AffineLinearOnSimplexWithNodalBasis) +from proteus.Comm import (globalMax, + globalSum) +from proteus.Profiling import memory +from proteus.Profiling import logEvent as log +from proteus.Transport import OneLevelTransport +from proteus.TransportCoefficients import TC_base +from proteus.SubgridError import SGE_base +from proteus.ShockCapturing import ShockCapturing_base +from . import cMCorr3P + + +class Coefficients(proteus.TransportCoefficients.TC_base): + from proteus.ctransportCoefficients import levelSetConservationCoefficientsEvaluate + from proteus.ctransportCoefficients import levelSetConservationCoefficientsEvaluate_sd + + def __init__( + self, + applyCorrection=True, + epsFactHeaviside=0.0, + epsFactDirac=1.0, + epsFactDiffusion=2.0, + LS_model=None, + V_model=None, + ME_model=None, + VOS_model=None, + VOF_model=None, + checkMass=True, + sd=True, + nd=None, + applyCorrectionToDOF=True, + useMetrics=0.0, + useConstantH=False, + set_vos=None): + self.set_vos = set_vos + self.useConstantH = useConstantH + self.useMetrics = useMetrics + self.sd = sd + self.checkMass = checkMass + self.variableNames = ['phiCorr'] + nc = 1 + mass = {} + advection = {} + hamiltonian = {} + diffusion = {0: {0: {0: 'constant'}}} + potential = {0: {0: 'u'}} + reaction = {0: {0: 'nonlinear'}} + # reaction={} + if self.sd: + assert nd is not None, "You must set the number of dimensions to use sparse diffusion in LevelSetConservationCoefficients" + sdInfo = {(0, + 0): (numpy.arange(start=0, + stop=nd + 1, + step=1, + dtype='i'), + numpy.arange(start=0, + stop=nd, + step=1, + dtype='i'))} + else: + sdInfo = {} + TC_base.__init__(self, + nc, + mass, + advection, + diffusion, + potential, + reaction, + hamiltonian, + self.variableNames, + sparseDiffusionTensors=sdInfo, + useSparseDiffusion=sd) + self.LS_model = LS_model + self.V_model = V_model + self.epsFactHeaviside = epsFactHeaviside + self.epsFactDirac = epsFactDirac + self.epsFactDiffusion = epsFactDiffusion + self.ME_model = ME_model + self.VOF_model = VOF_model + self.VOS_model = VOS_model + self.useC = True + self.applyCorrection = applyCorrection + if self.applyCorrection: + self.applyCorrectionToDOF = applyCorrectionToDOF + else: + self.applyCorrectionToDOF = False + self.massConservationError = 0.0 + + def initializeMesh(self, mesh): + self.h = mesh.h + self.epsHeaviside = self.epsFactHeaviside * mesh.h + self.epsDirac = self.epsFactDirac * mesh.h + self.epsDiffusion = self.epsFactDiffusion * mesh.h + + def attachModels(self, modelList): + import copy + log("Attaching models in LevelSetConservation") + # level set + self.lsModel = modelList[self.LS_model] + self.q_u_ls = modelList[self.LS_model].q[('u', 0)] + self.q_n_ls = modelList[self.LS_model].q[('grad(u)', 0)] + + self.ebqe_u_ls = modelList[self.LS_model].ebqe[('u', 0)] + self.ebqe_n_ls = modelList[ + self.LS_model].ebqe[ + ('grad(u)', 0)] + + if ('u', 0) in modelList[self.LS_model].ebq: + self.ebq_u_ls = modelList[self.LS_model].ebq[('u', 0)] + else: + self.ebq_u_ls = None + # volume of fluid + self.vofModel = modelList[self.VOF_model] + self.q_H_vof = modelList[self.VOF_model].q[('u', 0)] + if self.VOS_model is not None: + self.q_vos = modelList[self.VOS_model].q[('u', 0)] + else: + self.q_vos = self.vofModel.coefficients.q_vos + self.ebqe_H_vof = modelList[self.VOF_model].ebqe[('u', 0)] + if ('u', 0) in modelList[self.VOF_model].ebq: + self.ebq_H_vof = modelList[self.VOF_model].ebq[('u', 0)] + else: + self.ebq_H_vof = None + # correction + self.massCorrModel = modelList[self.ME_model] + self.vofModel.q[('m_last', 0)][:] = self.vofModel.q[('m', 0)] + if self.checkMass: + self.m_tmp = copy.deepcopy(self.massCorrModel.q[('r', 0)]) + if self.checkMass: + # self.vofGlobalMass = Norms.scalarDomainIntegral(self.vofModel.q['dV'], + # self.vofModel.q[('u',0)], + # self.massCorrModel.mesh.nElements_owned) + # self.lsGlobalMass = Norms.scalarHeavisideDomainIntegral(self.vofModel.q['dV'], + # self.lsModel.q[('u',0)], + # self.massCorrModel.mesh.nElements_owned) + #self.vofGlobalMass = 0.0 + #self.lsGlobalMass = self.massCorrModel.calculateMass(self.lsModel.q[('u',0)]) + # log("Attach Models MCorr3P: mass correction %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q['dV'], + # self.massCorrModel.q[('r',0)], + # self.massCorrModel.mesh.nElements_owned),),level=2) + self.fluxGlobal = 0.0 + self.totalFluxGlobal = 0.0 + self.vofGlobalMassArray = [] # self.vofGlobalMass] + self.lsGlobalMassArray = [] # self.lsGlobalMass] + # self.vofGlobalMass - self.vofGlobalMassArray[0]]# + + # self.vofModel.timeIntegration.dt*self.vofModel.coefficients.fluxIntegral] + self.vofGlobalMassErrorArray = [] + # self.lsGlobalMass - self.lsGlobalMassArray[0]]# + + # self.vofModel.timeIntegration.dt*self.vofModel.coefficients.fluxIntegral] + self.lsGlobalMassErrorArray = [] + self.fluxArray = [] # 0.0]#self.vofModel.coefficients.fluxIntegral] + self.timeArray = [] # self.vofModel.timeIntegration.t] + #log("Attach Models MCorr3P: Phase 0 mass after mass correction (VOF) %12.5e" % (self.vofGlobalMass,),level=2) + #log("Attach Models MCorr3P: Phase 0 mass after mass correction (LS) %12.5e" % (self.lsGlobalMass,),level=2) + #log("Attach Models MCorr3P: Phase 0 mass conservation (VOF) after step = %12.5e" % (self.vofGlobalMass - self.vofModel.coefficients.m_pre + self.vofModel.timeIntegration.dt*self.vofModel.coefficients.fluxIntegral,),level=2) + #log("Attach Models MCorr3P: Phase 0 mass conservation (LS) after step = %12.5e" % (self.lsGlobalMass - self.lsModel.coefficients.m_pre + self.vofModel.timeIntegration.dt*self.vofModel.coefficients.fluxIntegral,),level=2) + + def initializeElementQuadrature(self, t, cq): + if self.sd and ('a', 0, 0) in cq: + cq[('a', 0, 0)].fill(self.epsDiffusion) + + def initializeElementBoundaryQuadrature(self, t, cebq, cebq_global): + if self.sd and ('a', 0, 0) in cebq: + cebq[('a', 0, 0)].fill(self.epsDiffusion) + + def initializeGlobalExteriorElementBoundaryQuadrature(self, t, cebqe): + if self.sd and ('a', 0, 0) in cebqe: + cebqe[('a', 0, 0)].fill(self.epsDiffusion) + + def preStep(self, t, firstStep=False): + if self.checkMass: + log( + "Phase 0 mass before mass correction (VOF) %12.5e" % + (Norms.scalarDomainIntegral( + self.vofModel.q['dV'], self.vofModel.q[ + ('m', 0)], self.massCorrModel.mesh.nElements_owned),), level=2) + log( + "Phase 0 mass (primitive) before mass correction (LS) %12.5e" % + (Norms.scalarSmoothedHeavisideDomainIntegral( + self.epsFactHeaviside, + self.massCorrModel.elementDiameter, + self.vofModel.q['dV'], + self.lsModel.q[ + ('m', + 0)], + self.massCorrModel.mesh.nElements_owned), + ), + level=2) + log("Phase 0 mass (consistent) before mass correction (LS) %12.5e" % ( + self.massCorrModel.calculateMass(self.lsModel.q[('m', 0)]),), level=2) + copyInstructions = {'clear_uList': True} + return copyInstructions + + def postStep(self, t, firstStep=False): + if self.applyCorrection: + # ls + self.lsModel.u[0].dof += self.massCorrModel.u[0].dof + self.lsModel.q[('u', 0)] += self.massCorrModel.q[('u', 0)] + self.lsModel.ebqe[('u', 0)] += self.massCorrModel.ebqe[('u', 0)] + self.lsModel.q[ + ('grad(u)', 0)] += self.massCorrModel.q[('grad(u)', 0)] + self.lsModel.ebqe[ + ('grad(u)', 0)] += self.massCorrModel.ebqe[('grad(u)', 0)] + # vof + self.massCorrModel.setMassQuadrature() + self.vofModel.q[('m_tmp',0)][:] = (1.0 - self.vofModel.coefficients.q_vos)*self.vofModel.q[('u',0)] + #self.vofModel.q[('u',0)] += self.massCorrModel.q[('r',0)] + # print "********************max + # VOF************************",max(self.vofModel.q[('u',0)].flat[:]) + if self.checkMass: + log( + "Phase 0 mass after mass correction (VOF) %12.5e" % + (Norms.scalarDomainIntegral( + self.vofModel.q['dV'], self.vofModel.q[ + ('m', 0)], self.massCorrModel.mesh.nElements_owned),), level=2) + log( + "Phase 0 mass (primitive) after mass correction (LS) %12.5e" % + (Norms.scalarSmoothedHeavisideDomainIntegral( + self.epsFactHeaviside, + self.massCorrModel.elementDiameter, + self.vofModel.q['dV'], + self.lsModel.q[ + ('m', + 0)], + self.massCorrModel.mesh.nElements_owned), + ), + level=2) + log("Phase 0 mass (consistent) after mass correction (LS) %12.5e" % ( + self.massCorrModel.calculateMass(self.lsModel.q[('m', 0)]),), level=2) + copyInstructions = {} + # get the waterline on the obstacle if option set in NCLS (boundary==7) + self.lsModel.computeWaterline(t) + return copyInstructions + + def evaluate(self, t, c): + import math + if c[('u', 0)].shape == self.q_u_ls.shape: + u_ls = self.q_u_ls + H_vof = self.q_H_vof + elif c[('u', 0)].shape == self.ebqe_u_ls.shape: + u_ls = self.ebqe_u_ls + H_vof = self.ebqe_H_vof + elif self.ebq_u_ls is not None and c[('u', 0)].shape == self.ebq_u_ls.shape: + u_ls = self.ebq_u_ls + H_vof = self.ebq_H_vof + else: + #\todo trap errors in TransportCoefficients.py + u_ls = None + H_vof = None + if u_ls is not None and H_vof is not None: + if self.useC: + if self.sd: + self.levelSetConservationCoefficientsEvaluate_sd( + self.epsHeaviside, self.epsDirac, u_ls, H_vof, c[ + ('u', 0)], c[ + ('r', 0)], c[ + ('dr', 0, 0)]) + else: + self.levelSetConservationCoefficientsEvaluate( + self.epsHeaviside, self.epsDirac, self.epsDiffusion, u_ls, H_vof, c[ + ('u', 0)], c[ + ('r', 0)], c[ + ('dr', 0, 0)], c[ + ('a', 0, 0)]) + if (self.checkMass and c[('u', 0)].shape == self.q_u_ls.shape): + self.m_tmp[:] = H_vof + self.m_tmp += self.massCorrModel.q[('r', 0)] + log("mass correction during Newton %12.5e" % (Norms.scalarDomainIntegral(self.vofModel.q[ + 'dV'], self.massCorrModel.q[('r', 0)], self.massCorrModel.mesh.nElements_owned),), level=2) + log("Phase 0 mass during Newton %12.5e" % (Norms.scalarDomainIntegral( + self.vofModel.q['dV'], self.m_tmp, self.massCorrModel.mesh.nElements_owned),), level=2) + + +class LevelModel(proteus.Transport.OneLevelTransport): + nCalls = 0 + + def __init__(self, + uDict, + phiDict, + testSpaceDict, + matType, + dofBoundaryConditionsDict, + dofBoundaryConditionsSetterDict, + coefficients, + elementQuadrature, + elementBoundaryQuadrature, + fluxBoundaryConditionsDict=None, + advectiveFluxBoundaryConditionsSetterDict=None, + diffusiveFluxBoundaryConditionsSetterDictDict=None, + stressTraceBoundaryConditionsSetterDict=None, + stabilization=None, + shockCapturing=None, + conservativeFluxDict=None, + numericalFluxType=None, + TimeIntegrationClass=None, + massLumping=False, + reactionLumping=False, + options=None, + name='defaultName', + reuse_trial_and_test_quadrature=True, + sd=True, + movingDomain=False, + bdyNullSpace=False): + self.bdyNullSpace = bdyNullSpace + self.useConstantH = coefficients.useConstantH + # + # set the objects describing the method and boundary conditions + # + self.movingDomain = movingDomain + self.tLast_mesh = None + # + self.name = name + self.sd = sd + self.Hess = False + self.lowmem = True + self.timeTerm = True # allow turning off the time derivative + # self.lowmem=False + self.testIsTrial = True + self.phiTrialIsTrial = True + self.u = uDict + self.ua = {} # analytical solutions + self.phi = phiDict + self.dphi = {} + self.matType = matType + # mwf try to reuse test and trial information across components if + # spaces are the same + self.reuse_test_trial_quadrature = reuse_trial_and_test_quadrature # True#False + if self.reuse_test_trial_quadrature: + for ci in range(1, coefficients.nc): + assert self.u[ci].femSpace.__class__.__name__ == self.u[ + 0].femSpace.__class__.__name__, "to reuse_test_trial_quad all femSpaces must be the same!" + # Simplicial Mesh + # assume the same mesh for all components for now + self.mesh = self.u[0].femSpace.mesh + self.testSpace = testSpaceDict + self.dirichletConditions = dofBoundaryConditionsDict + # explicit Dirichlet conditions for now, no Dirichlet BC constraints + self.dirichletNodeSetList = None + self.coefficients = coefficients + self.coefficients.initializeMesh(self.mesh) + self.nc = self.coefficients.nc + self.stabilization = stabilization + self.shockCapturing = shockCapturing + # no velocity post-processing for now + self.conservativeFlux = conservativeFluxDict + self.fluxBoundaryConditions = fluxBoundaryConditionsDict + self.advectiveFluxBoundaryConditionsSetterDict = advectiveFluxBoundaryConditionsSetterDict + self.diffusiveFluxBoundaryConditionsSetterDictDict = diffusiveFluxBoundaryConditionsSetterDictDict + # determine whether the stabilization term is nonlinear + self.stabilizationIsNonlinear = False + # cek come back + if self.stabilization is not None: + for ci in range(self.nc): + if ci in coefficients.mass: + for flag in list(coefficients.mass[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.advection: + for flag in list(coefficients.advection[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.diffusion: + for diffusionDict in list(coefficients.diffusion[ci].values()): + for flag in list(diffusionDict.values()): + if flag != 'constant': + self.stabilizationIsNonlinear = True + if ci in coefficients.potential: + for flag in list(coefficients.potential[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.reaction: + for flag in list(coefficients.reaction[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.hamiltonian: + for flag in list(coefficients.hamiltonian[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + # determine if we need element boundary storage + self.elementBoundaryIntegrals = {} + for ci in range(self.nc): + self.elementBoundaryIntegrals[ci] = ( + (self.conservativeFlux is not None) or ( + numericalFluxType is not None) or ( + self.fluxBoundaryConditions[ci] == 'outFlow') or ( + self.fluxBoundaryConditions[ci] == 'mixedFlow') or ( + self.fluxBoundaryConditions[ci] == 'setFlow')) + # + # calculate some dimensions + # + # assume same space dim for all variables + self.nSpace_global = self.u[0].femSpace.nSpace_global + self.nDOF_trial_element = [ + u_j.femSpace.max_nDOF_element for u_j in list(self.u.values())] + self.nDOF_phi_trial_element = [ + phi_k.femSpace.max_nDOF_element for phi_k in list(self.phi.values())] + self.n_phi_ip_element = [ + phi_k.femSpace.referenceFiniteElement.interpolationConditions.nQuadraturePoints for phi_k in list(self.phi.values())] + self.nDOF_test_element = [ + femSpace.max_nDOF_element for femSpace in list(self.testSpace.values())] + self.nFreeDOF_global = [ + dc.nFreeDOF_global for dc in list(self.dirichletConditions.values())] + self.nVDOF_element = sum(self.nDOF_trial_element) + self.nFreeVDOF_global = sum(self.nFreeDOF_global) + # + NonlinearEquation.__init__(self, self.nFreeVDOF_global) + # + # build the quadrature point dictionaries from the input (this + # is just for convenience so that the input doesn't have to be + # complete) + # + elementQuadratureDict = {} + elemQuadIsDict = isinstance(elementQuadrature, dict) + if elemQuadIsDict: # set terms manually + for I in self.coefficients.elementIntegralKeys: + if I in elementQuadrature: + elementQuadratureDict[I] = elementQuadrature[I] + else: + elementQuadratureDict[I] = elementQuadrature['default'] + else: + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[I] = elementQuadrature + if self.stabilization is not None: + for I in self.coefficients.elementIntegralKeys: + if elemQuadIsDict: + if I in elementQuadrature: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature[I] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature['default'] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature + if self.shockCapturing is not None: + for ci in self.shockCapturing.components: + if elemQuadIsDict: + if ('numDiff', ci, ci) in elementQuadrature: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + ('numDiff', ci, ci)] + else: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + 'default'] + else: + elementQuadratureDict[ + ('numDiff', ci, ci)] = elementQuadrature + if massLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('m', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + if reactionLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('r', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + elementBoundaryQuadratureDict = {} + if isinstance(elementBoundaryQuadrature, dict): # set terms manually + for I in self.coefficients.elementBoundaryIntegralKeys: + if I in elementBoundaryQuadrature: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature[I] + else: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature['default'] + else: + for I in self.coefficients.elementBoundaryIntegralKeys: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature + # + # find the union of all element quadrature points and + # build a quadrature rule for each integral that has a + # weight at each point in the union + # mwf include tag telling me which indices are which quadrature rule? + (self.elementQuadraturePoints, self.elementQuadratureWeights, + self.elementQuadratureRuleIndeces) = Quadrature.buildUnion(elementQuadratureDict) + self.nQuadraturePoints_element = self.elementQuadraturePoints.shape[0] + self.nQuadraturePoints_global = self.nQuadraturePoints_element * \ + self.mesh.nElements_global + # + # Repeat the same thing for the element boundary quadrature + # + (self.elementBoundaryQuadraturePoints, self.elementBoundaryQuadratureWeights, + self.elementBoundaryQuadratureRuleIndeces) = Quadrature.buildUnion(elementBoundaryQuadratureDict) + self.nElementBoundaryQuadraturePoints_elementBoundary = self.elementBoundaryQuadraturePoints.shape[ + 0] + self.nElementBoundaryQuadraturePoints_global = ( + self.mesh.nElements_global * + self.mesh.nElementBoundaries_element * + self.nElementBoundaryQuadraturePoints_elementBoundary) + # + # simplified allocations for test==trial and also check if space is mixed or not + # + self.q = {} + self.ebq = {} + self.ebq_global = {} + self.ebqe = {} + self.phi_ip = {} + # mesh + #self.q['x'] = numpy.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,3),'d') + self.q[('u', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global), + 'd') + self.q[('r', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + + self.ebqe[ + ('u', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebqe[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + + self.points_elementBoundaryQuadrature = set() + self.scalars_elementBoundaryQuadrature = set( + [('u', ci) for ci in range(self.nc)]) + self.vectors_elementBoundaryQuadrature = set() + self.tensors_elementBoundaryQuadrature = set() + log(memory("element and element boundary Jacobians", + "OneLevelTransport"), level=4) + self.inflowBoundaryBC = {} + self.inflowBoundaryBC_values = {} + self.inflowFlux = {} + for cj in range(self.nc): + self.inflowBoundaryBC[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global,), 'i') + self.inflowBoundaryBC_values[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nDOF_trial_element[cj]), 'd') + self.inflowFlux[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.internalNodes = set(range(self.mesh.nNodes_global)) + # identify the internal nodes this is ought to be in mesh + # \todo move this to mesh + for ebNE in range(self.mesh.nExteriorElementBoundaries_global): + ebN = self.mesh.exteriorElementBoundariesArray[ebNE] + eN_global = self.mesh.elementBoundaryElementsArray[ebN, 0] + ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[ + ebN, 0] + for i in range(self.mesh.nNodes_element): + if i != ebN_element: + I = self.mesh.elementNodesArray[eN_global, i] + self.internalNodes -= set([I]) + self.nNodes_internal = len(self.internalNodes) + self.internalNodesArray = numpy.zeros((self.nNodes_internal,), 'i') + for nI, n in enumerate(self.internalNodes): + self.internalNodesArray[nI] = n + # + del self.internalNodes + self.internalNodes = None + log("Updating local to global mappings", 2) + self.updateLocal2Global() + log("Building time integration object", 2) + log(memory("inflowBC, internalNodes,updateLocal2Global", + "OneLevelTransport"), level=4) + # mwf for interpolating subgrid error for gradients etc + if self.stabilization and self.stabilization.usesGradientStabilization: + self.timeIntegration = TimeIntegrationClass( + self, integrateInterpolationPoints=True) + else: + self.timeIntegration = TimeIntegrationClass(self) + + if options is not None: + self.timeIntegration.setFromOptions(options) + log(memory("TimeIntegration", "OneLevelTransport"), level=4) + log("Calculating numerical quadrature formulas", 2) + self.calculateQuadrature() + self.setupFieldStrides() + + comm = Comm.get() + self.comm = comm + if comm.size() > 1: + assert numericalFluxType is not None and numericalFluxType.useWeakDirichletConditions, "You must use a numerical flux to apply weak boundary conditions for parallel runs" + + # STIFFNESS MATRIX # + self.interface_lumpedMassMatrix = numpy.zeros(self.u[0].dof.shape,'d') + self.stiffness_matrix_array = None + self.stiffness_matrix = None + + log(memory("stride+offset", "OneLevelTransport"), level=4) + if numericalFluxType is not None: + if options is None or options.periodicDirichletConditions is None: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict) + else: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict, + options.periodicDirichletConditions) + else: + self.numericalFlux = None + # set penalty terms + # cek todo move into numerical flux initialization + 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)) + # 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) + log(memory("numericalFlux", "OneLevelTransport"), level=4) + self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray + # use post processing tools to get conservative fluxes, None by default + from proteus import PostProcessingTools + self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser( + self) + log(memory("velocity postprocessor", "OneLevelTransport"), level=4) + # helper for writing out data storage + from proteus import Archiver + self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.globalResidualDummy = None + compKernelFlag = 0 + if self.coefficients.useConstantH: + self.elementDiameter = self.mesh.elementDiametersArray.copy() + self.elementDiameter[:] = max(self.mesh.elementDiametersArray) + else: + self.elementDiameter = self.mesh.elementDiametersArray + self.mcorr3p = cMCorr3P.newMCorr3P( + self.nSpace_global, + self.nQuadraturePoints_element, + self.u[0].femSpace.elementMaps.localFunctionSpace.dim, + self .u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim, + self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim, + self.nElementBoundaryQuadraturePoints_elementBoundary, + compKernelFlag) + # mwf these are getting called by redistancing classes, + + def calculateCoefficients(self): + pass + + def calculateElementResidual(self): + if self.globalResidualDummy is not None: + self.getResidual(self.u[0].dof, self.globalResidualDummy) + + def getResidual(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + if self.coefficients.set_vos: + self.coefficients.set_vos(self.q['x'], self.coefficients.q_vos) + r.fill(0.0) + self.interface_lumpedMassMatrix.fill(0.0) + # Load the unknowns into the finite element dof + self.setUnknowns(u) + + # no flux boundary conditions + self.mcorr3p.calculateResidual( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.coefficients.q_vos, + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + # FOR FAST ASSEMBLY of Jacobian matrix + self.interface_lumpedMassMatrix) + + log("Global residual", level=9, data=r) + self.coefficients.massConservationError = fabs(globalSum(r[:self.mesh.nNodes_owned].sum())) + log(" Mass Conservation Error", level=3, + data=self.coefficients.massConservationError) + self.nonlinear_function_evaluations += 1 + if self.globalResidualDummy is None: + self.globalResidualDummy = numpy.zeros(r.shape, 'd') + + def getStiffnessMatrix(self): + rowptr, colind, nzval = self.jacobian.getCSRrepresentation() + nnz = nzval.shape[-1] # number of non-zero entries in sparse matrix + self.stiffness_matrix_array = nzval.copy() + self.stiffness_matrix = SparseMat(self.nFreeDOF_global[0], + self.nFreeDOF_global[0], + nnz, + self.stiffness_matrix_array, + colind, + rowptr) + cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, + self.stiffness_matrix) + + (rowptr, colind, globalJacobian) = self.stiffness_matrix.getCSRrepresentation() + + self.mcorr3p.calculateStiffnessMatrix( + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.grad_psi, + self.mesh.nElements_global, + self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], + globalJacobian, + self.coefficients.useMetrics, + self.coefficients.epsFactDiffusion, + self.elementDiameter, + self.mesh.nodeDiametersArray) + + def getJacobian(self, jacobian): + cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, jacobian) + + if self.stiffness_matrix is None: + self.getStiffnessMatrix() + (rowptr, colind, globalJacobian) = jacobian.getCSRrepresentation() + self.mcorr3p.calculateJacobian(# element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.q_H_vof, + self.coefficients.q_vos, + self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], + globalJacobian, + # FAST ASSEMBLY + len(self.u[0].dof), + self.rowptr, + self.colind, + self.stiffness_matrix_array, + self.interface_lumpedMassMatrix) + + log("Jacobian ", level=10, data=jacobian) + # mwf decide if this is reasonable for solver statistics + self.nonlinear_function_jacobian_evaluations += 1 + return jacobian + + def elementSolve(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + r.fill(0.0) + # Load the unknowns into the finite element dof + self.setUnknowns(u) + + # no flux boundary conditions + self.mcorr3p.elementSolve( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.coefficients.q_vos, + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.maxIts, + self.atol) + + def elementConstantSolve(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + r.fill(0.0) + # Load the unknowns into the finite element dof + self.setUnknowns(u) + + # no flux boundary conditions + self.mcorr3p.elementConstantSolve( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.coefficients.q_vos, + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.maxIts, + self.atol) + + def globalConstantRJ(self, u, r, U): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + r.fill(0.0) + # Load the unknowns into the finite element dof + self.setUnknowns(u) + + # no flux boundary conditions + (R, J) = self.mcorr3p.globalConstantRJ( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_owned, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, + self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.offset[0], self.stride[0], + r, + self.coefficients.q_vos, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.maxIts, + self.atol, + U) + R = globalSum(R) + J = globalSum(J) + self.coefficients.massConservationError = fabs(R) + return (R, J) + + def globalConstantSolve(self, u, r): + U = 0.0 + R = 0.0 + J = 0.0 + (R, J) = self.globalConstantRJ(u, r, U) + its = 0 + 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)) + (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))) + (R, J) = self.globalConstantRJ(u, r, U) + its += 1 + log(" Mass Conservation Residual " + repr(its)+" ", level=3, data=R) + self.u[0].dof.flat[:] = U + + def calculateElementQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points. + + This function should be called only when the mesh changes. + """ + # self.u[0].femSpace.elementMaps.getValues(self.elementQuadraturePoints, + # self.q['x']) + self.u[0].femSpace.elementMaps.getBasisValuesIP( + self.u[0].femSpace.referenceFiniteElement.interpolationConditions.quadraturePointArray) + self.u[0].femSpace.elementMaps.getBasisValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.getBasisValuesRef(self.elementQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.coefficients.initializeElementQuadrature( + self.timeIntegration.t, self.q) + if self.stabilization is not None: + self.stabilization.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + self.stabilization.initializeTimeIntegration(self.timeIntegration) + if self.shockCapturing is not None: + self.shockCapturing.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + + def calculateElementBoundaryQuadrature(self): + pass + + def calculateExteriorElementBoundaryQuadrature(self): + self.u[0].femSpace.elementMaps.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + + def estimate_mt(self): + pass + + def calculateAuxiliaryQuantitiesAfterStep(self): + pass + + def calculateMass(self, q_phi): + return globalSum(self.mcorr3p.calculateMass( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_owned, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.u[0].dof, + q_phi, # self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.coefficients.q_vos, + self.offset[0], self.stride[0], + self.u[0].dof, # dummy r,not used + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray)) + + def setMassQuadrature(self): + self.mcorr3p.setMassQuadrature( # element + self.u[0].femSpace.elementMaps.psi_ip, + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.coefficients.epsFactHeaviside, + self.coefficients.epsFactDirac, + self.coefficients.epsFactDiffusion, + self.coefficients.lsModel.u[0].femSpace.dofMap.l2g, + self.elementDiameter, # self.mesh.elementDiametersArray, + self.mesh.nodeDiametersArray, + self.coefficients.lsModel.u[0].dof, + self.coefficients.q_u_ls, + self.coefficients.q_n_ls, + self.coefficients.ebqe_u_ls, + self.coefficients.ebqe_n_ls, + self.coefficients.q_H_vof, + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.ebqe[('u', 0)], + self.ebqe[('grad(u)', 0)], + self.q[('r', 0)], + self.coefficients.q_vos, + self.offset[0], self.stride[0], + self.u[0].dof, # dummy r,not used + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.coefficients.vofModel.u[0].dof) + # self.coefficients.q_H_vof.flat[:]=777.0 + + def calculateSolutionAtQuadrature(self): + pass + + def updateAfterMeshMotion(self): + pass + + +class DummyNewton(proteus.NonlinearSolvers.NonlinearSolver): + + def __init__(self, + linearSolver, + F, J=None, du=None, par_du=None, + rtol_r=1.0e-4, + atol_r=1.0e-16, + rtol_du=1.0e-4, + atol_du=1.0e-16, + maxIts=100, + norm=l2Norm, + convergenceTest='r', + computeRates=True, + printInfo=True, + fullNewton=True, + directSolver=False, + EWtol=True, + maxLSits=100): + import copy + self.par_du = par_du + if par_du is not None: + F.dim_proc = par_du.dim_proc + NonlinearSolver.__init__(self, F, J, du, + rtol_r, + atol_r, + rtol_du, + atol_du, + maxIts, + norm, + convergenceTest, + computeRates, + printInfo) + self.updateJacobian = True + self.fullNewton = fullNewton + self.linearSolver = linearSolver + self.directSolver = directSolver + self.lineSearch = True + # mwf turned back on self.lineSearch = False + self.EWtol = EWtol + # mwf added + self.maxLSits = maxLSits + if self.linearSolver.computeEigenvalues: + self.JLast = copy.deepcopy(self.J) + self.J_t_J = copy.deepcopy(self.J) + self.dJ_t_dJ = copy.deepcopy(self.J) + self.JLsolver = LU(self.J_t_J, computeEigenvalues=True) + self.dJLsolver = LU(self.dJ_t_dJ, computeEigenvalues=True) + self.u0 = numpy.zeros(self.F.dim, 'd') + + def info(self): + return "Not Implemented" + + def solve(self, u, r=None, b=None, par_u=None, par_r=None): + self.F.q[('r', 0)].flat[:] = 0.0 + self.F.q[('u', 0)].flat[:] = 0.0 + self.failedFlag = False + return self.failedFlag + + +class ElementNewton(proteus.NonlinearSolvers.NonlinearSolver): + + def __init__(self, + linearSolver, + F, J=None, du=None, par_du=None, + rtol_r=1.0e-4, + atol_r=1.0e-16, + rtol_du=1.0e-4, + atol_du=1.0e-16, + maxIts=100, + norm=l2Norm, + convergenceTest='r', + computeRates=True, + printInfo=True, + fullNewton=True, + directSolver=False, + EWtol=True, + maxLSits=100): + import copy + self.par_du = par_du + if par_du is not None: + F.dim_proc = par_du.dim_proc + NonlinearSolver.__init__(self, F, J, du, + rtol_r, + atol_r, + rtol_du, + atol_du, + maxIts, + norm, + convergenceTest, + computeRates, + printInfo) + self.updateJacobian = True + self.fullNewton = fullNewton + self.linearSolver = linearSolver + self.directSolver = directSolver + self.lineSearch = True + # mwf turned back on self.lineSearch = False + self.EWtol = EWtol + # mwf added + self.maxLSits = maxLSits + if self.linearSolver.computeEigenvalues: + self.JLast = copy.deepcopy(self.J) + self.J_t_J = copy.deepcopy(self.J) + self.dJ_t_dJ = copy.deepcopy(self.J) + self.JLsolver = LU(self.J_t_J, computeEigenvalues=True) + self.dJLsolver = LU(self.dJ_t_dJ, computeEigenvalues=True) + self.u0 = numpy.zeros(self.F.dim, 'd') + + def info(self): + return "Not Implemented" + + def solve(self, u, r=None, b=None, par_u=None, par_r=None): + self.F.maxIts = self.maxIts + self.F.maxLSits = self.maxLSits + self.F.atol = self.atol_r + self.F.elementSolve(u, r) + self.failedFlag = False + return self.failedFlag + + +class ElementConstantNewton(proteus.NonlinearSolvers.NonlinearSolver): + + def __init__(self, + linearSolver, + F, J=None, du=None, par_du=None, + rtol_r=1.0e-4, + atol_r=1.0e-16, + rtol_du=1.0e-4, + atol_du=1.0e-16, + maxIts=100, + norm=l2Norm, + convergenceTest='r', + computeRates=True, + printInfo=True, + fullNewton=True, + directSolver=False, + EWtol=True, + maxLSits=100): + import copy + self.par_du = par_du + if par_du is not None: + F.dim_proc = par_du.dim_proc + NonlinearSolver.__init__(self, F, J, du, + rtol_r, + atol_r, + rtol_du, + atol_du, + maxIts, + norm, + convergenceTest, + computeRates, + printInfo) + self.updateJacobian = True + self.fullNewton = fullNewton + self.linearSolver = linearSolver + self.directSolver = directSolver + self.lineSearch = True + # mwf turned back on self.lineSearch = False + self.EWtol = EWtol + # mwf added + self.maxLSits = maxLSits + if self.linearSolver.computeEigenvalues: + self.JLast = copy.deepcopy(self.J) + self.J_t_J = copy.deepcopy(self.J) + self.dJ_t_dJ = copy.deepcopy(self.J) + self.JLsolver = LU(self.J_t_J, computeEigenvalues=True) + self.dJLsolver = LU(self.dJ_t_dJ, computeEigenvalues=True) + self.u0 = numpy.zeros(self.F.dim, 'd') + + def info(self): + return "Not Implemented" + + def solve(self, u, r=None, b=None, par_u=None, par_r=None): + self.F.maxIts = self.maxIts + self.F.maxLSits = self.maxLSits + self.F.atol = self.atol_r + self.F.elementConstantSolve(u, r) + self.failedFlag = False + return self.failedFlag + + +class GlobalConstantNewton(proteus.NonlinearSolvers.NonlinearSolver): + + def __init__(self, + linearSolver, + F, J=None, du=None, par_du=None, + rtol_r=1.0e-4, + atol_r=1.0e-16, + rtol_du=1.0e-4, + atol_du=1.0e-16, + maxIts=100, + norm=l2Norm, + convergenceTest='r', + computeRates=True, + printInfo=True, + fullNewton=True, + directSolver=False, + EWtol=True, + maxLSits=100): + import copy + self.par_du = par_du + if par_du is not None: + F.dim_proc = par_du.dim_proc + NonlinearSolver.__init__(self, F, J, du, + rtol_r, + atol_r, + rtol_du, + atol_du, + maxIts, + norm, + convergenceTest, + computeRates, + printInfo) + self.updateJacobian = True + self.fullNewton = fullNewton + self.linearSolver = linearSolver + self.directSolver = directSolver + self.lineSearch = True + # mwf turned back on self.lineSearch = False + self.EWtol = EWtol + # mwf added + self.maxLSits = maxLSits + if self.linearSolver.computeEigenvalues: + self.JLast = copy.deepcopy(self.J) + self.J_t_J = copy.deepcopy(self.J) + self.dJ_t_dJ = copy.deepcopy(self.J) + self.JLsolver = LU(self.J_t_J, computeEigenvalues=True) + self.dJLsolver = LU(self.dJ_t_dJ, computeEigenvalues=True) + self.u0 = numpy.zeros(self.F.dim, 'd') + + def info(self): + return "Not Implemented" + + def solve(self, u, r=None, b=None, par_u=None, par_r=None): + self.F.maxIts = self.maxIts + self.F.maxLSits = self.maxLSits + self.F.atol = self.atol_r + self.F.globalConstantSolve(u, r) + self.failedFlag = False + return self.failedFlag + + +def conservationNorm(x): + return fabs(globalSum(sum(x.flat))) + + +class Newton_controller(proteus.StepControl.Newton_controller): + + def __init__(self, model, nOptions): + proteus.StepControl.Newton_controller.__init__(self, model, nOptions) + + def initializeTimeHistory(self): + proteus.StepControl.Newton_controller.initializeTimeHistory(self) + for m, u, r in zip(self.model.levelModelList, + self.model.uList, + self.model.rList): + # pass + # m.setMassQuadrature() + u.flat[:] = 0.0 + m.getResidual(u, r) + m.coefficients.postStep(self.t_model) + m.coefficients.vofModel.updateTimeHistory( + self.t_model, resetFromDOF=False) + m.coefficients.vofModel.timeIntegration.updateTimeHistory( + resetFromDOF=False) diff --git a/proteus/mprans2/NCLS3P.cpp b/proteus/mprans2/NCLS3P.cpp new file mode 100644 index 0000000000..edf13bdd25 --- /dev/null +++ b/proteus/mprans2/NCLS3P.cpp @@ -0,0 +1,1392 @@ +#include +#define FORCE_IMPORT_ARRAY +#include "NCLS3P.hpp" +#include "CompKernel.h" +#include "ModelFactory.h" + +#define cE 0.1 +#define cMax 0.1 + +namespace proteus +{ + inline double ENTROPY(const double& u) + { + return u; + } + + inline double DENTROPY(const double& u) + { + return 1.0; + } + + inline double Sign(const double& z) + { + return (z >= 0.0 ? 1.0 : -1.0); + } + + template + class cppNCLS3P : public cppNCLS3P_base + { + public: + + const int nDOF_test_X_trial_element; + CompKernelType ck; + + cppNCLS3P() + : nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element) + , ck() + {} + + + void calculateCFL(const double& elementDiameter, + const double df[nSpace], + double& cfl) + { + double h,nrm_v; + h = elementDiameter; + nrm_v=0.0; + for(int I=0;I 0.0) + { + flux = u*flow_movingDomain; + } + else + { + + flux = bc_u*flow_movingDomain - flow_fluid*(u-bc_u); + //std::cout<<"bc_u "< 0.0) + { + dflux = flow_movingDomain; + } + else + { + dflux = -flow_fluid; + } + } + + void calculateResidual(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof,xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray q_dH, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_rd_u_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_u, + xt::pyarray cell_interface_locator, + xt::pyarray interface_locator, + // FOR TAYLOR GALERKIN METHODS + int EXPLICIT_METHOD, + double degree_polynomial, + int stage, + xt::pyarray uTilde_dof, + double dt, + // TO KILL SUPG AND SHOCK CAPTURING + int PURE_BDF) override + { + double meanEntropy = 0., meanOmega = 0., maxEntropy = -1E10, minEntropy = 1E10; + register double maxVel[nElements_global], maxEntRes[nElements_global]; + //cek should this be read in? + double Ct_sge = 4.0; + + //loop over elements to compute volume integrals and load them into element and global residual + // + //eN is the element index + //eN_k is the quadrature point index for a scalar + //eN_k_nSpace is the quadrature point index for a vector + //eN_i is the element test function index + //eN_j is the element trial function index + //eN_k_j is the quadrature point index for a trial function + //eN_k_i is the quadrature point index for a trial function + for(int eN=0;eN mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof, + xt::pyarray velocity, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u_last, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_rd_u_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray csrColumnOffsets_eb_u_u, + // FOR TAYLOR GALERKIN METHODS + int EXPLICIT_METHOD, + // TO KILL SUPG AND SHOCK CAPTURING + int PURE_BDF) override + { + double Ct_sge = 4.0; + + // + //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian + // + for(int eN=0;eN wlc, + xt::pyarray waterline, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof,xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray q_dH, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray elementBoundaryMaterialTypes, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_u) override + { + // Tetrehedral elements specific extraction routine for waterline extraction + // Loops over boundaries and checks if boundary is infact a hull (hardwired check if mattype > 6) + // Extracts the nodal values of boundary triangle (4th point is dropped = hardwired assumption we are dealing with linear tet) + // Then computes an average value and position for both negative and positive values + // If both positive and negative values re found, and we are actually in a triangle containing the interface + // a linear interpolation of negative and positive average is reported as interface location (exact in case of linear tets) + + for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) + { + register int ebN = exteriorElementBoundariesArray[ebNE]; + register int eN = elementBoundaryElementsArray[ebN*2+0]; + register int bN = elementBoundaryLocalElementBoundariesArray[ebN*2+0]; + + if (elementBoundaryMaterialTypes[ebN] >6) + { + double val,x,y,z; + int pos=0, neg=0; + double xn=0.0, yn=0.0, zn=0.0, vn=0.0; + double xp=0.0, yp=0.0, zp=0.0, vp=0.0; + + for (int j=0;j 0) && (neg > 0) ) + { + vp /= pos; + vn /= neg; + + double alpha = vp/(vp -vn); + + waterline[wlc[0]*3 + 0] = alpha*(xn/neg) + (1.0-alpha)*(xp/pos); + waterline[wlc[0]*3 + 1] = alpha*(yn/neg) + (1.0-alpha)*(yp/pos); + waterline[wlc[0]*3 + 2] = alpha*(zn/neg) + (1.0-alpha)*(zp/pos); + wlc[0]++; + + } // end value if + } // end bnd mat check + }//ebNE + //std::cout<<"CPP WLC "<(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + else + { + return proteus::chooseAndAllocateDiscretization(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + } +} + +namespace py = pybind11; + +PYBIND11_MODULE(cNCLS3P, m) +{ + using proteus::cppNCLS3P_base; + using proteus::newNCLS3P; + + xt::import_numpy(); + + py::class_(m, "cppNCLS3P_base") + .def("calculateResidual", &cppNCLS3P_base::calculateResidual) + .def("calculateJacobian", &cppNCLS3P_base::calculateJacobian) + .def("calculateWaterline", &cppNCLS3P_base::calculateWaterline); + + m.def("newNCLS3P", newNCLS3P); +} + diff --git a/proteus/mprans2/NCLS3P.hpp b/proteus/mprans2/NCLS3P.hpp new file mode 100644 index 0000000000..a329c0ca19 --- /dev/null +++ b/proteus/mprans2/NCLS3P.hpp @@ -0,0 +1,192 @@ +#ifndef NCLS3P_HPP +#define NCLS3P_HPP + +#include "xtensor-python/pyarray.hpp" + +namespace proteus +{ + class cppNCLS3P_base + { + public: + + virtual ~cppNCLS3P_base() = default; + virtual void calculateResidual(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray meshVelocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof,xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray q_dH, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_rd_u_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_u, + xt::pyarray cell_interface_locator, + xt::pyarray interface_locator, + // FOR TAYLOR GALERKIN METHODS + int EXPLICIT_METHOD, + double degree_polynomial, + int stage, + xt::pyarray uTilde_dof, + double dt, + // TO KILL SUPG AND SHOCK CAPTURING + int PURE_BDF)=0; + virtual void calculateJacobian(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof, + xt::pyarray velocity, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u_last, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_rd_u_ext, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray csrColumnOffsets_eb_u_u, + // FOR TAYLOR GALERKIN METHODS + int EXPLICIT_METHOD, + // TO KILL SUPG AND SHOCK CAPTURING + int PURE_BDF) = 0; + virtual void calculateWaterline(//element + xt::pyarray wlc, + xt::pyarray waterline, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray meshVelocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + xt::pyarray u_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof,xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_n, + xt::pyarray q_dH, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray elementBoundaryMaterialTypes, + xt::pyarray ebqe_velocity_ext, + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray ebqe_u) = 0; + }; + + cppNCLS3P_base* newNCLS3P(int nSpaceIn, + int nQuadraturePoints_elementIn, + int nDOF_mesh_trial_elementIn, + int nDOF_trial_elementIn, + int nDOF_test_elementIn, + int nQuadraturePoints_elementBoundaryIn, + int CompKernelFlag); +} + +#endif + diff --git a/proteus/mprans2/NCLS3P.py b/proteus/mprans2/NCLS3P.py new file mode 100644 index 0000000000..feab9c18be --- /dev/null +++ b/proteus/mprans2/NCLS3P.py @@ -0,0 +1,1157 @@ +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 +from math import fabs +import os +from proteus import cfemIntegrals, Quadrature, Norms, Comm +from proteus.NonlinearSolvers import NonlinearEquation +from proteus.FemTools import (DOFBoundaryConditions, + FluxBoundaryConditions, + C0_AffineLinearOnSimplexWithNodalBasis) +from proteus.Comm import globalMax +from proteus.Profiling import memory +from proteus.Profiling import logEvent as log +from proteus.Transport import OneLevelTransport +from proteus.TransportCoefficients import TC_base +from proteus.SubgridError import SGE_base +from proteus.ShockCapturing import ShockCapturing_base +from . import cNCLS3P + + +class SubgridError(proteus.SubgridError.SGE_base): + + def __init__(self, coefficients, nd): + proteus.SubgridError.SGE_base.__init__(self, coefficients, nd, False) + + def initializeElementQuadrature(self, mesh, t, cq): + for ci in range(self.nc): + cq[('dH_sge', ci, ci)] = cq[('dH', ci, ci)] + + def calculateSubgridError(self, q): + pass + + def updateSubgridErrorHistory(self, initializationPhase=False): + pass + + +class ShockCapturing(proteus.ShockCapturing.ShockCapturing_base): + + def __init__( + self, + coefficients, + nd, + shockCapturingFactor=0.25, + lag=True, + nStepsToDelay=None): + proteus.ShockCapturing.ShockCapturing_base.__init__( + self, coefficients, nd, shockCapturingFactor, lag) + self.nStepsToDelay = nStepsToDelay + self.nSteps = 0 + if self.lag: + log("NCLS3P.ShockCapturing: lagging requested but must lag the first step; switching lagging off and delaying") + self.nStepsToDelay = 1 + self.lag = False + + def initializeElementQuadrature(self, mesh, t, cq): + self.mesh = mesh + self.numDiff = [] + self.numDiff_last = [] + for ci in range(self.nc): + self.numDiff.append(cq[('numDiff', ci, ci)]) + self.numDiff_last.append(cq[('numDiff', ci, ci)]) + + def updateShockCapturingHistory(self): + self.nSteps += 1 + if self.lag: + for ci in range(self.nc): + self.numDiff_last[ci][:] = self.numDiff[ci] + if self.lag == False and self.nStepsToDelay is not None and self.nSteps > self.nStepsToDelay: + log("NCLS3P.ShockCapturing: switched to lagged shock capturing") + self.lag = True + self.numDiff_last = [] + for ci in range(self.nc): + self.numDiff_last.append(self.numDiff[ci].copy()) + log("NCLS3P: max numDiff %e" % + (globalMax(self.numDiff_last[0].max()),)) + +class NumericalFlux( + proteus.NumericalFlux.HamiltonJacobi_DiagonalLesaintRaviart): + + def __init__(self, vt, getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions): + proteus.NumericalFlux.HamiltonJacobi_DiagonalLesaintRaviart.__init__( + self, + vt, + getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions) + + +class Coefficients(proteus.TransportCoefficients.TC_base): + from proteus.ctransportCoefficients import ncLevelSetCoefficientsEvaluate + def __init__(self, + V_model=0, + RD_model=None, + ME_model=1, + checkMass=True, epsFact=1.5, + useMetrics=0.0, sc_uref=1.0, sc_beta=1.0, + waterline_interval=-1, + movingDomain=False, + PURE_BDF=False, + EXPLICIT_METHOD=False, + outputQuantDOFs=False): + + self.EXPLICIT_METHOD=EXPLICIT_METHOD + self.outputQuantDOFs=outputQuantDOFs + self.PURE_BDF=PURE_BDF + self.movingDomain = movingDomain + self.useMetrics = useMetrics + self.epsFact = epsFact + self.variableNames = ['phi'] + nc = 1 + mass = {0: {0: 'linear'}} + hamiltonian = {0: {0: 'linear'}} + advection = {} + diffusion = {} + potential = {} + reaction = {} + TC_base.__init__(self, + nc, + mass, + advection, + diffusion, + potential, + reaction, + hamiltonian, + ['phi'], + movingDomain=movingDomain) + self.flowModelIndex = V_model + self.modelIndex = ME_model + self.RD_modelIndex = RD_model + self.checkMass = checkMass + self.sc_uref = sc_uref + self.sc_beta = sc_beta + self.waterline_interval = waterline_interval + + def attachModels(self, modelList): + # the level set model + self.model = modelList[self.modelIndex] + + # the velocity + if self.flowModelIndex >= 0: + self.flowModel = modelList[self.flowModelIndex] + self.q_v = modelList[self.flowModelIndex].q[('velocity', 0)] + self.ebqe_v = modelList[self.flowModelIndex].ebqe[('velocity', 0)] + if ('velocity', 0) in modelList[self.flowModelIndex].ebq: + self.ebq_v = modelList[ + self.flowModelIndex].ebq[ + ('velocity', 0)] + else: + self.ebq_v = None + if ('u', 0) not in self.model.ebq and ('u', 0) in self.flowModel.ebq: + self.model.ebq[('u', 0)] = numpy.zeros( + self.flowModel.ebq[('u', 0)].shape, 'd') + self.model.ebq[('grad(u)', 0)] = numpy.zeros( + self.flowModel.ebq[('grad(u)', 0)].shape, 'd') + if ('v', 1) in self.flowModel.ebq: + self.model.u[0].getValuesTrace( + self.flowModel.ebq[ + ('v', 1)], self.model.ebq[ + ('u', 0)]) + self.model.u[0].getGradientValuesTrace( + self.flowModel.ebq[ + ('grad(v)', 1)], self.model.ebq[ + ('grad(u)', 0)]) + if self.RD_modelIndex is not None: + self.rdModel = modelList[self.RD_modelIndex] + self.rdModel_ebqe = self.rdModel.ebqe[('u',0)] + else: + self.rdModel = None + self.rdModel_ebqe = numpy.copy(self.model.ebqe[('u',0)]) + + def initializeElementQuadrature(self, t, cq): + if self.flowModelIndex is None: + self.q_v = numpy.zeros(cq[('grad(u)', 0)].shape, 'd') + + def initializeElementBoundaryQuadrature(self, t, cebq, cebq_global): + if self.flowModelIndex is None: + self.ebq_v = numpy.zeros(cebq[('grad(u)', 0)].shape, 'd') + + def initializeGlobalExteriorElementBoundaryQuadrature(self, t, cebqe): + if self.flowModelIndex is None: + self.ebqe_v = numpy.zeros(cebqe[('grad(u)', 0)].shape, 'd') + + def preStep(self, t, firstStep=False): + # BOUNDARY CONDITION FROM re-distancing model + if self.rdModel is None: + self.rdModel_ebqe[:] = self.model.ebqe[('u',0)] + + # Restart flags for stages of taylor galerkin + self.model.stage = 1 + self.model.auxTaylorGalerkinFlag = 1 + + # SAVE OLD SOLUTION # + self.model.u_dof_old[:] = self.model.u[0].dof + + # COMPUTE NEW VELOCITY (if given by user) # + if self.model.hasVelocityFieldAsFunction: + self.model.updateVelocityFieldAsFunction() + + # if self.checkMass: + # self.m_pre = Norms.scalarSmoothedHeavisideDomainIntegral(self.epsFact, + # self.model.mesh.elementDiametersArray, + # self.model.q['dV'], + # self.model.q[('m',0)], + # self.model.mesh.nElements_owned) + # log("Phase 0 mass before NCLS3P step = %12.5e" % (self.m_pre,),level=2) + # self.m_last = Norms.scalarSmoothedHeavisideDomainIntegral(self.epsFact, + # self.model.mesh.elementDiametersArray, + # self.model.q['dV'], + # self.model.timeIntegration.m_last[0], + # self.model.mesh.nElements_owned) + # log("Phase 0 mass before NCLS3P step (m_last) = %12.5e" % (self.m_last,),level=2) + # #cek todo why is this here + # if self.flowModelIndex >= 0 and self.flowModel.ebq.has_key(('v',1)): + # self.model.u[0].getValuesTrace(self.flowModel.ebq[('v',1)],self.model.ebq[('u',0)]) + # self.model.u[0].getGradientValuesTrace(self.flowModel.ebq[('grad(v)',1)],self.model.ebq[('grad(u)',0)]) + copyInstructions = {} + return copyInstructions + + def postStep(self, t, firstStep=False): + self.model.q['dV_last'][:] = self.model.q['dV'] + # if self.checkMass: + # self.m_post = Norms.scalarSmoothedHeavisideDomainIntegral(self.epsFact, + # self.model.mesh.elementDiametersArray, + # self.model.q['dV'], + # self.model.q[('u',0)], + # self.model.mesh.nElements_owned) + # log("Phase 0 mass after NCLS3P step = %12.5e" % (self.m_post,),level=2) + # #need a flux here not a velocity + # self.fluxIntegral = Norms.fluxDomainBoundaryIntegralFromVector(self.flowModel.ebqe['dS'], + # self.flowModel.ebqe[('velocity',0)], + # self.flowModel.ebqe['n'], + # self.model.mesh) + # log("Flux integral = %12.5e" % (self.fluxIntegral,),level=2) + # log("Phase 0 mass conservation after NCLS3P step = %12.5e" % (self.m_post - self.m_last + self.model.timeIntegration.dt*self.fluxIntegral,),level=2) + # self.lsGlobalMass = self.m_post + # self.fluxGlobal = self.fluxIntegral*self.model.timeIntegration.dt + # self.totalFluxGlobal += self.fluxGlobal + # self.lsGlobalMassArray.append(self.lsGlobalMass) + # self.lsGlobalMassErrorArray.append(self.lsGlobalMass - self.lsGlobalMassArray[0] + self.totalFluxGlobal) + # self.fluxArray.append(self.fluxIntegral) + # self.timeArray.append(self.model.timeIntegration.t) + # if self.flowModelIndex >= 0 and self.flowModel.ebq.has_key(('v',1)): + # self.model.u[0].getValuesTrace(self.flowModel.ebq[('v',1)],self.model.ebq[('u',0)]) + # self.model.u[0].getGradientValuesTrace(self.flowModel.ebq[('grad(v)',1)],self.model.ebq[('grad(u)',0)]) + copyInstructions = {} + return copyInstructions + + def updateToMovingDomain(self, t, c): + # in a moving domain simulation the velocity coming in is already for + # the moving domain + pass + + def evaluate(self, t, c): + v = None + if c[('dH', 0, 0)].shape == self.q_v.shape: + v = self.q_v + elif c[('dH', 0, 0)].shape == self.ebqe_v.shape: + v = self.ebqe_v + elif self.ebq_v is not None and c[('dH', 0, 0)].shape == self.ebq_v.shape: + v = self.ebq_v + else: + raise RuntimeError("don't have v for NC Level set of shape = " + \ + repr(c[('dH', 0, 0)].shape)) + if v is not None: + self.ncLevelSetCoefficientsEvaluate(v, + c[('u', 0)], + c[('grad(u)', 0)], + c[('m', 0)], + c[('dm', 0, 0)], + c[('H', 0)], + c[('dH', 0, 0)]) + + +class LevelModel(OneLevelTransport): + nCalls = 0 + + def __init__(self, + uDict, + phiDict, + testSpaceDict, + matType, + dofBoundaryConditionsDict, + dofBoundaryConditionsSetterDict, + coefficients, + elementQuadrature, + elementBoundaryQuadrature, + fluxBoundaryConditionsDict=None, + advectiveFluxBoundaryConditionsSetterDict=None, + diffusiveFluxBoundaryConditionsSetterDictDict=None, + stressTraceBoundaryConditionsSetterDict=None, + stabilization=None, + shockCapturing=None, + conservativeFluxDict=None, + numericalFluxType=None, + TimeIntegrationClass=None, + massLumping=False, + reactionLumping=False, + options=None, + name='defaultName', + reuse_trial_and_test_quadrature=True, + sd=True, + movingDomain=False, + bdyNullSpace=False): + self.bdyNullSpace = bdyNullSpace + # + # set the objects describing the method and boundary conditions + # + self.movingDomain = movingDomain + self.tLast_mesh = None + # + self.name = name + self.sd = sd + self.Hess = False + self.lowmem = True + self.timeTerm = True # allow turning off the time derivative + # self.lowmem=False + self.testIsTrial = True + self.phiTrialIsTrial = True + self.u = uDict + self.ua = {} # analytical solutions + self.phi = phiDict + self.dphi = {} + self.matType = matType + # mwf try to reuse test and trial information across components if + # spaces are the same + self.reuse_test_trial_quadrature = reuse_trial_and_test_quadrature # True#False + if self.reuse_test_trial_quadrature: + for ci in range(1, coefficients.nc): + assert self.u[ci].femSpace.__class__.__name__ == self.u[ + 0].femSpace.__class__.__name__, "to reuse_test_trial_quad all femSpaces must be the same!" + self.u_dof_old = None + + # Simplicial Mesh + # assume the same mesh for all components for now + self.mesh = self.u[0].femSpace.mesh + self.testSpace = testSpaceDict + self.dirichletConditions = dofBoundaryConditionsDict + # explicit Dirichlet conditions for now, no Dirichlet BC constraints + self.dirichletNodeSetList = None + self.coefficients = coefficients + self.coefficients.initializeMesh(self.mesh) + self.nc = self.coefficients.nc + self.stabilization = stabilization + self.shockCapturing = shockCapturing + # no velocity post-processing for now + self.conservativeFlux = conservativeFluxDict + self.fluxBoundaryConditions = fluxBoundaryConditionsDict + self.advectiveFluxBoundaryConditionsSetterDict = advectiveFluxBoundaryConditionsSetterDict + self.diffusiveFluxBoundaryConditionsSetterDictDict = diffusiveFluxBoundaryConditionsSetterDictDict + # determine whether the stabilization term is nonlinear + self.stabilizationIsNonlinear = False + # cek come back + if self.stabilization is not None: + for ci in range(self.nc): + if ci in coefficients.mass: + for flag in list(coefficients.mass[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.advection: + for flag in list(coefficients.advection[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.diffusion: + for diffusionDict in list(coefficients.diffusion[ci].values()): + for flag in list(diffusionDict.values()): + if flag != 'constant': + self.stabilizationIsNonlinear = True + if ci in coefficients.potential: + for flag in list(coefficients.potential[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.reaction: + for flag in list(coefficients.reaction[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.hamiltonian: + for flag in list(coefficients.hamiltonian[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + # determine if we need element boundary storage + self.elementBoundaryIntegrals = {} + for ci in range(self.nc): + self.elementBoundaryIntegrals[ci] = ( + (self.conservativeFlux is not None) or ( + numericalFluxType is not None) or ( + self.fluxBoundaryConditions[ci] == 'outFlow') or ( + self.fluxBoundaryConditions[ci] == 'mixedFlow') or ( + self.fluxBoundaryConditions[ci] == 'setFlow')) + # + # calculate some dimensions + # + # assume same space dim for all variables + self.nSpace_global = self.u[0].femSpace.nSpace_global + self.nDOF_trial_element = [ + u_j.femSpace.max_nDOF_element for u_j in list(self.u.values())] + self.nDOF_phi_trial_element = [ + phi_k.femSpace.max_nDOF_element for phi_k in list(self.phi.values())] + self.n_phi_ip_element = [ + phi_k.femSpace.referenceFiniteElement.interpolationConditions.nQuadraturePoints for phi_k in list(self.phi.values())] + self.nDOF_test_element = [ + femSpace.max_nDOF_element for femSpace in list(self.testSpace.values())] + self.nFreeDOF_global = [ + dc.nFreeDOF_global for dc in list(self.dirichletConditions.values())] + self.nVDOF_element = sum(self.nDOF_trial_element) + self.nFreeVDOF_global = sum(self.nFreeDOF_global) + # + NonlinearEquation.__init__(self, self.nFreeVDOF_global) + # + # build the quadrature point dictionaries from the input (this + # is just for convenience so that the input doesn't have to be + # complete) + # + elementQuadratureDict = {} + elemQuadIsDict = isinstance(elementQuadrature, dict) + if elemQuadIsDict: # set terms manually + for I in self.coefficients.elementIntegralKeys: + if I in elementQuadrature: + elementQuadratureDict[I] = elementQuadrature[I] + else: + elementQuadratureDict[I] = elementQuadrature['default'] + else: + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[I] = elementQuadrature + if self.stabilization is not None: + for I in self.coefficients.elementIntegralKeys: + if elemQuadIsDict: + if I in elementQuadrature: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature[I] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature['default'] + else: + elementQuadratureDict[ + ('stab',) + I[1:]] = elementQuadrature + if self.shockCapturing is not None: + for ci in self.shockCapturing.components: + if elemQuadIsDict: + if ('numDiff', ci, ci) in elementQuadrature: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + ('numDiff', ci, ci)] + else: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[ + 'default'] + else: + elementQuadratureDict[ + ('numDiff', ci, ci)] = elementQuadrature + if massLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('m', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + if reactionLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('r', ci)] = Quadrature.SimplexLobattoQuadrature( + self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[ + ('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + elementBoundaryQuadratureDict = {} + if isinstance(elementBoundaryQuadrature, dict): # set terms manually + for I in self.coefficients.elementBoundaryIntegralKeys: + if I in elementBoundaryQuadrature: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature[I] + else: + elementBoundaryQuadratureDict[ + I] = elementBoundaryQuadrature['default'] + else: + for I in self.coefficients.elementBoundaryIntegralKeys: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature + # + # find the union of all element quadrature points and + # build a quadrature rule for each integral that has a + # weight at each point in the union + # mwf include tag telling me which indices are which quadrature rule? + (self.elementQuadraturePoints, self.elementQuadratureWeights, + self.elementQuadratureRuleIndeces) = Quadrature.buildUnion(elementQuadratureDict) + self.nQuadraturePoints_element = self.elementQuadraturePoints.shape[0] + self.nQuadraturePoints_global = self.nQuadraturePoints_element * \ + self.mesh.nElements_global + # + # Repeat the same thing for the element boundary quadrature + # + (self.elementBoundaryQuadraturePoints, self.elementBoundaryQuadratureWeights, + self.elementBoundaryQuadratureRuleIndeces) = Quadrature.buildUnion(elementBoundaryQuadratureDict) + self.nElementBoundaryQuadraturePoints_elementBoundary = self.elementBoundaryQuadraturePoints.shape[ + 0] + self.nElementBoundaryQuadraturePoints_global = ( + self.mesh.nElements_global * + self.mesh.nElementBoundaries_element * + self.nElementBoundaryQuadraturePoints_elementBoundary) +# if isinstance(self.u[0].femSpace,C0_AffineLinearOnSimplexWithNodalBasis): +# print self.nQuadraturePoints_element +# if self.nSpace_global == 3: +# assert(self.nQuadraturePoints_element == 5) +# elif self.nSpace_global == 2: +# assert(self.nQuadraturePoints_element == 6) +# elif self.nSpace_global == 1: +# assert(self.nQuadraturePoints_element == 3) +# +# print self.nElementBoundaryQuadraturePoints_elementBoundary +# if self.nSpace_global == 3: +# assert(self.nElementBoundaryQuadraturePoints_elementBoundary == 4) +# elif self.nSpace_global == 2: +# assert(self.nElementBoundaryQuadraturePoints_elementBoundary == 4) +# elif self.nSpace_global == 1: +# assert(self.nElementBoundaryQuadraturePoints_elementBoundary == 1) + # + # simplified allocations for test==trial and also check if space is mixed or not + # + self.q = {} + self.ebq = {} + self.ebq_global = {} + self.ebqe = {} + self.phi_ip = {} + # mesh + self.q['x'] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element, 3), 'd') + self.ebqe['x'] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + 3), + 'd') + self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * \ + numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('u', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global), + 'd') + self.q[('m_last', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('mt', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q['dV'] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q['dV_last'] = -1000 * \ + numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + # numpy.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') + self.q[('m_tmp', 0)] = self.q[('u', 0)] + # numpy.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') + self.q[('m', 0)] = self.q[('u', 0)] + # cek todo for NCLS3P we really don't need dH because it's just q_v + # from the flow model + self.q[('dH', 0, 0)] = numpy.zeros((self.mesh.nElements_global, + self.nQuadraturePoints_element, self.nSpace_global), 'd') + self.q[ + ('dH_sge', + 0, + 0)] = numpy.zeros( + (self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global), + 'd') + self.q[('cfl', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('numDiff', 0, 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.ebqe[ + ('u', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.ebqe[ + ('grad(u)', + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + # mwf for running as standalone + self.ebqe[ + ('dH', + 0, + 0)] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.nSpace_global), + 'd') + self.q[('dm', 0, 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('H', 0)] = numpy.zeros( + (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.points_elementBoundaryQuadrature = set() + self.scalars_elementBoundaryQuadrature = set( + [('u', ci) for ci in range(self.nc)]) + self.vectors_elementBoundaryQuadrature = set() + self.tensors_elementBoundaryQuadrature = set() + # + # allocate residual and Jacobian storage + # + self.inflowBoundaryBC = {} + self.inflowBoundaryBC_values = {} + self.inflowFlux = {} + for cj in range(self.nc): + self.inflowBoundaryBC[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global,), 'i') + self.inflowBoundaryBC_values[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nDOF_trial_element[cj]), 'd') + self.inflowFlux[cj] = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary), + 'd') + self.internalNodes = set(range(self.mesh.nNodes_global)) + # identify the internal nodes this is ought to be in mesh + # \todo move this to mesh + for ebNE in range(self.mesh.nExteriorElementBoundaries_global): + ebN = self.mesh.exteriorElementBoundariesArray[ebNE] + eN_global = self.mesh.elementBoundaryElementsArray[ebN, 0] + ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[ + ebN, 0] + for i in range(self.mesh.nNodes_element): + if i != ebN_element: + I = self.mesh.elementNodesArray[eN_global, i] + self.internalNodes -= set([I]) + self.nNodes_internal = len(self.internalNodes) + self.internalNodesArray = numpy.zeros((self.nNodes_internal,), 'i') + for nI, n in enumerate(self.internalNodes): + self.internalNodesArray[nI] = n + # + del self.internalNodes + self.internalNodes = None + log("Updating local to global mappings", 2) + self.updateLocal2Global() + log("Building time integration object", 2) + log(memory("inflowBC, internalNodes,updateLocal2Global", + "OneLevelTransport"), level=4) + # mwf for interpolating subgrid error for gradients etc + if self.stabilization and self.stabilization.usesGradientStabilization: + self.timeIntegration = TimeIntegrationClass( + self, integrateInterpolationPoints=True) + else: + self.timeIntegration = TimeIntegrationClass(self) + + if options is not None: + self.timeIntegration.setFromOptions(options) + log(memory("TimeIntegration", "OneLevelTransport"), level=4) + log("Calculating numerical quadrature formulas", 2) + self.calculateQuadrature() + + self.setupFieldStrides() + + comm = Comm.get() + self.comm = comm + if comm.size() > 1: + assert numericalFluxType is not None and numericalFluxType.useWeakDirichletConditions, "You must use a numerical flux to apply weak boundary conditions for parallel runs" + + log(memory("stride+offset", "OneLevelTransport"), level=4) + if numericalFluxType is not None: + if options is None or options.periodicDirichletConditions is None: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict) + else: + self.numericalFlux = numericalFluxType( + self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict, + options.periodicDirichletConditions) + else: + self.numericalFlux = None + # set penalty terms + # cek todo move into numerical flux initialization + 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)) + # 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) + log(memory("numericalFlux", "OneLevelTransport"), level=4) + self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray + # use post processing tools to get conservative fluxes, None by default + from proteus import PostProcessingTools + self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser( + self) + log(memory("velocity postprocessor", "OneLevelTransport"), level=4) + # helper for writing out data storage + from proteus import Archiver + self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + # TODO get rid of this +# for ci,fbcObject in self.fluxBoundaryConditionsObjectsDict.iteritems(): +# self.ebqe[('advectiveFlux_bc_flag',ci)] = numpy.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i') +# for t,g in fbcObject.advectiveFluxBoundaryConditionsDict.iteritems(): +# if self.coefficients.advection.has_key(ci): +# self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t) +# self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1 + + if hasattr(self.numericalFlux, 'setDirichletValues'): + self.numericalFlux.setDirichletValues(self.ebqe) + if not hasattr(self.numericalFlux, 'isDOFBoundary'): + self.numericalFlux.isDOFBoundary = { + 0: numpy.zeros(self.ebqe[('u', 0)].shape, 'i')} + if not hasattr(self.numericalFlux, 'ebqe'): + self.numericalFlux.ebqe = { + ('u', 0): numpy.zeros(self.ebqe[('u', 0)].shape, 'd')} + # TODO how to handle redistancing calls for + # calculateCoefficients,calculateElementResidual etc + self.globalResidualDummy = None + compKernelFlag = 0 + self.ncls3p = cNCLS3P.newNCLS3P( + self.nSpace_global, + self.nQuadraturePoints_element, + self.u[0].femSpace.elementMaps.localFunctionSpace.dim, + self.u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim, + self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim, + self.nElementBoundaryQuadraturePoints_elementBoundary, + compKernelFlag) + + self.forceStrongConditions = False + if self.forceStrongConditions: + self.dirichletConditionsForceDOF = DOFBoundaryConditions( + self.u[0].femSpace, + dofBoundaryConditionsSetterDict[0], + weakDirichletConditions=False) + + if self.movingDomain: + self.MOVING_DOMAIN = 1.0 + else: + self.MOVING_DOMAIN = 0.0 + if self.mesh.nodeVelocityArray is None: + self.mesh.nodeVelocityArray = numpy.zeros( + self.mesh.nodeArray.shape, 'd') + + self.waterline_calls = 0 + self.waterline_prints = 0 + + # mql. Allow the user to provide functions to define the velocity field + self.hasVelocityFieldAsFunction = False + if ('velocityField') in dir(options): + self.velocityField = options.velocityField + self.hasVelocityFieldAsFunction = True + + # interface locator + self.cell_interface_locator = numpy.zeros(self.mesh.nElements_global,'d') + self.interface_locator = numpy.zeros(self.u[0].dof.shape,'d') + self.quantDOFs = numpy.zeros(self.u[0].dof.shape,'d') + + # For Taylor Galerkin methods + self.stage = 1 + self.auxTaylorGalerkinFlag = 1 + self.uTilde_dof = numpy.zeros(self.u[0].dof.shape,'d') + if self.coefficients.EXPLICIT_METHOD==True: + self.useTwoStageNewton = True + + # Some asserts for NCLS with Taylor Galerkin + if self.coefficients.EXPLICIT_METHOD==True: + assert isinstance(self.timeIntegration,proteus.TimeIntegration.BackwardEuler_cfl), "If EXPLICIT_METHOD=True, use BackwardEuler_cfl" + assert options.levelNonlinearSolver == proteus.NonlinearSolvers.TwoStageNewton, "If EXPLICIT_METHOD=True, use levelNonlinearSolver=TwoStageNewton" + + # mwf these are getting called by redistancing classes, + def calculateCoefficients(self): + pass + + def updateVelocityFieldAsFunction(self): + X = {0: self.q[('x')][:, :, 0], + 1: self.q[('x')][:, :, 1], + 2: self.q[('x')][:, :, 2]} + t = self.timeIntegration.t + self.coefficients.q_v[..., 0] = self.velocityField[0](X, t) + self.coefficients.q_v[..., 1] = self.velocityField[1](X, t) + if (self.nSpace_global == 3): + self.coefficients.q_v[..., 2] = self.velocityField[2](X, t) + + # BOUNDARY + ebqe_X = {0: self.ebqe['x'][:, :, 0], + 1: self.ebqe['x'][:, :, 1], + 2: self.ebqe['x'][:, :, 2]} + self.coefficients.ebqe_v[..., 0] = self.velocityField[0](ebqe_X, t) + self.coefficients.ebqe_v[..., 1] = self.velocityField[1](ebqe_X, t) + if (self.nSpace_global == 3): + self.coefficients.ebqe_v[..., 2] = self.velocityField[2](ebqe_X, t) + + def calculateElementResidual(self): + if self.globalResidualDummy is not None: + self.getResidual(self.u[0].dof, self.globalResidualDummy) + + def getResidual(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + # mwf debug + # pdb.set_trace() + + if self.u_dof_old is None: + # Pass initial condition to u_dof_old + self.u_dof_old = numpy.copy(self.u[0].dof) + + r.fill(0.0) + self.cell_interface_locator.fill(0.0) + self.interface_locator.fill(0.0) + # Load the unknowns into the finite element dof + self.timeIntegration.calculateCoefs() + self.timeIntegration.calculateU(u) + self.setUnknowns(self.timeIntegration.u) + # cek can put in logic to skip of BC's don't depend on t or u + # Dirichlet boundary conditions + # if hasattr(self.numericalFlux,'setDirichletValues'): + if (self.stage!=2): + self.numericalFlux.setDirichletValues(self.ebqe) + # flux boundary conditions, SHOULDN'T HAVE + # cNCLS3P.calculateResidual(self.mesh.nElements_global, + # try to use 1d,2d,3d specific modules + + if self.forceStrongConditions: + for dofN, g in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.items()): + self.u[0].dof[dofN] = g( + self.dirichletConditionsForceDOF.DOFBoundaryPointDict[dofN], + self.timeIntegration.t) + + if (self.stage==2 and self.auxTaylorGalerkinFlag==1): + self.uTilde_dof[:] = self.u[0].dof + self.auxTaylorGalerkinFlag=0 + + self.ncls3p.calculateResidual( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.nodeVelocityArray, + self.MOVING_DOMAIN, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.timeIntegration.alpha_bdf, # mwf was self.timeIntegration.dt, + self.shockCapturing.lag, + self.shockCapturing.shockCapturingFactor, + self.coefficients.sc_uref, + self.coefficients.sc_beta, + self.u[0].femSpace.dofMap.l2g, + self.mesh.elementDiametersArray, + self.u[0].dof, + self.u_dof_old, + self.coefficients.q_v, + self.timeIntegration.m_tmp[0], + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.q[('dH_sge', 0, 0)], + # mwf was self.timeIntegration.m_last[0], + self.timeIntegration.beta_bdf[0], + self.q['dV'], + self.q['dV_last'], + self.q[('cfl', 0)], + self.shockCapturing.numDiff[0], + self.shockCapturing.numDiff_last[0], + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.coefficients.ebqe_v, + self.numericalFlux.isDOFBoundary[0], + #self.coefficients.rdModel.ebqe[('u', 0)], + self.coefficients.rdModel_ebqe, + self.numericalFlux.ebqe[('u', 0)], + self.ebqe[('u', 0)], + self.cell_interface_locator, + self.interface_locator, + self.coefficients.EXPLICIT_METHOD, + self.u[0].femSpace.order, + self.stage, + self.uTilde_dof, + self.timeIntegration.dt, + self.coefficients.PURE_BDF) + + #if self.coefficients.EXPLICIT_METHOD: + # self.taylorGalerkinStage = 2 + + self.quantDOFs[:] = self.interface_locator + + if self.forceStrongConditions: + for dofN, g in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.items()): + r[dofN] = 0 + + # print "velocity in ncls",self.coefficients.q_v, + # print "cfl",self.q[('cfl',0)] + if self.stabilization: + self.stabilization.accumulateSubgridMassHistory(self.q) + log("Global residual", level=9, data=r) + # mwf debug + # pdb.set_trace() + # mwf decide if this is reasonable for keeping solver statistics + self.nonlinear_function_evaluations += 1 + if self.globalResidualDummy is None: + self.globalResidualDummy = numpy.zeros(r.shape, 'd') + + def getJacobian(self, jacobian): + #import superluWrappers + #import numpy + import pdb + cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, + jacobian) + # mwf debug + # pdb.set_trace() + # cNCLS3P.calculateJacobian(self.mesh.nElements_global, + + (rowptr, colind, globalJacobian) = jacobian.getCSRrepresentation() + self.ncls3p.calculateJacobian( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.nodeVelocityArray, + self.MOVING_DOMAIN, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.timeIntegration.alpha_bdf, # mwf was dt + self.shockCapturing.lag, + self.shockCapturing.shockCapturingFactor, + self.u[0].femSpace.dofMap.l2g, + self.mesh.elementDiametersArray, + self.u[0].dof, + self.coefficients.q_v, + # mwf was self.timeIntegration.m_last[0], + self.timeIntegration.beta_bdf[0], + self.q[('cfl', 0)], + self.shockCapturing.numDiff_last[0], + self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], + globalJacobian, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.coefficients.ebqe_v, + self.numericalFlux.isDOFBoundary[0], + #self.coefficients.rdModel.ebqe[('u', 0)], + self.coefficients.rdModel_ebqe, + self.numericalFlux.ebqe[('u', 0)], + self.csrColumnOffsets_eb[(0, 0)], + self.coefficients.EXPLICIT_METHOD, + self.coefficients.PURE_BDF) + + # Load the Dirichlet conditions directly into residual + if self.forceStrongConditions: + scaling = 1.0 # probably want to add some scaling to match non-dirichlet diagonals in linear system + for dofN in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.keys()): + global_dofN = dofN + for i in range( + self.rowptr[global_dofN], + self.rowptr[ + global_dofN + 1]): + if (self.colind[i] == global_dofN): + # print "RBLES forcing residual cj = %s dofN= %s + # global_dofN= %s was self.nzval[i]= %s now =%s " % + # (cj,dofN,global_dofN,self.nzval[i],scaling) + self.nzval[i] = scaling + else: + self.nzval[i] = 0.0 + # print "RBLES zeroing residual cj = %s dofN= %s + # global_dofN= %s " % (cj,dofN,global_dofN) + + log("Jacobian ", level=10, data=jacobian) + # mwf decide if this is reasonable for solver statistics + self.nonlinear_function_jacobian_evaluations += 1 + return jacobian + + def calculateElementQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points. + + This function should be called only when the mesh changes. + """ + self.u[0].femSpace.elementMaps.getValues(self.elementQuadraturePoints, + self.q['x']) + self.u[0].femSpace.elementMaps.getBasisValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.getBasisValuesRef(self.elementQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.coefficients.initializeElementQuadrature( + self.timeIntegration.t, self.q) + if self.stabilization is not None: + self.stabilization.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + self.stabilization.initializeTimeIntegration(self.timeIntegration) + if self.shockCapturing is not None: + self.shockCapturing.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + + def calculateElementBoundaryQuadrature(self): + pass + + def calculateExteriorElementBoundaryQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points on global element boundaries. + + This function should be called only when the mesh changes. + """ + # + # get physical locations of element boundary quadrature points + # + # assume all components live on the same mesh + self.u[0].femSpace.elementMaps.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getValuesGlobalExteriorTrace( + self.elementBoundaryQuadraturePoints, self.ebqe['x']) + self.fluxBoundaryConditionsObjectsDict = dict([(cj, FluxBoundaryConditions(self.mesh, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.ebqe[('x')], + self.advectiveFluxBoundaryConditionsSetterDict[cj], + self.diffusiveFluxBoundaryConditionsSetterDictDict[cj])) + for cj in list(self.advectiveFluxBoundaryConditionsSetterDict.keys())]) + self.coefficients.initializeGlobalExteriorElementBoundaryQuadrature( + self.timeIntegration.t, self.ebqe) + + def estimate_mt(self): + pass + + def calculateSolutionAtQuadrature(self): + pass + + def calculateAuxiliaryQuantitiesAfterStep(self): + pass + + def computeWaterline(self, t): + self.waterline_calls += 1 + if self.coefficients.waterline_interval > 0 and self.waterline_calls % self.coefficients.waterline_interval == 0: + self.waterline_npoints = numpy.zeros((1,), 'i') + self.waterline_data = numpy.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nSpace_global), 'd') + self.ncls3p.calculateWaterline( # element + self.waterline_npoints, + self.waterline_data, + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.nodeVelocityArray, + self.MOVING_DOMAIN, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.timeIntegration.alpha_bdf, # mwf was self.timeIntegration.dt, + self.shockCapturing.lag, + self.shockCapturing.shockCapturingFactor, + self.coefficients.sc_uref, + self.coefficients.sc_beta, + self.u[0].femSpace.dofMap.l2g, + self.mesh.elementDiametersArray, + self.u[0].dof, + self.u_dof_old, + self.coefficients.q_v, + self.timeIntegration.m_tmp[0], + self.q[('u', 0)], + self.q[('grad(u)', 0)], + self.q[('dH_sge', 0, 0)], + # mwf was self.timeIntegration.m_last[0], + self.timeIntegration.beta_bdf[0], + self.q[('cfl', 0)], + self.shockCapturing.numDiff[0], + self.shockCapturing.numDiff_last[0], + self.offset[0], self.stride[0], + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.mesh.elementBoundaryMaterialTypes, + self.coefficients.ebqe_v, + self.numericalFlux.isDOFBoundary[0], + self.numericalFlux.ebqe[('u', 0)], + self.ebqe[('u', 0)]) + from proteus import Comm + comm = Comm.get() + filename = os.path.join(self.coefficients.opts.dataDir, + "waterline." + str(comm.rank()) + "." + str(self.waterline_prints)) + numpy.save( + filename, self.waterline_data[ + 0:self.waterline_npoints[0]]) + self.waterline_prints += 1 + + def updateAfterMeshMotion(self): + pass diff --git a/proteus/mprans2/SedClosure.cpp b/proteus/mprans2/SedClosure.cpp new file mode 100644 index 0000000000..ac9f33087a --- /dev/null +++ b/proteus/mprans2/SedClosure.cpp @@ -0,0 +1,59 @@ +#define FORCE_IMPORT_ARRAY +#include "SedClosure.hpp" + +namespace py = pybind11; + +PYBIND11_MODULE(SedClosure, m) +{ + using proteus::cppHsuSedStress2D; + + xt::import_numpy(); + + py::class_(m, "HsuSedStress2D") + .def(py::init()) + .def_readonly("aDarcy", &cppHsuSedStress2D::aDarcy_) + .def_readonly("betaForch", &cppHsuSedStress2D::betaForch_) + .def_readonly("grain", &cppHsuSedStress2D::grain_) + .def_readonly("packFraction", &cppHsuSedStress2D::packFraction_) + .def_readonly("packMargin", &cppHsuSedStress2D::packMargin_) + .def_readonly("maxFraction", &cppHsuSedStress2D::maxFraction_) + .def_readonly("frFraction", &cppHsuSedStress2D::frFraction_) + .def_readonly("sigmaC", &cppHsuSedStress2D::sigmaC_) + .def_readonly("C3e", &cppHsuSedStress2D::C3e_) + .def_readonly("C4e", &cppHsuSedStress2D::C4e_) + .def_readonly("eR", &cppHsuSedStress2D::eR_) + .def_readonly("fContact", &cppHsuSedStress2D::fContact_) + .def_readonly("mContact", &cppHsuSedStress2D::mContact_) + .def_readonly("nContact", &cppHsuSedStress2D::nContact_) + .def_readonly("angFriction", &cppHsuSedStress2D::angFriction_) + .def_readonly("vos_limiter", &cppHsuSedStress2D::vos_limiter_) + .def_readonly("mu_fr_limiter", &cppHsuSedStress2D::mu_fr_limiter_) + .def("betaCoeff", &cppHsuSedStress2D::betaCoeff) + .def("gs0", &cppHsuSedStress2D::gs0) + .def("kappa_sed1", &cppHsuSedStress2D::kappa_sed1) + .def("dkappa_sed1_dk", &cppHsuSedStress2D::dkappa_sed1_dk) + .def("deps_sed_deps", &cppHsuSedStress2D::deps_sed_deps) + .def("psc", &cppHsuSedStress2D::psc) + .def("psc_term", &cppHsuSedStress2D::psc_term) + .def("dpsc_term_dtheta", &cppHsuSedStress2D::dpsc_term_dtheta) + .def("mu_sc", &cppHsuSedStress2D::mu_sc) + .def("mu_fr", &cppHsuSedStress2D::mu_fr) + .def("l_sc", &cppHsuSedStress2D::l_sc) + .def("tausc_term_theta", &cppHsuSedStress2D::tausc_term_theta) + .def("gamma_s", &cppHsuSedStress2D::gamma_s) + .def("dgamma_s_dtheta", &cppHsuSedStress2D::dgamma_s_dtheta) + .def("jint1", &cppHsuSedStress2D::jint1) + .def("jint2", &cppHsuSedStress2D::jint2) + .def("djint2_dtheta", &cppHsuSedStress2D::djint2_dtheta) + .def("k_diff", &cppHsuSedStress2D::k_diff) + .def("p_friction", &cppHsuSedStress2D::p_friction) + .def("gradp_friction", &cppHsuSedStress2D::gradp_friction) + .def("mIntFluid", &cppHsuSedStress2D::mIntFluid) + .def("mIntSolid", &cppHsuSedStress2D::mIntSolid) + .def("mIntgradC", &cppHsuSedStress2D::mIntgradC) + .def("dmInt_duFluid", &cppHsuSedStress2D::dmInt_duFluid) + .def("dmInt_duSolid", &cppHsuSedStress2D::dmInt_duSolid) + .def("p_s", &cppHsuSedStress2D::p_s); +} diff --git a/proteus/mprans2/SedClosure.h b/proteus/mprans2/SedClosure.h new file mode 100644 index 0000000000..c06e918d96 --- /dev/null +++ b/proteus/mprans2/SedClosure.h @@ -0,0 +1,706 @@ +#ifndef SEDCLOSURE_H +#define SEDCLOSURE_H + +#include +#include +namespace proteus +{ + template + class cppHsuSedStress +{ +public: + cppHsuSedStress( + double aDarcy, // darcy parameter for drag term. Default value from Ergun (1952) is 150 + double betaForch, // forchheimer parameter for drag term. Default value from Ergun (1952) is 1.75 + double grain, // Grain size, default assumed as d50 + double packFraction, //Critical volume fraction for switching the drag relation 0.2 by default, see Chen and Hsu 2014 + double packMargin, // For packFraction +- packmargin, the drag coefficient is calculated by taking a weighted combination of the two relation (for packed and non-packed sediment + double maxFraction, + double frFraction, + double sigmaC, + double C3e, + double C4e, + double eR, + double fContact, + double mContact, + double nContact, + double angFriction, + double vos_limiter, + double mu_fr_limiter +): + + aDarcy_(aDarcy), + betaForch_(betaForch), + grain_(grain), + packFraction_(packFraction), + packMargin_(packMargin), + frFraction_(frFraction), + maxFraction_(maxFraction), + sigmaC_(sigmaC), + C3e_(C3e), + C4e_(C4e), + eR_(eR), + fContact_(fContact), + mContact_(mContact), + nContact_(nContact), + angFriction_(angFriction), + small_(1e-100), + notSoLarge_(1e+6), + large_(1e+100), + vos_limiter_(vos_limiter), + mu_fr_limiter_(mu_fr_limiter) + + + + {} + + inline double betaCoeff( + double sedF, // Sediment fraction + double rhoFluid, + double uFluid[nSpace], //Fluid velocity + double uSolid[nSpace], //Sediment velocity + double nu //Kinematic viscosity + ) + { + double du2 = 0.; + for (int ii=0; ii packFraction_ - packMargin_) + { + weight = 0.5 + 0.5* (sedF - packFraction_) /packMargin_; + } + else + { + weight = 0.; + } + } + + return (weight*gDrag1 + (1.-weight)*gDrag2)*rhoFluid; + } + + inline double gs0(double sedF) + { + double g0(0.); + if(sedF< 0.635) + { + if(sedF< 0.49) + { + g0 = 0.5*(2.-sedF)/((1-sedF)*(1-sedF)*(1-sedF)); + } + else + { + g0= 0.853744035/(0.64-sedF); + } + } + else g0 = 170.74880702; + return g0; + } + + inline double deps_sed_deps( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + double uFluid[nSpace], + double uSolid[nSpace], + double gradC[nSpace], //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + double g[nSpace]) + + { + + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + double gs = gs0(sedF)+small_; + double l_c = sqrt(M_PI)*grain_/(24.*(sedF+small_)*gs); + double t_p = rhoSolid/beta; + double t_c = l_c/(sqrt(theta_n) + small_); + double t_l = 0.165*kappa_n/(epsilon_n + small_); + double t_cl = std::min(t_c,t_l); + double alpha= t_cl/(t_cl + t_p); + double term = beta/(rhoFluid*(1.-sedF)); + double es_1 = 2.*term*(1-alpha)*sedF*kappa_n; + double g_gradC = 0.; + for (int ii=0; ii frFraction_) + { + double sedLim =std::min(sedF,vos_limiter_); + pf =fContact_*pow(sedLim-frFraction_,mContact_) / ( pow(maxFraction_ - sedLim,nContact_) + small_); + } + + return pf; + + } + + + inline double gradp_friction(double sedF) + + { + double coeff = 0; + double pf = p_friction(sedF); + if (sedF > frFraction_ ) + { + double sedLim =std::min(sedF,vos_limiter_); + + double den1 = (sedLim - frFraction_); + double den2 = (maxFraction_ - sedLim); + + coeff = pf *( (mContact_/den1) + (nContact_/den2) ); + } + + return coeff; + } + inline double mu_fr(double sedF, + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz) + { + double divU = du_dx + dv_dy + dw_dz; + double pf = p_friction(sedF); + double s11 = du_dx - (1./nSpace)*divU; + double s22 = dv_dy - (1./nSpace)*divU; + double s33 = dw_dz - (1./nSpace)*divU; + double s12 = 0.5*(du_dy + dv_dx); + double s13 = 0.5*(du_dz + dw_dx); + double s23 = 0.5*(dv_dz + dw_dy); + double sumS = s11*s11 + s22*s22 + s33*s33 + 2.*s12*s12 + 2.*s13*s13 + 2.*s23*s23; + double mu_sf = 0.0; + double mu_fr = 0.0; + if (sedF > frFraction_) + { + mu_sf = pf * sqrt(2.) * sin(angFriction_) / (2 * sqrt(sumS) + small_); + mu_fr = std::min(mu_sf,mu_fr_limiter_); + } +// if (sedF > 0.0 ) +// { +// printf("sedF --> %2.20f", sedF); +// } +// if (mu_sf > 0.0 ) +// { +// printf("mu_sf --> %2.20f", mu_sf); +// } +// if (mu_fr > 0.0 ) +// { +// printf("mu_fr --> %2.20f", mu_fr); +// } +// if (pf > 0.0 ) +// { +// printf("pf --> %2.20f", pf); +// } + + return mu_fr; + } + + + + + + + /* + inline double diffusion_theta_rhs( double sedF, + double rhoSolid, + double theta_n, + double dtheta_dx, + double dtheta_dy, + double dtheta_dz + ) + { + + double gs_0 = gs0(sedF); + double sq_pi = (sqrt(M_PI)); + double sedF2 = sedF * sedF; + double eRp1 = 1.+eR_; + double sq_theta = sqrt(theta_n); + + double divTheta = dtheta_dx + dtheta_dy + dtheta_dz; + + double k_diff = k_diff(rhoSolid); + + return kappa*divTheta; + + } + + + + + }*/ + + + + + + inline void mIntFluid( double * mint2, double sedF, + double rhoFluid, + double uFluid_n[nSpace], //Fluid velocity + double uSolid_n[nSpace], //Sediment velocity + double uFluid_np1[nSpace], //Fluid velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + double gradc[nSpace] + ) + { + + double beta = betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu); + for (int ii=0; ii cppHsuSedStress2D; +} + +#endif + diff --git a/proteus/mprans2/SedClosure.hpp b/proteus/mprans2/SedClosure.hpp new file mode 100644 index 0000000000..bb36442784 --- /dev/null +++ b/proteus/mprans2/SedClosure.hpp @@ -0,0 +1,915 @@ +#ifndef SEDCLOSURE_HPP +#define SEDCLOSURE_HPP + +#include +#include + +#include "xtensor-python/pyarray.hpp" + +namespace proteus +{ + template + class cppHsuSedStress + { + public: + + cppHsuSedStress( + double aDarcy, // darcy parameter for drag term. Default value from Ergun (1952) is 150 + double betaForch, // forchheimer parameter for drag term. Default value from Ergun (1952) is 1.75 + double grain, // Grain size, default assumed as d50 + double packFraction, //Critical volume fraction for switching the drag relation 0.2 by default, see Chen and Hsu 2014 + double packMargin, // For packFraction +- packmargin, the drag coefficient is calculated by taking a weighted combination of the two relation (for packed and non-packed sediment + double maxFraction, + double frFraction, + double sigmaC, + double C3e, + double C4e, + double eR, + double fContact, + double mContact, + double nContact, + double angFriction, + double vos_limiter, + double mu_fr_limiter + ); + + double betaCoeff( + double sedF, // Sediment fraction + double rhoFluid, + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + double nu //Kinematic viscosity + ); + + double gs0(double sedF); + + double deps_sed_deps( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const xt::pyarray& g + ); + + double kappa_sed1( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, + double nu, + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const xt::pyarray& g + ); + + double dkappa_sed1_dk( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + const xt::pyarray& gradC, //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n + ); + + double psc( + double sedF, + double rhoSolid, + double theta + ); + + double psc_term( + double sedF, + double rhoSolid, + double theta_np1, + double du_dx, + double dv_dy, + double dw_dz + ); + + double dpsc_term_dtheta( + double sedF, + double rhoSolid, + double du_dx, + double dv_dy, + double dw_dz + ); + + double mu_sc( + double sedF, + double rhoSolid, + double theta + ); + + double l_sc( + double sedF, + double rhoSolid, + double theta_n + ); + + double tausc_term_theta( + double sedF, // IN + double rhoSolid, //IN + double theta_n, //IN + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz + ); + + double gamma_s( + double sedF, + double rhoSolid, + double theta_n, + double theta_np1, + double du_dx, + double dv_dy, + double dw_dz + ); + + double dgamma_s_dtheta( + double sedF, + double rhoSolid, + double theta_n, + double du_dx, + double dv_dy, + double dw_dz + ); + + double jint1( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double kappa, + double epsilon, + double theta, + double nu + ); + + double jint2( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double theta, + double nu + ); + + double djint2_dtheta( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double nu + ); + + double k_diff( + double sedF, + double rhoSolid, + double theta + ); + + double p_friction(double sedF); + double gradp_friction(double sedF); + + double mu_fr( + double sedF, + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz + ); + + // TODO: check if this functio is called from C++ + // In that case, consider adding an overload taking mint2 by reference + void mIntFluid( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uFluid_np1, //Fluid velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ); + + // TODO: check if this functio is called from C++ + // In that case, consider adding an overload taking mint2 by reference + void mIntSolid( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uSolid_np1, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ); + + // TODO: check if this functio is called from C++ + // In that case, consider adding an overload taking mint2 by reference + void mIntgradC( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ); + + double dmInt_duFluid( + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + ); + + double dmInt_duSolid( + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + ); + + double p_s( + double sedF, + double rhoSolid, + double theta, + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz + ); + + double aDarcy_; + double betaForch_; + double grain_; + double packFraction_; + double packMargin_; + double frFraction_; + double maxFraction_; + double sigmaC_; + double C3e_; + double C4e_; + double eR_; + double fContact_; + double mContact_; + double nContact_; + double angFriction_; + double small_; + double notSoLarge_; + double large_; + double vos_limiter_; + double mu_fr_limiter_; + }; + + using cppHsuSedStress2D = cppHsuSedStress<2>; + + /********************************** + * cppHsuSedStress implementation * + **********************************/ + + template + inline cppHsuSedStress::cppHsuSedStress( + double aDarcy, // darcy parameter for drag term. Default value from Ergun (1952) is 150 + double betaForch, // forchheimer parameter for drag term. Default value from Ergun (1952) is 1.75 + double grain, // Grain size, default assumed as d50 + double packFraction, //Critical volume fraction for switching the drag relation 0.2 by default, see Chen and Hsu 2014 + double packMargin, // For packFraction +- packmargin, the drag coefficient is calculated by taking a weighted combination of the two relation (for packed and non-packed sediment + double maxFraction, + double frFraction, + double sigmaC, + double C3e, + double C4e, + double eR, + double fContact, + double mContact, + double nContact, + double angFriction, + double vos_limiter, + double mu_fr_limiter + ) + : aDarcy_(aDarcy) + , betaForch_(betaForch) + , grain_(grain) + , packFraction_(packFraction) + , packMargin_(packMargin) + , frFraction_(frFraction) + , maxFraction_(maxFraction) + , sigmaC_(sigmaC) + , C3e_(C3e) + , C4e_(C4e) + , eR_(eR) + , fContact_(fContact) + , mContact_(mContact) + , nContact_(nContact) + , angFriction_(angFriction) + , small_(1e-100) + , notSoLarge_(1e+6) + , large_(1e+100) + , vos_limiter_(vos_limiter) + , mu_fr_limiter_(mu_fr_limiter) + { + } + + template + inline double cppHsuSedStress::betaCoeff( + double sedF, // Sediment fraction + double rhoFluid, + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + double nu //Kinematic viscosity + ) + { + double du2 = 0.; + for (int ii=0; ii packFraction_ - packMargin_) + { + weight = 0.5 + 0.5* (sedF - packFraction_) /packMargin_; + } + else + { + weight = 0.; + } + } + return (weight*gDrag1 + (1.-weight)*gDrag2)*rhoFluid; + } + + template + inline double cppHsuSedStress::gs0(double sedF) + { + double g0(0.); + if(sedF< 0.635) + { + if(sedF< 0.49) + { + g0 = 0.5*(2.-sedF)/((1-sedF)*(1-sedF)*(1-sedF)); + } + else + { + g0= 0.853744035/(0.64-sedF); + } + } + else + { + g0 = 170.74880702; + } + return g0; + } + + template + inline double cppHsuSedStress::deps_sed_deps( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const xt::pyarray& g + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + double gs = gs0(sedF)+small_; + double l_c = sqrt(M_PI)*grain_/(24.*(sedF+small_)*gs); + double t_p = rhoSolid/beta; + double t_c = l_c/(sqrt(theta_n) + small_); + double t_l = 0.165*kappa_n/(epsilon_n + small_); + double t_cl = std::min(t_c,t_l); + double alpha= t_cl/(t_cl + t_p); + double term = beta/(rhoFluid*(1.-sedF)); + double es_1 = 2.*term*(1-alpha)*sedF*kappa_n; + double g_gradC = 0.; + for (int ii=0; ii + inline double cppHsuSedStress::kappa_sed1( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + const xt::pyarray& gradC, + double nu, + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n, + const xt::pyarray& g + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + double gs = gs0(sedF)+small_; + double l_c = sqrt(M_PI)*grain_/(24.*(sedF+small_)*gs); + double t_p = rhoSolid/beta; + double t_c = l_c/(sqrt(theta_n) + small_); + double t_l = 0.165*kappa_n/(epsilon_n + small_); + double t_cl = std::min(t_c,t_l); + double alpha= t_cl/(t_cl + t_p); + double term = beta/(rhoFluid*(1.-sedF)); + double es_1 = 2.*term*(1-alpha)*sedF*kappa_n; + double g_gradC = 0.; + for (int ii=0; ii + inline double cppHsuSedStress::dkappa_sed1_dk( + double sedF, // Sediment fraction + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, //Fluid velocity + const xt::pyarray& uSolid, //Sediment velocity + const xt::pyarray& gradC, //Sediment velocity + double nu, //Kinematic viscosity + double theta_n, + double kappa_n, + double epsilon_n, + double nuT_n + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + double gs = gs0(sedF)+small_; + double l_c = sqrt(M_PI)*grain_/(24.*(sedF+small_)*gs); + double t_p = rhoSolid/beta; + double t_c = l_c/(sqrt(theta_n) + small_); + double t_l = 0.165*kappa_n/(epsilon_n + small_); + double t_cl = std::min(t_c,t_l); + double alpha= t_cl/(t_cl + t_p); + double term = beta/(rhoFluid*(1.-sedF)); + double es_1 = 2.*term*rhoSolid*(1-alpha)*sedF; + return es_1; + } + + template + inline double cppHsuSedStress::psc( + double sedF, + double rhoSolid, + double theta + ) + { + double gs_0 = gs0(sedF); + double eRp1 = 1.+eR_; + double psc = rhoSolid * sedF * (1.+2.*eRp1*sedF*gs_0)*theta; + return psc; + } + + template + inline double cppHsuSedStress::psc_term( + double sedF, + double rhoSolid, + double theta_np1, + double du_dx, + double dv_dy, + double dw_dz) + { + return -2.*psc(sedF,rhoSolid,theta_np1)*(du_dx + dv_dy + dw_dz)/(3.*rhoSolid * sedF); + } + + template + inline double cppHsuSedStress::dpsc_term_dtheta( + double sedF, + double rhoSolid, + double du_dx, + double dv_dy, + double dw_dz + ) + { + double gs_0 = gs0(sedF); + double eRp1 = 1.+eR_; + double dpsc = rhoSolid * sedF * (1.+2.*eRp1*sedF*gs_0); + return -2.*dpsc*(du_dx + dv_dy + dw_dz)/(3.*rhoSolid * sedF); + } + + template + inline double cppHsuSedStress::mu_sc( + double sedF, + double rhoSolid, + double theta + ) + { + double gs_0 = gs0(sedF); + double sq_pi = (sqrt(M_PI)); + double sedF2 = sedF * sedF; + double eRp1 = 1.+eR_; + double sq_theta = sqrt(theta); + + double mu_sc = rhoSolid*grain_*sq_theta*( 0.8*sedF2*gs_0*eRp1/(sq_pi) + (1./15.)*sq_pi*sedF2*gs_0*eRp1 + (1./6.)*sq_pi*sedF + (5./48)*sq_pi/(gs_0*eRp1) ); + + return mu_sc; + } + + template + inline double cppHsuSedStress::l_sc( + double sedF, + double rhoSolid, + double theta_n + ) + { + double gs_0 = gs0(sedF); + double sq_pi = (sqrt(M_PI)); + double sedF2 = sedF * sedF; + double eRp1 = 1.+eR_; + double sq_theta = sqrt(theta_n); + double lambda = (4./3.)*sedF2*rhoSolid*grain_*gs_0*eRp1*sq_theta/sq_pi; + + return lambda; + } + + template + inline double cppHsuSedStress::tausc_term_theta( + double sedF, // IN + double rhoSolid, //IN + double theta_n, //IN + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz) + { + + double la = l_sc(sedF, rhoSolid, theta_n); + double mu = mu_sc(sedF, rhoSolid, theta_n); + + + double divU = du_dx + dv_dy + dw_dz; + double t11 = 2*mu*du_dx + (la - (2./3.)*mu)*divU ; + double t22 = 2*mu*dv_dy + (la - (2./3.)*mu)*divU ; + double t33 = 2*mu*dw_dz + (la - (2./3.)*mu)*divU ; + double t13 = mu*(du_dz + dw_dx); + double t23 = mu*(dv_dz + dw_dy); + double t12 = mu*(du_dy + dv_dx); + // No need to define t31, t32 and t21 as tensor is symmetric + + double term = t11 * du_dx + t22 * dv_dy + t33 * dw_dz; + term += t12*(du_dy +dv_dx); + term += t13*(du_dz +dw_dx); + term += t23*(dv_dz +dw_dy); + + return term* (2./3.) / (rhoSolid*sedF); + } + + template + inline double cppHsuSedStress::gamma_s( + double sedF, + double rhoSolid, + double theta_n, + double theta_np1, + double du_dx, + double dv_dy, + double dw_dz + ) + { + double sq_pi = (sqrt(M_PI)); + double sq_theta = sqrt(theta_n); + double divU = du_dx + dv_dy + dw_dz; + double gamma_s = - 2*(1-eR_*eR_)*sedF*gs0(sedF)*(4.*sq_theta/(sq_pi*grain_) - divU)*theta_np1; + return gamma_s; + } + + template + inline double cppHsuSedStress::dgamma_s_dtheta( + double sedF, + double rhoSolid, + double theta_n, + double du_dx, + double dv_dy, + double dw_dz + ) + { + double sq_pi = (sqrt(M_PI)); + double sq_theta = sqrt(theta_n); + double divU = du_dx + dv_dy + dw_dz; + double gamma_s = - 2*(1-eR_*eR_)*sedF*gs0(sedF)*(4.*sq_theta/(sq_pi*grain_) - divU); + return gamma_s; + } + + template + inline double cppHsuSedStress::jint1( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double kappa, + double epsilon, + double theta, + double nu + ) + { + + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + double gs = gs0(sedF)+small_; + double l_c = sqrt(M_PI)*grain_/(24.*(sedF+small_)*gs); + double t_p = rhoSolid/beta; + double t_c = l_c/(sqrt(theta) + small_); + double t_l = 0.165*kappa/(epsilon + small_); + double t_cl = std::min(t_c,t_l); + double alpha= t_cl/(t_cl + t_p); + + double Jint1 = 4. * alpha * beta * kappa /( 3.* rhoSolid) ; + return Jint1; + } + + template + inline double cppHsuSedStress::jint2( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double theta, + double nu + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + return - 2*beta*theta/rhoSolid; + } + + template + inline double cppHsuSedStress::djint2_dtheta( + double sedF, + double rhoFluid, + double rhoSolid, + const xt::pyarray& uFluid, + const xt::pyarray& uSolid, + double nu + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid,uSolid,nu)+small_; + return - 2*beta/rhoSolid; + } + + template + inline double cppHsuSedStress::k_diff( + double sedF, + double rhoSolid, + double theta + ) + { + double gs_0 = gs0(sedF); + double sq_pi = (sqrt(M_PI)); + double sedF2 = sedF * sedF; + double eRp1 = 1.+eR_; + double sq_theta = sqrt(theta); + double k_diff = rhoSolid*grain_*sq_theta*( 2.*sedF2*gs_0*eRp1/(sq_pi) + (0.5625)*sq_pi*sedF2*gs_0*eRp1 + (0.9375)*sq_pi*sedF + (0.390625)*sq_pi/(gs_0*eRp1) ); + return k_diff; + } + + template + inline double cppHsuSedStress::p_friction(double sedF) + { + double pf = 0.; + if (sedF > frFraction_) + { + double sedLim =std::min(sedF,vos_limiter_); + pf =fContact_*pow(sedLim-frFraction_,mContact_) / ( pow(maxFraction_ - sedLim,nContact_) + small_); + } + return pf; + } + + template + inline double cppHsuSedStress::gradp_friction(double sedF) + { + double coeff = 0; + double pf = p_friction(sedF); + if (sedF > frFraction_ ) + { + double sedLim =std::min(sedF,vos_limiter_); + + double den1 = (sedLim - frFraction_); + double den2 = (maxFraction_ - sedLim); + + coeff = pf *( (mContact_/den1) + (nContact_/den2) ); + } + return coeff; + } + + template + inline double cppHsuSedStress::mu_fr( + double sedF, + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz + ) + { + double divU = du_dx + dv_dy + dw_dz; + double pf = p_friction(sedF); + double s11 = du_dx - (1./nSpace)*divU; + double s22 = dv_dy - (1./nSpace)*divU; + double s33 = dw_dz - (1./nSpace)*divU; + double s12 = 0.5*(du_dy + dv_dx); + double s13 = 0.5*(du_dz + dw_dx); + double s23 = 0.5*(dv_dz + dw_dy); + double sumS = s11*s11 + s22*s22 + s33*s33 + 2.*s12*s12 + 2.*s13*s13 + 2.*s23*s23; + double mu_sf = 0.0; + double mu_fr = 0.0; + if (sedF > frFraction_) + { + mu_sf = pf * sqrt(2.) * sin(angFriction_) / (2 * sqrt(sumS) + small_); + mu_fr = std::min(mu_sf,mu_fr_limiter_); + } + return mu_fr; + } + + template + inline void cppHsuSedStress::mIntFluid( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uFluid_np1, //Fluid velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + + double beta = betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu); + for (int ii=0; ii + inline void cppHsuSedStress::mIntSolid( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + const xt::pyarray& uSolid_np1, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + double beta = betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu); + for (int ii=0; ii + inline void cppHsuSedStress::mIntgradC( + xt::pyarray mint2, + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu, //Kinematic viscosity + double nuT, //Turbulent viscosity + const xt::pyarray& gradc + ) + { + + double beta = betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu); + for (int ii=0; ii + inline double cppHsuSedStress::dmInt_duFluid( + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + ) + { + return -sedF*betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu)/(rhoFluid * (1. - sedF)); + } + + template + inline double cppHsuSedStress::dmInt_duSolid( + double sedF, + double rhoFluid, + const xt::pyarray& uFluid_n, //Fluid velocity + const xt::pyarray& uSolid_n, //Sediment velocity + double nu //Kinematic viscosity + ) + { + return +sedF*betaCoeff(sedF,rhoFluid,uFluid_n,uSolid_n,nu)/(rhoFluid * (1. - sedF)); + } + + template + inline double cppHsuSedStress::p_s( + double sedF, + double rhoSolid, + double theta, + double du_dx, + double du_dy, + double du_dz, + double dv_dx, + double dv_dy, + double dv_dz, + double dw_dx, + double dw_dy, + double dw_dz + ) + { + double divU = du_dx + dv_dy + dw_dz; + double mf = mu_fr(sedF, du_dx, du_dy, du_dz, dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz); + double msc = mu_sc(sedF, rhoSolid, theta ); + double lam = l_sc(sedF, rhoSolid, theta ); + double pcorr = ( (2./3.)*(msc + mf) - lam ) * divU; + return p_friction(sedF) + psc(sedF, rhoSolid, theta) + pcorr ; + } +} + +#endif diff --git a/proteus/mprans2/VOF3P.cpp b/proteus/mprans2/VOF3P.cpp new file mode 100644 index 0000000000..ac6b799904 --- /dev/null +++ b/proteus/mprans2/VOF3P.cpp @@ -0,0 +1,2105 @@ +#include + +#define FORCE_IMPORT_ARRAY +#include "VOF3P.hpp" +#include "CompKernel.h" +#include "ModelFactory.h" + +#define POWER_SMOOTHNESS_INDICATOR 2 +#define GLOBAL_FCT 0 + +namespace proteus +{ + // Power entropy //Å“ + inline double ENTROPY(const double& phi, const double& phiL, const double& phiR) + { + return 1./2.*std::pow(fabs(phi),2.); + } + + inline double DENTROPY(const double& phi, const double& phiL, const double& phiR) + { + return fabs(phi)*(phi>=0 ? 1 : -1); + } + + // Log entropy // for level set from 0 to 1 + inline double ENTROPY_LOG(const double& phi, const double& phiL, const double& phiR) + { + return std::log(fabs((phi-phiL)*(phiR-phi))+1E-14); + } + + inline double DENTROPY_LOG(const double& phi, const double& phiL, const double& phiR) + { + return (phiL+phiR-2*phi)*((phi-phiL)*(phiR-phi)>=0 ? 1 : -1)/(fabs((phi-phiL)*(phiR-phi))+1E-14); + } + + template + class cppVOF : public cppVOF3P_base + { + private: + + std::valarray Rpos, Rneg; + std::valarray FluxCorrectionMatrix; + std::valarray TransportMatrix, TransposeTransportMatrix; + std::valarray psi, eta, global_entropy_residual, boundary_integral; + + public: + + const int nDOF_test_X_trial_element; + CompKernelType ck; + + cppVOF() + : nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element) + , ck() + {} + + inline void calculateCFL(const double& elementDiameter, + const double df[nSpace], + double& cfl) + { + double h,nrm_v; + h = elementDiameter; + nrm_v=0.0; + for(int I=0;I= 0.0) + { + flux = u*flow; + //flux = flow; + } + else + { + flux = bc_u*flow; + //flux = flow; + } + } + else if (isFluxBoundary_u == 1) + { + flux = bc_flux_u; + //std::cout<<"Flux boundary flux and flow"<= 0.0) + { + flux = u*flow; + } + else + { + std::cout<<"warning: VOF open boundary with no external trace, setting to zero for inflow"<= 0.0) + { + dflux = flow; + } + else + { + dflux = 0.0; + } + } + else if (isFluxBoundary_u == 1) + { + dflux = 0.0; + } + else + { + if (flow >= 0.0) + { + dflux = flow; + } + } + } + + void calculateResidualElementBased(//element + double dt, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + //VRANS + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + double degree_polynomial, + xt::pyarray u_dof, + xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray edge_based_cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray ebqe_phi,double epsFact, + xt::pyarray ebqe_u, + xt::pyarray ebqe_flux, + //EXPLICIT METHODS + int stage, + double * uTilde_dof, + // PARAMETERS FOR EDGE BASED STABILIZATION + double cE, + double cMax, + double cK, + // PARAMETERS FOR LOG BASED ENTROPY FUNCTION + double uL, + double uR, + // PARAMETERS FOR EDGE VISCOSITY + int numDOFs, + int NNZ, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray csrRowIndeces_CellLoops, + xt::pyarray csrColumnOffsets_CellLoops, + xt::pyarray csrColumnOffsets_eb_CellLoops, + xt::pyarray ML, + // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE, + int ENTROPY_TYPE, + // FOR FCT + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray dt_times_dH_minus_dL, + xt::pyarray min_u_bc, + xt::pyarray max_u_bc, + // AUX QUANTITIES OF INTEREST + xt::pyarray quantDOFs) override + { + double meanEntropy = 0., meanOmega = 0., maxEntropy = -1E10, minEntropy = 1E10; + register double maxVel[nElements_global], maxEntRes[nElements_global]; + double Ct_sge = 4.0; + // + //loop over elements to compute volume integrals and load them into element and global residual + // + //eN is the element index + //eN_k is the quadrature point index for a scalar + //eN_k_nSpace is the quadrature point index for a vector + //eN_i is the element test function index + //eN_j is the element trial function index + //eN_k_j is the quadrature point index for a trial function + //eN_k_i is the quadrature point index for a trial function + for(int eN=0;eN=0.0) + ebqe_u[ebNE_kb] = u_ext; + else + ebqe_u[ebNE_kb] = bc_u_ext; + + if (STABILIZATION_TYPE==1) + { + if (stage==1) + { + flux_ext *= 1./3*dt; + } + else + { + flux_ext *= dt; + } + } + + // + //update residuals + // + for (int i=0;i mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + //VRANS + const xt::pyarray& q_vos, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof, + xt::pyarray velocity, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u_last, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray csrColumnOffsets_eb_u_u, + int STABILIZATION_TYPE) override + { + //std::cout<<"ndjaco address "< lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray soln, //DOFs of solution at time tn + xt::pyarray solH, //DOFs of high order solution at tnp1 + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray limited_solution, + xt::pyarray csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray MassMatrix, //mass matrix + xt::pyarray dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray max_u_bc, + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE) override + { + Rpos.resize(numDOFs,0.0), Rneg.resize(numDOFs,0.0); + FluxCorrectionMatrix.resize(NNZ,0.0); + ////////////////// + // LOOP in DOFs // + ////////////////// + int ij=0; + for (int i=0; i 0) ? 1. : 0.); + Pnegi += FluxCorrectionMatrix[ij]*((FluxCorrectionMatrix[ij] < 0) ? 1. : 0.); + + //update ij + ij+=1; + } + /////////////////////// + // COMPUTE Q VECTORS // + /////////////////////// + double Qposi = mi*(maxi-uLow[i]); + double Qnegi = mi*(mini-uLow[i]); + + /////////////////////// + // COMPUTE R VECTORS // + /////////////////////// + Rpos[i] = ((Pposi==0) ? 1. : fmin(1.0,Qposi/Pposi)); + Rneg[i] = ((Pnegi==0) ? 1. : fmin(1.0,Qnegi/Pnegi)); + } // i DOFs + + ////////////////////// + // COMPUTE LIMITERS // + ////////////////////// + ij=0; + for (int i=0; i0) ? fmin(Rposi,Rneg[j]) : fmin(Rnegi,Rpos[j])); + ith_Limiter_times_FluxCorrectionMatrix += Lij * FluxCorrectionMatrix[ij]; + //update ij + ij+=1; + } + limited_solution[i] = uLow[i] + 1./lumped_mass_matrix[i]*ith_Limiter_times_FluxCorrectionMatrix; + } + } + + void calculateResidualEdgeBased(//element + double dt, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, + double shockCapturingDiffusion, + double sc_uref, double sc_alpha, + //VRANS + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + double degree_polynomial, + xt::pyarray u_dof, + xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray edge_based_cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray ebqe_phi,double epsFact, + xt::pyarray ebqe_u, + xt::pyarray ebqe_flux, + //EXPLICIT METHODS + int stage, + double * uTilde_dof, + // PARAMETERS FOR EDGE BASED STABILIZATION + double cE, + double cMax, + double cK, + // PARAMETERS FOR LOG BASED ENTROPY FUNCTION + double uL, + double uR, + // PARAMETERS FOR EDGE VISCOSITY + int numDOFs, + int NNZ, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray csrRowIndeces_CellLoops, + xt::pyarray csrColumnOffsets_CellLoops, + xt::pyarray csrColumnOffsets_eb_CellLoops, + xt::pyarray ML, + // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE, + int ENTROPY_TYPE, + // FOR FCT + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray dt_times_dH_minus_dL, + xt::pyarray min_u_bc, + xt::pyarray max_u_bc, + // AUX QUANTITIES OF INTEREST + xt::pyarray quantDOFs) override + { + // NOTE: This function follows a different (but equivalent) implementation of the smoothness based indicator than NCLS.h + // Allocate space for the transport matrices + // This is used for first order KUZMIN'S METHOD + TransportMatrix.resize(NNZ,0.0), TransposeTransportMatrix.resize(NNZ,0.0); + for (int i=0; i= 0) //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"< Dissipation matrices as well. + double solni = u_dof_old[i]; // solution at time tn for the ith DOF + double porosityi = 1.-vos_dof[i]; + double ith_dissipative_term = 0; + double ith_low_order_dissipative_term = 0; + double ith_flux_term = 0; + double dLii = 0.; + + // loop over the sparsity pattern of the i-th DOF + for (int offset=csrRowIndeces_DofLoops[i]; offset(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + else + { + return proteus::chooseAndAllocateDiscretization(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } + } +} + +namespace py = pybind11; + +PYBIND11_MODULE(cVOF3P, m) +{ + using proteus::cppVOF3P_base; + using proteus::newVOF3P; + + xt::import_numpy(); + + py::class_(m, "cppVOF3P_base") + .def("calculateResidualElementBased", &cppVOF3P_base::calculateResidualElementBased) + .def("calculateJacobian", &cppVOF3P_base::calculateJacobian) + .def("FCTStep", &cppVOF3P_base::FCTStep) + .def("calculateResidualEdgeBased", &cppVOF3P_base::calculateResidualEdgeBased); + + m.def("newVOF3P", newVOF3P); +} + diff --git a/proteus/mprans2/VOF3P.hpp b/proteus/mprans2/VOF3P.hpp new file mode 100644 index 0000000000..d51fd7ef78 --- /dev/null +++ b/proteus/mprans2/VOF3P.hpp @@ -0,0 +1,299 @@ +#ifndef VOF3P_HPP +#define VOF3P_HPP + +#include "xtensor-python/pyarray.hpp" + +namespace proteus +{ + class cppVOF3P_base + { + public: + + virtual ~cppVOF3P_base() = default; + + virtual void calculateResidualElementBased(//element + double dt, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, + double shockCapturingDiffusion, + double sc_uref, + double sc_alpha, + //VRANS + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + double degree_polynomial, + xt::pyarray u_dof, + xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray edge_based_cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray ebqe_phi,double epsFact, + xt::pyarray ebqe_u, + xt::pyarray ebqe_flux, + // TAYLOR GALERKIN + int stage, + double * uTilde_dof, + // PARAMETERS FOR ENTROPY VISCOSITY + double cE, + double cMax, + double cK, + // PARAMETERS FOR LOG BASED ENTROPY FUNCTION + double uL, + double uR, + // PARAMETERS FOR EDGE VISCOSITY + int numDOFs, + int NNZ, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray csrRowIndeces_CellLoops, + xt::pyarray csrColumnOffsets_CellLoops, + xt::pyarray csrColumnOffsets_eb_CellLoops, + xt::pyarray ML, + // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE, + int ENTROPY_TYPE, + // FOR FCT + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray dt_times_dH_minus_dL, + xt::pyarray min_u_bc, + xt::pyarray max_u_bc, + // AUX QUANTITIES OF INTEREST + xt::pyarray quantDOFs) = 0; + + virtual void calculateJacobian(//element + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + //VRANS + const xt::pyarray& q_vos, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + xt::pyarray u_dof, + xt::pyarray velocity, + xt::pyarray q_m_betaBDF, + xt::pyarray cfl, + xt::pyarray q_numDiff_u_last, + xt::pyarray csrRowIndeces_u_u,xt::pyarray csrColumnOffsets_u_u, + xt::pyarray globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray csrColumnOffsets_eb_u_u, + int STABILIZATION_TYPE) = 0; + + virtual void FCTStep(double dt, + int NNZ, //number on non-zero entries on sparsity pattern + int numDOFs, //number of DOFs + xt::pyarray lumped_mass_matrix, //lumped mass matrix (as vector) + xt::pyarray soln, //DOFs of solution at time tn + xt::pyarray solH, //DOFs of high order solution at tnp1 + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray limited_solution, + xt::pyarray csrRowIndeces_DofLoops, //csr row indeces + xt::pyarray csrColumnOffsets_DofLoops, //csr column offsets + xt::pyarray MassMatrix, //mass matrix + xt::pyarray dt_times_dH_minus_dL, //low minus high order dissipative matrices + xt::pyarray min_u_bc, //min/max value at BCs. If DOF is not at boundary then min=1E10, max=-1E10 + xt::pyarray max_u_bc, + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE) = 0; + + virtual void calculateResidualEdgeBased(//element + double dt, + xt::pyarray mesh_trial_ref, + xt::pyarray mesh_grad_trial_ref, + xt::pyarray mesh_dof, + xt::pyarray mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray mesh_l2g, + xt::pyarray dV_ref, + xt::pyarray u_trial_ref, + xt::pyarray u_grad_trial_ref, + xt::pyarray u_test_ref, + xt::pyarray u_grad_test_ref, + //element boundary + xt::pyarray mesh_trial_trace_ref, + xt::pyarray mesh_grad_trial_trace_ref, + xt::pyarray dS_ref, + xt::pyarray u_trial_trace_ref, + xt::pyarray u_grad_trial_trace_ref, + xt::pyarray u_test_trace_ref, + xt::pyarray u_grad_test_trace_ref, + xt::pyarray normal_ref, + xt::pyarray boundaryJac_ref, + //physics + int nElements_global, + double useMetrics, + double alphaBDF, + int lag_shockCapturing, + double shockCapturingDiffusion, + double sc_uref, + double sc_alpha, + //VRANS + const xt::pyarray& q_vos, + const xt::pyarray& vos_dof, + // + xt::pyarray u_l2g, + xt::pyarray r_l2g, + xt::pyarray elementDiameter, + double degree_polynomial, + xt::pyarray u_dof, + xt::pyarray u_dof_old, + xt::pyarray velocity, + xt::pyarray q_m, + xt::pyarray q_u, + xt::pyarray q_m_betaBDF, + xt::pyarray q_dV, + xt::pyarray q_dV_last, + xt::pyarray cfl, + xt::pyarray edge_based_cfl, + xt::pyarray q_numDiff_u, + xt::pyarray q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray exteriorElementBoundariesArray, + xt::pyarray elementBoundaryElementsArray, + xt::pyarray elementBoundaryLocalElementBoundariesArray, + xt::pyarray ebqe_velocity_ext, + //VRANS + const xt::pyarray& ebqe_vos_ext, + // + xt::pyarray isDOFBoundary_u, + xt::pyarray ebqe_bc_u_ext, + xt::pyarray isFluxBoundary_u, + xt::pyarray ebqe_bc_flux_u_ext, + xt::pyarray ebqe_phi,double epsFact, + xt::pyarray ebqe_u, + xt::pyarray ebqe_flux, + //EXPLICIT METHODS + int stage, + double * uTilde_dof, + // PARAMETERS FOR EDGE BASED STABILIZATION + double cE, + double cMax, + double cK, + // PARAMETERS FOR LOG BASED ENTROPY FUNCTION + double uL, + double uR, + // PARAMETERS FOR EDGE VISCOSITY + int numDOFs, + int NNZ, + xt::pyarray csrRowIndeces_DofLoops, + xt::pyarray csrColumnOffsets_DofLoops, + xt::pyarray csrRowIndeces_CellLoops, + xt::pyarray csrColumnOffsets_CellLoops, + xt::pyarray csrColumnOffsets_eb_CellLoops, + xt::pyarray ML, + // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD + int LUMPED_MASS_MATRIX, + int STABILIZATION_TYPE, + int ENTROPY_TYPE, + // FOR FCT + xt::pyarray uLow, + xt::pyarray dLow, + xt::pyarray dt_times_dH_minus_dL, + xt::pyarray min_u_bc, + xt::pyarray max_u_bc, + // AUX QUANTITIES OF INTEREST + xt::pyarray quantDOFs) = 0; + }; + + cppVOF3P_base* newVOF3P(int nSpaceIn, + int nQuadraturePoints_elementIn, + int nDOF_mesh_trial_elementIn, + int nDOF_trial_elementIn, + int nDOF_test_elementIn, + int nQuadraturePoints_elementBoundaryIn, + int CompKernelFlag); + +} + +#endif //VOF3P_H diff --git a/proteus/mprans2/VOF3P.py b/proteus/mprans2/VOF3P.py new file mode 100644 index 0000000000..94f54dea8a --- /dev/null +++ b/proteus/mprans2/VOF3P.py @@ -0,0 +1,1396 @@ +# A type of -*- python -*- file +""" +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 +from proteus import cfemIntegrals, Quadrature, Norms, Comm +from proteus.NonlinearSolvers import NonlinearEquation +from proteus.FemTools import (DOFBoundaryConditions, + FluxBoundaryConditions, + C0_AffineLinearOnSimplexWithNodalBasis) +from proteus.Comm import globalMax +from proteus.Profiling import memory +from proteus.Profiling import logEvent +from proteus.Transport import OneLevelTransport +from proteus.TransportCoefficients import TC_base +from proteus.SubgridError import SGE_base +from proteus.ShockCapturing import ShockCapturing_base +from proteus.LinearAlgebraTools import SparseMat +from proteus.NonlinearSolvers import ExplicitLumpedMassMatrix,ExplicitConsistentMassMatrixForVOF,TwoStageNewton +from proteus import TimeIntegration +from proteus.mprans.cVOF3P import * +#from . import cVOF3P + +class SubgridError(SGE_base): + def __init__(self, coefficients, nd): + proteus.SubgridError.SGE_base.__init__(self, coefficients, nd, lag=False) + + def initializeElementQuadrature(self, mesh, t, cq): + pass + + def updateSubgridErrorHistory(self, initializationPhase=False): + pass + + def calculateSubgridError(self, q): + pass + +class ShockCapturing(ShockCapturing_base): + def __init__(self, + coefficients, + nd, + shockCapturingFactor=0.25, + lag=True, + nStepsToDelay=None): + proteus.ShockCapturing.ShockCapturing_base.__init__(self, + coefficients, + nd, + shockCapturingFactor, + lag) + self.nStepsToDelay = nStepsToDelay + self.nSteps = 0 + if self.lag: + logEvent("VOF3P.ShockCapturing: lagging requested but must lag the first step; switching lagging off and delaying") + self.nStepsToDelay = 1 + self.lag = False + + def initializeElementQuadrature(self, mesh, t, cq): + self.mesh = mesh + self.numDiff = [] + self.numDiff_last = [] + for ci in range(self.nc): + self.numDiff.append(cq[('numDiff', ci, ci)]) + self.numDiff_last.append(cq[('numDiff', ci, ci)]) + + def updateShockCapturingHistory(self): + self.nSteps += 1 + if self.lag: + for ci in range(self.nc): + self.numDiff_last[ci][:] = self.numDiff[ci] + if self.lag == False and self.nStepsToDelay is not None and self.nSteps > self.nStepsToDelay: + logEvent("VOF3P.ShockCapturing: switched to lagged shock capturing") + self.lag = True + self.numDiff_last = [] + for ci in range(self.nc): + self.numDiff_last.append(self.numDiff[ci].copy()) + logEvent("VOF3P: max numDiff %e" % (globalMax(self.numDiff_last[0].max()),)) + +class NumericalFlux(proteus.NumericalFlux.Advection_DiagonalUpwind_Diffusion_IIPG_exterior): + def __init__(self, + vt, + getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions, + getPeriodicBoundaryConditions=None): + proteus.NumericalFlux.Advection_DiagonalUpwind_Diffusion_IIPG_exterior.__init__( + self, + vt, + getPointwiseBoundaryConditions, + getAdvectiveFluxBoundaryConditions, + getDiffusiveFluxBoundaryConditions) + +class RKEV(proteus.TimeIntegration.SSP): + from proteus import TimeIntegration + """ + Wrapper for SSPRK time integration using EV + + ... more to come ... + """ + + def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoints=False): + TimeIntegration.SSP.__init__(self, + transport, + integrateInterpolationPoints=integrateInterpolationPoints) + self.runCFL = runCFL + self.dtLast = None + self.isAdaptive = True + assert transport.coefficients.STABILIZATION_TYPE>1, "SSP method just works for edge based EV methods; i.e., STABILIZATION_TYPE>1" + assert hasattr(transport, 'edge_based_cfl'), "No edge based cfl defined" + # About the cfl + self.cfl = transport.edge_based_cfl + # Stuff particular for SSP + self.timeOrder = timeOrder # order of approximation + self.nStages = timeOrder # number of stages total + self.lstage = 0 # last stage completed + # storage vectors + self.u_dof_last = {} + self.m_old = {} + # per component stage values, list with array at each stage + for ci in range(self.nc): + self.m_last[ci] = transport.q[('u',ci)].copy() + self.m_old[ci] = transport.q[('u',ci)].copy() + self.u_dof_last[ci] = transport.u[ci].dof.copy() + + def choose_dt(self): + maxCFL = 1.0e-6 + maxCFL = max(maxCFL, globalMax(self.cfl.max())) + self.dt = old_div(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): + """ + Modify self.dt + """ + self.tLast = t0 + self.choose_dt() + self.t = t0 + self.dt + + def setCoefficients(self): + """ + beta are all 1's here + mwf not used right now + """ + self.alpha = np.zeros((self.nStages, self.nStages), 'd') + self.dcoefs = np.zeros((self.nStages), 'd') + + def updateStage(self): + """ + Need to switch to use coefficients + """ + self.lstage += 1 + assert self.timeOrder in [1, 2, 3] + assert self.lstage > 0 and self.lstage <= self.timeOrder + if self.timeOrder == 3: + if self.lstage == 1: + logEvent("First stage of SSP33 method", level=4) + for ci in range(self.nc): + # save stage at quad points + self.m_last[ci][:] = self.transport.q[('u',ci)] + # DOFs + self.transport.u_dof_old[:] = self.transport.u[ci].dof + elif self.lstage == 2: + logEvent("Second stage of SSP33 method", level=4) + for ci in range(self.nc): + # Quad points + self.m_last[ci][:] = 1./4*self.transport.q[('u',ci)] + self.m_last[ci][:] += 3./4*self.m_old[ci] + # DOFs + self.transport.u_dof_old[:] = 1./4*self.transport.u[ci].dof + self.transport.u_dof_old[:] += 3./4* self.u_dof_last[ci] + elif self.lstage == 3: + logEvent("Third stage of SSP33 method", level=4) + for ci in range(self.nc): + # Quad points + self.m_last[ci][:] = 2./3*self.transport.q[('u',ci)] + self.m_last[ci][:] += 1./3*self.m_old[ci] + # DOFs + self.transport.u[0].dof[:] = 2./3*self.transport.u[ci].dof + self.transport.u[0].dof[:] += 1./3* self.u_dof_last[ci] + # update u_dof_old + self.transport.u_dof_old[:] = self.u_dof_last[ci] + elif self.timeOrder == 2: + if self.lstage == 1: + logEvent("First stage of SSP22 method", level=4) + for ci in range(self.nc): + # save stage at quad points + self.m_last[ci][:] = self.transport.q[('u',ci)] + # DOFs + self.transport.u_dof_old[:] = self.transport.u[ci].dof + elif self.lstage == 2: + logEvent("Second stage of SSP22 method", level=4) + for ci in range(self.nc): + # Quad points + self.m_last[ci][:] = 1./2*self.transport.q[('u',ci)] + self.m_last[ci][:] += 1./2*self.m_old[ci] + # DOFs + self.transport.u[0].dof[:] = 1./2*self.transport.u[ci].dof + self.transport.u[0].dof[:] += 1./2*self.u_dof_last[ci] + # update u_dof_old + self.transport.u_dof_old[:] = self.u_dof_last[ci] + else: + assert self.timeOrder == 1 + for ci in range(self.nc): + self.m_last[ci][:] = self.transport.q[('u',ci)] + + def initializeTimeHistory(self, resetFromDOF=True): + """ + Push necessary information into time history arrays + """ + for ci in range(self.nc): + self.m_old[ci][:] = self.transport.q[('u',ci)] + self.m_last[ci][:] = self.transport.q[('u',ci)] + self.u_dof_last[ci][:] = self.transport.u[ci].dof[:] + + def updateTimeHistory(self, resetFromDOF=False): + """ + assumes successful step has been taken + """ + self.t = self.tLast + self.dt + for ci in range(self.nc): + self.m_old[ci][:] = self.m_last[ci][:] + self.u_dof_last[ci][:] = self.transport.u[ci].dof[:] + self.lstage = 0 + self.dtLast = self.dt + self.tLast = self.t + + def generateSubsteps(self, tList): + """ + create list of substeps over time values given in tList. These correspond to stages + """ + self.substeps = [] + tLast = self.tLast + for t in tList: + dttmp = t - tLast + self.substeps.extend([tLast + dttmp for i in range(self.nStages)]) + tLast = t + + def resetOrder(self, order): + """ + initialize data structures for stage updges + """ + self.timeOrder = order # order of approximation + self.nStages = order # number of stages total + self.lstage = 0 # last stage completed + self.substeps = [self.t for i in range(self.nStages)] + + def setFromOptions(self, nOptions): + """ + allow classes to set various numerical parameters + """ + if 'runCFL' in dir(nOptions): + self.runCFL = nOptions.runCFL + flags = ['timeOrder'] + for flag in flags: + if flag in dir(nOptions): + val = getattr(nOptions, flag) + setattr(self, flag, val) + if flag == 'timeOrder': + self.resetOrder(self.timeOrder) + +class Coefficients(proteus.TransportCoefficients.TC_base): + from proteus.ctransportCoefficients import VOFCoefficientsEvaluate + from proteus.ctransportCoefficients import VolumeAveragedVOFCoefficientsEvaluate + from proteus.cfemIntegrals import copyExteriorElementBoundaryValuesFromElementBoundaryValues + + def __init__(self, + LS_model=None, + V_model=0, + RD_model=None, + ME_model=1, + VOS_model=None, + checkMass=True, + epsFact=0.0, + useMetrics=0.0, + sc_uref=1.0, + sc_beta=1.0, + setParamsFunc=None, + movingDomain=False, + set_vos=None, + forceStrongConditions=False, + STABILIZATION_TYPE=0, + # 0: supg + # 1: Taylor Galerkin with EV + # 2: EV with FCT (with or without art comp) + # 3: Smoothness indicator (with or without art comp) + # 4: DK's with FCT + #FOR EDGE BASED EV + ENTROPY_TYPE=0, + # 0: quadratic + # 1: logarithmic + # FOR ENTROPY VISCOSITY + cE=1.0, + cMax=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=0.0, + LUMPED_MASS_MATRIX=False, + FCT=True, + outputQuantDOFs=False, + #NULLSPACE INFO + nullSpace='NoNullSpace'): + + self.variableNames = ['vof'] + nc = 1 + mass = {0: {0: 'linear'}} + advection = {0: {0: 'linear'}} + hamiltonian = {} + diffusion = {} + potential = {} + reaction = {} + TC_base.__init__(self, + nc, + mass, + advection, + diffusion, + potential, + reaction, + hamiltonian, + self.variableNames, + movingDomain=movingDomain) + self.LS_modelIndex = LS_model + self.V_model = V_model + self.RD_modelIndex = RD_model + self.modelIndex = ME_model + self.VOS_model=VOS_model + self.checkMass = checkMass + self.epsFact = epsFact + self.useMetrics = useMetrics + self.sc_uref = sc_uref + self.sc_beta = sc_beta + self.setParamsFunc = setParamsFunc + self.movingDomain = movingDomain + self.forceStrongConditions = forceStrongConditions + self.STABILIZATION_TYPE = STABILIZATION_TYPE + self.ENTROPY_TYPE = ENTROPY_TYPE + self.cE = cE + self.cMax = cMax + self.uL = uL + self.uR = uR + self.cK = cK + self.LUMPED_MASS_MATRIX = LUMPED_MASS_MATRIX + self.FCT = FCT + self.outputQuantDOFs = outputQuantDOFs + self.nullSpace = nullSpace + # VRANS + self.q_vos = None + self.ebq_vos = None + self.ebqe_vos = None + self.vos_dof = None + self.flowCoefficients = None + self.set_vos = set_vos + + def initializeMesh(self, mesh): + self.eps = self.epsFact * mesh.h + + def attachModels(self, modelList): + # self + self.model = modelList[self.modelIndex] + # redistanced level set + if self.RD_modelIndex is not None: + self.rdModel = modelList[self.RD_modelIndex] + # level set + if self.LS_modelIndex is not None: + self.lsModel = modelList[self.LS_modelIndex] + self.q_phi = modelList[self.LS_modelIndex].q[('u', 0)] + self.ebqe_phi = modelList[self.LS_modelIndex].ebqe[('u', 0)] + if ('u', 0) in modelList[self.LS_modelIndex].ebq: + self.ebq_phi = modelList[self.LS_modelIndex].ebq[('u', 0)] + else: + self.ebqe_phi = np.zeros(self.model.ebqe[('u', 0)].shape, 'd') # cek hack, we don't need this + # flow model + if self.V_model is not None: + if ('velocity', 0) in modelList[self.V_model].q: + self.q_v = modelList[self.V_model].q[('velocity', 0)] + self.ebqe_v = modelList[self.V_model].ebqe[('velocity', 0)] + else: + self.q_v = modelList[self.V_model].q[('f', 0)] + self.ebqe_v = modelList[self.V_model].ebqe[('f', 0)] + if ('velocity', 0) in modelList[self.V_model].ebq: + self.ebq_v = modelList[self.V_model].ebq[('velocity', 0)] + else: + if ('f', 0) in modelList[self.V_model].ebq: + self.ebq_v = modelList[self.V_model].ebq[('f', 0)] + else: + self.q_v = np.ones(self.model.q[('u',0)].shape+(self.model.nSpace_global,),'d') + self.ebqe_v = np.ones(self.model.ebqe[('u',0)].shape+(self.model.nSpace_global,),'d') + # VRANS + if self.V_model is not None: + self.flowCoefficients = modelList[self.V_model].coefficients + else: + self.flowCoefficients = None + if self.VOS_model is not None: + self.model.q_vos = modelList[self.VOS_model].q[('u',0)] + self.model.ebqe_vos = modelList[self.VOS_model].ebqe[('u',0)] + self.q_vos = self.model.q_vos + self.ebqe_vos = self.model.ebqe_vos + else: + # If the flow model doesn't have porosity then set q_porosity=1 and porosity_dof=1 + self.q_porosity = np.ones(modelList[self.modelIndex].q[('u', 0)].shape, 'd') + #self.vos_dof = np.zeros(modelList[self.modelIndex].u[0].dof.shape, 'd') + if self.setParamsFunc is not None: + self.setParamsFunc(modelList[self.modelIndex].q['x'], self.q_porosity) + self.q_vos = 1.0 - self.q_porosity + if hasattr(self.flowCoefficients, 'ebq_porosity'): + self.ebq_porosity = self.flowCoefficients.ebq_porosity + self.ebq_vos = 1.0 - self.ebq_porosity + elif ('u', 0) in modelList[self.modelIndex].ebq: + self.ebq_porosity = np.ones(modelList[self.modelIndex].ebq[('u', 0)].shape,'d') + if self.setParamsFunc is not None: + self.setParamsFunc(modelList[self.modelIndex].ebq['x'], self.ebq_porosity) + self.ebq_vos = 1.0 - self.ebq_porosity + if hasattr(self.flowCoefficients, 'ebqe_porosity'): + self.ebqe_porosity = self.flowCoefficients.ebqe_porosity + self.ebqe_vos = 1.0 - self.ebqe_porosity + else: + self.ebqe_porosity = np.ones(self.model.ebqe[('u', 0)].shape, 'd') + if self.setParamsFunc is not None: + self.setParamsFunc(modelList[self.LS_modelIndex].ebqe['x'], self.ebqe_porosity) + self.ebqe_vos = 1.0 - self.ebqe_porosity + + def initializeElementQuadrature(self, t, cq): + # VRANS + self.q_vos = np.zeros(cq[('u', 0)].shape, 'd') + + def initializeElementBoundaryQuadrature(self, t, cebq, cebq_global): + # VRANS + self.ebq_vos = np.zeros(cebq[('u', 0)].shape, 'd') + + def initializeGlobalExteriorElementBoundaryQuadrature(self, t, cebqe): + # VRANS + self.ebqe_vos = np.zeros(cebqe[('u', 0)].shape, 'd') + + def preStep(self, t, firstStep=False): + # SAVE OLD SOLUTION # + self.model.u_dof_old[:] = self.model.u[0].dof + + # Restart flags for stages of taylor galerkin + self.model.stage = 1 + self.model.auxTaylorGalerkinFlag = 1 + + # COMPUTE NEW VELOCITY (if given by user) # + if self.model.hasVelocityFieldAsFunction: + self.model.updateVelocityFieldAsFunction() + + if self.checkMass: + self.m_pre = Norms.scalarDomainIntegral(self.model.q['dV_last'], + self.model.q[('m', 0)], + self.model.mesh.nElements_owned) + logEvent("Phase 0 mass before VOF3P step = %12.5e" % (self.m_pre,), level=2) + # self.m_last = Norms.scalarDomainIntegral(self.model.q['dV'], + # self.model.timeIntegration.m_last[0], + # self.model.mesh.nElements_owned) + # logEvent("Phase 0 mass before VOF3P (m_last) step = %12.5e" % (self.m_last,),level=2) + copyInstructions = {} + return copyInstructions + + def postStep(self, t, firstStep=False): + self.model.q['dV_last'][:] = self.model.q['dV'] + if self.checkMass: + self.m_post = Norms.scalarDomainIntegral(self.model.q['dV'], + self.model.q[('m', 0)], + self.model.mesh.nElements_owned) + logEvent("Phase 0 mass after VOF3P step = %12.5e" % (self.m_post,), level=2) + # self.fluxIntegral = Norms.fluxDomainBoundaryIntegral(self.model.ebqe['dS'], + # self.model.ebqe[('advectiveFlux',0)], + # self.model.mesh) + #logEvent("Phase 0 mass flux boundary integral after VOF step = %12.5e" % (self.fluxIntegral,),level=2) + #logEvent("Phase 0 mass conservation after VOF step = %12.5e" % (self.m_post - self.m_last + self.model.timeIntegration.dt*self.fluxIntegral,),level=2) + # divergence = Norms.fluxDomainBoundaryIntegralFromVector(self.model.ebqe['dS'], + # self.ebqe_v, + # self.model.ebqe['n'], + # self.model.mesh) + #logEvent("Divergence = %12.5e" % (divergence,),level=2) + copyInstructions = {} + return copyInstructions + + def updateToMovingDomain(self, t, c): + # in a moving domain simulation the velocity coming in is already for the moving domain + pass + + def evaluate(self, t, c): + # mwf debug + # print "VOF3Pcoeficients eval t=%s " % t + if c[('f', 0)].shape == self.q_v.shape: + v = self.q_v + phi = self.q_phi + porosity = self.q_porosity + elif c[('f', 0)].shape == self.ebqe_v.shape: + v = self.ebqe_v + phi = self.ebqe_phi + porosity = self.ebq_porosity + elif ((self.ebq_v is not None and self.ebq_phi is not None) and c[('f', 0)].shape == self.ebq_v.shape): + v = self.ebq_v + phi = self.ebq_phi + porosity = self.ebq_porosity + else: + v = None + phi = None + porosity = None + if v is not None: + # self.VOF3PCoefficientsEvaluate(self.eps, + # v, + # phi, + # c[('u',0)], + # c[('m',0)], + # c[('dm',0,0)], + # c[('f',0)], + # c[('df',0,0)]) + self.VolumeAveragedVOFCoefficientsEvaluate(self.eps, + v, + phi, + porosity, + c[('u', 0)], + c[('m', 0)], + c[('dm', 0, 0)], + c[('f', 0)], + c[('df', 0, 0)]) + # if self.checkMass: + # logEvent("Phase 0 mass in eavl = %12.5e" % (Norms.scalarDomainIntegral(self.model.q['dV'], + # self.model.q[('m',0)], + # self.model.mesh.nElements_owned),),level=2) + + +class LevelModel(proteus.Transport.OneLevelTransport): + nCalls = 0 + + def __init__(self, + uDict, + phiDict, + testSpaceDict, + matType, + dofBoundaryConditionsDict, + dofBoundaryConditionsSetterDict, + coefficients, + elementQuadrature, + elementBoundaryQuadrature, + fluxBoundaryConditionsDict=None, + advectiveFluxBoundaryConditionsSetterDict=None, + diffusiveFluxBoundaryConditionsSetterDictDict=None, + stressTraceBoundaryConditionsSetterDict=None, + stabilization=None, + shockCapturing=None, + conservativeFluxDict=None, + numericalFluxType=None, + TimeIntegrationClass=None, + massLumping=False, + reactionLumping=False, + options=None, + name='defaultName', + reuse_trial_and_test_quadrature=True, + sd=True, + movingDomain=False, + bdyNullSpace=False): + + self.auxiliaryCallCalculateResidual = False + # + # set the objects describing the method and boundary conditions + # + self.bdyNullSpace = bdyNullSpace + self.movingDomain = movingDomain + self.tLast_mesh = None + # + self.name = name + self.sd = sd + self.Hess = False + self.lowmem = True + self.timeTerm = True # allow turning off the time derivative + # self.lowmem=False + self.testIsTrial = True + self.phiTrialIsTrial = True + self.u = uDict + self.ua = {} # analytical solutions + self.phi = phiDict + self.dphi = {} + self.matType = matType + # mwf try to reuse test and trial information across components if spaces are the same + self.reuse_test_trial_quadrature = reuse_trial_and_test_quadrature # True#False + if self.reuse_test_trial_quadrature: + for ci in range(1, coefficients.nc): + assert self.u[ci].femSpace.__class__.__name__ == self.u[0].femSpace.__class__.__name__, "to reuse_test_trial_quad all femSpaces must be the same!" + self.u_dof_old = None + # Simplicial Mesh + self.mesh = self.u[0].femSpace.mesh # assume the same mesh for all components for now + self.testSpace = testSpaceDict + self.dirichletConditions = dofBoundaryConditionsDict + self.dirichletNodeSetList = None # explicit Dirichlet conditions for now, no Dirichlet BC constraints + self.coefficients = coefficients + self.coefficients.initializeMesh(self.mesh) + self.nc = self.coefficients.nc + self.stabilization = stabilization + self.shockCapturing = shockCapturing + self.conservativeFlux = conservativeFluxDict # no velocity post-processing for now + self.fluxBoundaryConditions = fluxBoundaryConditionsDict + self.advectiveFluxBoundaryConditionsSetterDict = advectiveFluxBoundaryConditionsSetterDict + self.diffusiveFluxBoundaryConditionsSetterDictDict = diffusiveFluxBoundaryConditionsSetterDictDict + # determine whether the stabilization term is nonlinear + self.stabilizationIsNonlinear = False + # cek come back + if self.stabilization is not None: + for ci in range(self.nc): + if ci in coefficients.mass: + for flag in list(coefficients.mass[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.advection: + for flag in list(coefficients.advection[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.diffusion: + for diffusionDict in list(coefficients.diffusion[ci].values()): + for flag in list(diffusionDict.values()): + if flag != 'constant': + self.stabilizationIsNonlinear = True + if ci in coefficients.potential: + for flag in list(coefficients.potential[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.reaction: + for flag in list(coefficients.reaction[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + if ci in coefficients.hamiltonian: + for flag in list(coefficients.hamiltonian[ci].values()): + if flag == 'nonlinear': + self.stabilizationIsNonlinear = True + # determine if we need element boundary storage + self.elementBoundaryIntegrals = {} + for ci in range(self.nc): + self.elementBoundaryIntegrals[ci] = ((self.conservativeFlux is not None) or + (numericalFluxType is not None) or + (self.fluxBoundaryConditions[ci] == 'outFlow') or + (self.fluxBoundaryConditions[ci] == 'mixedFlow') or + (self.fluxBoundaryConditions[ci] == 'setFlow')) + # + # calculate some dimensions + # + self.nSpace_global = self.u[0].femSpace.nSpace_global # assume same space dim for all variables + self.nDOF_trial_element = [u_j.femSpace.max_nDOF_element for u_j in list(self.u.values())] + self.nDOF_phi_trial_element = [phi_k.femSpace.max_nDOF_element for phi_k in list(self.phi.values())] + self.n_phi_ip_element = [phi_k.femSpace.referenceFiniteElement.interpolationConditions.nQuadraturePoints for phi_k in list(self.phi.values())] + self.nDOF_test_element = [femSpace.max_nDOF_element for femSpace in list(self.testSpace.values())] + self.nFreeDOF_global = [dc.nFreeDOF_global for dc in list(self.dirichletConditions.values())] + self.nVDOF_element = sum(self.nDOF_trial_element) + self.nFreeVDOF_global = sum(self.nFreeDOF_global) + # + NonlinearEquation.__init__(self, self.nFreeVDOF_global) + # + # build the quadrature point dictionaries from the input (this + # is just for convenience so that the input doesn't have to be + # complete) + # + elementQuadratureDict = {} + elemQuadIsDict = isinstance(elementQuadrature, dict) + if elemQuadIsDict: # set terms manually + for I in self.coefficients.elementIntegralKeys: + if I in elementQuadrature: + elementQuadratureDict[I] = elementQuadrature[I] + else: + elementQuadratureDict[I] = elementQuadrature['default'] + else: + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[I] = elementQuadrature + if self.stabilization is not None: + for I in self.coefficients.elementIntegralKeys: + if elemQuadIsDict: + if I in elementQuadrature: + elementQuadratureDict[('stab',) + I[1:]] = elementQuadrature[I] + else: + elementQuadratureDict[('stab',) + I[1:]] = elementQuadrature['default'] + else: + elementQuadratureDict[('stab',) + I[1:]] = elementQuadrature + if self.shockCapturing is not None: + for ci in self.shockCapturing.components: + if elemQuadIsDict: + if ('numDiff', ci, ci) in elementQuadrature: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature[('numDiff', ci, ci)] + else: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature['default'] + else: + elementQuadratureDict[('numDiff', ci, ci)] = elementQuadrature + if massLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('m', ci)] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + if reactionLumping: + for ci in list(self.coefficients.mass.keys()): + elementQuadratureDict[('r', ci)] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + for I in self.coefficients.elementIntegralKeys: + elementQuadratureDict[('stab',) + I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global, 1) + elementBoundaryQuadratureDict = {} + if isinstance(elementBoundaryQuadrature, dict): # set terms manually + for I in self.coefficients.elementBoundaryIntegralKeys: + if I in elementBoundaryQuadrature: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature[I] + else: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature['default'] + else: + for I in self.coefficients.elementBoundaryIntegralKeys: + elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature + # + # find the union of all element quadrature points and + # build a quadrature rule for each integral that has a + # weight at each point in the union + # mwf include tag telling me which indices are which quadrature rule? + (self.elementQuadraturePoints, self.elementQuadratureWeights, + self.elementQuadratureRuleIndeces) = Quadrature.buildUnion(elementQuadratureDict) + self.nQuadraturePoints_element = self.elementQuadraturePoints.shape[0] + self.nQuadraturePoints_global = self.nQuadraturePoints_element * self.mesh.nElements_global + # + # Repeat the same thing for the element boundary quadrature + # + (self.elementBoundaryQuadraturePoints, + self.elementBoundaryQuadratureWeights, + self.elementBoundaryQuadratureRuleIndeces) = Quadrature.buildUnion(elementBoundaryQuadratureDict) + self.nElementBoundaryQuadraturePoints_elementBoundary = self.elementBoundaryQuadraturePoints.shape[0] + self.nElementBoundaryQuadraturePoints_global = (self.mesh.nElements_global * + self.mesh.nElementBoundaries_element * + self.nElementBoundaryQuadraturePoints_elementBoundary) + # + # storage dictionaries + self.scalars_element = set() + # + # simplified allocations for test==trial and also check if space is mixed or not + # + self.q = {} + self.ebq = {} + self.ebq_global = {} + self.ebqe = {} + self.phi_ip = {} + self.edge_based_cfl = np.zeros(self.u[0].dof.shape) + # 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[('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[('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') + self.q[('mt', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q['dV'] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q['dV_last'] = -1000 * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('m_tmp', 0)] = self.q[('u', 0)].copy() + self.q[('cfl', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('numDiff', 0, 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.ebqe[('u', 0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + self.ebqe[('grad(u)', 0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global, + self.nElementBoundaryQuadraturePoints_elementBoundary, self.nSpace_global), 'd') + self.ebqe[('advectiveFlux_bc_flag', 0)] = np.zeros( + (self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'i') + self.ebqe[('advectiveFlux_bc', 0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + self.ebqe[('advectiveFlux', 0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + + self.points_elementBoundaryQuadrature = set() + self.scalars_elementBoundaryQuadrature = set([('u', ci) for ci in range(self.nc)]) + self.vectors_elementBoundaryQuadrature = set() + self.tensors_elementBoundaryQuadrature = set() + self.inflowBoundaryBC = {} + self.inflowBoundaryBC_values = {} + self.inflowFlux = {} + for cj in range(self.nc): + self.inflowBoundaryBC[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global,), 'i') + self.inflowBoundaryBC_values[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nDOF_trial_element[cj]), 'd') + self.inflowFlux[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') + self.internalNodes = set(range(self.mesh.nNodes_global)) + # identify the internal nodes this is ought to be in mesh + # \todo move this to mesh + for ebNE in range(self.mesh.nExteriorElementBoundaries_global): + ebN = self.mesh.exteriorElementBoundariesArray[ebNE] + eN_global = self.mesh.elementBoundaryElementsArray[ebN, 0] + ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[ebN, 0] + for i in range(self.mesh.nNodes_element): + if i != ebN_element: + I = self.mesh.elementNodesArray[eN_global, i] + self.internalNodes -= set([I]) + self.nNodes_internal = len(self.internalNodes) + self.internalNodesArray = np.zeros((self.nNodes_internal,), 'i') + for nI, n in enumerate(self.internalNodes): + self.internalNodesArray[nI] = n + # + del self.internalNodes + self.internalNodes = None + logEvent("Updating local to global mappings", 2) + self.updateLocal2Global() + logEvent("Building time integration object", 2) + logEvent(memory("inflowBC, internalNodes,updateLocal2Global", "OneLevelTransport"), level=4) + # mwf for interpolating subgrid error for gradients etc + if self.stabilization and self.stabilization.usesGradientStabilization: + self.timeIntegration = TimeIntegrationClass(self, integrateInterpolationPoints=True) + else: + self.timeIntegration = TimeIntegrationClass(self) + + if options is not None: + self.timeIntegration.setFromOptions(options) + logEvent(memory("TimeIntegration", "OneLevelTransport"), level=4) + logEvent("Calculating numerical quadrature formulas", 2) + self.calculateQuadrature() + self.setupFieldStrides() + + comm = Comm.get() + self.comm = comm + if comm.size() > 1: + assert numericalFluxType is not None and numericalFluxType.useWeakDirichletConditions, "You must use a numerical flux to apply weak boundary conditions for parallel runs" + + logEvent(memory("stride+offset", "OneLevelTransport"), level=4) + if numericalFluxType is not None: + if options is None or options.periodicDirichletConditions is None: + self.numericalFlux = numericalFluxType(self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict) + else: + self.numericalFlux = numericalFluxType(self, + dofBoundaryConditionsSetterDict, + advectiveFluxBoundaryConditionsSetterDict, + diffusiveFluxBoundaryConditionsSetterDictDict, + options.periodicDirichletConditions) + else: + self.numericalFlux = None + # set penalty terms + # cek todo move into numerical flux initialization + 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)) + # 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) + logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) + self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray + # use post processing tools to get conservative fluxes, None by default + from proteus import PostProcessingTools + self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser(self) + logEvent(memory("velocity postprocessor", "OneLevelTransport"), level=4) + # helper for writing out data storage + from proteus import Archiver + self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() + # TODO get rid of this + for ci, fbcObject in list(self.fluxBoundaryConditionsObjectsDict.items()): + self.ebqe[('advectiveFlux_bc_flag', ci)] = np.zeros(self.ebqe[('advectiveFlux_bc', ci)].shape, 'i') + for t, g in list(fbcObject.advectiveFluxBoundaryConditionsDict.items()): + if ci in self.coefficients.advection: + self.ebqe[('advectiveFlux_bc', ci)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t) + self.ebqe[('advectiveFlux_bc_flag', ci)][t[0], t[1]] = 1 + + if hasattr(self.numericalFlux, 'setDirichletValues'): + self.numericalFlux.setDirichletValues(self.ebqe) + if not hasattr(self.numericalFlux, 'isDOFBoundary'): + self.numericalFlux.isDOFBoundary = {0: np.zeros(self.ebqe[('u', 0)].shape, 'i')} + if not hasattr(self.numericalFlux, 'ebqe'): + self.numericalFlux.ebqe = {('u', 0): np.zeros(self.ebqe[('u', 0)].shape, 'd')} + # TODO how to handle redistancing calls for calculateCoefficients,calculateElementResidual etc + self.globalResidualDummy = None + compKernelFlag = 0 + self.vof = cVOF3P.newVOF3P( + self.nSpace_global, + self.nQuadraturePoints_element, + self.u[0].femSpace.elementMaps.localFunctionSpace.dim, + self.u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim, + self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim, + self.nElementBoundaryQuadraturePoints_elementBoundary, + compKernelFlag) + + self.forceStrongConditions = False + if self.forceStrongConditions: + self.dirichletConditionsForceDOF = DOFBoundaryConditions(self.u[0].femSpace, dofBoundaryConditionsSetterDict[0], weakDirichletConditions=False) + + if self.movingDomain: + self.MOVING_DOMAIN = 1.0 + else: + self.MOVING_DOMAIN = 0.0 + if self.mesh.nodeVelocityArray is None: + self.mesh.nodeVelocityArray = np.zeros(self.mesh.nodeArray.shape, 'd') + + # Stuff added by mql. + # Some ASSERTS to restrict the combination of the methods + if self.coefficients.STABILIZATION_TYPE > 1: + assert self.timeIntegration.isSSP == True, "If STABILIZATION_TYPE>1, use RKEV timeIntegration within VOF model" + cond = 'levelNonlinearSolver' in dir(options) and (options.levelNonlinearSolver == + ExplicitLumpedMassMatrix or options.levelNonlinearSolver == ExplicitConsistentMassMatrixForVOF) + assert cond, "If STABILIZATION_TYPE>1, use levelNonlinearSolver=ExplicitLumpedMassMatrix or ExplicitConsistentMassMatrixForVOF" + if 'levelNonlinearSolver' in dir(options) and options.levelNonlinearSolver == ExplicitLumpedMassMatrix: + assert self.coefficients.LUMPED_MASS_MATRIX, "If levelNonlinearSolver=ExplicitLumpedMassMatrix, use LUMPED_MASS_MATRIX=True" + if self.coefficients.LUMPED_MASS_MATRIX == True: + cond = 'levelNonlinearSolver' in dir(options) and options.levelNonlinearSolver == ExplicitLumpedMassMatrix + assert cond, "Use levelNonlinearSolver=ExplicitLumpedMassMatrix when the mass matrix is lumped" + if self.coefficients.FCT == True: + cond = self.coefficients.STABILIZATION_TYPE > 1, "Use FCT just with STABILIZATION_TYPE>1; i.e., edge based stabilization" + if self.coefficients.STABILIZATION_TYPE==1: + cond = 'levelNonlinearSolver' in dir(options) and options.levelNonlinearSolver == TwoStageNewton + assert cond, "If STABILIZATION_TYPE==1, use levelNonlinearSolver=TwoStageNewton" + if self.coefficients.STABILIZATION_TYPE==1: + self.useTwoStageNewton = True + assert isinstance(self.timeIntegration, proteus.TimeIntegration.BackwardEuler_cfl), "If STABILIZATION_TYPE=1, use BackwardEuler_cfl" + assert options.levelNonlinearSolver == TwoStageNewton, "If STABILIZATION_TYPE=1, use levelNonlinearSolver=TwoStageNewton" + assert self.coefficients.ENTROPY_TYPE in [0,1], "Set ENTROPY_TYPE={0,1}" + assert self.coefficients.STABILIZATION_TYPE in [0,1,2,3,4] + if self.coefficients.STABILIZATION_TYPE==4: + assert self.coefficients.FCT==True, "If STABILIZATION_TYPE=4, use FCT=True" + + # mql. Allow the user to provide functions to define the velocity field + self.hasVelocityFieldAsFunction = False + if ('velocityFieldAsFunction') in dir(options): + self.velocityFieldAsFunction = options.velocityFieldAsFunction + self.hasVelocityFieldAsFunction = True + + # For edge based methods + self.ML = None # lumped mass matrix + self.MC_global = None # consistent mass matrix + self.uLow = None + self.dt_times_dC_minus_dL = None + self.dLow = None + self.min_u_bc = None + self.max_u_bc = None + self.quantDOFs = np.zeros(self.u[0].dof.shape, 'd') + + # For Taylor Galerkin methods + self.stage = 1 + self.auxTaylorGalerkinFlag = 1 + self.uTilde_dof = np.zeros(self.u[0].dof.shape) + self.degree_polynomial = 1 + try: + self.degree_polynomial = self.u[0].femSpace.order + except: + pass + self.calculateJacobian = self.vof.calculateJacobian + if (self.coefficients.STABILIZATION_TYPE <= 1): # SUPG or Taylor Galerkin + self.calculateResidual = self.vof.calculateResidualElementBased + else: + self.calculateResidual = self.vof.calculateResidualEdgeBased + + def FCTStep(self): + rowptr, colind, MassMatrix = self.MC_global.getCSRrepresentation() + limited_solution = np.zeros(self.u[0].dof.shape) + + self.vof.FCTStep( + self.timeIntegration.dt, + self.nnz, + len(rowptr) - 1, # number of DOFs + self.ML, + self.u_dof_old, + self.timeIntegration.u, # high order solution + self.uLow, + self.dLow, + limited_solution, + rowptr, # Row indices for Sparsity Pattern (convenient for DOF loops) + colind, # Column indices for Sparsity Pattern (convenient for DOF loops) + MassMatrix, + self.dt_times_dC_minus_dL, + self.min_u_bc, + self.max_u_bc, + self.coefficients.LUMPED_MASS_MATRIX, + self.coefficients.STABILIZATION_TYPE) + #self.timeIntegration.u[:] = limited_solution + fromFreeToGlobal=0 #direction copying + cfemIntegrals.copyBetweenFreeUnknownsAndGlobalUnknowns(fromFreeToGlobal, + self.offset[0], + self.stride[0], + self.dirichletConditions[0].global2freeGlobal_global_dofs, + self.dirichletConditions[0].global2freeGlobal_free_dofs, + self.timeIntegration.u, + limited_solution) + + def updateVelocityFieldAsFunction(self): + X = {0: self.q[('x')][:, :, 0], + 1: self.q[('x')][:, :, 1], + 2: self.q[('x')][:, :, 2]} + t = self.timeIntegration.t + self.coefficients.q_v[..., 0] = self.velocityFieldAsFunction[0](X, t) + self.coefficients.q_v[..., 1] = self.velocityFieldAsFunction[1](X, t) + if (self.nSpace_global == 3): + self.coefficients.q_v[..., 2] = self.velocityFieldAsFunction[2](X, t) + + # BOUNDARY + ebqe_X = {0: self.ebqe['x'][:, :, 0], + 1: self.ebqe['x'][:, :, 1], + 2: self.ebqe['x'][:, :, 2]} + self.coefficients.ebqe_v[..., 0] = self.velocityFieldAsFunction[0](ebqe_X, t) + self.coefficients.ebqe_v[..., 1] = self.velocityFieldAsFunction[1](ebqe_X, t) + if (self.nSpace_global == 3): + self.coefficients.ebqe_v[..., 2] = self.velocityFieldAsFunction[2](ebqe_X, t) + + def calculateCoefficients(self): + pass + + def calculateElementResidual(self): + if self.globalResidualDummy is not None: + self.getResidual(self.u[0].dof, self.globalResidualDummy) + + def getMassMatrix(self): + # JACOBIANS (FOR ELEMENT TRANSFORMATION) + self.q[('J')] = np.zeros((self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global, + self.nSpace_global), + 'd') + self.q[('inverse(J)')] = np.zeros((self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nSpace_global, + self.nSpace_global), + 'd') + self.q[('det(J)')] = np.zeros((self.mesh.nElements_global, + self.nQuadraturePoints_element), + 'd') + self.u[0].femSpace.elementMaps.getJacobianValues(self.elementQuadraturePoints, + self.q['J'], + self.q['inverse(J)'], + self.q['det(J)']) + self.q['abs(det(J))'] = np.abs(self.q['det(J)']) + # SHAPE FUNCTIONS + self.q[('w',0)] = np.zeros((self.mesh.nElements_global, + self.nQuadraturePoints_element, + self.nDOF_test_element[0]), + 'd') + self.q[('w*dV_m',0)] = self.q[('w',0)].copy() + self.u[0].femSpace.getBasisValues(self.elementQuadraturePoints, self.q[('w',0)]) + cfemIntegrals.calculateWeightedShape(self.elementQuadratureWeights[('u',0)], + self.q['abs(det(J))'], + self.q[('w',0)], + self.q[('w*dV_m',0)]) + # assume a linear mass term + dm = np.ones(self.q[('u', 0)].shape, 'd') + elementMassMatrix = np.zeros((self.mesh.nElements_global, + self.nDOF_test_element[0], + self.nDOF_trial_element[0]), 'd') + cfemIntegrals.updateMassJacobian_weak_lowmem(dm, + self.q[('w', 0)], + self.q[('w*dV_m', 0)], + elementMassMatrix) + self.MC_a = self.nzval.copy() + self.MC_global = SparseMat(self.nFreeDOF_global[0], + self.nFreeDOF_global[0], + self.nnz, + self.MC_a, + self.colind, + self.rowptr) + cfemIntegrals.zeroJacobian_CSR(self.nnz, self.MC_global) + cfemIntegrals.updateGlobalJacobianFromElementJacobian_CSR(self.l2g[0]['nFreeDOF'], + self.l2g[0]['freeLocal'], + self.l2g[0]['nFreeDOF'], + self.l2g[0]['freeLocal'], + self.csrRowIndeces[(0, 0)], + self.csrColumnOffsets[(0, 0)], + elementMassMatrix, + self.MC_global) + + + self.ML = np.zeros((self.nFreeDOF_global[0],), 'd') + for i in range(self.nFreeDOF_global[0]): + self.ML[i] = self.MC_a[self.rowptr[i]:self.rowptr[i + 1]].sum() + np.testing.assert_almost_equal(self.ML.sum(), + self.mesh.volume, + err_msg="Trace of lumped mass matrix should be the domain volume", verbose=True) + + def initVectors(self): + if self.coefficients.vos_dof is None: + self.coefficients.vos_dof = np.zeros(self.u[0].dof.shape, 'd') + if self.u_dof_old is None: + # Pass initial condition to u_dof_old + self.u_dof_old = np.copy(self.u[0].dof) + + rowptr, colind, MC = self.MC_global.getCSRrepresentation() + # This is dummy. I just care about the csr structure of the sparse matrix + self.dt_times_dC_minus_dL = np.zeros(MC.shape, 'd') + self.uLow = np.zeros(self.u[0].dof.shape, 'd') + self.dLow = np.zeros(MC.shape, 'd') + + def getResidual(self, u, r): + import pdb + import copy + """ + Calculate the element residuals and add in to the global residual + """ + + if self.MC_global is None: + self.getMassMatrix() + self.initVectors() + + if self.coefficients.set_vos: + self.coefficients.set_vos(self.q['x'], self.coefficients.q_vos) + + # Reset some vectors for FCT + self.min_u_bc = np.zeros(self.u[0].dof.shape, 'd') + 1E10 + self.max_u_bc = np.zeros(self.u[0].dof.shape, 'd') - 1E10 + self.dt_times_dC_minus_dL.fill(0.0) + self.uLow.fill(0.0) + self.dLow.fill(0.0) + + r.fill(0.0) + # Load the unknowns into the finite element dof + self.timeIntegration.calculateCoefs() + self.timeIntegration.calculateU(u) + self.setUnknowns(self.timeIntegration.u) + # cek can put in logic to skip of BC's don't depend on t or u + # Dirichlet boundary conditions + # if hasattr(self.numericalFlux,'setDirichletValues'): + if (self.stage!=2): + self.numericalFlux.setDirichletValues(self.ebqe) + # flux boundary conditions + for t, g in list(self.fluxBoundaryConditionsObjectsDict[0].advectiveFluxBoundaryConditionsDict.items()): + self.ebqe[('advectiveFlux_bc', 0)][t[0], t[1]] = g(self.ebqe[('x')][t[0], t[1]], self.timeIntegration.t) + self.ebqe[('advectiveFlux_bc_flag', 0)][t[0], t[1]] = 1 + + if self.forceStrongConditions: + for dofN, g in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.items()): + self.u[0].dof[dofN] = g(self.dirichletConditionsForceDOF.DOFBoundaryPointDict[dofN], self.timeIntegration.t) + + if (self.stage==2 and self.auxTaylorGalerkinFlag==1): + self.uTilde_dof[:] = self.u[0].dof + self.auxTaylorGalerkinFlag=0 + + self.calculateResidual( # element + self.timeIntegration.dt, + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.nodeVelocityArray, + self.MOVING_DOMAIN, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.timeIntegration.alpha_bdf, + self.shockCapturing.lag, + self.shockCapturing.shockCapturingFactor, + self.coefficients.sc_uref, + self.coefficients.sc_beta, + # VRANS start + self.coefficients.q_vos, + self.coefficients.vos_dof, + # VRANS end + self.u[0].femSpace.dofMap.l2g, + self.l2g[0]['freeGlobal'], + self.mesh.elementDiametersArray, + self.degree_polynomial, + self.u[0].dof, + self.u_dof_old, # For Backward Euler this is un, for SSP this is the lstage + self.coefficients.q_v, + self.timeIntegration.m_tmp[0], + self.q[('u', 0)], + self.timeIntegration.beta_bdf[0], + self.q['dV'], + self.q['dV_last'], + self.q[('cfl', 0)], + self.edge_based_cfl, + self.shockCapturing.numDiff[0], + self.shockCapturing.numDiff_last[0], + self.offset[0], self.stride[0], + r, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.coefficients.ebqe_v, + # VRANS start + self.coefficients.ebqe_vos, + # VRANS end + self.numericalFlux.isDOFBoundary[0], + self.numericalFlux.ebqe[('u', 0)], + self.ebqe[('advectiveFlux_bc_flag', 0)], + self.ebqe[('advectiveFlux_bc', 0)], + self.coefficients.ebqe_phi, self.coefficients.epsFact, + self.ebqe[('u', 0)], + self.ebqe[('advectiveFlux', 0)], + # TAYLOR GALERKIN + self.stage, + self.uTilde_dof, + # ENTROPY VISCOSITY and ARTIFICIAL COMRPESSION + self.coefficients.cE, + self.coefficients.cMax, + self.coefficients.cK, + # PARAMETERS FOR LOG BASED ENTROPY FUNCTION + self.coefficients.uL, + self.coefficients.uR, + # PARAMETERS FOR EDGE VISCOSITY + len(self.rowptr) - 1, # num of DOFs + self.nnz, # num of non-zero entries in the sparsity pattern + self.rowptr, # Row indices for Sparsity Pattern (convenient for DOF loops) + self.colind, # Column indices for Sparsity Pattern (convenient for DOF loops) + self.csrRowIndeces[(0, 0)], # row indices (convenient for element loops) + self.csrColumnOffsets[(0, 0)], # column indices (convenient for element loops) + self.csrColumnOffsets_eb[(0, 0)], # indices for boundary terms + self.ML, + # PARAMETERS FOR 1st or 2nd ORDER MPP METHOD + self.coefficients.LUMPED_MASS_MATRIX, + self.coefficients.STABILIZATION_TYPE, + self.coefficients.ENTROPY_TYPE, + # FLUX CORRECTED TRANSPORT + self.uLow, + self.dLow, + self.dt_times_dC_minus_dL, + self.min_u_bc, + self.max_u_bc, + # AUX QUANTITIES OF INTEREST + self.quantDOFs) + + if self.forceStrongConditions: + for dofN, g in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.items()): + r[dofN] = 0 + + if (self.auxiliaryCallCalculateResidual == False): + edge_based_cflMax = globalMax(self.edge_based_cfl.max()) * self.timeIntegration.dt + cell_based_cflMax = globalMax(self.q[('cfl', 0)].max()) * self.timeIntegration.dt + logEvent("... Current dt = " + str(self.timeIntegration.dt), level=4) + logEvent("... Maximum Cell Based CFL = " + str(cell_based_cflMax), level=2) + logEvent("... Maximum Edge Based CFL = " + str(edge_based_cflMax), level=2) + + if self.stabilization: + self.stabilization.accumulateSubgridMassHistory(self.q) + logEvent("Global residual", level=9, data=r) + self.nonlinear_function_evaluations += 1 + if self.globalResidualDummy is None: + self.globalResidualDummy = np.zeros(r.shape, 'd') + + def getJacobian(self, jacobian): + cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, + jacobian) + + (rowptr, colind, globalJacobian) = jacobian.getCSRrepresentation() + self.calculateJacobian( # element + self.u[0].femSpace.elementMaps.psi, + self.u[0].femSpace.elementMaps.grad_psi, + self.mesh.nodeArray, + self.mesh.nodeVelocityArray, + self.MOVING_DOMAIN, + self.mesh.elementNodesArray, + self.elementQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + self.u[0].femSpace.psi, + self.u[0].femSpace.grad_psi, + # element boundary + self.u[0].femSpace.elementMaps.psi_trace, + self.u[0].femSpace.elementMaps.grad_psi_trace, + self.elementBoundaryQuadratureWeights[('u', 0)], + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.psi_trace, + self.u[0].femSpace.grad_psi_trace, + self.u[0].femSpace.elementMaps.boundaryNormals, + self.u[0].femSpace.elementMaps.boundaryJacobians, + # physics + self.mesh.nElements_global, + self.coefficients.useMetrics, + self.timeIntegration.alpha_bdf, + self.shockCapturing.lag, + self.shockCapturing.shockCapturingFactor, + # VRANS start + self.coefficients.q_vos, + # VRANS end + self.u[0].femSpace.dofMap.l2g, + self.l2g[0]['freeGlobal'], + self.mesh.elementDiametersArray, + self.u[0].dof, + self.coefficients.q_v, + self.timeIntegration.beta_bdf[0], + self.q[('cfl', 0)], + self.shockCapturing.numDiff_last[0], + self.csrRowIndeces[(0, 0)], self.csrColumnOffsets[(0, 0)], + globalJacobian, + self.mesh.nExteriorElementBoundaries_global, + self.mesh.exteriorElementBoundariesArray, + self.mesh.elementBoundaryElementsArray, + self.mesh.elementBoundaryLocalElementBoundariesArray, + self.coefficients.ebqe_v, + # VRANS start + self.coefficients.ebqe_vos, + # VRANS end + self.numericalFlux.isDOFBoundary[0], + self.numericalFlux.ebqe[('u', 0)], + self.ebqe[('advectiveFlux_bc_flag', 0)], + self.ebqe[('advectiveFlux_bc', 0)], + self.csrColumnOffsets_eb[(0, 0)], + self.coefficients.STABILIZATION_TYPE) + + # Load the Dirichlet conditions directly into residual + if self.forceStrongConditions: + scaling = 1.0 # probably want to add some scaling to match non-dirichlet diagonals in linear system + for dofN in list(self.dirichletConditionsForceDOF.DOFBoundaryConditionsDict.keys()): + global_dofN = dofN + for i in range(self.rowptr[global_dofN], + self.rowptr[global_dofN + 1]): + if (self.colind[i] == global_dofN): + # print "RBLES forcing residual cj = %s dofN= %s + # global_dofN= %s was self.nzval[i]= %s now =%s " % + # (cj,dofN,global_dofN,self.nzval[i],scaling) + self.nzval[i] = scaling + else: + self.nzval[i] = 0.0 + # print "RBLES zeroing residual cj = %s dofN= %s + # global_dofN= %s " % (cj,dofN,global_dofN) + logEvent("Jacobian ", level=10, data=jacobian) + # mwf decide if this is reasonable for solver statistics + self.nonlinear_function_jacobian_evaluations += 1 + return jacobian + + def calculateElementQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points. + + This function should be called only when the mesh changes. + """ + self.u[0].femSpace.elementMaps.getValues(self.elementQuadraturePoints, + self.q['x']) + self.u[0].femSpace.elementMaps.getBasisValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesRef( + self.elementQuadraturePoints) + self.u[0].femSpace.getBasisValuesRef(self.elementQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesRef(self.elementQuadraturePoints) + self.coefficients.initializeElementQuadrature(self.timeIntegration.t, + self.q) + if self.stabilization is not None: + self.stabilization.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + self.stabilization.initializeTimeIntegration(self.timeIntegration) + if self.shockCapturing is not None: + self.shockCapturing.initializeElementQuadrature( + self.mesh, self.timeIntegration.t, self.q) + + def calculateElementBoundaryQuadrature(self): + pass + + def calculateExteriorElementBoundaryQuadrature(self): + """ + Calculate the physical location and weights of the quadrature rules + and the shape information at the quadrature points on global element boundaries. + + This function should be called only when the mesh changes. + """ + # + # get physical locations of element boundary quadrature points + # + # assume all components live on the same mesh + self.u[0].femSpace.elementMaps.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.getBasisGradientValuesTraceRef( + self.elementBoundaryQuadraturePoints) + self.u[0].femSpace.elementMaps.getValuesGlobalExteriorTrace( + self.elementBoundaryQuadraturePoints, self.ebqe['x']) + self.fluxBoundaryConditionsObjectsDict = dict([(cj, FluxBoundaryConditions(self.mesh, + self.nElementBoundaryQuadraturePoints_elementBoundary, + self.ebqe[('x')], + self.advectiveFluxBoundaryConditionsSetterDict[cj], + self.diffusiveFluxBoundaryConditionsSetterDictDict[cj])) + for cj in list(self.advectiveFluxBoundaryConditionsSetterDict.keys())]) + self.coefficients.initializeGlobalExteriorElementBoundaryQuadrature( + self.timeIntegration.t, self.ebqe) + + def estimate_mt(self): + pass + + def calculateSolutionAtQuadrature(self): + pass + + def calculateAuxiliaryQuantitiesAfterStep(self): + pass + + def updateAfterMeshMotion(self): + pass diff --git a/proteus/richards/Richards.h b/proteus/richards/Richards.h index 536814027b..e790fd53a6 100644 --- a/proteus/richards/Richards.h +++ b/proteus/richards/Richards.h @@ -4,1271 +4,1292 @@ #include #include "CompKernel.h" #include "ModelFactory.h" +#include "xtensor-python/pyarray.hpp" #define nnz nSpace +namespace py = pybind11; + namespace proteus { - class Richards_base - { - //The base class defining the interface - public: - virtual ~Richards_base(){} - virtual void calculateResidual(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* meshVelocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - //physics - int nElements_global, - //new - double* ebqe_penalty_ext, - int* elementMaterialTypes, - int* isSeepageFace, - int* a_rowptr, - int* a_colind, - double rho, - double beta, - double* gravity, - double* alpha, - double* n, - double* thetaR, - double* thetaSR, - double* KWs, - //end new - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_dV, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int offset_u, int stride_u, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux)=0; - virtual void calculateJacobian(//element - double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - //element boundary - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - //physics - int nElements_global, - //new - double* ebqe_penalty_ext, - int* elementMaterialTypes, - int* isSeepageFace, - int* a_rowptr, - int* a_colind, - double rho, - double beta, - double* gravity, - double* alpha, - double* n, - double* thetaR, - double* thetaSR, - double* KWs, - //end new - double useMetrics, - double alphaBDF, - int lag_shockCapturing,/*mwf not used yet*/ - double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u)=0; - }; - - template - class Richards : public Richards_base - { - public: - const int nDOF_test_X_trial_element; - CompKernelType ck; - Richards(): - nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element), - ck() - {} - inline - void evaluateCoefficients(const int rowptr[nSpace], - const int colind[nnz], - const double rho, - const double beta, - const double gravity[nSpace], - const double alpha, - const double n_vg, - const double thetaR, - const double thetaSR, - const double KWs[nnz], - const double& u, - double& m, - double& dm, - double f[nSpace], - double df[nSpace], - double a[nnz], - double da[nnz]) + class Richards_base { - const int nSpace2=nSpace*nSpace; - register double psiC, - pcBar,pcBar_n,pcBar_nM1,pcBar_nM2, - onePlus_pcBar_n, - sBar,sqrt_sBar,DsBar_DpsiC, - thetaW,DthetaW_DpsiC, - vBar,vBar2,DvBar_DpsiC, - KWr,DKWr_DpsiC, - rho2=rho*rho, - thetaS, - rhom,drhom,m_vg,pcBarStar,sqrt_sBarStar; - psiC = -u; - m_vg = 1.0 - 1.0/n_vg; - thetaS = thetaR + thetaSR; - if (psiC > 0.0) - { - pcBar = alpha*psiC; - pcBarStar = pcBar; - if (pcBar < 1.0e-8) - pcBarStar=1.0e-8; - pcBar_nM2 = pow(pcBarStar,n_vg-2); - pcBar_nM1 = pcBar_nM2*pcBar; - pcBar_n = pcBar_nM1*pcBar; - onePlus_pcBar_n = 1.0 + pcBar_n; - - sBar = pow(onePlus_pcBar_n,-m_vg); - /* using -mn = 1-n */ - DsBar_DpsiC = alpha*(1.0-n_vg)*(sBar/onePlus_pcBar_n)*pcBar_nM1; - - vBar = 1.0-pcBar_nM1*sBar; - vBar2 = vBar*vBar; - DvBar_DpsiC = -alpha*(n_vg-1.0)*pcBar_nM2*sBar - pcBar_nM1*DsBar_DpsiC; - - thetaW = thetaSR*sBar + thetaR; - DthetaW_DpsiC = thetaSR * DsBar_DpsiC; - - sqrt_sBar = sqrt(sBar); - sqrt_sBarStar = sqrt_sBar; - if (sqrt_sBar < 1.0e-8) - sqrt_sBarStar = 1.0e-8; - KWr= sqrt_sBar*vBar2; - DKWr_DpsiC= ((0.5/sqrt_sBarStar)*DsBar_DpsiC*vBar2 - + - 2.0*sqrt_sBar*vBar*DvBar_DpsiC); - } - else - { - thetaW = thetaS; - DthetaW_DpsiC = 0.0; - KWr = 1.0; - DKWr_DpsiC = 0.0; - } - //slight compressibility - rhom = rho*exp(beta*u); - drhom = beta*rhom; - m = rhom*thetaW; - dm = -rhom*DthetaW_DpsiC+drhom*thetaW; - for (int I=0;I& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& meshVelocity_dof, + double MOVING_DOMAIN, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + //new + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& elementMaterialTypes, + xt::pyarray& isSeepageFace, + xt::pyarray& a_rowptr, + xt::pyarray& a_colind, + double rho, + double beta, + xt::pyarray& gravity, + xt::pyarray& alpha, + xt::pyarray& n, + xt::pyarray& thetaR, + xt::pyarray& thetaSR, + xt::pyarray& KWs, + //end new + double useMetrics, + double alphaBDF, + int lag_shockCapturing, + double shockCapturingDiffusion, + double sc_uref, + double sc_alpha, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_dV, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + int offset_u, + int stride_u, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& ebqe_phi, + double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux)=0; + virtual void calculateJacobian(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + //new + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& elementMaterialTypes, + xt::pyarray& isSeepageFace, + xt::pyarray& a_rowptr, + xt::pyarray& a_colind, + double rho, + double beta, + xt::pyarray& gravity, + xt::pyarray& alpha, + xt::pyarray& n, + xt::pyarray& thetaR, + xt::pyarray& thetaSR, + xt::pyarray& KWs, + //end new + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u, + xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_u_ext, + xt::pyarray& csrColumnOffsets_eb_u_u)=0; + }; - inline - void calculateSubgridError_tau(const double& elementDiameter, - const double& dmt, - const double dH[nSpace], - double& cfl, - double& tau) + template + class Richards : public Richards_base { - double h,nrm_v,oneByAbsdt; - h = elementDiameter; - nrm_v=0.0; - for(int I=0;I 0.0) + { + pcBar = alpha * psiC; + pcBarStar = pcBar; + if (pcBar < 1.0e-8) + pcBarStar = 1.0e-8; + pcBar_nM2 = pow(pcBarStar, n_vg - 2); + pcBar_nM1 = pcBar_nM2 * pcBar; + pcBar_n = pcBar_nM1 * pcBar; + onePlus_pcBar_n = 1.0 + pcBar_n; - inline - void calculateNumericalDiffusion(const double& shockCapturingDiffusion, - const double& elementDiameter, - const double& strong_residual, - const double grad_u[nSpace], - double& numDiff) - { - double h, - num, - den, - n_grad_u; - h = elementDiameter; - n_grad_u = 0.0; - for (int I=0;I 0.0) - { - isDOFBoundary = 1; - bc_u = bc_u_seepage; - } - else - { - isDOFBoundary = 0; - flux = 0.0; - } - } - /* //set DOF flag and flux correctly if seepage face */ - /* if (isSeepageFace) */ - /* { */ - /* if (flux < 0.0 || u < bc_u_seepage) */ - /* { */ - /* isDOFBoundary = 0; */ - /* flux = 0.0; */ - /* } */ - /* else */ - /* { */ - /* isDOFBoundary = 1; */ - /* bc_u = bc_u_seepage; */ - /* } */ - /* } */ - /* //Dirichlet penalty */ - /* if (isDOFBoundary) */ - /* flux += penalty*(u-bc_u); */ - } - else - flux = bc_flux; - } + vBar = 1.0-pcBar_nM1*sBar; + vBar2 = vBar*vBar; + DvBar_DpsiC = -alpha*(n_vg-1.0)*pcBar_nM2*sBar - pcBar_nM1*DsBar_DpsiC; - void exteriorNumericalFluxJacobian(const int rowptr[nSpace], - const int colind[nnz], - const int isDOFBoundary, - const double n[nSpace], - const double K[nnz], - const double dK[nnz], - const double grad_psi[nSpace], - const double grad_v[nSpace], - const double dK_rho_g[nSpace], - const double v, - const double penalty, - double& fluxJacobian) - { - if (isDOFBoundary) - { - fluxJacobian = 0.0; - for(int I=0;I 0.0) + { + isDOFBoundary = 1; + bc_u = bc_u_seepage; + } + else + { + isDOFBoundary = 0; + flux = 0.0; + } + } + /* //set DOF flag and flux correctly if seepage face */ + /* if (isSeepageFace) */ + /* { */ + /* if (flux < 0.0 || u < bc_u_seepage) */ + /* { */ + /* isDOFBoundary = 0; */ + /* flux = 0.0; */ + /* } */ + /* else */ + /* { */ + /* isDOFBoundary = 1; */ + /* bc_u = bc_u_seepage; */ + /* } */ + /* } */ + /* //Dirichlet penalty */ + /* if (isDOFBoundary) */ + /* flux += penalty*(u-bc_u); */ + } + else + flux = bc_flux; + } - globalResidual[offset_u+stride_u*u_l2g[eN_i]] += elementResidual_u[i]; - }//i - }//ebNE - } + void exteriorNumericalFluxJacobian(const int rowptr[nSpace], + const int colind[nnz], + const int isDOFBoundary, + const double n[nSpace], + const double K[nnz], + const double dK[nnz], + const double grad_psi[nSpace], + const double grad_v[nSpace], + const double dK_rho_g[nSpace], + const double v, + const double penalty, + double& fluxJacobian) + { + if (isDOFBoundary) + { + fluxJacobian = 0.0; + for(int I=0;I& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + //new + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& elementMaterialTypes, + xt::pyarray& isSeepageFace, + xt::pyarray& a_rowptr, + xt::pyarray& a_colind, + double rho, + double beta, + xt::pyarray& gravity, + xt::pyarray& alpha, + xt::pyarray& n, + xt::pyarray& thetaR, + xt::pyarray& thetaSR, + xt::pyarray& KWs, + //end new + double useMetrics, + double alphaBDF, + int lag_shockCapturing, /*mwf not used yet*/ + double shockCapturingDiffusion, + double sc_uref, + double sc_alpha, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& u_dof_old, + xt::pyarray& velocity, + xt::pyarray& q_m, + xt::pyarray& q_u, + xt::pyarray& q_dV, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u, + xt::pyarray& q_numDiff_u_last, + int offset_u, int stride_u, + xt::pyarray& globalResidual, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_ext, + xt::pyarray& ebqe_phi, + double epsFact, + xt::pyarray& ebqe_u, + xt::pyarray& ebqe_flux) + { + assert(a_rowptr.data()[nSpace] == nnz); + assert(a_rowptr.data()[nSpace] == nSpace); + //cek should this be read in? + double Ct_sge = 4.0; + + //loop over elements to compute volume integrals and load them into element and global residual + // + //eN is the element index + //eN_k is the quadrature point index for a scalar + //eN_k_nSpace is the quadrature point index for a vector + //eN_i is the element test function index + //eN_j is the element trial function index + //eN_k_j is the quadrature point index for a trial function + //eN_k_i is the quadrature point index for a trial function + for(int eN=0;eN(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); - } + void calculateJacobian(//element + xt::pyarray& mesh_trial_ref, + xt::pyarray& mesh_grad_trial_ref, + xt::pyarray& mesh_dof, + xt::pyarray& mesh_velocity_dof, + double MOVING_DOMAIN, + xt::pyarray& mesh_l2g, + xt::pyarray& dV_ref, + xt::pyarray& u_trial_ref, + xt::pyarray& u_grad_trial_ref, + xt::pyarray& u_test_ref, + xt::pyarray& u_grad_test_ref, + //element boundary + xt::pyarray& mesh_trial_trace_ref, + xt::pyarray& mesh_grad_trial_trace_ref, + xt::pyarray& dS_ref, + xt::pyarray& u_trial_trace_ref, + xt::pyarray& u_grad_trial_trace_ref, + xt::pyarray& u_test_trace_ref, + xt::pyarray& u_grad_test_trace_ref, + xt::pyarray& normal_ref, + xt::pyarray& boundaryJac_ref, + //physics + int nElements_global, + //new + xt::pyarray& ebqe_penalty_ext, + xt::pyarray& elementMaterialTypes, + xt::pyarray& isSeepageFace, + xt::pyarray& a_rowptr, + xt::pyarray& a_colind, + double rho, + double beta, + xt::pyarray& gravity, + xt::pyarray& alpha, + xt::pyarray& n, + xt::pyarray& thetaR, + xt::pyarray& thetaSR, + xt::pyarray& KWs, + //end new + double useMetrics, + double alphaBDF, + int lag_shockCapturing,/*mwf not used yet*/ + double shockCapturingDiffusion, + xt::pyarray& u_l2g, + xt::pyarray& elementDiameter, + xt::pyarray& u_dof, + xt::pyarray& velocity, + xt::pyarray& q_m_betaBDF, + xt::pyarray& cfl, + xt::pyarray& q_numDiff_u_last, + xt::pyarray& csrRowIndeces_u_u,xt::pyarray& csrColumnOffsets_u_u, + xt::pyarray& globalJacobian, + int nExteriorElementBoundaries_global, + xt::pyarray& exteriorElementBoundariesArray, + xt::pyarray& elementBoundaryElementsArray, + xt::pyarray& elementBoundaryLocalElementBoundariesArray, + xt::pyarray& ebqe_velocity_ext, + xt::pyarray& isDOFBoundary_u, + xt::pyarray& ebqe_bc_u_ext, + xt::pyarray& isFluxBoundary_u, + xt::pyarray& ebqe_bc_flux_ext, + xt::pyarray& csrColumnOffsets_eb_u_u) + { + assert(a_rowptr.data()[nSpace] == nnz); + assert(a_rowptr.data()[nSpace] == nSpace); + double Ct_sge = 4.0; + + // + //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian + // + for(int eN=0;eN(nSpaceIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, + CompKernelFlag); + } }//proteus #endif diff --git a/proteus/richards/Richards.py b/proteus/richards/Richards.py index 17d5f26944..0033919b5c 100644 --- a/proteus/richards/Richards.py +++ b/proteus/richards/Richards.py @@ -3,6 +3,10 @@ from past.utils import old_div import proteus from .cRichards import * +import numpy +from proteus import * +from proteus.Transport import * +from proteus.Transport import OneLevelTransport class Coefficients(proteus.TransportCoefficients.TC_base): """ @@ -732,7 +736,7 @@ def getJacobian(self,jacobian): self.q[('cfl',0)], self.q[('cfl',0)],#cek hack self.shockCapturing.numDiff_last[0], self.csrRowIndeces[(0,0)],self.csrColumnOffsets[(0,0)], - jacobian, + jacobian.getCSRrepresentation()[2], self.mesh.nExteriorElementBoundaries_global, self.mesh.exteriorElementBoundariesArray, self.mesh.elementBoundaryElementsArray, diff --git a/proteus/richards/cRichards.cpp b/proteus/richards/cRichards.cpp new file mode 100644 index 0000000000..aff98edf1b --- /dev/null +++ b/proteus/richards/cRichards.cpp @@ -0,0 +1,29 @@ +#include "pybind11/pybind11.h" +#include "pybind11/stl_bind.h" + +#define FORCE_IMPORT_ARRAY +#include "Richards.h" + +#if defined(__GNUC__) && !defined(__clang__) + namespace workaround + { + inline void define_allocators() + { + std::allocator a0; + std::allocator a1; + } + } +#endif + +namespace py = pybind11; +using proteus::Richards_base; + +PYBIND11_MODULE(cRichards, m) +{ + xt::import_numpy(); + + py::class_(m, "cRichards_base") + .def(py::init(&proteus::newRichards)) + .def("calculateResidual", &Richards_base::calculateResidual) + .def("calculateJacobian", &Richards_base::calculateJacobian); +} diff --git a/proteus/richards/cRichards.pyx b/proteus/richards/cRichards.pyx deleted file mode 100644 index de3720f038..0000000000 --- a/proteus/richards/cRichards.pyx +++ /dev/null @@ -1,405 +0,0 @@ -import numpy -cimport numpy -from proteus import * -from proteus.Transport import * -from proteus.Transport import OneLevelTransport - -cdef extern from "Richards.h" namespace "proteus": - cdef cppclass Richards_base: - void calculateResidual(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - double* ebqe_penalty_ext, - int* elementMaterialTypes, - int* isSeepageFace, - int* a_rowptr, - int* a_colind, - double rho, - double beta, - double* gravity, - double* alpha, - double* n, - double* thetaR, - double* thetaSR, - double* KWs, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - int* u_l2g, - double* elementDiameter, - double* u_dof,double* u_dof_old, - double* velocity, - double* q_m, - double* q_u, - double* q_dV, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u, - double* q_numDiff_u_last, - int offset_u, int stride_u, - double* globalResidual, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - double* ebqe_phi,double epsFact, - double* ebqe_u, - double* ebqe_flux) - void calculateJacobian(double* mesh_trial_ref, - double* mesh_grad_trial_ref, - double* mesh_dof, - double* mesh_velocity_dof, - double MOVING_DOMAIN, - int* mesh_l2g, - double* dV_ref, - double* u_trial_ref, - double* u_grad_trial_ref, - double* u_test_ref, - double* u_grad_test_ref, - double* mesh_trial_trace_ref, - double* mesh_grad_trial_trace_ref, - double* dS_ref, - double* u_trial_trace_ref, - double* u_grad_trial_trace_ref, - double* u_test_trace_ref, - double* u_grad_test_trace_ref, - double* normal_ref, - double* boundaryJac_ref, - int nElements_global, - double* ebqe_penalty_ext, - int* elementMaterialTypes, - int* isSeepageFace, - int* a_rowptr, - int* a_colind, - double rho, - double beta, - double* gravity, - double* alpha, - double* n, - double* thetaR, - double* thetaSR, - double* KWs, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - int* u_l2g, - double* elementDiameter, - double* u_dof, - double* velocity, - double* q_m_betaBDF, - double* cfl, - double* q_numDiff_u_last, - int* csrRowIndeces_u_u,int* csrColumnOffsets_u_u, - double* globalJacobian, - int nExteriorElementBoundaries_global, - int* exteriorElementBoundariesArray, - int* elementBoundaryElementsArray, - int* elementBoundaryLocalElementBoundariesArray, - double* ebqe_velocity_ext, - int* isDOFBoundary_u, - double* ebqe_bc_u_ext, - int* isFluxBoundary_u, - double* ebqe_bc_flux_u_ext, - int* csrColumnOffsets_eb_u_u) - Richards_base* newRichards(int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag) - -cdef class cRichards_base: - cdef Richards_base* thisptr - def __cinit__(self, - int nSpaceIn, - int nQuadraturePoints_elementIn, - int nDOF_mesh_trial_elementIn, - int nDOF_trial_elementIn, - int nDOF_test_elementIn, - int nQuadraturePoints_elementBoundaryIn, - int CompKernelFlag): - self.thisptr = newRichards(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag) - def __dealloc__(self): - del self.thisptr - def calculateResidual(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray elementMaterialTypes, - numpy.ndarray isSeepageFace, - numpy.ndarray a_rowptr, - numpy.ndarray a_colind, - double rho, - double beta, - numpy.ndarray gravity, - numpy.ndarray alpha, - numpy.ndarray n, - numpy.ndarray thetaR, - numpy.ndarray thetaSR, - numpy.ndarray KWs, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - double sc_uref, double sc_alpha, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray u_dof_old, - numpy.ndarray velocity, - numpy.ndarray q_m, - numpy.ndarray q_u, - numpy.ndarray q_dV, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u, - numpy.ndarray q_numDiff_u_last, - int offset_u, int stride_u, - numpy.ndarray globalResidual, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray ebqe_phi,double epsFact, - numpy.ndarray ebqe_u, - numpy.ndarray ebqe_flux): - self.thisptr.calculateResidual( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - ebqe_penalty_ext.data, - elementMaterialTypes.data, - isSeepageFace.data, - a_rowptr.data, - a_colind.data, - rho, - beta, - gravity.data, - alpha.data, - n.data, - thetaR.data, - thetaSR.data, - KWs.data, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - sc_uref, sc_alpha, - u_l2g.data, - elementDiameter.data, - u_dof.data, - u_dof_old.data, - velocity.data, - q_m.data, - q_u.data, - q_dV.data, - q_m_betaBDF.data, - cfl.data, - q_numDiff_u.data, - q_numDiff_u_last.data, - offset_u, stride_u, - globalResidual.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_velocity_ext.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - ebqe_phi.data, - epsFact, - ebqe_u.data, - ebqe_flux.data) - def calculateJacobian(self, - numpy.ndarray mesh_trial_ref, - numpy.ndarray mesh_grad_trial_ref, - numpy.ndarray mesh_dof, - numpy.ndarray mesh_velocity_dof, - double MOVING_DOMAIN, - numpy.ndarray mesh_l2g, - numpy.ndarray dV_ref, - numpy.ndarray u_trial_ref, - numpy.ndarray u_grad_trial_ref, - numpy.ndarray u_test_ref, - numpy.ndarray u_grad_test_ref, - numpy.ndarray mesh_trial_trace_ref, - numpy.ndarray mesh_grad_trial_trace_ref, - numpy.ndarray dS_ref, - numpy.ndarray u_trial_trace_ref, - numpy.ndarray u_grad_trial_trace_ref, - numpy.ndarray u_test_trace_ref, - numpy.ndarray u_grad_test_trace_ref, - numpy.ndarray normal_ref, - numpy.ndarray boundaryJac_ref, - int nElements_global, - numpy.ndarray ebqe_penalty_ext, - numpy.ndarray elementMaterialTypes, - numpy.ndarray isSeepageFace, - numpy.ndarray a_rowptr, - numpy.ndarray a_colind, - double rho, - double beta, - numpy.ndarray gravity, - numpy.ndarray alpha, - numpy.ndarray n, - numpy.ndarray thetaR, - numpy.ndarray thetaSR, - numpy.ndarray KWs, - double useMetrics, - double alphaBDF, - int lag_shockCapturing, - double shockCapturingDiffusion, - numpy.ndarray u_l2g, - numpy.ndarray elementDiameter, - numpy.ndarray u_dof, - numpy.ndarray velocity, - numpy.ndarray q_m_betaBDF, - numpy.ndarray cfl, - numpy.ndarray q_numDiff_u_last, - numpy.ndarray csrRowIndeces_u_u,numpy.ndarray csrColumnOffsets_u_u, - globalJacobian, - int nExteriorElementBoundaries_global, - numpy.ndarray exteriorElementBoundariesArray, - numpy.ndarray elementBoundaryElementsArray, - numpy.ndarray elementBoundaryLocalElementBoundariesArray, - numpy.ndarray ebqe_velocity_ext, - numpy.ndarray isDOFBoundary_u, - numpy.ndarray ebqe_bc_u_ext, - numpy.ndarray isFluxBoundary_u, - numpy.ndarray ebqe_bc_flux_u_ext, - numpy.ndarray csrColumnOffsets_eb_u_u): - cdef numpy.ndarray rowptr,colind,globalJacobian_a - (rowptr,colind,globalJacobian_a) = globalJacobian.getCSRrepresentation() - self.thisptr.calculateJacobian( mesh_trial_ref.data, - mesh_grad_trial_ref.data, - mesh_dof.data, - mesh_velocity_dof.data, - MOVING_DOMAIN, - mesh_l2g.data, - dV_ref.data, - u_trial_ref.data, - u_grad_trial_ref.data, - u_test_ref.data, - u_grad_test_ref.data, - mesh_trial_trace_ref.data, - mesh_grad_trial_trace_ref.data, - dS_ref.data, - u_trial_trace_ref.data, - u_grad_trial_trace_ref.data, - u_test_trace_ref.data, - u_grad_test_trace_ref.data, - normal_ref.data, - boundaryJac_ref.data, - nElements_global, - ebqe_penalty_ext.data, - elementMaterialTypes.data, - isSeepageFace.data, - a_rowptr.data, - a_colind.data, - rho, - beta, - gravity.data, - alpha.data, - n.data, - thetaR.data, - thetaSR.data, - KWs.data, - useMetrics, - alphaBDF, - lag_shockCapturing, - shockCapturingDiffusion, - u_l2g.data, - elementDiameter.data, - u_dof.data, - velocity.data, - q_m_betaBDF.data, - cfl.data, - q_numDiff_u_last.data, - csrRowIndeces_u_u.data, csrColumnOffsets_u_u.data, - globalJacobian_a.data, - nExteriorElementBoundaries_global, - exteriorElementBoundariesArray.data, - elementBoundaryElementsArray.data, - elementBoundaryLocalElementBoundariesArray.data, - ebqe_velocity_ext.data, - isDOFBoundary_u.data, - ebqe_bc_u_ext.data, - isFluxBoundary_u.data, - ebqe_bc_flux_u_ext.data, - csrColumnOffsets_eb_u_u.data) diff --git a/setup.py b/setup.py index 7d567fc215..ebaf814aff 100644 --- a/setup.py +++ b/setup.py @@ -6,10 +6,7 @@ if type(value) == str: cfg_vars[key] = cfg_vars[key].replace("-Wstrict-prototypes", "") cfg_vars[key] = cfg_vars[key].replace("-Wall", "-w") - #cfg_vars[key] = cfg_vars[key].replace("-O3", "") - #cfg_vars[key] = cfg_vars[key].replace("-O2", "") - #cfg_vars[key] = cfg_vars[key].replace("-DNDEBUG", "-UNDEBUG") - #cfg_vars[key] = cfg_vars[key].replace(" -g ", " ")#linux-gnu gotcha + from distutils.core import setup, Extension from Cython.Build import cythonize @@ -43,8 +40,49 @@ proteus_install_path = proteus_install_path.partition(sys.prefix + '/')[-1] break +def get_xtensor_include(): + return [str(get_pybind_include()), + str(get_pybind_include(user=True)), + str(get_numpy_include()), + os.path.join(sys.prefix, 'include'), + os.path.join(sys.prefix, 'Library', 'include'), + 'proteus', + 'proteus/xtensor/pybind11/include', + 'proteus/xtensor/xtensor-python/include', + 'proteus/xtensor/xtensor/include', + 'proteus/xtensor/xtl/include'] + +class get_pybind_include(object): + """Helper class to determine the pybind11 include path + + The purpose of this class is to postpone importing pybind11 + until it is actually installed, so that the ``get_include()`` + method can be invoked. """ + + def __init__(self, user=False): + self.user = user + + def __str__(self): + import pybind11 + return pybind11.get_include(self.user) + + +class get_numpy_include(object): + """Helper class to determine the numpy include path + + The purpose of this class is to postpone importing numpy + until it is actually installed, so that the ``get_include()`` + method can be invoked. """ + + def __init__(self): + pass + + def __str__(self): + import numpy as np + return np.get_include() + EXTENSIONS_TO_BUILD = [ - Extension("MeshAdaptPUMI.MeshAdaptPUMI", + Extension("MeshAdaptPUMI.MeshAdaptPUMI", sources = ['proteus/MeshAdaptPUMI/MeshAdaptPUMI.pyx', 'proteus/MeshAdaptPUMI/cMeshAdaptPUMI.cpp', 'proteus/MeshAdaptPUMI/MeshConverter.cpp', 'proteus/MeshAdaptPUMI/ParallelMeshConverter.cpp', 'proteus/MeshAdaptPUMI/MeshFields.cpp', 'proteus/MeshAdaptPUMI/SizeField.cpp', @@ -66,95 +104,109 @@ libraries=PROTEUS_SCOREC_LIBS, extra_compile_args=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.cPres",['proteus/mprans/cPres.pyx'], - depends=['proteus/mprans/Pres.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus'],), - Extension("mprans.cPresInit",['proteus/mprans/cPresInit.pyx'], - depends=['proteus/mprans/PresInit.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cPresInc",['proteus/mprans/cPresInc.pyx'], - depends=['proteus/mprans/PresInc.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cAddedMass",['proteus/mprans/cAddedMass.pyx'], + Extension( + 'mprans.cPres', + ['proteus/mprans/Pres.cpp'], + depends=['proteus/mprans/Pres.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cPresInit', + ['proteus/mprans/PresInit.cpp'], + depends=['proteus/mprans/PresInit.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cPresInc', + ['proteus/mprans/PresInc.cpp'], + depends=['proteus/mprans/PresInc.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension('mprans.cAddedMass', ['proteus/mprans/AddedMass.cpp'], depends=['proteus/mprans/AddedMass.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.SedClosure",['proteus/mprans/SedClosure.pyx'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14']), + Extension('mprans.SedClosure', ['proteus/mprans/SedClosure.cpp'], depends=['proteus/mprans/SedClosure.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cVOF3P",['proteus/mprans/cVOF3P.pyx'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14']), + Extension('mprans.cVOF3P', ['proteus/mprans/VOF3P.cpp'], depends=['proteus/mprans/VOF3P.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cVOS3P",['proteus/mprans/cVOS3P.pyx'], - depends=['proteus/mprans/VOS3P.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cNCLS3P",['proteus/mprans/cNCLS3P.pyx'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14']), + Extension( + 'mprans.cVOS3P', + ['proteus/mprans/VOS3P.cpp'], + depends=['proteus/mprans/VOS3P.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension('mprans.cNCLS3P', ['proteus/mprans/NCLS3P.cpp'], depends=['proteus/mprans/NCLS3P.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cMCorr3P", - ["proteus/mprans/cMCorr3P.pyx"], - depends=["proteus/mprans/MCorr3P.h", 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - define_macros=[('PROTEUS_LAPACK_H', - PROTEUS_LAPACK_H), - ('PROTEUS_LAPACK_INTEGER', - PROTEUS_LAPACK_INTEGER), - ('PROTEUS_BLAS_H', - PROTEUS_BLAS_H)], - language="c++", - include_dirs=[numpy.get_include(), 'proteus'], - library_dirs=[PROTEUS_LAPACK_LIB_DIR, - PROTEUS_BLAS_LIB_DIR], - libraries=['m',PROTEUS_LAPACK_LIB, - PROTEUS_BLAS_LIB], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT, - extra_link_args=PROTEUS_EXTRA_LINK_ARGS), - Extension("richards.cRichards",['proteus/richards/cRichards.pyx'], - depends=['proteus/richards/Richards.h','proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14']), + Extension('mprans.cMCorr3P', ['proteus/mprans/MCorr3P.cpp'], + depends=['proteus/mprans/MCorr3P.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), - Extension("elastoplastic.cElastoPlastic", - ['proteus/elastoplastic/cElastoPlastic.pyx'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + extra_link_args=PROTEUS_EXTRA_LINK_ARGS, define_macros=[('PROTEUS_LAPACK_H', PROTEUS_LAPACK_H), ('PROTEUS_LAPACK_INTEGER', PROTEUS_LAPACK_INTEGER), ('PROTEUS_BLAS_H', PROTEUS_BLAS_H)], - depends=['proteus/elastoplastic/ElastoPlastic.h','proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - include_dirs=[numpy.get_include(),'proteus'], library_dirs=[PROTEUS_LAPACK_LIB_DIR, PROTEUS_BLAS_LIB_DIR], libraries=['m',PROTEUS_LAPACK_LIB, PROTEUS_BLAS_LIB], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT, - extra_link_args=PROTEUS_EXTRA_LINK_ARGS), + ), + Extension( + 'mprans.RANS3PSed', + ['proteus/mprans/RANS3PSed.cpp'], + depends=['proteus/mprans/RANS3PSed.h','proteus/mprans/RANS3PSed2D.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'richards.cRichards', + ['proteus/richards/cRichards.cpp'], + depends=['proteus/richards/Richards.h','proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + language='c++', + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + ), + Extension( + 'elastoplastic.cElastoPlastic', + ['proteus/elastoplastic/cElastoPlastic.cpp'], + define_macros=[('PROTEUS_LAPACK_H', + PROTEUS_LAPACK_H), + ('PROTEUS_LAPACK_INTEGER', + PROTEUS_LAPACK_INTEGER), + ('PROTEUS_BLAS_H', + PROTEUS_BLAS_H)], + depends=['proteus/elastoplastic/ElastoPlastic.h','proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + language='c++', + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + library_dirs=[PROTEUS_LAPACK_LIB_DIR, + PROTEUS_BLAS_LIB_DIR], + libraries=['m',PROTEUS_LAPACK_LIB, + PROTEUS_BLAS_LIB] + ), Extension("mprans.cRANS3PF",['proteus/mprans/cRANS3PF.pyx'], depends=['proteus/mprans/RANS3PF.h','proteus/mprans/RANS3PF2D.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', - extra_compile_args=PROTEUS_OPT+["-std=c++11","-mavx"], - include_dirs=[numpy.get_include(),'proteus']), - Extension("mprans.cRANS3PSed",['proteus/mprans/cRANS3PSed.pyx'], - depends=['proteus/mprans/RANS3PSed.h','proteus/mprans/RANS3PSed2D.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), + extra_compile_args=PROTEUS_OPT+["-std=c++14","-mavx"], + include_dirs=get_xtensor_include()), Extension("Isosurface",['proteus/Isosurface.pyx'], language='c', extra_compile_args=PROTEUS_OPT, @@ -221,11 +273,14 @@ library_dirs=[PROTEUS_NCURSES_LIB_DIR,], libraries=['ncurses','stdc++','m'], extra_compile_args=["-std=c++11"]), - Extension("ADR",['proteus/ADR.pyx'], - depends=['proteus/ADR.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - language='c++', - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(),'proteus']), + Extension( + 'ADR', + ['proteus/ADR.cpp'], + depends=['proteus/ADR.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++' + ), Extension("subsurfaceTransportFunctions",['proteus/subsurfaceTransportFunctions.pyx'], include_dirs=[numpy.get_include(),'proteus'], extra_compile_args=PROTEUS_OPT, @@ -520,112 +575,147 @@ extra_link_args=PROTEUS_EXTRA_LINK_ARGS + PROTEUS_PETSC_EXTRA_LINK_ARGS, extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS + PROTEUS_PETSC_EXTRA_COMPILE_ARGS+PROTEUS_OPT, ), - Extension("mprans.cCLSVOF",["proteus/mprans/cCLSVOF.pyx"], - depends=["proteus/mprans/CLSVOF.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cNCLS",["proteus/mprans/cNCLS.pyx"], - depends=["proteus/mprans/NCLS.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cMCorr",["proteus/mprans/cMCorr.pyx"], - depends=["proteus/mprans/MCorr.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ - "proteus/equivalent_polynomials.h", - "proteus/equivalent_polynomials_utils.h", - "proteus/equivalent_polynomials_coefficients.h"], - define_macros=[('PROTEUS_LAPACK_H',PROTEUS_LAPACK_H), - ('PROTEUS_LAPACK_INTEGER',PROTEUS_LAPACK_INTEGER), - ('PROTEUS_BLAS_H',PROTEUS_BLAS_H)],language="c++", - include_dirs=[numpy.get_include(), 'proteus'], - library_dirs=[PROTEUS_LAPACK_LIB_DIR, - PROTEUS_BLAS_LIB_DIR], - libraries=['m',PROTEUS_LAPACK_LIB,PROTEUS_BLAS_LIB], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT+["-std=c++11"], - extra_link_args=PROTEUS_EXTRA_LINK_ARGS), - Extension("mprans.cRANS2P",["proteus/mprans/cRANS2P.pyx"], - depends=["proteus/mprans/RANS2P.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ - "proteus/equivalent_polynomials.h", - "proteus/equivalent_polynomials_utils.h", - "proteus/equivalent_polynomials_coefficients.h"], - extra_compile_args=PROTEUS_OPT+["-std=c++11"], - language="c++", include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cRANS2P_IB",["proteus/mprans/cRANS2P_IB.pyx"], - depends=["proteus/mprans/RANS2P_IB.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ - "proteus/equivalent_polynomials.h", - "proteus/equivalent_polynomials_utils.h", - "proteus/equivalent_polynomials_coefficients.h"], - extra_compile_args=PROTEUS_OPT+["-std=c++11"], - language="c++", include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cRANS2P2D",["proteus/mprans/cRANS2P2D.pyx"], - depends=["proteus/mprans/RANS2P2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"]+ [ - "proteus/equivalent_polynomials.h", - "proteus/equivalent_polynomials_utils.h", - "proteus/equivalent_polynomials_coefficients.h"], - language="c++", - extra_compile_args=PROTEUS_OPT+["-std=c++11"], - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cRDLS",["proteus/mprans/cRDLS.pyx"], - depends=["proteus/mprans/RDLS.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"]+ [ - "proteus/equivalent_polynomials.h", - "proteus/equivalent_polynomials_utils.h", - "proteus/equivalent_polynomials_coefficients.h"], - language="c++", - extra_compile_args=PROTEUS_OPT+["-std=c++11"], - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cVOF",["proteus/mprans/cVOF.pyx"], - depends=["proteus/mprans/VOF.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cMoveMesh",["proteus/mprans/cMoveMesh.pyx"], - depends=["proteus/mprans/MoveMesh.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cMoveMesh2D",["proteus/mprans/cMoveMesh2D.pyx"], - depends=["proteus/mprans/MoveMesh2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cSW2D",["proteus/mprans/cSW2D.pyx"], - depends=["proteus/mprans/SW2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - include_dirs=[numpy.get_include(), 'proteus'], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+['-g']+PROTEUS_OPT, - extra_link_args=PROTEUS_EXTRA_LINK_ARGS+['-g']), - Extension("mprans.cSW2DCV",["proteus/mprans/cSW2DCV.pyx"], - depends=["proteus/mprans/SW2DCV.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - include_dirs=[numpy.get_include(), 'proteus'], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+['-g']+PROTEUS_OPT, - extra_link_args=PROTEUS_EXTRA_LINK_ARGS+['-g']), - Extension("mprans.cGN_SW2DCV",["proteus/mprans/cGN_SW2DCV.pyx"], - depends=["proteus/mprans/GN_SW2DCV.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - include_dirs=[numpy.get_include(), 'proteus'], - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+['-g']+PROTEUS_OPT, - extra_link_args=PROTEUS_EXTRA_LINK_ARGS+['-g']), - Extension("mprans.cKappa",["proteus/mprans/cKappa.pyx"], - depends=["proteus/mprans/Kappa.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cKappa2D",["proteus/mprans/cKappa2D.pyx"], - depends=["proteus/mprans/Kappa2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cDissipation",["proteus/mprans/cDissipation.pyx"], - depends=["proteus/mprans/Dissipation.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), - Extension("mprans.cDissipation2D",["proteus/mprans/cDissipation2D.pyx"], - depends=["proteus/mprans/Dissipation2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], - language="c++", - extra_compile_args=PROTEUS_OPT, - include_dirs=[numpy.get_include(), 'proteus']), + Extension( + 'mprans.cCLSVOF', + ['proteus/mprans/CLSVOF.cpp'], + depends=["proteus/mprans/CLSVOF.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cNCLS', + ['proteus/mprans/NCLS.cpp'], + depends=["proteus/mprans/NCLS.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cMCorr', + ['proteus/mprans/MCorr.cpp'], + depends=["proteus/mprans/MCorr.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ + "proteus/equivalent_polynomials.h", + "proteus/equivalent_polynomials_utils.h", + "proteus/equivalent_polynomials_coefficients.h"], + define_macros=[('PROTEUS_LAPACK_H',PROTEUS_LAPACK_H), + ('PROTEUS_LAPACK_INTEGER',PROTEUS_LAPACK_INTEGER), + ('PROTEUS_BLAS_H',PROTEUS_BLAS_H)], + include_dirs=get_xtensor_include(), + library_dirs=[PROTEUS_LAPACK_LIB_DIR, + PROTEUS_BLAS_LIB_DIR], + libraries=['m',PROTEUS_LAPACK_LIB,PROTEUS_BLAS_LIB], + extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT+['-std=c++14'], + extra_link_args=PROTEUS_EXTRA_LINK_ARGS, + language='c++'), + Extension( + 'mprans.cRANS2P', + ['proteus/mprans/RANS2P.cpp'], + depends=["proteus/mprans/RANS2P.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + "proteus/equivalent_polynomials.h", + "proteus/equivalent_polynomials_utils.h", + "proteus/equivalent_polynomials_coefficients.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cRANS2P_IB', + ['proteus/mprans/RANS2P_IB.cpp'], + depends=["proteus/mprans/RANS2P_IB.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + "proteus/equivalent_polynomials.h", + "proteus/equivalent_polynomials_utils.h", + "proteus/equivalent_polynomials_coefficients.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cRANS2P2D', + ['proteus/mprans/RANS2P2D.cpp'], + depends=["proteus/mprans/RANS2P2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + "proteus/equivalent_polynomials.h", + "proteus/equivalent_polynomials_utils.h", + "proteus/equivalent_polynomials_coefficients.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cRDLS', + ['proteus/mprans/RDLS.cpp'], + depends=["proteus/mprans/RDLS.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + "proteus/equivalent_polynomials.h", + "proteus/equivalent_polynomials_utils.h", + "proteus/equivalent_polynomials_coefficients.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cVOF', + ['proteus/mprans/VOF.cpp'], + depends=["proteus/mprans/VOF.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cMoveMesh', + ['proteus/mprans/MoveMesh.cpp'], + depends=["proteus/mprans/MoveMesh.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cMoveMesh2D', + ['proteus/mprans/MoveMesh2D.cpp'], + depends=["proteus/mprans/MoveMesh2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cSW2D', + ['proteus/mprans/SW2D.cpp'], + depends=["proteus/mprans/SW2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cSW2DCV', + ['proteus/mprans/SW2DCV.cpp'], + depends=["proteus/mprans/SW2DCV.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cGN_SW2DCV', + ['proteus/mprans/GN_SW2DCV.cpp'], + depends=["proteus/mprans/GN_SW2DCV.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cKappa', + ['proteus/mprans/Kappa.cpp'], + depends=["proteus/mprans/Kappa.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cKappa2D', + ['proteus/mprans/Kappa2D.cpp'], + depends=["proteus/mprans/Kappa2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cDissipation', + ['proteus/mprans/Dissipation.cpp'], + depends=["proteus/mprans/Dissipation.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), + Extension( + 'mprans.cDissipation2D', + ['proteus/mprans/Dissipation2D.cpp'], + depends=["proteus/mprans/Dissipation2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + include_dirs=get_xtensor_include(), + extra_compile_args=PROTEUS_OPT+['-std=c++14'], + language='c++'), ] def setup_given_extensions(extensions): @@ -747,97 +837,95 @@ def setup_given_extensions(extensions): ['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','SWFlow','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','dam_over_bumps','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','oneD_dambreak_flat_bottom','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','paraboloid_with_friction','oneD','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','paraboloid_with_friction','twoD','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','test_gauges','comparison_files'), - []), + []), (os.path.join(proteus_install_path,'tests','SWEs','test_reflecting_BCs','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'), - []), + []), + (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',