Commit 0b1b1564 authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

interpol changes

parent 7ef6933f
......@@ -18,7 +18,7 @@
// ------------------------------------------------------------
//
// interpolate.h
// variable.h
//
// ------------------------------------------------------------
......@@ -38,23 +38,23 @@
/*
data structure on structured grid
ny-1 * * * * * *
* + + + + *
ny * * * * * *
ny-1 * + + + + *
3 * + + + + *
2 * + + + + *
1 * + + + + *
0 * * * * * *
0 1 2 3 nx-1
0 1 2 3 nx-1 nx
*/
/**
/***
* interpolates data from blockgrid_ to rectangular block [pWSD, pENT]
**/
***/
class Interpolate_on_structured_grid {
public:
/**
/***
* preparation for interpolation
@param nx_ number of structured grid points x-direction
@param ny_ number of structured grid points y-direction
......@@ -62,36 +62,30 @@ class Interpolate_on_structured_grid {
@param pWSD Corner WSD of structured grid
@param pENT Corner WSD of structured grid
@param blockgrid_ of unstructured grid
**/
***/
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_);
/**
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
Blockgrid& blockgrid_);
/***
* interpolates from Variable u(of unstructured blockgrid) to structured data
@param u: Variable on unstructured blockgrid
@param data: pointer to structured grid data i+nx*(j+ny*k)
**/
***/
template <class DTyp>
void interpolate(Variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation);
/**
* interpolates from Variable u(of unstructured blockgrid) to structured data
@param u: Variable on unstructured blockgrid
@param data: pointer to structured grid data i+nx*(j+ny*k)
**/
template <class DTyp>
void interpolate(Cell_variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation);
~Interpolate_on_structured_grid();
private:
public:
int nx, ny, nz;
D3vector pENT,pWSD;
private:
int* ids_hex;
int *ids_i, *ids_j, *ids_k;
int *typ_tet;
D3vector *lambda;
int nx, ny, nz;
double hx, hy, hz;
Blockgrid* blockgrid;
......@@ -194,54 +188,22 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
}
}
template <class DTyp>
void Interpolate_on_structured_grid::interpolate(Cell_variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation) {
int i,j,k, id_hex, typ;
int ind_global;
for(int id=0;id<ug->Give_number_hexahedra();++id)
u.template Update<hexahedronEl>(id);
for(int ks = 0; ks < nz;++ks)
for(int js = 0; js < ny;++js)
for(int is = 0; is < nx;++is) {
ind_global = is+nx*(js+ny*ks);
i = ids_i[ind_global];
j = ids_j[ind_global];
k = ids_k[ind_global];
id_hex = ids_hex[ind_global];
if(id_hex < 0) data[ind_global] = defaultInterpolation;
else {
Blockgrid* blockgrid = u.getBlockgrid();
int Nx = blockgrid->Give_Nx_hexahedron(id_hex);
int Ny = blockgrid->Give_Ny_hexahedron(id_hex);
int Nz = blockgrid->Give_Nz_hexahedron(id_hex);
data[ind_global] = u.Give_cell_hexahedra(id_hex,Ind_loc_matrix_hexahedra(i,j,k),i,j,k,Nx,Ny);
}
}
}
/////////////////////////////////////////////////////////////
// 2. Interpolate from blockgrid to blockgrid
/////////////////////////////////////////////////////////////
/**
* interpolates data from blockgrid_ to rectangular block [pWSD, pENT]
**/
/***
* interpolates data from blockgrid_from to blockgrid_to_ using an internal rectangular grid if size nx,ny,nz
***/
class Interpolate_on_block_grid {
public:
/**
/***
* preparation for interpolation
@param nx_ number of structured grid points x-direction
@param ny_ number of structured grid points y-direction
@param nz_ number of structured grid points z-direction
@param blockgrid_ of unstructured grid
**/
***/
Interpolate_on_block_grid(int nx_, int ny_, int nz_,
Blockgrid* blockgrid_from, Blockgrid* blockgrid_to_);
~Interpolate_on_block_grid();
......@@ -269,4 +231,92 @@ private:
};
/////////////////////////////////////////////////////////////
// 3. Interpolate from Variable on a blockgrid to any point using structured intermediate grid
/////////////////////////////////////////////////////////////
/*
class Intermadiate_grid_for_PointInterpolator : public Interpolate_on_structured_grid
{
public:
Intermadiate_grid_for_PointInterpolator(int nx_, int ny_, int nz_, Variable<double>* U_from);
int nx, ny, nz;
Interpolate_on_structured_grid* interpolatorStructured(int nx_, int ny_, int nz_,D3vector pWSD, D3vector pENT,
Variable<double>* U_from);
D3vector pWSD;
D3vector pENT;
};
* interpolates data from blockgrid_from to blockgrid_to_ using an internal rectangular grid if size nx,ny,nz
***/
class PointInterpolator {
friend Interpolate_on_structured_grid;
public:
/***
* preparation for interpolation
@param nx_ number of structured grid points x-direction
@param ny_ number of structured grid points y-direction
@param nz_ number of structured grid points z-direction
@param blockgrid_ of unstructured grid
***/
PointInterpolator(int nx_, int ny_, int nz_,
Variable<double>* U_from, double defaultInterpolation_ = 0.0);
PointInterpolator(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT,
Variable<double>* U_from, double defaultInterpolation_ = 0.0);
PointInterpolator(Interpolate_on_structured_grid* intermediateGrid,
Variable<double>* U_from, double defaultInterpolation_ = 0.0);
/**
* Calculates an intermediate Grid for above constructor
*/
Interpolate_on_structured_grid* intermediateGrid;
~PointInterpolator();
/**
* interpoliert Daten. Falls an einem Punkt nicht interpoliert werden kann
* da U_from keine Zelle hat, dann wird
* defaultInterpolation
* verwendet.
* @param coord_x, coord_y, coord_z, Koordinaten des Punktes
* @return interpolierter Wert
***/
double evaluate(double coord_x, double coord_y, double coord_z);
std::vector<double> evaluateGradient(double coord_x, double coord_y, double coord_z);
void smoothGrid();
void writeOnInterpolatedGrid(double coord_x, double coord_y, double coord_z, double value);
void subtractOnInterpolatedGrid(double coord_x, double coord_y, double coord_z, double value);
void shiftInterpolatedGrid(double coord_x, double coord_y, double coord_z);
void scaleInterpolatedData(double scale, double zeroVal = 0.0);
void QPrint_VTK(QString DateiName);
private:
int nx, ny, nz;
double hx, hy, hz;
double shiftx, shifty, shiftz;
Interpolate_on_structured_grid* interpolatorStructured;
double* data;
D3vector pWSD;
D3vector pENT;
double defaultInterpolation;
};
#endif // INTERPOL_H
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