Mimetic Operators Library Enhanced 4.0
Loading...
Searching...
No Matches
Interpol Class Reference

Mimetic Interpolator operator. More...

#include <interpol.h>

Inheritance diagram for Interpol:

Public Member Functions

 Interpol (u32 m, Real c)
 1-D Mimetic Interpolator Constructor
 
 Interpol (u32 m, u32 n, Real c1, Real c2)
 2-D Mimetic Interpolator Constructor
 
 Interpol (u32 m, u32 n, u32 o, Real c1, Real c2, Real c3)
 3-D Mimetic Interpolator Constructor
 
 Interpol (bool type, u32 m, Real c)
 1-D Mimetic Interpolator Constructor
 
 Interpol (bool type, u32 m, u32 n, Real c1, Real c2)
 2-D Mimetic Interpolator Constructor
 
 Interpol (bool type, u32 m, u32 n, u32 o, Real c1, Real c2, Real c3)
 3-D Mimetic Interpolator Constructor
 

Detailed Description

Mimetic Interpolator operator.

Definition at line 25 of file interpol.h.

Constructor & Destructor Documentation

◆ Interpol() [1/6]

Interpol::Interpol ( u32 m,
Real c )

1-D Mimetic Interpolator Constructor

Parameters
mNumber of cells
cWeight for ends, can be any value from 0.0<=c<=1.0

Definition at line 19 of file interpol.cpp.

19 : sp_mat(m + 1, m + 2) {
20 assert(m >= 4);
21 assert(c >= 0 && c <= 1);
22
23 at(0, 0) = 1;
24 at(m, m + 1) = 1;
25
26 for (u32 i = 1; i < m; i++) {
27 at(i, i) = c;
28 at(i, i + 1) = 1 - c;
29 }
30}

◆ Interpol() [2/6]

Interpol::Interpol ( u32 m,
u32 n,
Real c1,
Real c2 )

2-D Mimetic Interpolator Constructor

Parameters
mNumber of cells in x-direction
nNumber of cells in y-direction
c1Weight for ends in x-direction, can be any value from 0.0<=c<=1.0
c2Weight for ends in y-direction, can be any value from 0.0<=c<=1.0

Definition at line 33 of file interpol.cpp.

33 {
34 Interpol Ix(m, c1);
35 Interpol Iy(n, c2);
36
37 sp_mat Im = speye(m + 2, m + 2);
38 sp_mat In = speye(n + 2, n + 2);
39
40 Im.shed_row(0);
41 Im.shed_row(m);
42 In.shed_row(0);
43 In.shed_row(n);
44
45 sp_mat I1 = Utils::spkron(In, Ix);
46 sp_mat I2 = Utils::spkron(Iy, Im);
47
48 // Dimensions = 2*m*n+m+n, (m+2)*(n+2)
49 if (m != n)
50 *this = Utils::spjoin_cols(I1, I2);
51 else {
52 sp_mat A1(2, 1);
53 sp_mat A2(2, 1);
54 A1(0, 0) = A2(1, 0) = 1.0;
55 *this = Utils::spkron(A1, I1) + Utils::spkron(A2, I2);
56 }
57}
Interpol(u32 m, Real c)
1-D Mimetic Interpolator Constructor
Definition interpol.cpp:19
static sp_mat spjoin_cols(const sp_mat &A, const sp_mat &B)
An in place operation for joining two matrices by columns.
Definition utils.cpp:138
static sp_mat spkron(const sp_mat &A, const sp_mat &B)
A wrappper for implementing a sparse Kroenecker product.
Definition utils.cpp:70

◆ Interpol() [3/6]

Interpol::Interpol ( u32 m,
u32 n,
u32 o,
Real c1,
Real c2,
Real c3 )

3-D Mimetic Interpolator Constructor

Parameters
mNumber of cells in x-direction
nNumber of cells in y-direction
oNumber of cells in z-direction
c1Weight for ends in x-direction, can be any value from 0.0<=c<=1.0
c2Weight for ends in y-direction, can be any value from 0.0<=c<=1.0
c3Weight for ends in z-direction, can be any value from 0.0<=c<=1.0

Definition at line 60 of file interpol.cpp.

