Commit 8690ec10 authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

added function to update interpolator

parent 3c798d08
...@@ -129,7 +129,6 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block ...@@ -129,7 +129,6 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block
D3vector lam; D3vector lam;
//Variable<double> coordXYZ(*blockgrid); //Variable<double> coordXYZ(*blockgrid);
X_coordinate Xc(blockgrid_); X_coordinate Xc(blockgrid_);
Y_coordinate Yc(blockgrid_); Y_coordinate Yc(blockgrid_);
...@@ -168,15 +167,9 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block ...@@ -168,15 +167,9 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block
D3vector ploc; D3vector ploc;
// ids_hex = new int[num_total];
// ids_i = new int[num_total];
// ids_j = new int[num_total];
// ids_k = new int[num_total];
// typ_tet = new int[num_total];
// lambda = new D3vector[num_total];
for(int i=0;i<num_total;++i) ids_hex[i] = -1; for(int i=0;i<num_total;++i) ids_hex[i] = -1;
...@@ -349,7 +342,8 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block ...@@ -349,7 +342,8 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block
Interpolate_on_structured_grid::Interpolate_on_structured_grid(int nx_, int ny_, int nz_, Interpolate_on_structured_grid::Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT, D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_) { Blockgrid& blockgrid_, Interpolate_direct *id_) {
id = id_;
int Nx, Ny, Nz; int Nx, Ny, Nz;
// int typ; // int typ;
...@@ -609,13 +603,12 @@ if(boxWSD.z < 0 && boxENT.z > 0.0 && boxWSD.y < 0.5 && boxENT.y > 0.5 && boxWSD. ...@@ -609,13 +603,12 @@ if(boxWSD.z < 0 && boxENT.z > 0.0 && boxWSD.y < 0.5 && boxENT.y > 0.5 && boxWSD.
Interpolate_on_structured_grid::Interpolate_on_structured_grid(int nx_, int ny_, int nz_, Interpolate_on_structured_grid::Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
Blockgrid& blockgrid_) { Blockgrid& blockgrid_, Interpolate_direct *id_) {
id = id_;
int Nx, Ny, Nz; int Nx, Ny, Nz;
int typ; int typ;
assert(nx_ > 1); assert(nx_ > 1);
assert(ny_ > 1); assert(ny_ > 1);
assert(nz_ > 1); assert(nz_ > 1);
...@@ -1111,8 +1104,9 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid* intermediat ...@@ -1111,8 +1104,9 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid* intermediat
intermediateGrid->interpolate<double>(*U_from,data,defaultInterpolation_); intermediateGrid->interpolate<double>(*U_from,data,defaultInterpolation_);
} }
PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediateGrid, double defaultInterpolation_) PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediateGrid, double defaultInterpolation_, bool counter)
{ {
dataCounterFlag = counter;
defaultInterpolation = defaultInterpolation_; defaultInterpolation = defaultInterpolation_;
nx = intermediateGrid->nx; nx = intermediateGrid->nx;
...@@ -1120,11 +1114,17 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat ...@@ -1120,11 +1114,17 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat
nz = intermediateGrid->nz; nz = intermediateGrid->nz;
data = new double[nx*ny*nz]; data = new double[nx*ny*nz];
dataCounter = new int[nx*ny*nz]; if (counter)
{
dataCounter = new int[nx*ny*nz];
}
for (int iter = 0 ; iter < nx*ny*nz;iter++) for (int iter = 0 ; iter < nx*ny*nz;iter++)
{ {
data[iter]=0.0; data[iter]=0.0;
if (counter)
{
dataCounter[iter]=0; dataCounter[iter]=0;
}
} }
pENT = intermediateGrid->pENT; pENT = intermediateGrid->pENT;
...@@ -1134,6 +1134,8 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat ...@@ -1134,6 +1134,8 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat
hy = intermediateGrid->getHy(); hy = intermediateGrid->getHy();
hz = intermediateGrid->getHz(); hz = intermediateGrid->getHz();
interpolatorStructured = intermediateGrid;
} }
/* /*
...@@ -1171,12 +1173,12 @@ double PointInterpolator::evaluate(double coord_x, double coord_y, double coord_ ...@@ -1171,12 +1173,12 @@ double PointInterpolator::evaluate(double coord_x, double coord_y, double coord_
coord_y-=shifty; coord_y-=shifty;
coord_z-=shiftz; coord_z-=shiftz;
if(coord_x > pENT.x) return defaultInterpolation; if(coord_x > (pENT.x+(1e-10))) return defaultInterpolation;
if(coord_x < pWSD.x) return defaultInterpolation; if(coord_x < (pWSD.x-(1e-10))) return defaultInterpolation;
if(coord_y > pENT.y) return defaultInterpolation; if(coord_y > (pENT.y+(1e-10))) return defaultInterpolation;
if(coord_y < pWSD.y) return defaultInterpolation; if(coord_y < (pWSD.y-(1e-10))) return defaultInterpolation;
if(coord_z > pENT.z) return defaultInterpolation; if(coord_z > (pENT.z+(1e-10))) return defaultInterpolation;
if(coord_z < pWSD.z) return defaultInterpolation; if(coord_z < (pWSD.z-(1e-10))) return defaultInterpolation;
//cout << "coord_z " << coord_z << " pWSD.z " << pWSD.z << endl; //cout << "coord_z " << coord_z << " pWSD.z " << pWSD.z << endl;
/* /*
...@@ -1635,24 +1637,35 @@ void PointInterpolator::scaleInterpolatedData(double scale, double zeroVal) ...@@ -1635,24 +1637,35 @@ void PointInterpolator::scaleInterpolatedData(double scale, double zeroVal)
} }
PointInterpolator::~PointInterpolator() {
//delete interpolatorStructured;
delete[] data; void PointInterpolator::updateVariable(Variable<double> *U_from)
{
interpolatorStructured->interpolate<double>(*U_from,data,defaultInterpolation);
} }
void PointInterpolator::updatePointInterpolator(Interpolate_on_structured_grid *intermediateGrid) void PointInterpolator::updatePointInterpolator(Interpolate_on_structured_grid *intermediateGrid_)
{ {
this->interpolatorStructured = intermediateGrid_;
this->intermediateGrid = intermediateGrid_;
nx = intermediateGrid->nx; nx = intermediateGrid->nx;
ny = intermediateGrid->ny; ny = intermediateGrid->ny;
nz = intermediateGrid->nz; nz = intermediateGrid->nz;
for (int iter = 0 ; iter < nx*ny*nz;iter++) for (int iter = 0 ; iter < nx*ny*nz;iter++)
{ {
data[iter]=0.0; data[iter]=defaultInterpolation;
}
if (dataCounterFlag)
{
for (int iter = 0 ; iter < nx*ny*nz;iter++)
{
dataCounter[iter]=0; dataCounter[iter]=0;
}
} }
pENT = intermediateGrid->pENT; pENT = intermediateGrid->pENT;
pWSD = intermediateGrid->pWSD; pWSD = intermediateGrid->pWSD;
...@@ -1661,7 +1674,14 @@ void PointInterpolator::updatePointInterpolator(Interpolate_on_structured_grid * ...@@ -1661,7 +1674,14 @@ void PointInterpolator::updatePointInterpolator(Interpolate_on_structured_grid *
hz = intermediateGrid->getHz(); hz = intermediateGrid->getHz();
} }
PointInterpolator::~PointInterpolator() {
//delete interpolatorStructured;
if (dataCounterFlag)
{
delete[] dataCounter;
}
delete[] data;
}
void Interpolate_direct::init() void Interpolate_direct::init()
{ {
......
...@@ -52,6 +52,7 @@ ny-1 * + + + + * ...@@ -52,6 +52,7 @@ ny-1 * + + + + *
\endverbatim \endverbatim
* interpolates data from blockgrid_ to rectangular block [pWSD, pENT] * interpolates data from blockgrid_ to rectangular block [pWSD, pENT]
**/ **/
class Interpolate_direct;
class Interpolate_on_structured_grid { class Interpolate_on_structured_grid {
public: public:
/** /**
...@@ -65,9 +66,10 @@ class Interpolate_on_structured_grid { ...@@ -65,9 +66,10 @@ class Interpolate_on_structured_grid {
**/ **/
Interpolate_on_structured_grid(int nx_, int ny_, int nz_, Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT, D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_); Blockgrid& blockgrid_, Interpolate_direct *id = NULL);
Interpolate_on_structured_grid(int nx_, int ny_, int nz_, Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
Blockgrid& blockgrid_); Blockgrid& blockgrid_, Interpolate_direct *id = NULL);
~Interpolate_on_structured_grid(); ~Interpolate_on_structured_grid();
/** /**
* interpolates from Variable u(of unstructured blockgrid) to structured data * interpolates from Variable u(of unstructured blockgrid) to structured data
...@@ -78,6 +80,7 @@ class Interpolate_on_structured_grid { ...@@ -78,6 +80,7 @@ class Interpolate_on_structured_grid {
void interpolate(Variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation); void interpolate(Variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation);
void update_Interpolate_on_structured_grid(Blockgrid& blockgrid_); void update_Interpolate_on_structured_grid(Blockgrid& blockgrid_);
void setInterpolateDirect(Interpolate_direct *id_){id = id_;}
int getNx(){return nx;} int getNx(){return nx;}
int getNy(){return ny;} int getNy(){return ny;}
...@@ -101,6 +104,8 @@ public: ...@@ -101,6 +104,8 @@ public:
Blockgrid* blockgrid; Blockgrid* blockgrid;
Unstructured_grid* ug; Unstructured_grid* ug;
Interpolate_direct* id{NULL};
}; };
/* @} */ /* @} */
...@@ -145,6 +150,7 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data, ...@@ -145,6 +150,7 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
int ind_global; int ind_global;
for(int id=0;id<ug->Give_number_hexahedra();++id) for(int id=0;id<ug->Give_number_hexahedra();++id)
u.template Update<hexahedronEl>(id); u.template Update<hexahedronEl>(id);
...@@ -197,6 +203,8 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data, ...@@ -197,6 +203,8 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
du.ENT(),du.WNT(),du.EST(),du.END()); du.ENT(),du.WNT(),du.EST(),du.END());
if(typ==5) data[ind_global] = interpolate_in_tet(lambda[ind_global], if(typ==5) data[ind_global] = interpolate_in_tet(lambda[ind_global],
du.WNT(),du.WND(),du.EST(),du.END()); du.WNT(),du.WND(),du.EST(),du.END());
if(typ==6) data[ind_global] = interpolate_in_tet_trilinear(lambda[ind_global],du.END(),du.ESD(),du.WSD(),du.WND(),
du.WNT(),du.WST(),du.EST(),du.ENT());
} }
} }
} }
...@@ -321,7 +329,7 @@ class PointInterpolator { ...@@ -321,7 +329,7 @@ class PointInterpolator {
PointInterpolator(Interpolate_on_structured_grid* intermediateGrid, PointInterpolator(Interpolate_on_structured_grid* intermediateGrid,
Variable<double>* U_from, double defaultInterpolation_ = 0.0); Variable<double>* U_from, double defaultInterpolation_ = 0.0);
PointInterpolator(Interpolate_on_structured_grid* intermediateGrid, double defaultInterpolation_ = -1.0); PointInterpolator(Interpolate_on_structured_grid* intermediateGrid, double defaultInterpolation_ = -1.0, bool counter = false);
...@@ -344,6 +352,7 @@ class PointInterpolator { ...@@ -344,6 +352,7 @@ class PointInterpolator {
* @return interpolierter Wert * @return interpolierter Wert
**/ **/
void updateVariable(Variable<double>* U_from);
void updatePointInterpolator(Interpolate_on_structured_grid* intermediateGrid); void updatePointInterpolator(Interpolate_on_structured_grid* intermediateGrid);
double evaluate(double coord_x, double coord_y, double coord_z); double evaluate(double coord_x, double coord_y, double coord_z);
std::vector<double> evaluateGradient(double coord_x, double coord_y, double coord_z); std::vector<double> evaluateGradient(double coord_x, double coord_y, double coord_z);
...@@ -368,6 +377,7 @@ private: ...@@ -368,6 +377,7 @@ private:
Interpolate_on_structured_grid* interpolatorStructured; Interpolate_on_structured_grid* interpolatorStructured;
double* data; double* data;
bool dataCounterFlag{false};
int* dataCounter; int* dataCounter;
...@@ -437,6 +447,12 @@ class Interpolate_direct { ...@@ -437,6 +447,12 @@ class Interpolate_direct {
D3vector lambda; D3vector lambda;
D3vector vNow{1e10,1e10,1e10}, vPrev, vPrevPrev, vPrevPrevPrev; D3vector vNow{1e10,1e10,1e10}, vPrev, vPrevPrev, vPrevPrevPrev;
int getI(){return iNow;}
int getJ(){return jNow;}
int getK(){return kNow;}
D3vector getLam(){return lambda;}
int getTet(){return typ_tet;}
int getHex(){return idHexNow;}
D3vector trilinarInterpolation(D3vector v, int id_Hex,int i, int j, int k ); 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); bool vectorInBox(D3vector vWSD, D3vector vENT, D3vector v, double eps = 1e-10);
......
...@@ -111,7 +111,7 @@ void spectrumPlaneWave(std::complex<double> (*aperture) (double x, double y), ...@@ -111,7 +111,7 @@ void spectrumPlaneWave(std::complex<double> (*aperture) (double x, double y),
void estimateBeamQuality(VariableFFT& varIn, double lambda) void estimateBeamQuality(VariableFFT& varIn, double lambda)
{ {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.5.2, 2020-08-27T17:02:37. --> <!-- Written by QtCreator 4.5.2, 2020-10-09T11:12:46. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
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