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

interpolator now trilinear

parent 5ebf0313
......@@ -19,5 +19,8 @@ source/program.pro
*.stash
*pro.user*
*pro.user
Makefile
*.opt
*.user
/program2D/Makefile
/program2D/debug/
\ No newline at end of file
......@@ -1288,6 +1288,22 @@ void Blockgrid_coordinates::init_blockgrid_coordinates_boundary()
void Blockgrid_coordinates::init_blockgrid_coordinates_boundary_fast()
{
bool cantUseFast = false;
int numfree = bg->Give_unstructured_grid()->degree_of_freedom();
for (int iter = 0 ; iter < numfree; iter++)
{
if(bg->getNumberPointsDegree(iter)%2 !=0)
{
cantUseFast = true;
}
}
if (cantUseFast)
{
std::cout << "odd gridpoint number, cant use fast method to initialize boundary points. Slow version used instead.\n";
init_blockgrid_coordinates_boundary();
return;
}
blockgrid_hexa_boundary.clear();
counter = 0;
blockgrid_hexa_boundary.resize(bg->Give_unstructured_grid()->Give_number_hexahedra());
......
This diff is collapsed.
......@@ -67,6 +67,7 @@ class Interpolate_on_structured_grid {
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
D3vector pWSD, D3vector pENT,
Blockgrid& blockgrid_, bool trilinearInterpolationFlag_ = false);
Interpolate_on_structured_grid(int nx_, int ny_, int nz_,
Blockgrid& blockgrid_, bool trilinearInterpolationFlag_ = false);
......@@ -181,7 +182,7 @@ void Interpolate_on_structured_grid::interpolate(Variable<DTyp>& u, DTyp* data,
Give_corner_data_of_cube<DTyp> du(u, id_hex, i,j,k);
typ = typ_tet[ind_global];
// std::cout << typ << std::endl;
/*
if( ind_global == 3)
......@@ -232,6 +233,7 @@ public:
Interpolate_on_block_grid_from_pointinterpolator(PointInterpolator *interp, Blockgrid* blockgrid_to_ );
//~Interpolate_on_block_grid_from_pointinterpolator();
void interpolate(Variable<double>* U_to, Boundary_Marker *marker = NULL);
double evaluate(double coord_x, double coord_y, double coord_z);
......@@ -335,14 +337,14 @@ class PointInterpolator {
PointInterpolator(Interpolate_on_structured_grid* intermediateGrid, double defaultInterpolation_ = -1.0, bool counter = false);
~PointInterpolator();
/**
* Calculates an intermediate Grid for above constructor
*/
Interpolate_on_structured_grid* intermediateGrid;
~PointInterpolator();
......@@ -362,8 +364,9 @@ class PointInterpolator {
void smoothGrid();
void resetInterpolator();
void normToNumberOfWritings();
void normToNumberOfWritings(bool p2norm = false);
void writeOnInterpolatedGrid(double coord_x, double coord_y, double coord_z, double value);
void writeOnInterpolatedGridPoint(int i, int j, int k, 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);
......@@ -434,6 +437,8 @@ class Interpolate_direct {
// void interpolate(Variable<DTyp>& u, DTyp* data, DTyp defaultInterpolation);
template <class DTyp>
DTyp evaluate(Variable<DTyp>& u);
template <class DTyp>
DTyp evaluateSurface(Variable<DTyp>& u);
std::vector<std::vector<std::vector<int> > > getBoundaryBox(){return array_box_boundary;}
std::vector<std::vector<std::vector<D3vector> > > * getArrayBox() {return &arrayBoxWSDENT;}
......@@ -469,6 +474,10 @@ class Interpolate_direct {
int idHexPrevPrevPrev{-1}, iPrevPrevPrev{-1}, jPrevPrevPrev{-1}, kPrevPrevPrev{-1};
int idHexPrevPrev{-1}, iPrevPrev{-1}, jPrevPrev{-1}, kPrevPrev{-1};
int idHexNow{-1}, iNow{-1}, jNow{-1}, kNow{-1};
int idHexPrevSurface{-1}, iPrevSurface{-1}, jPrevSurface{-1}, kPrevSurface{-1};
int idHexPrevPrevPrevSurface{-1}, iPrevPrevPrevSurface{-1}, jPrevPrevPrevSurface{-1}, kPrevPrevPrevSurface{-1};
int idHexPrevPrevSurface{-1}, iPrevPrevSurface{-1}, jPrevPrevSurface{-1}, kPrevPrevSurface{-1};
int idHexNowSurface{-1}, iNowSurface{-1}, jNowSurface{-1}, kNowSurface{-1};
double lamLowerLimit{-0.1};
double lamUpperLimit{1.1};
......@@ -506,6 +515,9 @@ private:
void setPrevIndex();
void setPrevPrevIndex();
void setPrevPrevPrevIndex();
void setPrevIndexSurface();
void setPrevPrevIndexSurface();
void setPrevPrevPrevIndexSurface();
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);
......@@ -561,7 +573,48 @@ DTyp Interpolate_direct::evaluate(Variable<DTyp> &u)
if(typ==5) returnVal = interpolate_in_tet(lambda,
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());
du.WNT(),du.WST(),du.EST(),du.ENT());
}
// D3vector cWSD = {1,1,0}; // 1,1,0 : x2
// D3vector cESD = {2,0,-1}; // 1,0,0 : x1
// D3vector cWND = {0,1,0}; // 0,1,0 : x3
// D3vector cEND = {-1,0,-1.0}; // 0,0,0 : x0
// D3vector cWST = {1,1,1}; // 1,1,1 : x5
// D3vector cEST = {2,0,2}; // 1,0,1 : x6
// D3vector cWNT = {0,1,1}; // 0,1,1 : x4
// D3vector cENT = {-1,0,2}; // 0,0,1 : x7
return returnVal;
};
template<class DTyp>
DTyp Interpolate_direct::evaluateSurface(Variable<DTyp> &u)
{
int i,j,k, id_hex, typ;
int ind_global;
DTyp returnVal;
// for(int id=0;id<5;++id)
// u.template Update<hexahedronEl>(id);
if(idHexNowSurface < 0 )
{returnVal = -1;}
else {
Give_corner_data_of_cube<DTyp> du(u, idHexNowSurface , iNowSurface,jNowSurface,kNowSurface);
int typ = typ_tet;
if (lambda == D3vector(0,0,0))
{
cout << "no point found " << endl;
}
//cout << "lambda : " ; lambda.Print();cout<<endl;
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);
......@@ -588,4 +641,7 @@ DTyp Interpolate_direct::evaluate(Variable<DTyp> &u)
};
#endif // INTERPOL_H
......@@ -92,10 +92,12 @@ D3vector lambda_of_p_in_tet(D3vector p,
D3vector cA, D3vector cB,
D3vector cC, D3vector cD) {
D3matrix M(cB-cA,cC-cA,cD-cA);
// D3vector t;
// t = M.invert_apply(p-cA);
// interpolate_in_tet(t, cA,cB,cC,cD).Print();
// cout<<"calculating lambda = ";t.Print();cout<<endl;
D3vector t;
//t = M.invert_apply(p-cA);
//cout<<"calculating lambda = ";t.Print();cout<<endl;
return M.invert_apply(p-cA);
}
......
......@@ -8,8 +8,8 @@
#include <iostream>
#include <string>
#include <vector>
#include "source/ugblock2D.h"
#include "ugblock.h"
#include "source/ugblock2D.h"
#include "source/ugblock2D3D.h"
......@@ -171,21 +171,39 @@ void amplification(double dz,
VariableFFT& varWavenumber,
VariableFFT& temp)
{
double c = 3e10;// mm / s
double c = 3e11;// mm / s
//c = 3e8;// m / s
double planck = 6.626e-34;
double emissionCrosssection = 7.7* 1e-18;//mm²
// emissionCrosssection = 7.7* 1e-20;//cm²
// emissionCrosssection = 7.7* 1e-24;//m²
double upperLevelLifetime = 230e-6;
double Ntot = 1.3e+17; //( 1 / mm^3)
//Ntot = 1.3e+26; //( 1 / m^3)
//pumppower : W / mm³
VariableFFT photonDensity(temp);
VariableFFT inversion(temp);
VariableFFT pumpPhotons(temp);
Function2d1<double, std::complex<double> > absolute(ABS);
photonDensity = absolute(varIn) * absolute(varIn)/ (planck * c / lambda) / dz;
temp = pumppower / (planck * c / lambda); // N /1 / mm³
pumpPhotons = pumppower / (planck * c / lambda); // N / s mm³
// falsch : alle pumpphotonen werden zur verstärkung genutzt -> anpassen
std::cout << "pumppower "<< L_infty(pumppower) << std::endl;
std::cout << "inversion "<< L_infty(temp) << std::endl;
std::cout << "photonDensity "<< L_infty(photonDensity) << std::endl;
Function2d1<std::complex<double>,std::complex<double>> Exp(expComplex);
temp= emissionCrosssection * temp * photonDensity * dz ;
inversion = pumpPhotons / (emissionCrosssection * pumpPhotons * photonDensity * c + 1.0 / upperLevelLifetime + pumpPhotons / Ntot);
std::cout << "pumppower "<< L_infty(pumppower) << std::endl;
std::cout << "photonDensity "<< L_infty(photonDensity) << std::endl;
std::cout << "inversion "<< L_infty(inversion) << std::endl;
std::cout << "pumpPhotons "<< L_infty(pumpPhotons) << std::endl;
temp= emissionCrosssection * inversion * photonDensity * dz ;
std::cout << "arg exp temp "<< L_infty(temp) << std::endl;
temp = Exp(temp);
std::cout << "exp temp "<< L_infty(temp) << std::endl;
......@@ -667,8 +685,8 @@ int main(int argc, char** argv) {
std::cout << "curvature " << curvature << std::endl;
VTK_Reader reader( QString("/local/er96apow/FAUbox/Promotion/Vectorial_BPM/fibercryst_exmaple/RefractionIndexTherm_last.vtk"));
VTK_Reader readerPumppower(QString("/local/er96apow/FAUbox/Promotion/Vectorial_BPM/fibercryst_exmaple/abspower.vtk"));
VTK_Reader reader( QString("C:/Users/rall/FAUbox/Promotion/Vectorial_BPM/fibercryst_exmaple/RefractionIndexTherm_last.vtk"));
VTK_Reader readerPumppower(QString("C:/Users/rall/FAUbox/Promotion/Vectorial_BPM/fibercryst_exmaple/abspower.vtk"));
Variable<double> * thermalRefractiveIndex3D = reader.give_first_variable();
Variable<double> * pumpPowerRaytracing = readerPumppower.give_first_variable();
......@@ -738,6 +756,11 @@ int main(int argc, char** argv) {
varE = Aperture(X,Y);
double power = 1.0;
double amp = sqrt(2.0 * power / M_PI / radiusGauss / radiusGauss);
varE = varE * amp;
std::ofstream DATEIG;
DATEIG.open("/local/er96apow/FFT_results/varE___before.vtk");
varE.Print_VTK(DATEIG);
......
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