ngsolve 6.2.2506.post74.dev0__cp314-cp314-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ngsolve might be problematic. Click here for more details.
- netgen/include/analytic_integrals.hpp +10 -0
- netgen/include/arnoldi.hpp +55 -0
- netgen/include/bandmatrix.hpp +334 -0
- netgen/include/basematrix.hpp +957 -0
- netgen/include/basevector.hpp +1268 -0
- netgen/include/bdbequations.hpp +2805 -0
- netgen/include/bdbintegrator.hpp +1660 -0
- netgen/include/bem_diffops.hpp +475 -0
- netgen/include/bessel.hpp +1064 -0
- netgen/include/bilinearform.hpp +963 -0
- netgen/include/bla.hpp +29 -0
- netgen/include/blockalloc.hpp +95 -0
- netgen/include/blockjacobi.hpp +328 -0
- netgen/include/bspline.hpp +116 -0
- netgen/include/calcinverse.hpp +141 -0
- netgen/include/cg.hpp +368 -0
- netgen/include/chebyshev.hpp +44 -0
- netgen/include/cholesky.hpp +720 -0
- netgen/include/clapack.h +7254 -0
- netgen/include/code_generation.hpp +296 -0
- netgen/include/coefficient.hpp +2033 -0
- netgen/include/coefficient_impl.hpp +19 -0
- netgen/include/coefficient_stdmath.hpp +167 -0
- netgen/include/commutingAMG.hpp +106 -0
- netgen/include/comp.hpp +79 -0
- netgen/include/compatibility.hpp +41 -0
- netgen/include/complex_wrapper.hpp +73 -0
- netgen/include/compressedfespace.hpp +110 -0
- netgen/include/contact.hpp +235 -0
- netgen/include/diagonalmatrix.hpp +154 -0
- netgen/include/differentialoperator.hpp +276 -0
- netgen/include/diffop.hpp +1286 -0
- netgen/include/diffop_impl.hpp +328 -0
- netgen/include/diffopwithfactor.hpp +123 -0
- netgen/include/discontinuous.hpp +84 -0
- netgen/include/dump.hpp +949 -0
- netgen/include/ectypes.hpp +121 -0
- netgen/include/eigen.hpp +60 -0
- netgen/include/eigensystem.hpp +18 -0
- netgen/include/elasticity_equations.hpp +595 -0
- netgen/include/elementbyelement.hpp +195 -0
- netgen/include/elementtopology.hpp +1760 -0
- netgen/include/elementtransformation.hpp +339 -0
- netgen/include/evalfunc.hpp +405 -0
- netgen/include/expr.hpp +1686 -0
- netgen/include/facetfe.hpp +175 -0
- netgen/include/facetfespace.hpp +180 -0
- netgen/include/facethofe.hpp +111 -0
- netgen/include/facetsurffespace.hpp +112 -0
- netgen/include/fe_interfaces.hpp +32 -0
- netgen/include/fem.hpp +87 -0
- netgen/include/fesconvert.hpp +14 -0
- netgen/include/fespace.hpp +1449 -0
- netgen/include/finiteelement.hpp +286 -0
- netgen/include/globalinterfacespace.hpp +77 -0
- netgen/include/globalspace.hpp +115 -0
- netgen/include/gridfunction.hpp +525 -0
- netgen/include/h1amg.hpp +124 -0
- netgen/include/h1hofe.hpp +188 -0
- netgen/include/h1hofe_impl.hpp +1262 -0
- netgen/include/h1hofefo.hpp +148 -0
- netgen/include/h1hofefo_impl.hpp +185 -0
- netgen/include/h1hofespace.hpp +167 -0
- netgen/include/h1lofe.hpp +1240 -0
- netgen/include/h1lumping.hpp +41 -0
- netgen/include/hcurl_equations.hpp +1381 -0
- netgen/include/hcurlcurlfe.hpp +2241 -0
- netgen/include/hcurlcurlfespace.hpp +78 -0
- netgen/include/hcurlfe.hpp +259 -0
- netgen/include/hcurlfe_utils.hpp +107 -0
- netgen/include/hcurlhdiv_dshape.hpp +857 -0
- netgen/include/hcurlhdivfes.hpp +308 -0
- netgen/include/hcurlhofe.hpp +175 -0
- netgen/include/hcurlhofe_impl.hpp +1871 -0
- netgen/include/hcurlhofespace.hpp +193 -0
- netgen/include/hcurllofe.hpp +1146 -0
- netgen/include/hdiv_equations.hpp +880 -0
- netgen/include/hdivdivfe.hpp +2923 -0
- netgen/include/hdivdivsurfacespace.hpp +76 -0
- netgen/include/hdivfe.hpp +206 -0
- netgen/include/hdivfe_utils.hpp +717 -0
- netgen/include/hdivfes.hpp +75 -0
- netgen/include/hdivhofe.hpp +447 -0
- netgen/include/hdivhofe_impl.hpp +1107 -0
- netgen/include/hdivhofefo.hpp +229 -0
- netgen/include/hdivhofespace.hpp +177 -0
- netgen/include/hdivhosurfacefespace.hpp +106 -0
- netgen/include/hdivlofe.hpp +773 -0
- netgen/include/hidden.hpp +74 -0
- netgen/include/householder.hpp +181 -0
- netgen/include/hypre_ams_precond.hpp +123 -0
- netgen/include/hypre_precond.hpp +73 -0
- netgen/include/integrator.hpp +2012 -0
- netgen/include/integratorcf.hpp +253 -0
- netgen/include/interpolate.hpp +49 -0
- netgen/include/intrule.hpp +2542 -0
- netgen/include/intrules_SauterSchwab.hpp +25 -0
- netgen/include/irspace.hpp +49 -0
- netgen/include/jacobi.hpp +153 -0
- netgen/include/kernels.hpp +762 -0
- netgen/include/l2hofe.hpp +194 -0
- netgen/include/l2hofe_impl.hpp +564 -0
- netgen/include/l2hofefo.hpp +542 -0
- netgen/include/l2hofespace.hpp +344 -0
- netgen/include/la.hpp +38 -0
- netgen/include/linearform.hpp +266 -0
- netgen/include/matrix.hpp +2140 -0
- netgen/include/memusage.hpp +41 -0
- netgen/include/meshaccess.hpp +1359 -0
- netgen/include/mgpre.hpp +204 -0
- netgen/include/mp_coefficient.hpp +145 -0
- netgen/include/mptools.hpp +2281 -0
- netgen/include/multigrid.hpp +42 -0
- netgen/include/multivector.hpp +447 -0
- netgen/include/mumpsinverse.hpp +187 -0
- netgen/include/mycomplex.hpp +361 -0
- netgen/include/ng_lapack.hpp +1661 -0
- netgen/include/ngblas.hpp +1232 -0
- netgen/include/ngs_defines.hpp +30 -0
- netgen/include/ngs_stdcpp_include.hpp +106 -0
- netgen/include/ngs_utils.hpp +121 -0
- netgen/include/ngsobject.hpp +1019 -0
- netgen/include/ngsstream.hpp +113 -0
- netgen/include/ngstd.hpp +72 -0
- netgen/include/nodalhofe.hpp +96 -0
- netgen/include/nodalhofe_impl.hpp +141 -0
- netgen/include/normalfacetfe.hpp +223 -0
- netgen/include/normalfacetfespace.hpp +98 -0
- netgen/include/normalfacetsurfacefespace.hpp +84 -0
- netgen/include/order.hpp +251 -0
- netgen/include/parallel_matrices.hpp +222 -0
- netgen/include/paralleldofs.hpp +340 -0
- netgen/include/parallelngs.hpp +23 -0
- netgen/include/parallelvector.hpp +269 -0
- netgen/include/pardisoinverse.hpp +200 -0
- netgen/include/periodic.hpp +129 -0
- netgen/include/plateaufespace.hpp +25 -0
- netgen/include/pml.hpp +275 -0
- netgen/include/pmltrafo.hpp +631 -0
- netgen/include/postproc.hpp +142 -0
- netgen/include/potentialtools.hpp +22 -0
- netgen/include/precomp.hpp +60 -0
- netgen/include/preconditioner.hpp +602 -0
- netgen/include/prolongation.hpp +377 -0
- netgen/include/python_comp.hpp +107 -0
- netgen/include/python_fem.hpp +89 -0
- netgen/include/python_linalg.hpp +58 -0
- netgen/include/python_ngstd.hpp +386 -0
- netgen/include/recursive_pol.hpp +4896 -0
- netgen/include/recursive_pol_tet.hpp +395 -0
- netgen/include/recursive_pol_trig.hpp +492 -0
- netgen/include/reorderedfespace.hpp +81 -0
- netgen/include/sample_sort.hpp +105 -0
- netgen/include/scalarfe.hpp +335 -0
- netgen/include/shapefunction_utils.hpp +113 -0
- netgen/include/simd_complex.hpp +329 -0
- netgen/include/smoother.hpp +253 -0
- netgen/include/solve.hpp +89 -0
- netgen/include/sparsecholesky.hpp +313 -0
- netgen/include/sparsematrix.hpp +1038 -0
- netgen/include/sparsematrix_dyn.hpp +90 -0
- netgen/include/sparsematrix_impl.hpp +1013 -0
- netgen/include/special_matrix.hpp +463 -0
- netgen/include/specialelement.hpp +125 -0
- netgen/include/statushandler.hpp +33 -0
- netgen/include/stringops.hpp +12 -0
- netgen/include/superluinverse.hpp +136 -0
- netgen/include/symbolicintegrator.hpp +850 -0
- netgen/include/symmetricmatrix.hpp +144 -0
- netgen/include/tangentialfacetfe.hpp +224 -0
- netgen/include/tangentialfacetfespace.hpp +91 -0
- netgen/include/tensor.hpp +522 -0
- netgen/include/tensorcoefficient.hpp +446 -0
- netgen/include/tensorproductintegrator.hpp +113 -0
- netgen/include/thcurlfe.hpp +128 -0
- netgen/include/thcurlfe_impl.hpp +380 -0
- netgen/include/thdivfe.hpp +80 -0
- netgen/include/thdivfe_impl.hpp +492 -0
- netgen/include/tpdiffop.hpp +461 -0
- netgen/include/tpfes.hpp +133 -0
- netgen/include/tpintrule.hpp +224 -0
- netgen/include/triangular.hpp +465 -0
- netgen/include/tscalarfe.hpp +245 -0
- netgen/include/tscalarfe_impl.hpp +1029 -0
- netgen/include/umfpackinverse.hpp +148 -0
- netgen/include/vector.hpp +1273 -0
- netgen/include/voxelcoefficientfunction.hpp +41 -0
- netgen/include/vtkoutput.hpp +198 -0
- netgen/include/vvector.hpp +208 -0
- netgen/include/webgui.hpp +92 -0
- netgen/libngbla.dylib +0 -0
- netgen/libngcomp.dylib +0 -0
- netgen/libngfem.dylib +0 -0
- netgen/libngla.dylib +0 -0
- netgen/libngsbem.dylib +0 -0
- netgen/libngsolve.dylib +0 -0
- netgen/libngstd.dylib +0 -0
- ngsolve/TensorProductTools.py +210 -0
- ngsolve/__console.py +94 -0
- ngsolve/__expr.py +181 -0
- ngsolve/__init__.py +148 -0
- ngsolve/__init__.pyi +233 -0
- ngsolve/_scikit_build_core_dependencies.py +30 -0
- ngsolve/bla.pyi +1153 -0
- ngsolve/bvp.py +78 -0
- ngsolve/bvp.pyi +32 -0
- ngsolve/cmake/NGSolveConfig.cmake +102 -0
- ngsolve/cmake/ngsolve-targets-release.cmake +79 -0
- ngsolve/cmake/ngsolve-targets.cmake +163 -0
- ngsolve/comp/__init__.pyi +5449 -0
- ngsolve/comp/pml.pyi +89 -0
- ngsolve/config/__init__.py +1 -0
- ngsolve/config/__init__.pyi +43 -0
- ngsolve/config/__main__.py +4 -0
- ngsolve/config/config.py +60 -0
- ngsolve/config/config.pyi +45 -0
- ngsolve/demos/TensorProduct/__init__.py +0 -0
- ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +80 -0
- ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +73 -0
- ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +72 -0
- ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +66 -0
- ngsolve/demos/__init__.py +0 -0
- ngsolve/demos/howto/__init__.py +0 -0
- ngsolve/demos/howto/hhj.py +44 -0
- ngsolve/demos/howto/hybrid_dg.py +53 -0
- ngsolve/demos/howto/mixed.py +30 -0
- ngsolve/demos/howto/nonlin.py +29 -0
- ngsolve/demos/howto/pickling.py +26 -0
- ngsolve/demos/howto/pml.py +31 -0
- ngsolve/demos/howto/taskmanager.py +20 -0
- ngsolve/demos/howto/tdnns.py +47 -0
- ngsolve/demos/howto/timeDG-skeleton.py +45 -0
- ngsolve/demos/howto/timeDG.py +38 -0
- ngsolve/demos/howto/timeDGlap.py +42 -0
- ngsolve/demos/howto/timeDGwave.py +61 -0
- ngsolve/demos/intro/__init__.py +0 -0
- ngsolve/demos/intro/adaptive.py +123 -0
- ngsolve/demos/intro/cmagnet.py +59 -0
- ngsolve/demos/intro/elasticity.py +76 -0
- ngsolve/demos/intro/navierstokes.py +74 -0
- ngsolve/demos/intro/poisson.ipynb +170 -0
- ngsolve/demos/intro/poisson.py +41 -0
- ngsolve/demos/mpi/__init__.py +0 -0
- ngsolve/demos/mpi/mpi_cmagnet.py +87 -0
- ngsolve/demos/mpi/mpi_navierstokes.py +117 -0
- ngsolve/demos/mpi/mpi_poisson.py +89 -0
- ngsolve/demos/mpi/mpi_timeDG.py +82 -0
- ngsolve/directsolvers.py +26 -0
- ngsolve/directsolvers.pyi +15 -0
- ngsolve/eigenvalues.py +364 -0
- ngsolve/eigenvalues.pyi +30 -0
- ngsolve/fem.pyi +1647 -0
- ngsolve/internal.py +89 -0
- ngsolve/krylovspace.py +1013 -0
- ngsolve/krylovspace.pyi +298 -0
- ngsolve/la.pyi +1230 -0
- ngsolve/meshes.py +748 -0
- ngsolve/ngs2petsc.py +310 -0
- ngsolve/ngscxx.py +42 -0
- ngsolve/ngslib.so +0 -0
- ngsolve/ngstd.pyi +59 -0
- ngsolve/nonlinearsolvers.py +203 -0
- ngsolve/nonlinearsolvers.pyi +95 -0
- ngsolve/preconditioners.py +11 -0
- ngsolve/preconditioners.pyi +7 -0
- ngsolve/solve.pyi +109 -0
- ngsolve/solve_implementation.py +168 -0
- ngsolve/solve_implementation.pyi +42 -0
- ngsolve/solvers.py +7 -0
- ngsolve/solvers.pyi +14 -0
- ngsolve/timestepping.py +185 -0
- ngsolve/timestepping.pyi +28 -0
- ngsolve/timing.py +108 -0
- ngsolve/timing.pyi +54 -0
- ngsolve/utils.py +167 -0
- ngsolve/utils.pyi +273 -0
- ngsolve/webgui.py +670 -0
- ngsolve-6.2.2506.post74.dev0.data/data/Netgen.icns +0 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngscxx +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngsld +13 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngsolve.tcl +648 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngspy +2 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/beam.geo +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/beam.vol +240 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/chip.in2d +41 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/chip.vol +614 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coil.geo +12 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coil.vol +2560 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coilshield.geo +24 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coilshield.vol +3179 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/cube.geo +19 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/cube.vol +1832 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d10_DGdoubleglazing.pde +50 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d11_chip_nitsche.pde +40 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d1_square.pde +43 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d2_chip.pde +35 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d3_helmholtz.pde +22 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d4_cube.pde +46 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d5_beam.pde +74 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d6_shaft.pde +73 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d7_coil.pde +50 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d8_coilshield.pde +49 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d9_hybridDG.pde +72 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/doubleglazing.in2d +27 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/doubleglazing.vol +737 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/shaft.geo +73 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/shaft.vol +4291 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/square.in2d +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/square.vol +149 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/METADATA +13 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/RECORD +315 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/WHEEL +5 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/licenses/LICENSE +504 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
#ifndef FILE_RECURSIVE_POL_TRIG
|
|
2
|
+
#define FILE_RECURSIVE_POL_TRIG
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#include "recursive_pol.hpp"
|
|
6
|
+
|
|
7
|
+
namespace ngfem
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Computes face shape functions for triangles.
|
|
12
|
+
|
|
13
|
+
*/
|
|
14
|
+
class TrigShapesInnerLegendre
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
/// compute shape functions in factored form $\varphi_{ij} = u_i v_j$
|
|
18
|
+
template <typename Sx, typename Sy, typename T>
|
|
19
|
+
INLINE static void CalcSplitted (int n, Sx x, Sy y, T & val1, T & val2)
|
|
20
|
+
{
|
|
21
|
+
LegendrePolynomial leg;
|
|
22
|
+
|
|
23
|
+
Sx bub1 = (1-x-y)*(1+x-y);
|
|
24
|
+
leg.EvalScaledMult (n-3, x, 1-y, bub1, val1);
|
|
25
|
+
leg.EvalMult (n-3, 2*y-1, y, val2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
template <int n, typename Sx, typename Sy, typename T>
|
|
30
|
+
INLINE static void CalcSplitted (Sx x, Sy y, T & val1, T & val2)
|
|
31
|
+
{
|
|
32
|
+
Sx bub1 = (1-x-y)*(1+x-y);
|
|
33
|
+
// ScaledLegendrePolynomialMult (n-3, x, 1-y, bub1, val1);
|
|
34
|
+
// LegendrePolynomialFO<n-3>::EvalScaledMult (x, 1-y, bub1, val1);
|
|
35
|
+
LegendrePolynomial leg;
|
|
36
|
+
leg.EvalScaledMultFO<n-3> (x, 1-y, bub1, val1);
|
|
37
|
+
|
|
38
|
+
// LegendrePolynomialMult (n-3, 2*y-1, y, val2);
|
|
39
|
+
// LegendrePolynomialFO<n-3>::EvalMult (2*y-1, y, val2);
|
|
40
|
+
leg.EvalMultFO<n-3> (2*y-1, y, val2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/// computes all shape functions
|
|
45
|
+
template < typename Sx, typename Sy, typename T>
|
|
46
|
+
static int Calc (int n, Sx x, Sy y, T & values)
|
|
47
|
+
{
|
|
48
|
+
ArrayMem<Sx, 20> polx(n-2), poly(n-2);
|
|
49
|
+
|
|
50
|
+
ScaledLegendrePolynomial (n-3, x, 1-y, polx);
|
|
51
|
+
LegendrePolynomial (n-3, 2*y-1, poly);
|
|
52
|
+
Sx bub = y * (1-x-y) * (1+x-y);
|
|
53
|
+
|
|
54
|
+
int ii = 0;
|
|
55
|
+
for (int i = 0; i <= n-3; i++)
|
|
56
|
+
for (int j = 0; j <= n-3-i; j++)
|
|
57
|
+
values[ii++] = bub * polx[i] * poly[j];
|
|
58
|
+
|
|
59
|
+
return ii;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
template <int n, typename Sx, typename Sy, typename T>
|
|
63
|
+
static int Calc (Sx x, Sy y, T & values)
|
|
64
|
+
{
|
|
65
|
+
// ArrayMem<Sx, 20> polx(n-2), poly(n-2);
|
|
66
|
+
Sx polx[n], poly[n];
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
ScaledLegendrePolynomial (n-3, x, 1-y, polx);
|
|
70
|
+
LegendrePolynomial (n-3, 2*y-1, poly);
|
|
71
|
+
Sx bub = y * (1-x-y) * (1+x-y);
|
|
72
|
+
*/
|
|
73
|
+
CalcSplitted<n> (x, y, polx, poly);
|
|
74
|
+
int ii = 0;
|
|
75
|
+
for (int i = 0; i <= n-3; i++)
|
|
76
|
+
for (int j = 0; j <= n-3-i; j++)
|
|
77
|
+
values[ii++] = /* bub * */ polx[i] * poly[j];
|
|
78
|
+
|
|
79
|
+
return ii;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/// computes all shape functions
|
|
87
|
+
template <typename Sx, typename Sy, typename Sf, typename T>
|
|
88
|
+
static int CalcMult (int n, Sx x, Sy y, Sf & fac, T & values)
|
|
89
|
+
{
|
|
90
|
+
ArrayMem<Sx, 20> polx(n-2), poly(n-2);
|
|
91
|
+
|
|
92
|
+
ScaledLegendrePolynomial (n-3, x, 1-y, polx);
|
|
93
|
+
LegendrePolynomial (n-3, 2*y-1, poly);
|
|
94
|
+
|
|
95
|
+
Sx bub = fac * y * (1-x-y) * (1+x-y);
|
|
96
|
+
|
|
97
|
+
int ii = 0;
|
|
98
|
+
for (int i = 0; i <= n-3; i++)
|
|
99
|
+
for (int j = 0; j <= n-3-i; j++)
|
|
100
|
+
values[ii++] = bub * polx[i] * poly[j];
|
|
101
|
+
|
|
102
|
+
return ii;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
Compute triangular face shape functions.
|
|
111
|
+
Shape functions are $L_2$-orthogonal Jacobi polynomials
|
|
112
|
+
*/
|
|
113
|
+
class TrigShapesInnerJacobi
|
|
114
|
+
{
|
|
115
|
+
public:
|
|
116
|
+
/// computes all base functions
|
|
117
|
+
template <typename Sx, typename Sy, typename T>
|
|
118
|
+
static int Calc (int n, Sx x, Sy y, T & values)
|
|
119
|
+
{
|
|
120
|
+
int ii = 0;
|
|
121
|
+
ArrayMem<Sx, 20> polx(n+1), poly(n+1);
|
|
122
|
+
|
|
123
|
+
Sx bub = y * (1-x-y) * (1+x-y);
|
|
124
|
+
ScaledJacobiPolynomial (n-3, x, 1-y, 2, 2, polx);
|
|
125
|
+
|
|
126
|
+
for (int ix = 0; ix <= n-3; ix++)
|
|
127
|
+
{
|
|
128
|
+
JacobiPolynomial (n-3, 2*y-1, 2*ix+5, 2, poly);
|
|
129
|
+
for (int j = 0; j <= n-3-ix; j++)
|
|
130
|
+
values[ii++] = bub * polx[ix] * poly[j];
|
|
131
|
+
}
|
|
132
|
+
return ii;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
//*************************************MONOMIAL EXTENSION***********************************************************
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
Compute triangle edge-shape functions.
|
|
143
|
+
|
|
144
|
+
functions vanish on upper two edges
|
|
145
|
+
|
|
146
|
+
x,y: coordinates in triangle (-1, 0), (1, 0), (0, 1)
|
|
147
|
+
|
|
148
|
+
f_i (x, 0) = IntegratedLegendrePol_i (x)
|
|
149
|
+
|
|
150
|
+
f_i ... pol of order i
|
|
151
|
+
|
|
152
|
+
Monomial extension:
|
|
153
|
+
*/
|
|
154
|
+
class TrigExtensionMonomial
|
|
155
|
+
{
|
|
156
|
+
public:
|
|
157
|
+
/// computes function on triangle
|
|
158
|
+
template <class Sx, class Sy, class T>
|
|
159
|
+
inline static int CalcTrigExt (int n, Sx x, Sy y, T & values)
|
|
160
|
+
{
|
|
161
|
+
Sy fy = (1-y)*(1-y);
|
|
162
|
+
Sx p3 = 0;
|
|
163
|
+
Sx p2 = -1;
|
|
164
|
+
Sx p1 = x;
|
|
165
|
+
|
|
166
|
+
for (int j=2; j<=n; j++)
|
|
167
|
+
{
|
|
168
|
+
p3=p2; p2=p1;
|
|
169
|
+
p1=( (2*j-3) * x * p2 - (j-3) * fy * p3) / j;
|
|
170
|
+
values[j-2] = p1;
|
|
171
|
+
}
|
|
172
|
+
return n-1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
/// computes derivates on triangle, values must be $N \times 2$ matrix
|
|
177
|
+
template <class T>
|
|
178
|
+
inline static int CalcTrigExtDeriv (int n, double x, double y, T & values)
|
|
179
|
+
{
|
|
180
|
+
double fy = (1-y)*(1-y);
|
|
181
|
+
double p3 = 0, p3x = 0, p3y = 0;
|
|
182
|
+
double p2 = -1, p2x = 0, p2y = 0;
|
|
183
|
+
double p1 = x, p1x = 1, p1y = 0;
|
|
184
|
+
|
|
185
|
+
for (int j=2; j<=n; j++)
|
|
186
|
+
{
|
|
187
|
+
p3=p2; p3x = p2x; p3y = p2y;
|
|
188
|
+
p2=p1; p2x = p1x; p2y = p1y;
|
|
189
|
+
double c1 = (2.0*j-3) / j;
|
|
190
|
+
double c2 = (j-3.0) / j;
|
|
191
|
+
|
|
192
|
+
p1 = c1 * x * p2 - c2 * fy * p3;
|
|
193
|
+
p1x = c1 * p2 + c1 * x * p2x - c2 * fy * p3x;
|
|
194
|
+
p1y = c1 * x * p2y - (c2 * 2 * (y-1) * p3 + c2 * fy * p3y);
|
|
195
|
+
values (j-2, 0) = p1x;
|
|
196
|
+
values (j-2, 1) = p1y;
|
|
197
|
+
}
|
|
198
|
+
return n-1;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/// computes values on edge
|
|
202
|
+
template <class Sx, class T>
|
|
203
|
+
inline static int Calc (int n, Sx x, T & values)
|
|
204
|
+
{
|
|
205
|
+
Sx p3 = 0;
|
|
206
|
+
Sx p2 = -1;
|
|
207
|
+
Sx p1 = x;
|
|
208
|
+
|
|
209
|
+
for (int j=2; j<=n; j++)
|
|
210
|
+
{
|
|
211
|
+
p3=p2; p2=p1;
|
|
212
|
+
p1=( (2*j-3) * x * p2 - (j-3) * p3) / j;
|
|
213
|
+
values[j-2] = p1;
|
|
214
|
+
}
|
|
215
|
+
return n-1;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/// computes derivatives on edge
|
|
220
|
+
template <class T>
|
|
221
|
+
inline static int CalcDeriv (int n, double x, T & values)
|
|
222
|
+
{
|
|
223
|
+
double p1 = 1.0, p2 = 0.0, p3;
|
|
224
|
+
|
|
225
|
+
for (int j=1; j<=n-1; j++)
|
|
226
|
+
{
|
|
227
|
+
p3 = p2; p2 = p1;
|
|
228
|
+
p1 = ((2.0*j-1.0)*x*p2 - (j-1.0)*p3) / j;
|
|
229
|
+
values[j-1] = p1;
|
|
230
|
+
}
|
|
231
|
+
return n-1;
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
// *********************** OPTIMAL EXTENSION *****************************************
|
|
238
|
+
/**
|
|
239
|
+
Evaluete optimal edge-shape function.
|
|
240
|
+
on triangle (with coordinates (-1,0),(1,0),(0,1))
|
|
241
|
+
$$
|
|
242
|
+
\varphi_i:=\frac{1}{y}\int_{x-y}^{x+y}C_{i-1}^{-1/2}(s)ds
|
|
243
|
+
$$
|
|
244
|
+
vanishes on other both edges
|
|
245
|
+
Computed by recurrence
|
|
246
|
+
$$
|
|
247
|
+
{\varphi}_i:=
|
|
248
|
+
p_n(x,y) = a_n p_{n-4}} + b_n x p_{n-3} + (c_n + d_n (x*x-y*y)) p_{n-2}} + e_n x p_{n-1}}
|
|
249
|
+
$$
|
|
250
|
+
*/
|
|
251
|
+
class TrigExtensionOptimal
|
|
252
|
+
{
|
|
253
|
+
enum { SIZE = 1000 };
|
|
254
|
+
static double coefs[SIZE][5];
|
|
255
|
+
static bool initialized;
|
|
256
|
+
public:
|
|
257
|
+
|
|
258
|
+
TrigExtensionOptimal ();
|
|
259
|
+
|
|
260
|
+
template <class Sx, class Sy, class T>
|
|
261
|
+
inline static int CalcTrigExt (int p, Sx x, Sy y, T & values)
|
|
262
|
+
{
|
|
263
|
+
Sx p1(0.0), p2(0.0), p3(0.0), p4(0.0), p5(0.0);
|
|
264
|
+
Sx bub = (1.+x-y)*(x+y-1);
|
|
265
|
+
switch(p)
|
|
266
|
+
{
|
|
267
|
+
default:
|
|
268
|
+
case 5:
|
|
269
|
+
|
|
270
|
+
{
|
|
271
|
+
p5 = -1./24. * bub*x * (-9.+21.*x*x-14.*y+35.*y*y);
|
|
272
|
+
values[3] = p5;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
case 4:
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
p4 = -0.125 * bub * (-1.+5.*x*x-2.*y+3.*y*y);
|
|
279
|
+
values[2] = p4;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
case 3:
|
|
283
|
+
|
|
284
|
+
{
|
|
285
|
+
p3 = -0.5 * bub * x;
|
|
286
|
+
values[1] = p3;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
case 2:
|
|
290
|
+
|
|
291
|
+
{
|
|
292
|
+
p2 = -0.5 * bub;
|
|
293
|
+
values[0] = p2;
|
|
294
|
+
}
|
|
295
|
+
case 1:
|
|
296
|
+
case 0:
|
|
297
|
+
;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
for (int j = 6; j <= p; j++)
|
|
301
|
+
{
|
|
302
|
+
p1 =
|
|
303
|
+
-coefs[j-6][0] * p2
|
|
304
|
+
+ coefs[j-6][1] * x * p3
|
|
305
|
+
- (coefs[j-6][2]+coefs[j-6][3]*(x*x-y*y)) * p4
|
|
306
|
+
+ coefs[j-6][4] * x * p5;
|
|
307
|
+
p2 = p3; p3 = p4; p4 = p5; p5 = p1;
|
|
308
|
+
values[j-2] = p1;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return p-1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
template <class T>
|
|
315
|
+
inline static int CalcTrigExtDeriv (int n, double x, double y, T & values)
|
|
316
|
+
{
|
|
317
|
+
ArrayMem<AutoDiff<2>,10> ad_values(n-1);
|
|
318
|
+
AutoDiff<2> ad_x(x, 0);
|
|
319
|
+
AutoDiff<2> ad_y(y, 1);
|
|
320
|
+
|
|
321
|
+
CalcTrigExt (n, ad_x, ad_y, ad_values);
|
|
322
|
+
|
|
323
|
+
for (int i = 0; i < n-1; i++)
|
|
324
|
+
for (int j = 0; j < 2; j++)
|
|
325
|
+
values(i,j) = ad_values[i].DValue(j);
|
|
326
|
+
return n-1;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
template <class Sx, class T>
|
|
331
|
+
inline static int Calc (int n, Sx x, T & values)
|
|
332
|
+
{
|
|
333
|
+
Sx y = 0.0;
|
|
334
|
+
return CalcTrigExt (n, x, y, values);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
template <class T>
|
|
338
|
+
inline static int CalcDeriv (int n, double x, T & values)
|
|
339
|
+
{
|
|
340
|
+
return CalcTrigExtDeriv (n, x, 0.0, values);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
// ************************ MINIMAL EXTENSION *************************
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
.......
|
|
351
|
+
*/
|
|
352
|
+
class TrigExtensionMin
|
|
353
|
+
{
|
|
354
|
+
public:
|
|
355
|
+
template <class Sx, class Sy, class T>
|
|
356
|
+
inline static int CalcTrigExt (int n, Sx x, Sy y, T & values)
|
|
357
|
+
{
|
|
358
|
+
#ifdef ABC
|
|
359
|
+
// TrigExtensionOptimal::CalcTrigExt (n, x, y, values);
|
|
360
|
+
|
|
361
|
+
ArrayMem<Sx, 20> polx(n+1);
|
|
362
|
+
|
|
363
|
+
const IntegrationRule & rule =
|
|
364
|
+
GetIntegrationRules().SelectIntegrationRule (ET_SEGM, n+2);
|
|
365
|
+
|
|
366
|
+
Sx bub = (1-x-y) * (1+x-y);
|
|
367
|
+
for (int i = 0; i <= n-2; i++)
|
|
368
|
+
values[i] = 0;
|
|
369
|
+
|
|
370
|
+
for (int i = 0; i < rule.GetNIP(); i++)
|
|
371
|
+
{
|
|
372
|
+
const IntegrationPoint & ip = rule.GetIP(i);
|
|
373
|
+
|
|
374
|
+
Sx hx = x + y * (2.0*ip(0)-1.0);
|
|
375
|
+
|
|
376
|
+
JacobiPolynomial (n-2, hx, 1, 1, polx);
|
|
377
|
+
// LegendrePolynomial (n-2, hx, polx);
|
|
378
|
+
|
|
379
|
+
Sx fac = bub * ip.Weight(); // / (z*z);
|
|
380
|
+
|
|
381
|
+
for (int j = 0; j <= n-2; j++)
|
|
382
|
+
values[j] += fac * polx[j];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
// IntegratedLegendreMonomialExt::CalcTrigExt (n, x, y, values);
|
|
388
|
+
|
|
389
|
+
/*
|
|
390
|
+
Sy fy = (1-y)*(1-y);
|
|
391
|
+
Sx p3 = 0;
|
|
392
|
+
Sx p2 = -1;
|
|
393
|
+
Sx p1 = x;
|
|
394
|
+
|
|
395
|
+
for (int j=2; j<=n; j++)
|
|
396
|
+
{
|
|
397
|
+
p3=p2; p2=p1;
|
|
398
|
+
p1=( (2*j-3) * x * p2 - (j-3) * fy * p3) / j;
|
|
399
|
+
values[j-2] = p1;
|
|
400
|
+
}
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
/*
|
|
404
|
+
Sx fac = 1;
|
|
405
|
+
for (int j = n-2; j >= 0; j--)
|
|
406
|
+
{
|
|
407
|
+
values[j] = fac * values[j];
|
|
408
|
+
fac = fac * (1-y);
|
|
409
|
+
}
|
|
410
|
+
*/
|
|
411
|
+
|
|
412
|
+
for (int j = 0; j < n-3; j++)
|
|
413
|
+
values[j] *= VertexExtensionOptimal<2>::Calc (n-2-j, 1-y);
|
|
414
|
+
|
|
415
|
+
return n-1;
|
|
416
|
+
#endif
|
|
417
|
+
|
|
418
|
+
if (y == 0.0) y += 1e-8;
|
|
419
|
+
ArrayMem<Sx, 20> pol1(n+2), pol2(n+2);
|
|
420
|
+
JacobiPolynomial (n+1, x-y, 1, 1, pol1);
|
|
421
|
+
JacobiPolynomial (n+1, x+y, 1, 1, pol2);
|
|
422
|
+
for (int i = 0; i <= n-2; i++)
|
|
423
|
+
values[i] = (pol2[i+1]-pol1[i+1]) / (2*y);
|
|
424
|
+
|
|
425
|
+
/*
|
|
426
|
+
ScaledJacobiPolynomial (n-2, x, 1-y, 2, 2, values);
|
|
427
|
+
for (int i = 0; i < n-1; i++)
|
|
428
|
+
values[i] *= 0.5 * (i+4) * (1-x*x);
|
|
429
|
+
*/
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
LowEnergyVertexPolynomials2D (n, 1-2*y, pol1);
|
|
434
|
+
for (int i = 0; i <= n-2; i++)
|
|
435
|
+
values[i] *= pol1[n-2-i] * (1-x-y) * (1+x-y);
|
|
436
|
+
|
|
437
|
+
return n-1;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
template <class T>
|
|
441
|
+
inline static int CalcTrigExtDeriv (int n, double x, double y, T & values)
|
|
442
|
+
{
|
|
443
|
+
ArrayMem<AutoDiff<2>,10> ad_values(n-1);
|
|
444
|
+
AutoDiff<2> ad_x(x, 0);
|
|
445
|
+
AutoDiff<2> ad_y(y, 1);
|
|
446
|
+
|
|
447
|
+
CalcTrigExt (n, ad_x, ad_y, ad_values);
|
|
448
|
+
|
|
449
|
+
for (int i = 0; i < n-1; i++)
|
|
450
|
+
for (int j = 0; j < 2; j++)
|
|
451
|
+
values(i,j) = ad_values[i].DValue(j);
|
|
452
|
+
return n-1;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
template <class Sx, class T>
|
|
458
|
+
inline static int Calc (int n, Sx x, T & values)
|
|
459
|
+
{
|
|
460
|
+
/*
|
|
461
|
+
Sx y = 0.0;
|
|
462
|
+
CalcTrigExt (n, x, y, values);
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
JacobiPolynomial (n-2, x, 2, 2, values);
|
|
466
|
+
for (int i = 0; i < n-1; i++)
|
|
467
|
+
values[i] *= 0.5 * (i+4) * (1-x*x);
|
|
468
|
+
|
|
469
|
+
return n-1;
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
template <class T>
|
|
474
|
+
inline static int CalcDeriv (int n, double x, T & values)
|
|
475
|
+
{
|
|
476
|
+
ArrayMem<AutoDiff<1>,10> ad_values(n-1);
|
|
477
|
+
AutoDiff<1> ad_x(x, 0);
|
|
478
|
+
|
|
479
|
+
Calc (n, ad_x, ad_values);
|
|
480
|
+
|
|
481
|
+
for (int i = 0; i < n-1; i++)
|
|
482
|
+
values[i] = ad_values[i].DValue(0);
|
|
483
|
+
return n-1;
|
|
484
|
+
|
|
485
|
+
// return CalcTrigExtDeriv (n, x, 0.0, values);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
#endif
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#ifndef FILE_REORDERED_
|
|
2
|
+
#define FILE_REORDERED_
|
|
3
|
+
|
|
4
|
+
/*********************************************************************/
|
|
5
|
+
/* File: reordered.hpp */
|
|
6
|
+
/* Author: Joachim Schoeberl */
|
|
7
|
+
/* Date: Jun 2019 */
|
|
8
|
+
/*********************************************************************/
|
|
9
|
+
|
|
10
|
+
#include "fespace.hpp"
|
|
11
|
+
|
|
12
|
+
namespace ngcomp
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
// A reordered wrapper class for fespaces
|
|
16
|
+
|
|
17
|
+
class ReorderedFESpace : public FESpace
|
|
18
|
+
{
|
|
19
|
+
protected:
|
|
20
|
+
Array<DofId> dofmap;
|
|
21
|
+
shared_ptr<FESpace> space;
|
|
22
|
+
shared_ptr<Table<DofId>> clusters;
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
ReorderedFESpace (shared_ptr<FESpace> space, const Flags & flags);
|
|
26
|
+
|
|
27
|
+
virtual ~ReorderedFESpace () { ; }
|
|
28
|
+
|
|
29
|
+
virtual void Update() override;
|
|
30
|
+
|
|
31
|
+
virtual void FinalizeUpdate() override;
|
|
32
|
+
|
|
33
|
+
ProxyNode MakeProxyFunction (bool testfunction,
|
|
34
|
+
const function<shared_ptr<ProxyFunction>(shared_ptr<ProxyFunction>)> & addblock) const override
|
|
35
|
+
{
|
|
36
|
+
return GetBaseSpace()->MakeProxyFunction (testfunction, addblock);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
virtual string GetClassName() const override { return "Reordered" + space->GetClassName(); }
|
|
40
|
+
shared_ptr<FESpace> GetBaseSpace() const { return space; }
|
|
41
|
+
|
|
42
|
+
virtual FiniteElement & GetFE (ElementId ei, Allocator & alloc) const override;
|
|
43
|
+
|
|
44
|
+
virtual void GetDofNrs (ElementId ei, Array<DofId> & dnums) const override;
|
|
45
|
+
virtual void GetDofNrs (NodeId ni, Array<DofId> & dnums) const override;
|
|
46
|
+
|
|
47
|
+
auto GetClusters() const { return clusters; }
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
virtual SymbolTable<shared_ptr<DifferentialOperator>> GetAdditionalEvaluators () const override
|
|
51
|
+
{ return space->GetAdditionalEvaluators (); }
|
|
52
|
+
|
|
53
|
+
[[deprecated("Use GetDofNrs(NODE_TYPE(NT_VERTEX,nr) instead")]]
|
|
54
|
+
virtual void GetVertexDofNrs (int vnr, Array<DofId> & dnums) const override;
|
|
55
|
+
|
|
56
|
+
[[deprecated("Use GetDofNrs(NODE_TYPE(NT_EDGE,nr) instead")]]
|
|
57
|
+
virtual void GetEdgeDofNrs (int ednr, Array<DofId> & dnums) const override;
|
|
58
|
+
|
|
59
|
+
virtual void GetFaceDofNrs (int fanr, Array<DofId> & dnums) const override;
|
|
60
|
+
|
|
61
|
+
virtual void GetInnerDofNrs (int elnr, Array<DofId> & dnums) const override
|
|
62
|
+
{ space->GetInnerDofNrs(elnr, dnums); }
|
|
63
|
+
|
|
64
|
+
virtual void VTransformMR (ElementId ei,
|
|
65
|
+
SliceMatrix<double> mat, TRANSFORM_TYPE tt) const override
|
|
66
|
+
{ space-> VTransformMR(ei, mat, tt); }
|
|
67
|
+
virtual void VTransformMC (ElementId ei,
|
|
68
|
+
SliceMatrix<Complex> mat, TRANSFORM_TYPE tt) const override
|
|
69
|
+
{ space->VTransformMC (ei, mat, tt); }
|
|
70
|
+
virtual void VTransformVR (ElementId ei,
|
|
71
|
+
SliceVector<double> vec, TRANSFORM_TYPE tt) const override
|
|
72
|
+
{ space->VTransformVR(ei, vec, tt); }
|
|
73
|
+
virtual void VTransformVC (ElementId ei,
|
|
74
|
+
SliceVector<Complex> vec, TRANSFORM_TYPE tt) const override
|
|
75
|
+
{ space->VTransformVC(ei, vec, tt); }
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
#endif // FILE_REORDERED_
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#ifndef SAMPLE_SORT_HPP_
|
|
2
|
+
#define SAMPLE_SORT_HPP_
|
|
3
|
+
|
|
4
|
+
/**************************************************************************/
|
|
5
|
+
/* File: sample_sort.hpp */
|
|
6
|
+
/* Author: Bernd Schwarzenbacher, Joachim Schoeberl */
|
|
7
|
+
/* Date: Nov 2017 */
|
|
8
|
+
/**************************************************************************/
|
|
9
|
+
|
|
10
|
+
#include <random>
|
|
11
|
+
|
|
12
|
+
namespace ngstd
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
template <typename T, typename TI>
|
|
16
|
+
void SampleSortI(FlatArray<T> data, FlatArray<TI> index)
|
|
17
|
+
{
|
|
18
|
+
static Timer Tsample_sort("Sample Sort");
|
|
19
|
+
RegionTimer Rsample_sort(Tsample_sort);
|
|
20
|
+
|
|
21
|
+
size_t n = index.Size();
|
|
22
|
+
int nr_buckets = ngstd::TaskManager::GetNumThreads();
|
|
23
|
+
int sample_size = nr_buckets-1;
|
|
24
|
+
int over_sample = 10;
|
|
25
|
+
int over_sample_size = over_sample * sample_size;
|
|
26
|
+
|
|
27
|
+
Array<TI> over_sampled_ind(over_sample_size);
|
|
28
|
+
|
|
29
|
+
std::random_device rd;
|
|
30
|
+
std::mt19937 engine(rd());
|
|
31
|
+
std::uniform_int_distribution<int> dist(0, index.Size()-1);
|
|
32
|
+
for (auto i : Range(over_sample_size))
|
|
33
|
+
over_sampled_ind[i] = index[dist(engine)];
|
|
34
|
+
|
|
35
|
+
QuickSortI(data, over_sampled_ind);
|
|
36
|
+
|
|
37
|
+
Array<TI> sample_ind(sample_size);
|
|
38
|
+
for (auto i : Range(sample_size)) {
|
|
39
|
+
sample_ind[i] = over_sampled_ind[i * over_sample];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Array<int> bucket_of_ind(n);
|
|
43
|
+
ParallelFor(n, [&] (auto i) {
|
|
44
|
+
int start = 0;
|
|
45
|
+
int end = sample_size-1;
|
|
46
|
+
int mid = (start+end)/2;
|
|
47
|
+
while (start <= end) {
|
|
48
|
+
mid = (start+end)/2;
|
|
49
|
+
if (data[sample_ind[mid]] < data[i]) {
|
|
50
|
+
start = mid + 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
else if (data[sample_ind[mid]] > data[i]) {
|
|
54
|
+
end = mid - 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
else { break; }
|
|
58
|
+
}
|
|
59
|
+
if (start > end) {
|
|
60
|
+
bucket_of_ind[i] = start;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
bucket_of_ind[i] = mid;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
static Timer T3_2("Sample Sort - inverse index bucket map");
|
|
68
|
+
T3_2.Start();
|
|
69
|
+
ngstd::TableCreator<int> buckets_creator(nr_buckets);
|
|
70
|
+
for (; !buckets_creator.Done(); buckets_creator++) {
|
|
71
|
+
ParallelForRange (n, [&] (IntRange r)
|
|
72
|
+
{
|
|
73
|
+
ngstd::TableCreator<int> mycreator(nr_buckets);
|
|
74
|
+
for (; !mycreator.Done(); mycreator++)
|
|
75
|
+
for (auto i : r)
|
|
76
|
+
mycreator.Add (bucket_of_ind[i], i);
|
|
77
|
+
|
|
78
|
+
auto mytab = mycreator.MoveTable();
|
|
79
|
+
for (auto i : Range(nr_buckets))
|
|
80
|
+
buckets_creator.Add (i, mytab[i]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
auto table = buckets_creator.MoveTable();
|
|
85
|
+
T3_2.Stop();
|
|
86
|
+
|
|
87
|
+
static Timer T4("Sample Sort - sort buckets");
|
|
88
|
+
T4.Start();
|
|
89
|
+
ParallelFor(nr_buckets, [&] (auto bucket) {
|
|
90
|
+
QuickSortI(data, table[bucket]);
|
|
91
|
+
});
|
|
92
|
+
T4.Stop();
|
|
93
|
+
|
|
94
|
+
size_t start = 0;
|
|
95
|
+
for (size_t bucket = 0; bucket < table.Size(); ++bucket) {
|
|
96
|
+
size_t end = start+table[bucket].Size();
|
|
97
|
+
index.Range(start, end) = table[bucket];
|
|
98
|
+
start = end;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#endif // SAMPLE_SORT_HPP_
|