As I am trying to verify if the given result / 0.00241392
/ before the False is good or not, I use a numerical path , that is I divide the ImplicitRegion
into smaller rectangular areas, multiply the area with the inner product of the normal vector and the given f[x,y,z]
vector field value at the corners of the small rectangular areas and add them together. Because the Implicit Region
is vertical to the xz
-plane, I determine the small rectangular areas' corner points by their x- and y-valuse and calculate the z-value from the condition that the {x,y.z}
values have to be in the plane of the Implicit region. Let's say the y-directional side of this small rectangular area is dd
, then the x-side value will be dd*Cos[alpha]
if the ImplicitRegion has an alpha angle with the xy-plane
, and the z-valus will calculated from the x-values.
Clear[x, y, z]
zz = Table[
Reduce[Dot[{x, y, z} - mHi3ret[[3, i, 1, 1]],
mHi3ret[[4, i]] ] == {0., 0.} , {x, y, z}] , {i, 1,
Length[mHi3ret[[3]] ]}]
where mHi3ret[[3]]
contain the polygons describing the i-eth ImplicitRegion
, so mHi3ret[[3, i, 1, 1]]
is the starting corner point of the i-eth ImplicitRegion
, mHi3ret[[4, i]]
is the normal vector of the i-eth ImplicitRegion
and Reduce
is giving the linear connection of the z-value corresponding to a given x-value of the i-eth ImplicitRegion
. So later on I refer to this zz
Table
to calculate the right z-velue if the x-value is given.
cosalpha =
Table[Cos[
ArcTan[mHi3ret[[3, i, 1, 1, 1]],
mHi3ret[[3, i, 1, 1, 3]] ] ] , {i, 1, Length[mHi3ret[[3]] ]}];
is giving me the Cos[alpha]
values.
With dd=0.008
, I calculate the corner points of the small rectangular regions this way:
impoints = ParallelTable[
Flatten[Table[{x, y, zz[[i, 2]]}, {x,
If[(mHi3ret[[3, i, 1, 2, 1]] - mHi3ret[[3, i, 1, 1, 1]]) >=
0 , mHi3ret[[3, i, 1, 1, 1]], mHi3ret[[3, i, 1, 2, 1]] ],
If[(mHi3ret[[3, i, 1, 2, 1]] - mHi3ret[[3, i, 1, 1, 1]]) >= 0,
mHi3ret[[3, i, 1, 2, 1]], mHi3ret[[3, i, 1, 1, 1]] ],
dd*cosalpha[[i]]}, {y, -0.0075, 0.0075, dd}], 1], {i, 1,
Length[mHi3ret[[3]] ]}]; // AbsoluteTiming
I
t takes more than an hour to calculate, on my laptop with OSX 10.13.3 and Mathematica 11.0.1 it takes 3695.71 second, that is more than an hour to get these points, although we are speaking here 6 points per ImpliciteRegion
multiplied by 440, the total numbers of ImplicitRegions
. So all together it is 2640 points. Telling otherwise Mathematica
is using more than a second to create a Point
from pre-computed numerical values on a machine that is capable almost a trillion floating point calculations in a second, with plenty of free memory, so the disk is not touched during the calculation. Why?
Given the impoints
, I calculate the flux for all the ImplicitRegions
this way:
In[350]:=
fluximpreg008 =
ParallelTable[
Total[dd^2 *
Map[Dot[mHi3ret[[4, i]], #] &,
Map[f[x, y, z] /. {x -> #[[1]], y -> #[[2]], z -> #[[3]]} &,
impoints[[i]] ] ] ], {i, 1,
Length[impoints]}]; // AbsoluteTiming
Out[350]= {2154.58, Null}
Again it takes "forever" to calculate it for such a simple vector field of :
f[x_, y_, z_] := {x + y - z, x - y + z, -x + y + z};
Any good ideas what can be done to speed up this computation? Of course I have to do it for smaller and smaller dd
s to see if the definite integral was good or not.
Thanks ahead,
János