60 {
61 Interpol Ix(m, c1);
62 Interpol Iy(n, c2);
63 Interpol Iz(o, c3);
64
65 sp_mat Im = speye(m + 2, m + 2);
66 sp_mat In = speye(n + 2, n + 2);
67 sp_mat Io = speye(o + 2, o + 2);
68
69 Im.shed_row(0);
70 Im.shed_row(m);
71 In.shed_row(0);
72 In.shed_row(n);
73 Io.shed_row(0);
74 Io.shed_row(o);
75
76 sp_mat I1 = Utils::spkron(Utils::spkron(Io, In), Ix);
77 sp_mat I2 = Utils::spkron(Utils::spkron(Io, Iy), Im);
78 sp_mat I3 = Utils::spkron(Utils::spkron(Iz, In), Im);
79
80 // Dimensions = 3*m*n*o+m*n+m*o+n*o, (m+2)*(n+2)*(o+2)
81 if ((m != n) || (n != o))
82 *this = Utils::spjoin_cols(Utils::spjoin_cols(I1, I2), I3);
83 else {
84 sp_mat A1(3, 1);
85 sp_mat A2(3, 1);
86 sp_mat A3(3, 1);
87 A1(0, 0) = A2(1, 0) = A3(2, 0) = 1.0;
88 *this =
89 Utils::spkron(A1, I1) + Utils::spkron(A2, I2) + Utils::spkron(A3, I3);
90 }
91}

◆ Interpol() [4/6]

Interpol::Interpol ( bool type,
u32 m,
Real c )

1-D Mimetic Interpolator Constructor

Parameters
typeDummy holder to trigger overloaded function
mNumber of cells
cWeight for ends, can be any value from 0.0<=c<=1.0

Definition at line 94 of file interpol.cpp.

94 : sp_mat(m + 2, m + 1) {
95 assert(m >= 4 && "m >= 4");
96 assert(c >= 0 && c <= 1 && "0 <= c <= 1");
97
98 at(0, 0) = 1;
99 at(m + 2 - 1, m + 1 - 1) = 1;
100
101 vec avg = {c, 1 - c};
102
103 int j = 0;
104 for (int i = 1; i < m + 1; ++i) {
105 at(i, j) = avg(0);
106 at(i, j + 1) = avg(1);
107 j++;
108 }
109}

◆ Interpol() [5/6]

Interpol::Interpol ( bool type,
u32 m,
u32 n,
Real c1,
Real c2 )

2-D Mimetic Interpolator Constructor

Parameters
typeDummy holder to trigger overloaded function
mNumber of cells in x-direction
nNumber of cells in y-direction
c1Weight for ends in x-direction, can be any value from 0.0<=c<=1.0
c2Weight for ends in y-direction, can be any value from 0.0<=c<=1.0

Definition at line 112 of file interpol.cpp.

112 {
113 Interpol Ix(true, m, c1);
114 Interpol Iy(true, n, c2);
115
116 sp_mat Im(m + 2, m);
117 Im.submat(1, 0, m, m - 1) = speye(m, m);
118
119 sp_mat In(n + 2, n);
120 In.submat(1, 0, n, n - 1) = speye(n, n);
121
122 sp_mat Sx = Utils::spkron(In, Ix);
123 sp_mat Sy = Utils::spkron(Iy, Im);
124
125 *this = Utils::spjoin_rows(Sx, Sy);
126}
static sp_mat spjoin_rows(const sp_mat &A, const sp_mat &B)
An in place operation for joining two matrices by rows.
Definition utils.cpp:103

◆ Interpol() [6/6]

Interpol::Interpol ( bool type,
u32 m,
u32 n,
u32 o,
Real c1,
Real c2,
Real c3 )

3-D Mimetic Interpolator Constructor

Parameters
typeDummy holder to trigger overloaded function
mNumber of cells in x-direction
nNumber of cells in y-direction
oNumber of cells in z-direction
c1Weight for ends in x-direction, can be any value from 0.0<=c<=1.0
c2Weight for ends in y-direction, can be any value from 0.0<=c<=1.0
c3Weight for ends in z-direction, can be any value from 0.0<=c<=1.0

Definition at line 129 of file interpol.cpp.

129 {
130 Interpol Ix(true, m, c1);
131 Interpol Iy(true, n, c2);
132 Interpol Iz(true, o, c3);
133
134 sp_mat Im(m + 2, m);
135 Im.submat(1, 0, m, m - 1) = speye(m, m);
136
137 sp_mat In(n + 2, n);
138 In.submat(1, 0, n, n - 1) = speye(n, n);
139
140 sp_mat Io(o + 2, o);
141 Io.submat(1, 0, o, o - 1) = speye(o, o);
142
143 sp_mat Sx = Utils::spkron(Utils::spkron(Io, In), Ix);
144 sp_mat Sy = Utils::spkron(Utils::spkron(Io, Iy), Im);
145 sp_mat Sz = Utils::spkron(Utils::spkron(Iz, In), Im);
146
147 *this = Utils::spjoin_rows(Utils::spjoin_rows(Sx, Sy), Sz);
148}

The documentation for this class was generated from the following files: