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
D3vector lam;
//Variable<double> coordXYZ(*blockgrid);
X_coordinate Xc(blockgrid_);
Y_coordinate Yc(blockgrid_);
......@@ -168,15 +167,9 @@ void Interpolate_on_structured_grid::update_Interpolate_on_structured_grid(Block
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;
......@@ -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_,
D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_) {
Blockgrid& blockgrid_, Interpolate_direct *id_) {
id = id_;
int Nx, Ny, Nz;
// int typ;
......@@ -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_,
Blockgrid& blockgrid_) {
Blockgrid& blockgrid_, Interpolate_direct *id_) {
id = id_;
int Nx, Ny, Nz;
int typ;
assert(nx_ > 1);
assert(ny_ > 1);
assert(nz_ > 1);
......@@ -1111,8 +1104,9 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid* intermediat
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_;
nx = intermediateGrid->nx;
......@@ -1120,11 +1114,17 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat
nz = intermediateGrid->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++)
{
data[iter]=0.0;
if (counter)
{
dataCounter[iter]=0;
}
}
pENT = intermediateGrid->pENT;
......@@ -1134,6 +1134,8 @@ PointInterpolator::PointInterpolator(Interpolate_on_structured_grid *intermediat
hy = intermediateGrid->getHy();
hz = intermediateGrid->getHz();
interpolatorStructured = intermediateGrid;
}
/*
......@@ -1171,12 +1173,12 @@ double PointInterpolator::evaluate(double coord_x, double coord_y, double coord_
coord_y-=shifty;
coord_z-=shiftz;
if(coord_x > pENT.x) return defaultInterpolation;
if(coord_x < pWSD.x) return defaultInterpolation;
if(coord_y > pENT.y) return defaultInterpolation;
if(coord_y < pWSD.y) return defaultInterpolation;
if(coord_z > pENT.z) return defaultInterpolation;
if(coord_z < pWSD.z) return defaultInterpolation;
if(coord_x > (pENT.x+(1e-10))) return defaultInterpolation;
if(coord_x < (pWSD.x-(1e-10))) return defaultInterpolation;
if(coord_y > (pENT.y+(1e-10))) return defaultInterpolation;
if(coord_y < (pWSD.y-(1e-10))) return defaultInterpolation;
if(coord_z > (pENT.z+(1e-10))) return defaultInterpolation;
if(coord_z < (pWSD.z-(1e-10))) return defaultInterpolation;
//cout << "coord_z " << coord_z << " pWSD.z " << pWSD.z << endl;
/*
......@@ -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;
ny = intermediateGrid->ny;
nz = intermediateGrid->nz;
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;
}
}
pENT = intermediateGrid->pENT;
pWSD = intermediateGrid->pWSD;
......@@ -1661,7 +1674,14 @@ void PointInterpolator::updatePointInterpolator(Interpolate_on_structured_grid *
hz = intermediateGrid->getHz();
}
PointInterpolator::~PointInterpolator() {
//delete interpolatorStructured;
if (dataCounterFlag)
{
delete[] dataCounter;
}
delete[] data;
}
void Interpolate_direct::init()
{
......
......@@ -52,6 +52,7 @@ ny-1 * + + + + *
\endverbatim
* interpolates data from blockgrid_ to rectangular block [pWSD, pENT]
**/
class Interpolate_direct;
class Interpolate_on_structured_grid {
public:
/**
......@@ -65,9 +66,10 @@ class Interpolate_on_structured_grid {
**/
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_);
Blockgrid& blockgrid_, Interpolate_direct *id = NULL);
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
Blockgrid& blockgrid_);
Blockgrid& blockgrid_, Interpolate_direct *id = NULL);
~Interpolate_on_structured_grid();
/**
* interpolates from Variable u(of unstructured blockgrid) to structured data
......@@ -78,6 +80,7 @@ class Interpolate_on_structured_grid {
void interpolate(Variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation);
void update_Interpolate_on_structured_grid(Blockgrid& blockgrid_);
void setInterpolateDirect(Interpolate_direct *id_){id = id_;}
int getNx(){return nx;}
int getNy(){return ny;}
......@@ -101,6 +104,8 @@ public:
Blockgrid* blockgrid;
Unstructured_grid* ug;
Interpolate_direct* id{NULL};
};
/* @} */
......@@ -145,6 +150,7 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
int ind_global;
for(int id=0;id<ug->Give_number_hexahedra();++id)
u.template Update<hexahedronEl>(id);
......@@ -197,6 +203,8 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
du.ENT(),du.WNT(),du.EST(),du.END());
if(typ==5) data[ind_global] = interpolate_in_tet(lambda[ind_global],
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 {
PointInterpolator(Interpolate_on_structured_grid* intermediateGrid,
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 {
* @return interpolierter Wert
**/
void updateVariable(Variable<double>* U_from);
void updatePointInterpolator(Interpolate_on_structured_grid* intermediateGrid);
double evaluate(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:
Interpolate_on_structured_grid* interpolatorStructured;
double* data;
bool dataCounterFlag{false};
int* dataCounter;
......@@ -437,6 +447,12 @@ class Interpolate_direct {
D3vector lambda;
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 );
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),
void estimateBeamQuality(VariableFFT& varIn, double lambda)
{
}
int main(int argc, char** argv) {
......
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data>
<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