Commit bb52a776 authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

added interpolator, special for surface only! faster than general...

added interpolator, special for surface only! faster than general interpolator, especially helpfor for interpolation of surface deformation
parent 4f3e9058
......@@ -467,7 +467,7 @@ Boundary_Marker::Boundary_Marker ( Unstructured_grid* ug_ ) : Marker ( ug_ )
else {
Set_marker<quadrangleEl> ( id, yes_mark );
for ( int i=0; i<4; ++i )
Set_marker<edgeEl> ( quad->Give_id_edge ( ( dir2D ) i ), yes_mark );
Set_marker<edgeEl> ( quad->Give_id_edge ( ( dir2D ) i ), yes_mark );
for ( int i=0; i<4; ++i )
Set_marker<pointEl> ( quad->Give_id_corner ( ( dir2D_sons ) i ), yes_mark );
}
......
This diff is collapsed.
......@@ -418,6 +418,7 @@ class Interpolate_direct {
*
**/
void find_cell(D3vector v);
void find_surface_cell(D3vector v);
/**
* Print a vtk file with a box, surrounding the cell.
**/
......@@ -457,9 +458,12 @@ class Interpolate_direct {
int getTet(){return typ_tet;}
int getHex(){return idHexNow;}
D3vector bilinearInterpolation(D3vector v,D3vector a,D3vector b,D3vector c,D3vector d);
D3vector trilinarInterpolation(D3vector v, int id_Hex,int i, int j, int k );
bool vectorInBox(D3vector vWSD, D3vector vENT, D3vector v, double eps = 1e-10);
int checkBox(int idHex, int i, int j, int k, D3vector v);
int checkBoxSurface(int idHex, int i, int j, int k, D3vector v);
private:
int idHexPrev{-1}, iPrev{-1}, jPrev{-1}, kPrev{-1};
int idHexPrevPrevPrev{-1}, iPrevPrevPrev{-1}, jPrevPrevPrev{-1}, kPrevPrevPrev{-1};
......@@ -477,6 +481,7 @@ class Interpolate_direct {
D3vector cWNT, cENT;
Blockgrid *blockgrid;
std::vector<std::vector<std::vector<D3vector> > > arrayBoxWSDENT;
std::vector<std::vector<bool > > isOuterBoundaryFlag;
std::vector<std::vector<std::vector<int> > > array_box_boundary;
std::vector<std::vector<std::vector<int> > > array_point_boundary;
......@@ -502,10 +507,14 @@ private:
void setPrevPrevIndex();
void setPrevPrevPrevIndex();
int checkForHexaNeighbours(int idHex, int i, int j, int k, D3vector v);
int checkForHexaNeighboursSurface(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, bool neglectBadLambda = false);
int checkBoxSurroundingSurface(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 checkCornerSurface(int idHex, int i, int j, int k, D3vector v);
int checkEdge(int idHex, int i, int j, int k, D3vector v);
int checkEdgeSurface(int idHex, int i, int j, int k, D3vector v);
bool checkOverlapOfBoxes(D3vector vWSD, D3vector vENT, D3vector wWSD, D3vector wENT);
double calculateOverlapOfBoxes(D3vector vWSD, D3vector vENT, D3vector wWSD, D3vector wENT);
......@@ -553,6 +562,19 @@ DTyp Interpolate_direct::evaluate(Variable<DTyp> &u)
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());
if(typ==7) returnVal = interpolate_in_tet(lambda,du.EST(),du.ESD(),du.ENT(),0.0);
if(typ==8) returnVal = interpolate_in_tet(lambda,du.END(),du.ESD(),du.ENT(),0.0);
if(typ==9) returnVal = interpolate_in_tet(lambda,du.WND(),du.END(),du.WSD(),0.0);
if(typ==10) returnVal = interpolate_in_tet(lambda,du.ESD(),du.END(),du.WSD(),0.0);
if(typ==11) returnVal = interpolate_in_tet(lambda,du.ENT(),du.WNT(),du.EST(),0.0);
if(typ==12) returnVal = interpolate_in_tet(lambda,du.WST(),du.WNT(),du.EST(),0.0);
if(typ==13) returnVal = interpolate_in_tet_bilinear(lambda,du.WND(),du.END(),du.WSD(),du.ESD());
if(typ==14) returnVal = interpolate_in_tet_bilinear(lambda,du.ENT(),du.WNT(),du.WST(),du.EST());
}
// D3vector cWSD = {1,1,0}; // 1,1,0 : x2
// D3vector cESD = {2,0,-1}; // 1,0,0 : x1
......
......@@ -54,6 +54,34 @@ double calc_maximal_face_angle(const D3vector& v0,
angle_between_faces(v0,v1,v3,v2)));
}
D3matrix rotationMatrix(D3vector vIn, D3vector vOut)
{
//calculates rotation matrix, which rotates vIn, such that is points into direction vOut
if (D3VectorNorm(vIn) == 0 || D3VectorNorm(vOut) == 0)
{
return D3matrix();
}
D3vector cross = cross_product(vOut,vIn);
double normed = D3VectorNorm(cross_product(vOut,vIn));
D3vector orthogonal = cross / normed;
double alpha = atan2(normed,product(vOut,vIn));
double s = sin(alpha);
double c = cos(alpha);
double mc = 1.0 - c;
double x = orthogonal.x;
double y = orthogonal.y;
double z = orthogonal.z;
D3vector cx(c + x * x * mc,x * y * mc + z * s,x * z * mc - y * s); // first column
D3vector cy(x * y * mc - z * s,c + y * y * mc,y * z * mc + x * s); // second column
D3vector cz(x * z * mc + y * s,y * z * mc - x * s,c + z * z * mc); // third column
D3matrix ret(cx,cy,cz);
ret.transpose();
return ret;
}
////////////////////////////////////
// lambda of p in tet
......@@ -72,6 +100,7 @@ D3vector lambda_of_p_in_tet(D3vector p,
}
////////////////////////////////////
// D3vector
////////////////////////////////////
......
......@@ -153,7 +153,12 @@ class D3matrix {
D3matrix(D3vector cx, D3vector cy, D3vector cz) :
x1(cx.x), y1(cy.x), z1(cz.x),
x2(cx.y), y2(cy.y), z2(cz.y),
x3(cx.z), y3(cy.z), z3(cz.z) {};
x3(cx.z), y3(cy.z), z3(cz.z) {}
D3matrix() :
x1(1), y1(0), z1(0),
x2(0), y2(1), z2(0),
x3(0), y3(0), z3(1) {}
double Determinante() {
return (x1 * (y2*z3 - y3*z2) - y1 * (x2*z3 - x3*z2) + z1 * (x2*y3 - x3*y2));
......@@ -225,6 +230,9 @@ class D3matrix {
return D3matrix(cx,cy,cz);
}
D3vector vectorMultiply(D3vector m)
{
// D3vector res = {x1 * m.x + x2 * m.x + x3 * m.x,
......@@ -300,7 +308,7 @@ class D3matrix {
for (int i = order - 1; i > 0; i--) {
//Swapping each and every element of the two rows
if (a[i - 1][0] < a[i][0] && a[i][0]!=0)
if (a[i - 1][0] < a[i][0])// && a[i][0]!=0)
for (int j = 0; j < 2 * order; j++) {
// Swapping of the row, if above
......@@ -335,6 +343,10 @@ class D3matrix {
for (int k = 0; k < 2 * order; k++) {
a[j][k] -= a[i][k] * temp;
// if (fabs(a[j][k]) < 1e-20 )
// {
// std::cout << "is small???";
// }
}
}
}
......@@ -343,14 +355,18 @@ class D3matrix {
// Multiply each row by a nonzero integer.
// Divide row element by the diagonal element
for (int i = 0; i < order; i++) {
if (a[i][i] == 0)
{
std::cout << "debug here";
}
// if (a[i][i] == 0)
// {
// std::cout << "debug here";
// }
temp = a[i][i];
for (int j = 0; j < 2 * order; j++) {
a[i][j] = a[i][j] / temp;
// if (a[i][j] == 0)
// {
// std::cout << "is zero here";
// }
}
}
// std::cout << "inverted matrix : " << std::endl;
......@@ -392,10 +408,17 @@ D3vector lambda_of_p_in_tet(D3vector p,
template <class DTyp>
DTyp interpolate_in_tet(D3vector lambda,
DTyp vA, DTyp vB,
DTyp vC, DTyp vD) {
DTyp vC, DTyp vD) {
return vA + (vB-vA) * lambda.x + (vC-vA) * lambda.y + (vD-vA) * lambda.z;
}
inline D3vector interpolate_in_tet_D3vector(D3vector lambda,
D3vector vA, D3vector vB,
D3vector vC, D3vector vD) {
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,
......@@ -417,6 +440,20 @@ DTyp interpolate_in_tet_trilinear(D3vector lambda,
// return vA + (vB-vA) * lambda.x + (vC-vA) * lambda.y + (vD-vA) * lambda.z;
}
template <class DTyp>
DTyp interpolate_in_tet_bilinear(D3vector lambda,
DTyp x1, DTyp x2,
DTyp x3, DTyp x4)
{
DTyp A = x1;
DTyp B = x2-x1;
DTyp C = x3-x1;
DTyp D = x4-x2+x1-x3;
DTyp R = A + lambda.x * B + lambda.y * C + lambda.x * lambda.y * D;
return R;
}
//////////////////////////////////////////////////////////////////////
// 3. geometric operators for 3D vectors
......@@ -483,6 +520,7 @@ inline double angle_between_vectors_rad(const D3vector& va,
return acos(var);
}
inline double max_interior_angel_of_triangle(const D3vector& va,
const D3vector& vb,
const D3vector& vc) {
......@@ -513,6 +551,7 @@ double calc_maximal_face_angle(const D3vector& va,
D3matrix rotationMatrix(D3vector vIn, D3vector vOut);
//////////////////////////////////////////////
// Implementierung einiger Memberfunktionen
......
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