Peano 4
Loading...
Searching...
No Matches
BSplinesStencilFactory.cpph
Go to the documentation of this file.
1#include "peano4/utils/Loop.h"
2#include "ElementMatrix.h"
3
4
5template <int p, int N>
9) {
11
12 d2for(row,N)
13 tarch::la::Vector<2,int> relativeIntegrationElement = tarch::la::Vector<2,int>(N) - 1 - row;
14 tarch::la::Vector<(2*p+1)*(2*p+1),double> rowStencil = stencilProduct(
15 stencilX[relativeIntegrationElement(0)],
16 stencilY[relativeIntegrationElement(1)]
17 );
18 d2for(col,N)
19 tarch::la::Vector<2,int> stencilEntry = tarch::la::Vector<2,int>((2*p+1)/2) + col - row;
20 if ( tarch::la::allGreaterEquals(stencilEntry,0) && tarch::la::allSmaller(stencilEntry,2*p+1) ) {
21 int linearisedStencilEntry = peano4::utils::d2Linearised(stencilEntry,2*p+1);
22 result(rowScalar,colScalar) = rowStencil(linearisedStencilEntry);
23 }
26 return result;
27}
28
29
30template <int p, int N>
35) {
37
38 d3for(row,N)
39 tarch::la::Vector<3,int> relativeIntegrationElement = tarch::la::Vector<3,int>(N) - 1 - row;
40 tarch::la::Vector<(2*p+1)*(2*p+1)*(2*p+1),double> rowStencil = stencilProduct(
41 stencilX[relativeIntegrationElement(0)],
42 stencilY[relativeIntegrationElement(1)],
43 stencilZ[relativeIntegrationElement(2)]
44 );
45 d3for(col,N)
46 tarch::la::Vector<3,int> stencilEntry = tarch::la::Vector<3,int>((2*p+1)/2) + col - row;
47 if ( tarch::la::allGreaterEquals(stencilEntry,0) && tarch::la::allSmaller(stencilEntry,2*p+1) ) {
48 int linearisedStencilEntry = peano4::utils::d3Linearised(stencilEntry,2*p+1);
49 result(rowScalar,colScalar) = rowStencil(linearisedStencilEntry);
50 }
53 return result;
54}
#define d3for(counter, max)
If Dimensions is not set to three, we might nevertheless need two-dimensional loops.
Definition Loop.h:790
#define d2for(counter, max)
If Dimensions is not set to two, we might nevertheless need two-dimensional loops.
Definition Loop.h:718
#define enddforx
I prefer to use this macro for dforx instead of a closing bracket as many syntax parser fail otherwis...
Definition Loop.h:928
Static (i.e.
Definition Matrix.h:31
static tarch::la::Matrix< N *N, N *N, double > getElementWiseAssemblyMatrix(tarch::la::Vector< 2 *p+1, double > stencilX[N], tarch::la::Vector< 2 *p+1, double > stencilY[N])
N means NumberOfInfluencingVerticesAroundCurrentElementAlongEachAxis.
int d2Linearised(const tarch::la::Vector< 2, int > &counter, int max)
Special 2d variant of dLinearised that works also if you compile with other dimensions.
Definition Loop.cpp:116
int d3Linearised(const tarch::la::Vector< 3, int > &counter, int max)
Special 3d variant of dLinearised that works also if you compile with other dimensions.
Definition Loop.cpp:129
bool allGreaterEquals(const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
bool allSmaller(const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
tarch::la::Vector< StencilSize *StencilSize, double > stencilProduct(const tarch::la::Vector< StencilSize, double > &a, const tarch::la::Vector< StencilSize, double > &b)
Simple vector class.
Definition Vector.h:134