13 We return a square matrix
14 with 2**Dimensions rows.
16 Much of this code is identical to 2d version. We could
17 even reuse this for the 2d version with clever indexing,
18 but it the code is much more readable this way.
23 TwoPowerD = 2 ** Dimensions
24 result = np.zeros((TwoPowerD, TwoPowerD))
34 for iScalar
in range(TwoPowerD):
35 i = [0
for _
in range(Dimensions)]
40 BBi = int( not( AAi ^ BBi ) )
41 CCi = int( CCi
or ( not(AAi)
and not(BBi)
and not(CCi) ) )
43 for jScalar
in range(TwoPowerD):
44 j = [0
for _
in range(Dimensions)]
49 BBj = int( not( AAj ^ BBj ) )
50 CCj = int( CCi
or ( not(AAj)
and not(BBj)
and not(CCj) ) )
52 stencilEntry = [0
for _
in range(Dimensions)]
53 commonFacesPower2 = 1.0
55 for d
in range(Dimensions):
56 stencilEntry[d] = i[d] - j[d] + 1
58 commonFacesPower2 *= 2.0
59 result[iScalar, jScalar] = stencil.flatten()[
dLinearised(stencilEntry,3, Dimensions) ] / commonFacesPower2
64 This is borrowed from src/toolbox/ElementMatrix.cpp.
65 In particular toolbox::finiteelements::getElementWiseAssemblyMatrix()
68 assert stencil.shape == (3,3),
"Wrong shape for this dimensions!"
71 TwoPowerD = 2 ** Dimensions
72 result = np.zeros((TwoPowerD, TwoPowerD))
80 for iScalar
in range(TwoPowerD):
81 i = [0
for _
in range(Dimensions)]
85 BBi = int( not( AAi ^ BBi ) )
88 for jScalar
in range(TwoPowerD):
89 j = [0
for _
in range(Dimensions)]
93 BBj = int( not( AAj ^ BBj ) )
95 stencilEntry = [0
for _
in range(Dimensions)]
96 commonFacesPower2 = 1.0
98 for d
in range(Dimensions):
99 stencilEntry[d] = i[d] - j[d] + 1
101 commonFacesPower2 *= 2.0
102 result[iScalar, jScalar] = stencil.flatten()[
dLinearised(stencilEntry,3, Dimensions) ] / commonFacesPower2
106 result = vector[dimensions - 1]
107 for d
in range(dimensions-2, -1, -1):
108 result = result * max + vector[d]