Commit 7407dc14 authored by Phillip Lino Rall's avatar Phillip Lino Rall
Browse files

merged interpol.h

parents 12550a67 81774387
#ifndef EXAMPLES_UG_OPTICS_H
#define EXAMPLES_UG_OPTICS_H
#include <vector>
class Lens : public Unstructured_grid {
public:
Lens(double Radius, double radius, double thickness, double curvatureLeft, double curvatureRight, double offsetX, double offsetY, double offsetZ, bool inner_grid_arched = false);
~Lens(){};
double Radius;
double radius;
double length;
private:
};
class LensQuadrangle : public Unstructured_grid {
public:
LensQuadrangle(double Radius, double radius, double thickness, double curvatureLeft, double curvatureRight, double offsetX, double offsetY, double offsetZ, bool inner_grid_arched = false);
~LensQuadrangle(){};
double Radius;
double radius;
double length;
private:
};
#endif // EXAMPLES_UG_OPTICS_H
......@@ -18,7 +18,7 @@
// ------------------------------------------------------------
//
// variable.h
// interpolate.h
//
// ------------------------------------------------------------
......@@ -38,24 +38,22 @@
/*
data structure on structured grid
ny * * * * * *
ny-1 * + + + + *
ny-1 * * * * * *
* + + + + *
3 * + + + + *
2 * + + + + *
1 * + + + + *
0 * * * * * *
0 1 2 3 nx-1 nx
0 1 2 3 nx-1
*/
/***
* 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
......@@ -63,30 +61,36 @@ 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);
public:
int nx, ny, nz;
D3vector pENT,pWSD;
private:
/**
* 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:
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;
......@@ -189,22 +193,54 @@ 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_from to blockgrid_to_ using an internal rectangular grid if size nx,ny,nz
***/
/**
* interpolates data from blockgrid_ to rectangular block [pWSD, pENT]
**/
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();
......@@ -231,8 +267,6 @@ private:
};
/////////////////////////////////////////////////////////////
// 3. Interpolate from Variable on a blockgrid to any point using structured intermediate grid
/////////////////////////////////////////////////////////////
......@@ -320,5 +354,4 @@ private:
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