Commit 26f0d171 authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

increased efficiency of iterpolator. trilinear interpolation not worth it, as...

increased efficiency of iterpolator. trilinear interpolation not worth it, as it increases computational effort quiet a lot, while barely being more accurate
parent 01bc6394
This diff is collapsed.
......@@ -385,6 +385,8 @@ class Interpolate_direct {
int boxCounter{};
int typCounter0{},typCounter1{},typCounter2{},typCounter3{},typCounter4{},typCounter5{};
bool debugTest;
bool badLambdaFound;
bool trilinearInterpolationFlag{false};
D3vector lambda;
D3vector vNow{1e10,1e10,1e10}, vPrev, vPrevPrev, vPrevPrevPrev;
......@@ -435,7 +437,7 @@ private:
void setPrevPrevPrevIndex();
int checkForHexaNeighbours(int idHex, int i, int j, int k, D3vector v);
int checkBoxSurrounding(int idHex, int i, int j, int k, D3vector v);
int checkBoxSurroundingOptimized(int idHex, int i, int j, int k, D3vector v);
int checkBoxSurroundingOptimized(int idHex, int i, int j, int k, D3vector v, bool neglectBadLambda = false);
int checkCorner(int idHex, int i, int j, int k, D3vector v);
int checkEdge(int idHex, int i, int j, int k, D3vector v);
bool checkOverlapOfBoxes(D3vector vWSD, D3vector vENT, D3vector wWSD, D3vector wENT);
......@@ -455,8 +457,8 @@ DTyp Interpolate_direct::evaluate(Variable<DTyp> &u)
DTyp returnVal;
//for(int id=0;id<ug->Give_number_hexahedra();++id)
// u.template Update<hexahedronEl>(id);
// for(int id=0;id<5;++id)
// u.template Update<hexahedronEl>(id);
if(idHexNow < 0)
......@@ -483,7 +485,17 @@ DTyp Interpolate_direct::evaluate(Variable<DTyp> &u)
du.ENT(),du.WNT(),du.EST(),du.END());
if(typ==5) returnVal = interpolate_in_tet(lambda,
du.WNT(),du.WND(),du.EST(),du.END());
if(typ==6) returnVal = interpolate_in_tet_trilinear(lambda,du.END(),du.ESD(),du.WSD(),du.WND(),
du.WNT(),du.WST(),du.EST(),du.ENT());
}
// D3vector cWSD = {1,1,0}; // 1,1,0 : x2
// D3vector cESD = {2,0,-1}; // 1,0,0 : x1
// D3vector cWND = {0,1,0}; // 0,1,0 : x3
// D3vector cEND = {-1,0,-1.0}; // 0,0,0 : x0
// D3vector cWST = {1,1,1}; // 1,1,1 : x5
// D3vector cEST = {2,0,2}; // 1,0,1 : x6
// D3vector cWNT = {0,1,1}; // 0,1,1 : x4
// D3vector cENT = {-1,0,2}; // 0,0,1 : x7
return returnVal;
};
......
......@@ -377,6 +377,26 @@ DTyp interpolate_in_tet(D3vector lambda,
return vA + (vB-vA) * lambda.x + (vC-vA) * lambda.y + (vD-vA) * lambda.z;
}
template <class DTyp>
DTyp interpolate_in_tet_trilinear(D3vector lambda,
DTyp x0, DTyp x1,
DTyp x2, DTyp x3,
DTyp x4, DTyp x5,
DTyp x6, DTyp x7) {
DTyp A = x0;
DTyp B = x1-x0;
DTyp C = x3-x0;
DTyp D = x7-x0;
DTyp E = x2-x1-x3+x0;
DTyp F = x4-x3-x7+x0;
DTyp G = x6-x1-x7+x0;
DTyp H = x1+x3+x5+x7-x0-x2-x4-x6;
DTyp R = A + B * lambda.x + C * lambda.y + D * lambda.z + E * lambda.x*lambda.y + F * lambda.y*lambda.z + G * lambda.x * lambda.z + H * lambda.x*lambda.y*lambda.z;
return R;
// return vA + (vB-vA) * lambda.x + (vC-vA) * lambda.y + (vD-vA) * lambda.z;
}
//////////////////////////////////////////////////////////////////////
// 3. geometric operators for 3D vectors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment