3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
doubleexpintegrationconstants.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 * *
19 * This version is modified after the original version by John D. Cook *
20 * see https://www.codeproject.com/ *
21 * Articles/31550/Fast-Numerical-Integration *
22 * which is licensed under BSD-2-clause, which reads as follows: *
23 * Copyright John D. Cook *
24 * *
25 * Redistribution and use in source and binary forms, with or without *
26 * modification, are permitted provided that the following *
27 * conditions are met: *
28 * 1. Redistributions of source code must retain the above *
29 * copyright notice, this list of conditions *
30 and the following disclaimer. *
31 * 2. Redistributions in binary form must reproduce the above *
32 * copyright notice, this list of conditions *
33 * and the following disclaimer *
34 * in the documentation and/or other materials *
35 * provided with the distribution. *
36 * *
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
38 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
39 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
40 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
41 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, *
42 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE *
44 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
45 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, *
46 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE *
47 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, *
48 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
49 * *
50 *****************************************************************************/
56#ifndef DUMUX_COMMON_DOUBLEEXP_INTEGRATION_CONSTANTS_HH
57#define DUMUX_COMMON_DOUBLEEXP_INTEGRATION_CONSTANTS_HH
58
59/*
60The double exponential rule is based on the observation that the trapezoid rule converges
61very rapidly for functions on the entire real line that go to zero like exp( - exp(t) ).
62The change of variables x = tanh( pi sinh(t) /2) transforms an integral over [-1, 1]
63into an integral with integrand suited to the double exponential rule.
64
65The transformed integral is infinite, but we truncate the domain of integration to [-3, 3].
66The limit '3' was chosen for two reasons: for t = 3, the transformed x values
67are nearly equal to 1 for 12 or more significant figures. Also, for t = 3, the
68smallest weights are 12 orders of magnitude smaller than the largest weights; setting
69the cutoff larger than 3 would not have a significant impact on the integral value
70unless there is a strong singularity at one of the end points.
71
72The change of variables x(t) is an odd function, i.e. x(-t) = -x(t), and so we need only
73store the positive x values. Also, the derivative w(t) = x'(t) is even, i.e. w(-t) = w(t),
74and so we need only store the weights corresponding to positive values of x.
75
76The integration first applies the trapezoid rule to [-3, 3] in steps of size 1.
77Then it subsequently cuts the step size in half each time, comparing the results.
78Integration stops when subsequent iterations are close enough together or the maximum
79integration points have been used.
80By cutting h in half, the previous integral can be reused; we only need evaluate the
81integrand at the newly added points.
82
83Finally, note that we're not strictly using the trapezoid rule: we don't treat the
84end points differently. This is because we assume the values at the ends of the interval
85hardly matter due to the rapid decay of the integrand.
86
87All values below were calculated with Mathematica.
88*/
89
90namespace Dumux {
91
93{
94 // 1st layer abcissas: transformed 0, 1, 2, 3
95 0.00000000000000000000,
96 0.95136796407274694573,
97 0.99997747719246159286,
98 0.99999999999995705839,
99 // 2nd layer abcissas: transformed 1/2, 3/2, 5/2
100 0.67427149224843582608,
101 0.99751485645722438683,
102 0.99999998887566488198,
103 // 3rd layer abcissas: transformed 1/4, 3/4, ...
104 0.37720973816403417379,
105 0.85956905868989663517,
106 0.98704056050737689169,
107 0.99968826402835320905,
108 0.99999920473711471266,
109 0.99999999995285644818,
110 // 4th layer abcissas: transformed 1/8, 3/8, ...
111 0.19435700332493543161,
112 0.53914670538796776905,
113 0.78060743898320029925,
114 0.91487926326457461091,
115 0.97396686819567744856,
116 0.99405550663140214329,
117 0.99906519645578584642,
118 0.99990938469514399984,
119 0.99999531604122052843,
120 0.99999989278161241838,
121 0.99999999914270509218,
122 0.99999999999823216531,
123 // 5th layer abcissa: transformed 1/16, 3/16, ...
124 0.097923885287832333262,
125 0.28787993274271591456,
126 0.46125354393958570440,
127 0.61027365750063894488,
128 0.73101803479256151149,
129 0.82331700550640237006,
130 0.88989140278426019808,
131 0.93516085752198468323,
132 0.96411216422354729193,
133 0.98145482667733517003,
134 0.99112699244169880223,
135 0.99610866543750854254,
136 0.99845420876769773751,
137 0.99945143443527460584,
138 0.99982882207287494166,
139 0.99995387100562796075,
140 0.99998948201481850361,
141 0.99999801714059543208,
142 0.99999969889415261122,
143 0.99999996423908091534,
144 0.99999999678719909830,
145 0.99999999978973286224,
146 0.99999999999039393352,
147 0.99999999999970809734,
148 // 6th layer abcissas: transformed 1/32, 3/32, ...
149 0.049055967305077886315,
150 0.14641798429058794053,
151 0.24156631953888365838,
152 0.33314226457763809244,
153 0.41995211127844715849,
154 0.50101338937930910152,
155 0.57558449063515165995,
156 0.64317675898520470128,
157 0.70355000514714201566,
158 0.75669390863372994941,
159 0.80279874134324126576,
160 0.84221924635075686382,
161 0.87543539763040867837,
162 0.90301328151357387064,
163 0.92556863406861266645,
164 0.94373478605275715685,
165 0.95813602271021369012,
166 0.96936673289691733517,
167 0.97797623518666497298,
168 0.98445883116743083087,
169 0.98924843109013389601,
170 0.99271699719682728538,
171 0.99517602615532735426,
172 0.99688031812819187372,
173 0.99803333631543375402,
174 0.99879353429880589929,
175 0.99928111192179195541,
176 0.99958475035151758732,
177 0.99976797159956083506,
178 0.99987486504878034648,
179 0.99993501992508242369,
180 0.99996759306794345976,
181 0.99998451990227082442,
182 0.99999293787666288565,
183 0.99999693244919035751,
184 0.99999873547186590954,
185 0.99999950700571943689,
186 0.99999981889371276701,
187 0.99999993755407837378,
188 0.99999997987450320175,
189 0.99999999396413420165,
190 0.99999999832336194826,
191 0.99999999957078777261,
192 0.99999999989927772326,
193 0.99999999997845533741,
194 0.99999999999582460688,
195 0.99999999999927152627,
196 0.99999999999988636130,
197 // 7th layer abcissas: transformed 1/64, 3/64, ...
198 0.024539763574649160379,
199 0.073525122985671294475,
200 0.12222912220155764235,
201 0.17046797238201051811,
202 0.21806347346971200463,
203 0.26484507658344795046,
204 0.31065178055284596083,
205 0.35533382516507453330,
206 0.39875415046723775644,
207 0.44078959903390086627,
208 0.48133184611690504422,
209 0.52028805069123015958,
210 0.55758122826077823080,
211 0.59315035359195315880,
212 0.62695020805104287950,
213 0.65895099174335012438,
214 0.68913772506166767176,
215 0.71750946748732412721,
216 0.74407838354734739913,
217 0.76886868676824658459,
218 0.79191549237614211447,
219 0.81326360850297385168,
220 0.83296629391941087564,
221 0.85108400798784873261,
222 0.86768317577564598669,
223 0.88283498824466895513,
224 0.89661425428007602579,
225 0.90909831816302043511,
226 0.92036605303195280235,
227 0.93049693799715340631,
228 0.93957022393327475539,
229 0.94766419061515309734,
230 0.95485549580502268541,
231 0.96121861515111640753,
232 0.96682537031235585284,
233 0.97174454156548730892,
234 0.97604156025657673933,
235 0.97977827580061576265,
236 0.98301279148110110558,
237 0.98579936302528343597,
238 0.98818835380074264243,
239 0.99022624046752774694,
240 0.99195566300267761562,
241 0.99341551316926403900,
242 0.99464105571251119672,
243 0.99566407681695316965,
244 0.99651305464025377317,
245 0.99721334704346870224,
246 0.99778739195890653083,
247 0.99825491617199629344,
248 0.99863314864067747762,
249 0.99893703483351217373,
250 0.99917944893488591716,
251 0.99937140114093768690,
252 0.99952223765121720422,
253 0.99963983134560036519,
254 0.99973076151980848263,
255 0.99980048143113838630,
256 0.99985347277311141171,
257 0.99989338654759256426,
258 0.99992317012928932869,
259 0.99994518061445869309,
260 0.99996128480785666613,
261 0.99997294642523223656,
262 0.99998130127012072679,
263 0.99998722128200062811,
264 0.99999136844834487344,
265 0.99999423962761663478,
266 0.99999620334716617675,
267 0.99999752962380516793,
268 0.99999841381096473542,
269 0.99999899541068996962,
270 0.99999937270733536947,
271 0.99999961398855024275,
272 0.99999976602333243312,
273 0.99999986037121459941,
274 0.99999991800479471056,
275 0.99999995264266446185,
276 0.99999997311323594362,
277 0.99999998500307631173,
278 0.99999999178645609907,
279 0.99999999558563361584,
280 0.99999999767323673790,
281 0.99999999879798350040,
282 0.99999999939177687583,
283 0.99999999969875436925,
284 0.99999999985405611550,
285 0.99999999993088839501,
286 0.99999999996803321674,
287 0.99999999998556879008,
288 0.99999999999364632387,
289 0.99999999999727404948,
290 0.99999999999886126543,
291 0.99999999999953722654,
292 0.99999999999981720098,
293 0.99999999999992987953
294}; // end abcissas
295
297{
298 // First layer weights
299 1.5707963267948966192,
300 0.230022394514788685,
301 0.00026620051375271690866,
302 1.3581784274539090834e-12,
303 // 2nd layer weights
304 0.96597657941230114801,
305 0.018343166989927842087,
306 2.1431204556943039358e-7,
307 // 3rd layer weights
308 1.3896147592472563229,
309 0.53107827542805397476,
310 0.076385743570832304188,
311 0.0029025177479013135936,
312 0.000011983701363170720047,
313 1.1631165814255782766e-9,
314 // 4th layer weights
315 1.5232837186347052132,
316 1.1934630258491569639,
317 0.73743784836154784136,
318 0.36046141846934367417,
319 0.13742210773316772341,
320 0.039175005493600779072,
321 0.0077426010260642407123,
322 0.00094994680428346871691,
323 0.000062482559240744082891,
324 1.8263320593710659699e-6,
325 1.8687282268736410132e-8,
326 4.9378538776631926964e-11,
327 // 5th layer weights
328 1.5587733555333301451,
329 1.466014426716965781,
330 1.297475750424977998,
331 1.0816349854900704074,
332 0.85017285645662006895,
333 0.63040513516474369106,
334 0.44083323627385823707,
335 0.290240679312454185,
336 0.17932441211072829296,
337 0.10343215422333290062,
338 0.055289683742240583845,
339 0.027133510013712003219,
340 0.012083543599157953493,
341 0.0048162981439284630173,
342 0.0016908739981426396472,
343 0.00051339382406790336017,
344 0.00013205234125609974879,
345 0.000028110164327940134749,
346 4.8237182032615502124e-6,
347 6.4777566035929719908e-7,
348 6.5835185127183396672e-8,
349 4.8760060974240625869e-9,
350 2.5216347918530148572e-10,
351 8.6759314149796046502e-12,
352 // 6th layer weights
353 1.5677814313072218572,
354 1.5438811161769592204,
355 1.4972262225410362896,
356 1.4300083548722996676,
357 1.3452788847662516615,
358 1.2467012074518577048,
359 1.1382722433763053734,
360 1.0240449331118114483,
361 0.90787937915489531693,
362 0.79324270082051671787,
363 0.68306851634426375464,
364 0.57967810308778764708,
365 0.48475809121475539287,
366 0.39938474152571713515,
367 0.32408253961152890402,
368 0.258904639514053516,
369 0.20352399885860174519,
370 0.15732620348436615027,
371 0.11949741128869592428,
372 0.089103139240941462841,
373 0.065155533432536205042,
374 0.046668208054846613644,
375 0.032698732726609031113,
376 0.022379471063648476483,
377 0.014937835096050129696,
378 0.0097072237393916892692,
379 0.0061300376320830301252,
380 0.0037542509774318343023,
381 0.0022250827064786427022,
382 0.0012733279447082382027,
383 0.0007018595156842422708,
384 0.00037166693621677760301,
385 0.00018856442976700318572,
386 0.000091390817490710122732,
387 0.000042183183841757600604,
388 0.000018481813599879217116,
389 7.6595758525203162562e-6,
390 2.9916615878138787094e-6,
391 1.0968835125901264732e-6,
392 3.7595411862360630091e-7,
393 1.1992442782902770219e-7,
394 3.5434777171421953043e-8,
395 9.6498888961089633609e-9,
396 2.4091773256475940779e-9,
397 5.482835779709497755e-10,
398 1.1306055347494680536e-10,
399 2.0989335404511469109e-11,
400 3.4841937670261059685e-12,
401 // 7th layer weights
402 1.5700420292795931467,
403 1.5640214037732320999,
404 1.5520531698454121192,
405 1.5342817381543034316,
406 1.5109197230741697127,
407 1.48224329788553807,
408 1.4485862549613225916,
409 1.4103329714462590129,
410 1.3679105116808964881,
411 1.3217801174437728579,
412 1.2724283455378627082,
413 1.2203581095793582207,
414 1.1660798699324345766,
415 1.1101031939653403796,
416 1.0529288799552666556,
417 0.99504180404613271514,
418 0.93690461274566793366,
419 0.87895234555278212039,
420 0.82158803526696470334,
421 0.7651792989089561367,
422 0.71005590120546898385,
423 0.65650824613162753076,
424 0.60478673057840362158,
425 0.55510187800363350959,
426 0.5076251588319080997,
427 0.4624903980553677613,
428 0.41979566844501548066,
429 0.37960556938665160999,
430 0.3419537959230168323,
431 0.30684590941791694932,
432 0.27426222968906810637,
433 0.24416077786983990868,
434 0.21648020911729617038,
435 0.19114268413342749532,
436 0.16805663794826916233,
437 0.14711941325785693248,
438 0.12821973363120098675,
439 0.11123999898874453035,
440 0.096058391865189467849,
441 0.082550788110701737654,
442 0.070592469906866999352,
443 0.060059642358636300319,
444 0.05083075757257047107,
445 0.042787652157725676034,
446 0.035816505604196436523,
447 0.029808628117310126969,
448 0.024661087314753282511,
449 0.020277183817500123926,
450 0.016566786254247575375,
451 0.013446536605285730674,
452 0.010839937168255907211,
453 0.0086773307495391815854,
454 0.0068957859690660035329,
455 0.0054388997976239984331,
456 0.0042565295990178580165,
457 0.0033044669940348302363,
458 0.0025440657675291729678,
459 0.0019418357759843675814,
460 0.0014690143599429791058,
461 0.0011011261134519383862,
462 0.00081754101332469493115,
463 0.00060103987991147422573,
464 0.00043739495615911687786,
465 0.00031497209186021200274,
466 0.00022435965205008549104,
467 0.00015802788400701191949,
468 0.00011002112846666697224,
469 0.000075683996586201477788,
470 0.000051421497447658802092,
471 0.0000344921247593431977,
472 0.000022832118109036146591,
473 0.000014908514031870608449,
474 9.5981941283784710776e-6,
475 6.0899100320949039256e-6,
476 3.8061983264644899045e-6,
477 2.3421667208528096843e-6,
478 1.4183067155493917523e-6,
479 8.4473756384859863469e-7,
480 4.9458288702754198508e-7,
481 2.8449923659159806339e-7,
482 1.6069394579076224911e-7,
483 8.9071395140242387124e-8,
484 4.8420950198072369669e-8,
485 2.579956822953589238e-8,
486 1.3464645522302038796e-8,
487 6.8784610955899001111e-9,
488 3.4371856744650090511e-9,
489 1.6788897682161906807e-9,
490 8.0099784479729665356e-10,
491 3.7299501843052790038e-10,
492 1.6939457789411646876e-10,
493 7.4967397573818224522e-11,
494 3.230446433325236576e-11,
495 1.3542512912336274432e-11,
496 5.5182369468174885821e-12,
497 2.1835922099233609052e-12
498}; // end weights
499
500} // end namespace Dumux
501
502#endif
Definition: adapt.hh:29
constexpr double doubleExponentialIntegrationWeights[]
Definition: doubleexpintegrationconstants.hh:296
constexpr double doubleExponentialIntegrationAbcissas[]
Definition: doubleexpintegrationconstants.hh:92