ngsolve 6.2.2506.post216.dev0__cp314-cp314-manylinux_2_28_x86_64.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.
Files changed (306) hide show
  1. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvcc +22 -0
  2. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvlink +17 -0
  3. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngscxx +15 -0
  4. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsld +11 -0
  5. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsolve.tcl +648 -0
  6. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngspy +2 -0
  7. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/analytic_integrals.hpp +10 -0
  8. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/arnoldi.hpp +55 -0
  9. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bandmatrix.hpp +334 -0
  10. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basematrix.hpp +963 -0
  11. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basevector.hpp +1268 -0
  12. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbequations.hpp +2807 -0
  13. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbintegrator.hpp +1660 -0
  14. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bem_diffops.hpp +475 -0
  15. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bessel.hpp +1064 -0
  16. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bilinearform.hpp +966 -0
  17. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bla.hpp +29 -0
  18. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockalloc.hpp +95 -0
  19. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockjacobi.hpp +328 -0
  20. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bspline.hpp +116 -0
  21. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/calcinverse.hpp +141 -0
  22. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cg.hpp +368 -0
  23. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/chebyshev.hpp +44 -0
  24. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cholesky.hpp +720 -0
  25. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/clapack.h +7254 -0
  26. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/code_generation.hpp +296 -0
  27. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient.hpp +2033 -0
  28. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_impl.hpp +19 -0
  29. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_stdmath.hpp +167 -0
  30. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/commutingAMG.hpp +106 -0
  31. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/comp.hpp +79 -0
  32. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compatibility.hpp +41 -0
  33. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/complex_wrapper.hpp +101 -0
  34. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compressedfespace.hpp +110 -0
  35. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/contact.hpp +239 -0
  36. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_core.hpp +216 -0
  37. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_linalg.hpp +185 -0
  38. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngbla.hpp +317 -0
  39. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngstd.hpp +414 -0
  40. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_profiler.hpp +240 -0
  41. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diagonalmatrix.hpp +160 -0
  42. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/differentialoperator.hpp +276 -0
  43. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop.hpp +1286 -0
  44. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop_impl.hpp +328 -0
  45. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffopwithfactor.hpp +123 -0
  46. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/discontinuous.hpp +84 -0
  47. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/dump.hpp +949 -0
  48. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ectypes.hpp +121 -0
  49. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigen.hpp +60 -0
  50. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigensystem.hpp +18 -0
  51. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elasticity_equations.hpp +595 -0
  52. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementbyelement.hpp +201 -0
  53. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtopology.hpp +1760 -0
  54. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtransformation.hpp +339 -0
  55. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/evalfunc.hpp +405 -0
  56. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/expr.hpp +1693 -0
  57. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfe.hpp +175 -0
  58. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfespace.hpp +180 -0
  59. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facethofe.hpp +111 -0
  60. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetsurffespace.hpp +112 -0
  61. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fe_interfaces.hpp +32 -0
  62. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fem.hpp +87 -0
  63. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fesconvert.hpp +14 -0
  64. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fespace.hpp +1454 -0
  65. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/finiteelement.hpp +286 -0
  66. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalinterfacespace.hpp +77 -0
  67. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalspace.hpp +115 -0
  68. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/gridfunction.hpp +525 -0
  69. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1amg.hpp +124 -0
  70. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe.hpp +188 -0
  71. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe_impl.hpp +1262 -0
  72. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo.hpp +148 -0
  73. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo_impl.hpp +185 -0
  74. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofespace.hpp +167 -0
  75. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lofe.hpp +1240 -0
  76. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lumping.hpp +41 -0
  77. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurl_equations.hpp +1381 -0
  78. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfe.hpp +2241 -0
  79. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfespace.hpp +78 -0
  80. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe.hpp +259 -0
  81. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe_utils.hpp +107 -0
  82. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdiv_dshape.hpp +857 -0
  83. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdivfes.hpp +308 -0
  84. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe.hpp +175 -0
  85. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe_impl.hpp +1871 -0
  86. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofespace.hpp +193 -0
  87. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurllofe.hpp +1146 -0
  88. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdiv_equations.hpp +880 -0
  89. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivfe.hpp +2923 -0
  90. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivsurfacespace.hpp +76 -0
  91. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe.hpp +206 -0
  92. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe_utils.hpp +717 -0
  93. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfes.hpp +75 -0
  94. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe.hpp +447 -0
  95. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe_impl.hpp +1107 -0
  96. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofefo.hpp +229 -0
  97. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofespace.hpp +177 -0
  98. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhosurfacefespace.hpp +106 -0
  99. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivlofe.hpp +773 -0
  100. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hidden.hpp +74 -0
  101. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/householder.hpp +181 -0
  102. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_ams_precond.hpp +123 -0
  103. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_precond.hpp +73 -0
  104. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integrator.hpp +2012 -0
  105. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integratorcf.hpp +253 -0
  106. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/interpolate.hpp +49 -0
  107. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrule.hpp +2542 -0
  108. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrules_SauterSchwab.hpp +25 -0
  109. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/irspace.hpp +49 -0
  110. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/jacobi.hpp +153 -0
  111. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/kernels.hpp +724 -0
  112. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe.hpp +194 -0
  113. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe_impl.hpp +564 -0
  114. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofefo.hpp +542 -0
  115. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofespace.hpp +344 -0
  116. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/la.hpp +38 -0
  117. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linalg_kernels.hpp +70 -0
  118. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linearform.hpp +266 -0
  119. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/matrix.hpp +2145 -0
  120. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/memusage.hpp +41 -0
  121. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/meshaccess.hpp +1359 -0
  122. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mgpre.hpp +204 -0
  123. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mp_coefficient.hpp +145 -0
  124. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mptools.hpp +2281 -0
  125. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multigrid.hpp +42 -0
  126. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multivector.hpp +447 -0
  127. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mumpsinverse.hpp +187 -0
  128. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mycomplex.hpp +361 -0
  129. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ng_lapack.hpp +1661 -0
  130. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngblas.hpp +1232 -0
  131. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_defines.hpp +30 -0
  132. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_stdcpp_include.hpp +106 -0
  133. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_utils.hpp +121 -0
  134. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsobject.hpp +1019 -0
  135. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsstream.hpp +113 -0
  136. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngstd.hpp +72 -0
  137. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe.hpp +96 -0
  138. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe_impl.hpp +141 -0
  139. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfe.hpp +223 -0
  140. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfespace.hpp +98 -0
  141. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetsurfacefespace.hpp +84 -0
  142. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/order.hpp +251 -0
  143. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallel_matrices.hpp +222 -0
  144. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/paralleldofs.hpp +340 -0
  145. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelngs.hpp +23 -0
  146. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelvector.hpp +269 -0
  147. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pardisoinverse.hpp +200 -0
  148. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/periodic.hpp +129 -0
  149. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/plateaufespace.hpp +25 -0
  150. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pml.hpp +275 -0
  151. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pmltrafo.hpp +631 -0
  152. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/postproc.hpp +142 -0
  153. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/potentialtools.hpp +22 -0
  154. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/precomp.hpp +60 -0
  155. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/preconditioner.hpp +602 -0
  156. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/prolongation.hpp +380 -0
  157. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_comp.hpp +107 -0
  158. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_fem.hpp +89 -0
  159. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_linalg.hpp +58 -0
  160. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_ngstd.hpp +386 -0
  161. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol.hpp +4896 -0
  162. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_tet.hpp +395 -0
  163. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_trig.hpp +492 -0
  164. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/reorderedfespace.hpp +81 -0
  165. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sample_sort.hpp +105 -0
  166. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/scalarfe.hpp +335 -0
  167. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/shapefunction_utils.hpp +113 -0
  168. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/simd_complex.hpp +329 -0
  169. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/smoother.hpp +253 -0
  170. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/solve.hpp +89 -0
  171. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsecholesky.hpp +317 -0
  172. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsefactorization_interface.hpp +159 -0
  173. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix.hpp +1052 -0
  174. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_dyn.hpp +90 -0
  175. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_impl.hpp +1055 -0
  176. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/special_matrix.hpp +463 -0
  177. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/specialelement.hpp +125 -0
  178. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/statushandler.hpp +33 -0
  179. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/stringops.hpp +12 -0
  180. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/superluinverse.hpp +136 -0
  181. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symbolicintegrator.hpp +850 -0
  182. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symmetricmatrix.hpp +144 -0
  183. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfe.hpp +224 -0
  184. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfespace.hpp +91 -0
  185. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensor.hpp +522 -0
  186. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorcoefficient.hpp +446 -0
  187. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorproductintegrator.hpp +113 -0
  188. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe.hpp +128 -0
  189. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe_impl.hpp +380 -0
  190. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe.hpp +80 -0
  191. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe_impl.hpp +492 -0
  192. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpdiffop.hpp +461 -0
  193. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpfes.hpp +133 -0
  194. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpintrule.hpp +224 -0
  195. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/triangular.hpp +465 -0
  196. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe.hpp +245 -0
  197. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe_impl.hpp +1029 -0
  198. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/umfpackinverse.hpp +148 -0
  199. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/unifiedvector.hpp +103 -0
  200. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vector.hpp +1452 -0
  201. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/voxelcoefficientfunction.hpp +41 -0
  202. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vtkoutput.hpp +198 -0
  203. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vvector.hpp +208 -0
  204. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/webgui.hpp +92 -0
  205. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/NGSolveConfig.cmake +102 -0
  206. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets-release.cmake +89 -0
  207. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets.cmake +180 -0
  208. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngbla.so +0 -0
  209. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngcomp.so +0 -0
  210. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngfem.so +0 -0
  211. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngla.so +0 -0
  212. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsbem.so +0 -0
  213. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngscudalib.so +0 -0
  214. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsolve.so +0 -0
  215. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngstd.so +0 -0
  216. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/TensorProductTools.py +210 -0
  217. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__console.py +94 -0
  218. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__expr.py +181 -0
  219. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__init__.py +148 -0
  220. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/_scikit_build_core_dependencies.py +30 -0
  221. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/bvp.py +78 -0
  222. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__init__.py +1 -0
  223. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__main__.py +4 -0
  224. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/config.py +60 -0
  225. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/__init__.py +0 -0
  226. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +80 -0
  227. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +73 -0
  228. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +72 -0
  229. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +66 -0
  230. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/__init__.py +0 -0
  231. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/__init__.py +0 -0
  232. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hhj.py +44 -0
  233. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hybrid_dg.py +53 -0
  234. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/mixed.py +30 -0
  235. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/nonlin.py +29 -0
  236. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pickling.py +26 -0
  237. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pml.py +31 -0
  238. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/taskmanager.py +20 -0
  239. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/tdnns.py +47 -0
  240. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG-skeleton.py +45 -0
  241. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG.py +38 -0
  242. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGlap.py +42 -0
  243. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGwave.py +61 -0
  244. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/__init__.py +0 -0
  245. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/adaptive.py +123 -0
  246. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/cmagnet.py +59 -0
  247. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/elasticity.py +76 -0
  248. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/navierstokes.py +74 -0
  249. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.ipynb +170 -0
  250. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.py +41 -0
  251. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/__init__.py +0 -0
  252. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_cmagnet.py +87 -0
  253. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_navierstokes.py +117 -0
  254. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_poisson.py +89 -0
  255. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_timeDG.py +82 -0
  256. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/directsolvers.py +14 -0
  257. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/eigenvalues.py +364 -0
  258. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/internal.py +89 -0
  259. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/krylovspace.py +1182 -0
  260. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/meshes.py +748 -0
  261. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngs2petsc.py +310 -0
  262. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscuda.so +0 -0
  263. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscxx.py +42 -0
  264. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngslib.so +0 -0
  265. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/nonlinearsolvers.py +203 -0
  266. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/preconditioners.py +11 -0
  267. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solve_implementation.py +168 -0
  268. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/__init__.py +7 -0
  269. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/cudss.py +112 -0
  270. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timestepping.py +185 -0
  271. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timing.py +108 -0
  272. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/utils.py +167 -0
  273. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/webgui.py +671 -0
  274. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.geo +17 -0
  275. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.vol +240 -0
  276. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.in2d +41 -0
  277. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.vol +614 -0
  278. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.geo +12 -0
  279. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.vol +2560 -0
  280. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.geo +24 -0
  281. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.vol +3179 -0
  282. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.geo +19 -0
  283. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.vol +1832 -0
  284. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d10_DGdoubleglazing.pde +50 -0
  285. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d11_chip_nitsche.pde +40 -0
  286. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d1_square.pde +43 -0
  287. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d2_chip.pde +35 -0
  288. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d3_helmholtz.pde +22 -0
  289. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d4_cube.pde +46 -0
  290. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d5_beam.pde +74 -0
  291. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d6_shaft.pde +73 -0
  292. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d7_coil.pde +50 -0
  293. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d8_coilshield.pde +49 -0
  294. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d9_hybridDG.pde +72 -0
  295. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.in2d +27 -0
  296. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.vol +737 -0
  297. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  298. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.geo +73 -0
  299. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.vol +4291 -0
  300. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.in2d +17 -0
  301. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.vol +149 -0
  302. ngsolve-6.2.2506.post216.dev0.dist-info/METADATA +14 -0
  303. ngsolve-6.2.2506.post216.dev0.dist-info/RECORD +306 -0
  304. ngsolve-6.2.2506.post216.dev0.dist-info/WHEEL +5 -0
  305. ngsolve-6.2.2506.post216.dev0.dist-info/licenses/LICENSE +504 -0
  306. ngsolve-6.2.2506.post216.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1182 @@
1
+
2
+ from ngsolve import Projector, Norm, TimeFunction, BaseMatrix, Preconditioner, InnerProduct, \
3
+ Norm, sqrt, Vector, Matrix, BaseVector, BlockVector, BitArray
4
+ from typing import Optional, Callable, Union
5
+ import logging
6
+ from netgen.libngpy._meshing import _PushStatus, _GetStatus, _SetThreadPercentage
7
+ from math import log
8
+ import os
9
+
10
+
11
+ if os.name == "nt":
12
+ _clear_line_command = ""
13
+ else:
14
+ _clear_line_command = "\33[2K"
15
+
16
+ linear_solver_param_doc = """
17
+ mat : BaseMatrix
18
+ The left hand side of the equation to solve.
19
+
20
+ pre : Preconditioner, BaseMatrix = None
21
+ If provided, the preconditioner for the system.
22
+
23
+ freedofs : BitArray = None
24
+ If no preconditioner is provided, the BitArray of the FESpace freedofs must be given.
25
+
26
+ tol : double = 1e-12
27
+ Relative tolerance for the residuum reduction.
28
+
29
+ maxiter : int = 100
30
+ Maximum number of iterations, if reached solver will emit a warning.
31
+
32
+ callback : Callable[[int, float], None] = None
33
+ Callback function that is called with iteration number and residual in each iteration step.
34
+
35
+ callback_sol : Callable[[BaseVector], None] = None
36
+ Callback function that is called with solution x_k in each iteration step.
37
+
38
+ printrates : bool = False
39
+ Print iterations to stdout. One can give a string to be passed as an `end`
40
+ argument to the print function, for example:
41
+ >>> printrates="\r"
42
+ will call
43
+ >>> print("iteration = 1, residual = 1e-3", end="\r")
44
+ if "\r" is passed, a final output will also be printed.
45
+
46
+ plotrates : bool = False
47
+ matplotlib plot of errors (residuals)
48
+ """
49
+
50
+ class LinearSolver(BaseMatrix):
51
+ """Base class for linear solvers.
52
+ """ + linear_solver_param_doc
53
+ name = "LinearSolver"
54
+ def __init__(self, mat : BaseMatrix,
55
+ pre : Optional[Preconditioner] = None,
56
+ freedofs : Optional[BitArray] = None,
57
+ tol : float = None,
58
+ maxiter : int = 100,
59
+ atol : float = None,
60
+ callback : Optional[Callable[[int, float], None]] = None,
61
+ callback_sol : Optional[Callable[[BaseVector], None]] = None,
62
+ printrates : bool = False,
63
+ plotrates : bool = False):
64
+ super().__init__()
65
+ if atol is None and tol is None:
66
+ tol = 1e-12
67
+ self.mat = mat
68
+ assert (freedofs is None) != (pre is None) # either pre or freedofs must be given
69
+ self.pre = pre if pre else Projector(freedofs, True)
70
+ self.tol = tol
71
+ self.atol = atol
72
+ self.maxiter = maxiter
73
+ self.callback = callback
74
+ self.callback_sol = callback_sol
75
+ self.printrates = printrates
76
+ self.plotrates = plotrates
77
+ self.residuals = []
78
+ self.iterations = 0
79
+
80
+ @TimeFunction
81
+ def Solve(self, rhs : BaseVector, sol : Optional[BaseVector] = None,
82
+ initialize : bool = True) -> BaseVector:
83
+ self.iterations = 0
84
+ self.residuals = []
85
+ old_status = _GetStatus()
86
+ _PushStatus(self.name + " Solve")
87
+ _SetThreadPercentage(0)
88
+ if sol is None:
89
+ sol = rhs.CreateVector()
90
+ initialize = True
91
+ if initialize:
92
+ sol[:] = 0
93
+ self.sol = sol
94
+ self._SolveImpl(rhs=rhs, sol=sol)
95
+ if old_status[0] != "idle":
96
+ _PushStatus(old_status[0])
97
+ _SetThreadPercentage(old_status[1])
98
+ return sol
99
+
100
+ def Height(self) -> int:
101
+ return self.mat.width
102
+
103
+ def Width(self) -> int:
104
+ return self.mat.height
105
+
106
+ def CreateVector(self,col):
107
+ return self.mat.CreateVector(not col)
108
+
109
+ def IsComplex(self) -> bool:
110
+ return self.mat.IsComplex()
111
+
112
+ def Mult(self, x : BaseVector, y : BaseVector) -> None:
113
+ self.Solve(rhs=x, sol=y, initialize=True)
114
+
115
+ def Update(self):
116
+ if hasattr(self.pre, "Update"):
117
+ self.pre.Update()
118
+
119
+ def CheckResidual(self, residual):
120
+ self.iterations += 1
121
+ self.residuals.append(residual)
122
+ if len(self.residuals) == 1:
123
+ if self.tol is None:
124
+ self._final_residual = self.atol
125
+ else:
126
+ self._final_residual = residual * self.tol
127
+ if self.atol is not None:
128
+ self._final_residual = max(self._final_residual, self.atol)
129
+ else:
130
+ if self.callback is not None:
131
+ self.callback(self.iterations, residual)
132
+ if self.callback_sol is not None:
133
+ self.callback_sol(self.sol)
134
+ if self.residuals[0] != 0:
135
+ logerrstop = log(self._final_residual)
136
+ logerrfirst = log(self.residuals[0])
137
+ if residual == 0:
138
+ _SetThreadPercentage(100)
139
+ else:
140
+ _SetThreadPercentage(100.*max(self.iterations/self.maxiter,
141
+ (log(residual)-logerrfirst)/(logerrstop - logerrfirst)))
142
+ if self.printrates:
143
+ print("{}{} iteration {}, residual = {} ".format(_clear_line_command, self.name, self.iterations, residual), end="\n" if isinstance(self.printrates, bool) else self.printrates)
144
+ if self.iterations == self.maxiter and residual > self._final_residual:
145
+ print("{}WARNING: {} did not converge to TOL".format(_clear_line_command, self.name))
146
+ is_converged = self.iterations >= self.maxiter or residual <= self._final_residual
147
+ if is_converged and self.printrates == "\r":
148
+ print("{}{} {}converged in {} iterations to residual {}".format(_clear_line_command, self.name, "NOT " if residual >= self._final_residual else "", self.iterations, residual))
149
+
150
+ if self.plotrates:
151
+ if self.iterations==1:
152
+ import matplotlib.pyplot as plt
153
+ from IPython.display import display, clear_output
154
+ fig, ax = plt.subplots()
155
+ self.plt = plt
156
+ self.ax = ax
157
+ self.fig = fig
158
+ self.its = []
159
+ self.ress = []
160
+ self.clear_output=clear_output
161
+ self.display=display
162
+ plt.ioff()
163
+ plt.show()
164
+ self.its.append(self.iterations)
165
+ self.ress.append(residual)
166
+ # update_plot(plt, ax, self.its, self.ress)
167
+ self.ax.clear()
168
+ self.ax.semilogy(self.its, self.ress, label='error')
169
+ self.ax.set_xlabel('iteration')
170
+ self.ax.set_ylabel('error')
171
+ self.ax.set_title('CG Solver Convergence')
172
+ self.ax.legend()
173
+ self.plt.draw()
174
+ self.clear_output(wait=True)
175
+ self.display(self.fig)
176
+
177
+
178
+ return is_converged
179
+
180
+ class CGSolver(LinearSolver):
181
+ """Preconditioned conjugate gradient method
182
+
183
+ Parameters
184
+ ----------
185
+
186
+ """ + linear_solver_param_doc + """
187
+
188
+ conjugate : bool = False
189
+ If set to True, then the complex inner product is used, else a pseudo inner product that makes CG work with complex symmetric matrices.
190
+ """
191
+ name = "CG"
192
+
193
+ def __init__(self, *args,
194
+ conjugate : bool = False,
195
+ abstol : float = None,
196
+ maxsteps : int = None,
197
+ printing : bool = False,
198
+ **kwargs):
199
+ if printing:
200
+ print("WARNING: printing is deprecated, use printrates instead!")
201
+ kwargs["printrates"] = printing
202
+ if abstol is not None:
203
+ print("WARNING: abstol is deprecated, use atol instead!")
204
+ kwargs["abstol"] = abstol
205
+ if maxsteps is not None:
206
+ print("WARNING: maxsteps is deprecated, use maxiter instead!")
207
+ kwargs["maxiter"] = maxsteps
208
+ super().__init__(*args, **kwargs)
209
+ self.conjugate = conjugate
210
+
211
+ # for backward compatibility
212
+ @property
213
+ def errors(self):
214
+ return self.residuals
215
+
216
+ def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
217
+ d, w, s = [sol.CreateVector() for i in range(3)]
218
+ conjugate = self.conjugate
219
+ d.data = rhs - self.mat * sol
220
+ w.data = self.pre * d
221
+ s.data = w
222
+ wdn = w.InnerProduct(d, conjugate=conjugate)
223
+ if self.CheckResidual(sqrt(abs(wdn))):
224
+ return
225
+
226
+ while True:
227
+ w.data = self.mat * s
228
+ wd = wdn
229
+ as_s = s.InnerProduct(w, conjugate=conjugate)
230
+ if as_s == 0 or wd == 0: break
231
+ alpha = wd / as_s
232
+ sol.data += alpha * s
233
+ d.data += (-alpha) * w
234
+
235
+ w.data = self.pre * d
236
+
237
+ wdn = w.InnerProduct(d, conjugate=conjugate)
238
+ if self.CheckResidual(sqrt(abs(wdn))):
239
+ return
240
+
241
+ beta = wdn / wd
242
+ s *= beta
243
+ s.data += w
244
+
245
+
246
+ def CG(mat, rhs, pre=None, sol=None, tol=1e-12, maxsteps = 100, printrates = True, plotrates = False, initialize = True, conjugate=False, callback=None, **kwargs):
247
+ """preconditioned conjugate gradient method
248
+
249
+
250
+ Parameters
251
+ ----------
252
+
253
+ mat : Matrix
254
+ The left hand side of the equation to solve. The matrix has to be spd o hermitsch.
255
+
256
+ rhs : Vector
257
+ The right hand side of the equation.
258
+
259
+ pre : Preconditioner
260
+ If provided the preconditioner is used.
261
+
262
+ sol : Vector
263
+ Start vector for CG method, if initialize is set False. Gets overwritten by the solution vector. If sol = None then a new vector is created.
264
+
265
+ tol : double
266
+ Tolerance of the residuum. CG stops if tolerance is reached.
267
+
268
+ maxsteps : int
269
+ Number of maximal steps for CG. If the maximal number is reached before the tolerance is reached CG stops.
270
+
271
+ printrates : bool
272
+ If set to True then the error of the iterations is displayed.
273
+
274
+ plotrates : bool
275
+ If set to True then the error of the iterations is plotted.
276
+
277
+ initialize : bool
278
+ If set to True then the initial guess for the CG method is set to zero. Otherwise the values of the vector sol, if provided, is used.
279
+
280
+ conjugate : bool
281
+ If set to True, then the complex inner product is used.
282
+
283
+
284
+ Returns
285
+ -------
286
+ (vector)
287
+ Solution vector of the CG method.
288
+
289
+ """
290
+ solver = CGSolver(mat=mat, pre=pre, conjugate=conjugate, tol=tol, maxiter=maxsteps,
291
+ callback=callback, printrates=printrates, plotrates=plotrates, **kwargs)
292
+ solver.Solve(rhs=rhs, sol=sol, initialize=initialize)
293
+ return solver.sol
294
+
295
+
296
+
297
+
298
+
299
+ class QMRSolver(LinearSolver):
300
+ """Quasi Minimal Residuum method
301
+
302
+ Parameters
303
+ ----------
304
+
305
+ """ + linear_solver_param_doc + """
306
+
307
+ pre2 : Preconditioner = None
308
+ Second preconditioner, if provided.
309
+
310
+ ep : double
311
+ Start epsilon.
312
+ """
313
+
314
+ name = "QMR"
315
+
316
+ def __init__(self, *args, pre2 : Preconditioner = None,
317
+ matT = None,
318
+ ep : float = 1., **kwargs):
319
+ super().__init__(*args, **kwargs)
320
+ self.pre2 = pre2
321
+ self.ep = ep
322
+ self.matT = matT if matT is not None else self.mat.T
323
+
324
+ def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
325
+ u, mat, matT, ep, pre1, pre2 = sol, self.mat, self.matT, self.ep, self.pre, self.pre2
326
+ r = rhs.CreateVector()
327
+ v = rhs.CreateVector()
328
+ v_tld = rhs.CreateVector()
329
+ w = rhs.CreateVector()
330
+ w_tld = rhs.CreateVector()
331
+ y = rhs.CreateVector()
332
+ y_tld = rhs.CreateVector()
333
+ z = rhs.CreateVector()
334
+ z_tld = rhs.CreateVector()
335
+ p = rhs.CreateVector()
336
+ p_tld = rhs.CreateVector()
337
+ q = rhs.CreateVector()
338
+ d = rhs.CreateVector()
339
+ s = rhs.CreateVector()
340
+
341
+ r.data = rhs - mat * u
342
+ v_tld.data = r
343
+ y.data = pre1 * v_tld
344
+
345
+ rho = InnerProduct(y,y)
346
+ rho = sqrt(rho)
347
+
348
+ w_tld.data = r
349
+ z.data = pre2.T * w_tld if pre2 else w_tld
350
+
351
+ xi = InnerProduct(z,z)
352
+ xi = sqrt(xi)
353
+
354
+ gamma = 1.0
355
+ eta = -1.0
356
+ theta = 0.0
357
+
358
+ for i in range(1,self.maxiter+1):
359
+ if (rho == 0.0):
360
+ print('Breakdown in rho')
361
+ return
362
+ if (xi == 0.0):
363
+ print('Breakdown in xi')
364
+ return
365
+ v.data = (1.0/rho) * v_tld
366
+ y.data = (1.0/rho) * y
367
+
368
+ w.data = (1.0/xi) * w_tld
369
+ z.data = (1.0/xi) * z
370
+
371
+ delta = InnerProduct(z,y)
372
+ if (delta == 0.0):
373
+ print('Breakdown in delta')
374
+ return
375
+
376
+ y_tld.data = pre2 * y if pre2 else y
377
+ z_tld.data = pre1.T * z
378
+
379
+ if (i > 1):
380
+ p.data = (-xi*delta / ep) * p
381
+ p.data += y_tld
382
+
383
+ q.data = (-rho * delta / ep) * q
384
+ q.data += z_tld
385
+ else:
386
+ p.data = y_tld
387
+ q.data = z_tld
388
+
389
+ p_tld.data = mat * p
390
+ ep = InnerProduct(q, p_tld)
391
+ if (ep == 0.0):
392
+ print('Breakdown in epsilon')
393
+ return
394
+
395
+ beta = ep/delta
396
+ if (beta == 0.0):
397
+ print('Breakdown in beta')
398
+ return
399
+
400
+ v_tld.data = p_tld - beta * v;
401
+
402
+ y.data = pre1 * v_tld
403
+
404
+ rho_1 = rho
405
+ rho = InnerProduct(y,y)
406
+ rho = sqrt(rho)
407
+
408
+ w_tld.data = matT * q
409
+ w_tld.data -= beta * w
410
+
411
+ z.data = pre2.T * w_tld if pre2 else w_tld
412
+
413
+ xi = InnerProduct(z,z)
414
+ xi = sqrt(xi)
415
+
416
+ gamma_1 = gamma
417
+ theta_1 = theta
418
+
419
+ theta = rho/(gamma_1 * abs(beta))
420
+ gamma = 1.0 / sqrt(1.0 + theta * theta)
421
+ if (gamma == 0.0):
422
+ print('Breakdown in gamma')
423
+ return
424
+
425
+ eta = -eta * rho_1 * gamma * gamma / (beta * gamma_1 * gamma_1);
426
+
427
+ if (i > 1):
428
+ d.data = (theta_1 * theta_1 * gamma * gamma) * d
429
+ d.data += eta * p
430
+
431
+ s.data = (theta_1 * theta_1 * gamma * gamma) * s
432
+ s.data += eta * p_tld
433
+
434
+ else:
435
+ d.data = eta * p
436
+ s.data = eta * p_tld
437
+
438
+ u.data += d
439
+ r.data -= s
440
+
441
+ #Projected residuum: Better terminating condition necessary?
442
+ v.data = self.pre * r
443
+ ResNorm = sqrt(InnerProduct(r,v))
444
+ # ResNorm = sqrt( np.dot(r.FV().NumPy()[fdofs],r.FV().NumPy()[fdofs]))
445
+ #ResNorm = sqrt(InnerProduct(r,r))
446
+ if self.CheckResidual(ResNorm):
447
+ return
448
+
449
+ def QMR(mat, rhs, fdofs, pre1=None, pre2=None, sol=None, maxsteps = 100, printrates = True, initialize = True, ep = 1.0, tol = 1e-7):
450
+ """Quasi Minimal Residuum method
451
+
452
+
453
+ Parameters
454
+ ----------
455
+
456
+ mat : Matrix
457
+ The left hand side of the equation to solve
458
+
459
+ rhs : Vector
460
+ The right hand side of the equation.
461
+
462
+ fdofs : BitArray
463
+ BitArray of free degrees of freedoms.
464
+
465
+ pre1 : Preconditioner
466
+ First preconditioner if provided
467
+
468
+ pre2 : Preconditioner
469
+ Second preconditioner if provided
470
+
471
+ sol : Vector
472
+ Start vector for QMR method, if initialize is set False. Gets overwritten by the solution vector. If sol = None then a new vector is created.
473
+
474
+ maxsteps : int
475
+ Number of maximal steps for QMR. If the maximal number is reached before the tolerance is reached QMR stops.
476
+
477
+ printrates : bool
478
+ If set to True then the error of the iterations is displayed.
479
+
480
+ initialize : bool
481
+ If set to True then the initial guess for the QMR method is set to zero. Otherwise the values of the vector sol, if provided, is used.
482
+
483
+ ep : double
484
+ Start epsilon.
485
+
486
+ tol : double
487
+ Tolerance of the residuum. QMR stops if tolerance is reached.
488
+
489
+
490
+ Returns
491
+ -------
492
+ (vector)
493
+ Solution vector of the QMR method.
494
+
495
+ """
496
+ # backwards compatibility, but freedofs are not needed then.
497
+ if pre1 is not None:
498
+ fdofs = None
499
+ return QMRSolver(mat=mat, freedofs=fdofs, pre=pre1,
500
+ pre2=pre2, maxiter=maxsteps,
501
+ printrates=printrates, ep=ep,
502
+ tol=tol).Solve(rhs=rhs, sol=sol, initialize=initialize)
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+ class TFQMRSolver(LinearSolver):
511
+ """Transpose-Free Quasi Minimal Residuum method
512
+
513
+ Parameters
514
+ ----------
515
+
516
+ """ + linear_solver_param_doc + """
517
+
518
+ """
519
+
520
+ name = "TFQMR"
521
+
522
+ def __init__(self, *args, pre2 : Preconditioner = None,
523
+ matT = None,
524
+ ep : float = 1., **kwargs):
525
+ super().__init__(*args, **kwargs)
526
+
527
+ def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
528
+ # following implementation from scipy
529
+ mat,pre,tol = self.mat, self.pre, self.tol
530
+
531
+ r = rhs.CreateVector()
532
+ u = rhs.CreateVector()
533
+ v = rhs.CreateVector()
534
+ w = rhs.CreateVector()
535
+ uhat = rhs.CreateVector()
536
+ uNext = rhs.CreateVector()
537
+ rstar = rhs.CreateVector()
538
+ d = rhs.CreateVector()
539
+ x = rhs.CreateVector()
540
+ z = rhs.CreateVector()
541
+ tmp = rhs.CreateVector()
542
+ d[:] = 0
543
+
544
+ if Norm(rhs)==0:
545
+ sol.data = 0
546
+ return
547
+
548
+ x.data = sol
549
+ r.data = rhs - mat*sol
550
+
551
+ u.data = r
552
+ w.data = r
553
+ rstar.data = r
554
+
555
+ v.data = pre@mat * r
556
+ uhat.data = v
557
+
558
+ theta = eta = 0
559
+
560
+ rho = InnerProduct(rstar, r)
561
+ rhoLast = rho
562
+ r0norm = sqrt(rho)
563
+
564
+ tau = r0norm
565
+ if r0norm == 0:
566
+ return
567
+
568
+ for iter in range(0,self.maxiter):
569
+ even = iter%2 == 0
570
+ if (even):
571
+ vtrstar = InnerProduct(rstar, v)
572
+ if vtrstar==0:
573
+ return
574
+
575
+ alpha = rho/vtrstar
576
+ uNext.data = u-alpha*v
577
+
578
+ w -= alpha*uhat
579
+ d *= theta**2/alpha*eta
580
+ d += u
581
+ theta = Norm(w)/tau
582
+ c = sqrt(1/(1+theta**2))
583
+ tau *= theta*c
584
+
585
+ eta = c**2 * alpha
586
+ z.data = pre*d
587
+ x += eta*z
588
+
589
+ # callback ...
590
+
591
+ if self.CheckResidual(tau):
592
+ sol.data = x
593
+ return
594
+ # if tau < tol:
595
+ # return
596
+
597
+ if not even:
598
+ rho = InnerProduct(rstar, w)
599
+ beta = rho/rhoLast
600
+ u *= beta
601
+ u += w
602
+ v *= beta**2
603
+ v += beta*uhat
604
+ # uhat.data = pre@mat * u
605
+ tmp.data = mat*u
606
+ uhat.data = pre*tmp
607
+ v += uhat
608
+ else:
609
+ # uhat.data = pre@mat * uNext
610
+ tmp.data = mat*uNext
611
+ uhat.data = pre*tmp
612
+ u.data = uNext
613
+ rhoLast = rho
614
+
615
+
616
+ def TFQMR(mat, rhs, pre=None, sol=None, maxsteps = 100, printrates = True, initialize = True, tol = 1e-7):
617
+ """Quasi Minimal Residuum method
618
+
619
+
620
+ Parameters
621
+ ----------
622
+
623
+ mat : Matrix
624
+ The left hand side of the equation to solve
625
+
626
+ rhs : Vector
627
+ The right hand side of the equation.
628
+
629
+ fdofs : BitArray
630
+ BitArray of free degrees of freedoms.
631
+
632
+ pre : Preconditioner
633
+ preconditioner if provided
634
+
635
+ sol : Vector
636
+ Start vector for QMR method, if initialize is set False. Gets overwritten by the solution vector. If sol = None then a new vector is created.
637
+
638
+ maxsteps : int
639
+ Number of maximal steps for QMR. If the maximal number is reached before the tolerance is reached QMR stops.
640
+
641
+ printrates : bool
642
+ If set to True then the error of the iterations is displayed.
643
+
644
+ initialize : bool
645
+ If set to True then the initial guess for the QMR method is set to zero. Otherwise the values of the vector sol, if provided, is used.
646
+
647
+ tol : double
648
+ Tolerance of the residuum. QMR stops if tolerance is reached.
649
+
650
+
651
+ Returns
652
+ -------
653
+ (vector)
654
+ Solution vector of the QMR method.
655
+
656
+ """
657
+ # backwards compatibility, but freedofs are not needed then.
658
+ return TFQMRSolver(mat=mat, pre=pre,
659
+ maxiter=maxsteps,
660
+ printrates=printrates,
661
+ tol=tol).Solve(rhs=rhs, sol=sol, initialize=initialize)
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+ #Source: Michael Kolmbauer https://www.numa.uni-linz.ac.at/Teaching/PhD/Finished/kolmbauer-diss.pdf
671
+ class MinResSolver(LinearSolver):
672
+ """Minimal Residuum method
673
+
674
+ Parameters
675
+ ----------
676
+ """ + linear_solver_param_doc
677
+ def __init__(self, *args, **kwargs):
678
+ super().__init__(*args, **kwargs)
679
+
680
+ def _SolveImpl(self, rhs: BaseVector, sol : BaseVector):
681
+ pre, mat, u = self.pre, self.mat, sol
682
+ v_new = rhs.CreateVector()
683
+ v = rhs.CreateVector()
684
+ v_old = rhs.CreateVector()
685
+ w_new = rhs.CreateVector()
686
+ w = rhs.CreateVector()
687
+ w_old = rhs.CreateVector()
688
+ z_new = rhs.CreateVector()
689
+ z = rhs.CreateVector()
690
+ mz = rhs.CreateVector()
691
+
692
+ v.data = rhs - mat * u
693
+
694
+ z.data = pre * v
695
+
696
+ #First Step
697
+ gamma = sqrt(InnerProduct(z,v))
698
+ gamma_new = 0
699
+ z.data = 1/gamma * z
700
+ v.data = 1/gamma * v
701
+
702
+ ResNorm = gamma
703
+ ResNorm_old = gamma
704
+
705
+ if self.CheckResidual(ResNorm):
706
+ return
707
+
708
+ eta_old = gamma
709
+ c_old = 1
710
+ c = 1
711
+ s_new = 0
712
+ s = 0
713
+ s_old = 0
714
+
715
+ v_old[:] = 0.0
716
+ w_old[:] = 0.0
717
+ w[:] = 0.0
718
+
719
+ k = 1
720
+ while True:
721
+ mz.data = mat*z
722
+ delta = InnerProduct(mz,z)
723
+ v_new.data = mz - delta*v - gamma * v_old
724
+
725
+ z_new.data = pre * v_new
726
+
727
+ gamma_new = sqrt(InnerProduct(z_new, v_new))
728
+ z_new *= 1/gamma_new
729
+ v_new *= 1/gamma_new
730
+
731
+ alpha0 = c*delta - c_old*s*gamma
732
+ alpha1 = sqrt(alpha0*alpha0 + gamma_new*gamma_new) #**
733
+ alpha2 = s*delta + c_old*c*gamma
734
+ alpha3 = s_old * gamma
735
+
736
+ c_new = alpha0/alpha1
737
+ s_new = gamma_new/alpha1
738
+
739
+ w_new.data = z - alpha3*w_old - alpha2*w
740
+ w_new.data = 1/alpha1 * w_new
741
+
742
+ u.data += c_new*eta_old * w_new
743
+ eta = -s_new * eta_old
744
+
745
+ #update of residuum
746
+ ResNorm = abs(s_new) * ResNorm_old
747
+ if self.CheckResidual(ResNorm):
748
+ return
749
+ k += 1
750
+
751
+ # shift vectors by renaming
752
+ v_old, v, v_new = v, v_new, v_old
753
+ w_old, w, w_new = w, w_new, w_old
754
+ z, z_new = z_new, z
755
+
756
+ eta_old = eta
757
+
758
+ s_old = s
759
+ s = s_new
760
+
761
+ c_old = c
762
+ c = c_new
763
+
764
+ gamma = gamma_new
765
+ ResNorm_old = ResNorm
766
+
767
+ def MinRes(mat, rhs, pre=None, sol=None, maxsteps = 100, printrates = True, initialize = True, tol = 1e-7):
768
+ """Minimal Residuum method
769
+
770
+
771
+ Parameters
772
+ ----------
773
+
774
+ mat : Matrix
775
+ The left hand side of the equation to solve
776
+
777
+ rhs : Vector
778
+ The right hand side of the equation.
779
+
780
+ pre : Preconditioner
781
+ If provided the preconditioner is used.
782
+
783
+ sol : Vector
784
+ Start vector for MinRes method, if initialize is set False. Gets overwritten by the solution vector. If sol = None then a new vector is created.
785
+
786
+ maxsteps : int
787
+ Number of maximal steps for MinRes. If the maximal number is reached before the tolerance is reached MinRes stops.
788
+
789
+ printrates : bool
790
+ If set to True then the error of the iterations is displayed.
791
+
792
+ initialize : bool
793
+ If set to True then the initial guess for the MinRes method is set to zero. Otherwise the values of the vector sol, if prevented, is used.
794
+
795
+ tol : double
796
+ Tolerance of the residuum. MinRes stops if tolerance is reached.
797
+
798
+
799
+ Returns
800
+ -------
801
+ (vector)
802
+ Solution vector of the MinRes method.
803
+
804
+ """
805
+ return MinResSolver(mat=mat, pre=pre, maxiter=maxsteps,
806
+ printrates=printrates,
807
+ tol=tol).Solve(rhs=rhs, sol=sol,
808
+ initialize=initialize)
809
+
810
+
811
+ class RichardsonSolver(LinearSolver):
812
+ """ Preconditioned Richardson Iteration
813
+
814
+ Parameters
815
+ ----------
816
+ """ + linear_solver_param_doc + """
817
+
818
+ dampfactor : float = 1.
819
+ Set the damping factor for the Richardson iteration. If it is 1 then no damping is done. Values greater than 1 are allowed.
820
+ """
821
+ name = "Richardson"
822
+ def __init__(self, *args, dampfactor = 1., **kwargs):
823
+ super().__init__(*args, **kwargs)
824
+ self.dampfactor = dampfactor
825
+
826
+ def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
827
+ r = rhs.CreateVector()
828
+ d = sol.CreateVector()
829
+ r.data = rhs - self.mat*sol
830
+ d.data = self.pre * r
831
+ res_norm = abs(InnerProduct(d,r))
832
+ if self.CheckResidual(res_norm):
833
+ return
834
+
835
+ while True:
836
+ sol.data += self.dampfactor * d
837
+ r.data = rhs - self.mat * sol
838
+ d.data = self.pre * r
839
+
840
+ res_norm = abs(InnerProduct(d,r))
841
+ if self.CheckResidual(res_norm):
842
+ return
843
+
844
+
845
+ def PreconditionedRichardson(a, rhs, pre=None, freedofs=None, maxit=100, tol=1e-8, dampfactor=1.0, printing=True):
846
+ """ Preconditioned Richardson Iteration
847
+
848
+ Parameters
849
+ ----------
850
+ a : BilinearForm
851
+ The left hand side of the equation to solve
852
+
853
+ rhs : Vector
854
+ The right hand side of the equation.
855
+
856
+ pre : Preconditioner
857
+ If provided the preconditioner is used.
858
+
859
+ freedofs : BitArray
860
+ The FreeDofs on which the Richardson iteration acts. If argument is 'None' then the FreeDofs of the underlying FESpace is used.
861
+
862
+ maxit : int
863
+ Number of maximal iteration for Richardson iteration. If the maximal number is reached before the tolerance is reached a warning is displayed.
864
+
865
+ tol : double
866
+ Tolerance of the residuum. Richardson iteration stops if residuum < tolerance*initial_residuum is reached.
867
+
868
+ dampfactor : float
869
+ Set the damping factor for the Richardson iteration. If it is 1 then no damping is done. Values greater than 1 are allowed.
870
+
871
+ printing : bool
872
+ Set if Richardson iteration should print informations about the actual iteration like the residuum.
873
+
874
+ Returns
875
+ -------
876
+ (vector)
877
+ Solution vector of the Preconditioned Richardson iteration.
878
+
879
+ """
880
+ u = rhs.CreateVector()
881
+ r = rhs.CreateVector()
882
+ u[:] = 0
883
+
884
+ projector = Projector(freedofs if freedofs else a.space.FreeDofs(coupling=a.condense), False)
885
+
886
+ r.data = rhs # r.data = rhs - a.mat*u
887
+ r.data -= projector*r
888
+
889
+ it = 0
890
+ initial_res_norm = Norm(r)
891
+ if printing:
892
+ print("it =", it, " ||res||_2 =", initial_res_norm)
893
+
894
+ for it in range(1, maxit+1):
895
+ u.data += dampfactor*(pre*r if pre else r)
896
+ r.data = rhs - a.mat*u
897
+ r.data -= projector*r
898
+
899
+ res_norm = Norm(r)
900
+ if printing:
901
+ print("it =", it, " ||res||_2 =", res_norm)
902
+ if res_norm < tol*initial_res_norm:
903
+ break
904
+ else:
905
+ print("Warning: Preconditioned Richardson did not converge to TOL")
906
+
907
+ return u
908
+
909
+ class GMResSolver(LinearSolver):
910
+ """Preconditioned GMRes solver. Minimizes the preconditioned residuum pre * (b-A*x)
911
+
912
+ Parameters
913
+ ----------
914
+
915
+ """ + linear_solver_param_doc + """
916
+
917
+ innerproduct : Callable[[BaseVector, BaseVector], Union[float, complex]] = None
918
+ Innerproduct to be used in iteration, all orthogonalizations/norms are computed with respect to that inner product.
919
+
920
+ restart : int = None
921
+ If given, GMRes is restarted with the current solution x every 'restart' steps.
922
+ """
923
+ name = "GMRes"
924
+
925
+ def __init__(self, *args,
926
+ innerproduct : Optional[Callable[[BaseVector, BaseVector],
927
+ Union[float, complex]]] = None,
928
+ restart : Optional[int] = None,
929
+ **kwargs):
930
+ super().__init__(*args, **kwargs)
931
+ if innerproduct is not None:
932
+ self.innerproduct = innerproduct
933
+ self.norm = lambda x: sqrt(innerproduct(x,x).real)
934
+ self.restart = restart
935
+ else:
936
+ self.innerproduct = lambda x, y: y.InnerProduct(x, conjugate=True)
937
+ self.norm = Norm
938
+ self.restart = restart
939
+
940
+ def _SolveImpl(self, rhs : BaseVector, sol : BaseVector):
941
+ is_complex = rhs.is_complex
942
+ A, pre, innerproduct, norm = self.mat, self.pre, self.innerproduct, self.norm
943
+ n = len(rhs)
944
+ m = self.maxiter
945
+ sn = Vector(m, is_complex)
946
+ cs = Vector(m, is_complex)
947
+ sn[:] = 0
948
+ cs[:] = 0
949
+ if self.callback_sol is not None:
950
+ sol_start = sol.CreateVector()
951
+ sol_start.data = sol
952
+ r = rhs.CreateVector()
953
+ tmp = rhs.CreateVector()
954
+ tmp.data = rhs - A * sol
955
+ r.data = pre * tmp
956
+ Q = []
957
+ H = []
958
+ Q.append(rhs.CreateVector())
959
+ r_norm = norm(r)
960
+ if self.CheckResidual(abs(r_norm)):
961
+ return sol
962
+ Q[0].data = 1./r_norm * r
963
+ beta = Vector(m+1, is_complex)
964
+ beta[:] = 0
965
+ beta[0] = r_norm
966
+
967
+ def arnoldi(A,Q,k):
968
+ q = rhs.CreateVector()
969
+ tmp.data = A * Q[k]
970
+ q.data = pre * tmp
971
+ h = Vector(m+1, is_complex)
972
+ h[:] = 0
973
+ for i in range(k+1):
974
+ h[i] = innerproduct(Q[i],q)
975
+ q -= h[i] * Q[i]
976
+ h[k+1] = norm(q)
977
+ if abs(h[k+1]) < 1e-12:
978
+ return h, None
979
+ q *= 1./h[k+1].real
980
+ return h, q
981
+
982
+ def givens_rotation(v1,v2):
983
+ if v2 == 0:
984
+ return 1,0
985
+ elif v1 == 0:
986
+ return 0,v2/abs(v2)
987
+ else:
988
+ t = sqrt((v1.conjugate()*v1+v2.conjugate()*v2).real)
989
+ cs = abs(v1)/t
990
+ sn = v1/abs(v1) * v2.conjugate()/t
991
+ return cs,sn
992
+
993
+ def apply_givens_rotation(h, cs, sn, k):
994
+ for i in range(k):
995
+ temp = cs[i] * h[i] + sn[i] * h[i+1]
996
+ h[i+1] = -sn[i].conjugate() * h[i] + cs[i].conjugate() * h[i+1]
997
+ h[i] = temp
998
+ cs[k], sn[k] = givens_rotation(h[k], h[k+1])
999
+ h[k] = cs[k] * h[k] + sn[k] * h[k+1]
1000
+ h[k+1] = 0
1001
+
1002
+ def calcSolution(k):
1003
+ # if callback_sol is set we need to recompute solution in every step
1004
+ if self.callback_sol is not None:
1005
+ sol.data = sol_start
1006
+ mat = Matrix(k+1,k+1, is_complex)
1007
+ for i in range(k+1):
1008
+ mat[:,i] = H[i][:k+1]
1009
+ rs = Vector(k+1, is_complex)
1010
+ rs[:] = beta[:k+1]
1011
+ y = mat.I * rs
1012
+ for i in range(k+1):
1013
+ sol.data += y[i] * Q[i]
1014
+
1015
+ for k in range(m):
1016
+ h,q = arnoldi(A,Q,k)
1017
+ H.append(h)
1018
+ if q is None:
1019
+ break
1020
+ Q.append(q)
1021
+ apply_givens_rotation(h, cs, sn, k)
1022
+ beta[k+1] = -sn[k].conjugate() * beta[k]
1023
+ beta[k] = cs[k] * beta[k]
1024
+ error = abs(beta[k+1])
1025
+ if self.callback_sol is not None:
1026
+ calcSolution(k)
1027
+ if self.CheckResidual(error):
1028
+ break
1029
+ if self.restart is not None and (k+1 == self.restart and not (self.restart == self.maxiter)):
1030
+ calcSolution(k)
1031
+ del Q
1032
+ restarted_solver = GMResSolver(mat=self.mat,
1033
+ pre=self.pre,
1034
+ tol=0,
1035
+ atol=self._final_residual,
1036
+ callback=self.callback,
1037
+ callback_sol=self.callback_sol,
1038
+ maxiter=self.maxiter,
1039
+ restart=self.restart,
1040
+ printrates=self.printrates)
1041
+ restarted_solver.iterations = self.iterations
1042
+ sol = restarted_solver.Solve(rhs = rhs, sol = sol, initialize=False)
1043
+ self.residuals += restarted_solver.residuals
1044
+ self.iterations = restarted_solver.iterations
1045
+ return sol
1046
+ calcSolution(k)
1047
+ return sol
1048
+
1049
+ def GMRes(A, b, pre=None, freedofs=None, x=None, maxsteps = 100, tol = None, innerproduct=None,
1050
+ callback=None, restart=None, startiteration=0, printrates=True, reltol=None):
1051
+ """Restarting preconditioned gmres solver for A*x=b. Minimizes the preconditioned residuum pre*(b-A*x).
1052
+
1053
+ Parameters
1054
+ ----------
1055
+
1056
+ A : BaseMatrix
1057
+ The left hand side of the linear system.
1058
+
1059
+ b : BaseVector
1060
+ The right hand side of the linear system.
1061
+
1062
+ pre : BaseMatrix = None
1063
+ The preconditioner for the system. If no preconditioner is given, the freedofs
1064
+ of the system must be given.
1065
+
1066
+ freedofs : BitArray = None
1067
+ Freedofs to solve on, only necessary if no preconditioner is given.
1068
+
1069
+ x : BaseVector = None
1070
+ Startvector, if given it will be modified in the routine and returned. Will be created
1071
+ if not given.
1072
+
1073
+ maxsteps : int = 100
1074
+ Maximum iteration steps.
1075
+
1076
+ tol : float = 1e-7
1077
+
1078
+ innerproduct : function = None
1079
+ Innerproduct to be used in iteration, all orthogonalizations/norms are computed with
1080
+ respect to that inner product.
1081
+
1082
+ callback : function = None
1083
+ If given, this function is called with the solution vector x in each step. Only for debugging
1084
+
1085
+ restart : int = None
1086
+ If given, gmres is restarted with the current solution x every 'restart' steps.
1087
+
1088
+ startiteration : int = 0
1089
+ Internal value to count total number of iterations in restarted setup, no user input required
1090
+ here.
1091
+
1092
+ printrates : bool = True
1093
+ Print norm of preconditioned residual in each step.
1094
+ """
1095
+ solver = GMResSolver(mat=A, pre=pre, freedofs=freedofs,
1096
+ maxiter=maxsteps, tol=reltol, atol=tol,
1097
+ innerproduct=innerproduct,
1098
+ callback_sol=callback, restart=restart,
1099
+ printrates=printrates)
1100
+ return solver.Solve(rhs=b, sol=x)
1101
+
1102
+
1103
+
1104
+
1105
+ from ngsolve.la import EigenValues_Preconditioner
1106
+ def BramblePasciakCG(A, B, C, f, g, preA, preS, maxit=1000, tol=1e-8, \
1107
+ printrates=False):
1108
+
1109
+ printeol = "\n"
1110
+ if isinstance(printrates, str):
1111
+ printeol = printrates
1112
+ printrates = True
1113
+
1114
+ lam = EigenValues_Preconditioner(A,preA)
1115
+ if printrates==True:
1116
+ print ("lammin/lammax = ", lam[0], '/', lam[-1])
1117
+ preA = 1.2/lam[0]*preA # scaling
1118
+
1119
+
1120
+ x = BlockVector([f.CreateVector(), g.CreateVector()])
1121
+ w,r,p,ap = [x.CreateVector() for i in range(4)]
1122
+
1123
+ # r.data = b
1124
+ # p.data = pre*r
1125
+ pru = (preA * f).Evaluate()
1126
+ r[0].data = A*pru - f
1127
+ r[1].data = B*pru - g
1128
+ p[0].data = pru
1129
+ p[1].data = preS*r[1]
1130
+
1131
+ wrn = InnerProduct(r,p)
1132
+ err0 = sqrt(wrn)
1133
+
1134
+ x[:] = 0
1135
+ for it in range(maxit):
1136
+ # ap.data = A * p
1137
+ hv = (A * p[0] + B.T * p[1]).Evaluate()
1138
+ papu = (preA * hv).Evaluate()
1139
+ ap[0].data = A * papu - hv
1140
+ ap[1].data = B * (papu - p[0])
1141
+ if C is not None:
1142
+ ap[1].data += C * p[1]
1143
+
1144
+ pap = InnerProduct(p, ap)
1145
+ wr = wrn
1146
+ alpha = wr / pap
1147
+
1148
+ x += alpha * p
1149
+ r -= alpha * ap
1150
+ pru -= alpha * papu
1151
+
1152
+ # w.data = pre*r
1153
+ w[0].data = pru
1154
+ w[1].data = preS * r[1]
1155
+
1156
+ wrn = InnerProduct(w, r)
1157
+ err = sqrt(wrn)
1158
+ if printrates==True:
1159
+ print ("Iteration",it,"err=",err," ",end=printeol)
1160
+ if err < tol * err0: break
1161
+
1162
+ beta = wrn / wr
1163
+
1164
+ p *= beta
1165
+ p.data += w
1166
+
1167
+ return x[0], x[1]
1168
+
1169
+
1170
+
1171
+ def update_plot(plt, ax, its, ress):
1172
+ # its.append(it)
1173
+ # ress.append(res)
1174
+ ax.clear()
1175
+ ax.semilogy(its, ress, label='error')
1176
+ ax.set_xlabel('iteration')
1177
+ ax.set_ylabel('error')
1178
+ ax.set_title('CG Solver Convergence')
1179
+ ax.legend()
1180
+ plt.draw()
1181
+ clear_output(wait=True)
1182
+ display(fig)