main.cc 2.73 KB
Newer Older
Phillip Lino Rall's avatar
Phillip Lino Rall committed
1
2
3
4
5
6
7
8
9
10
// ------------------------------------------------------------
// main.cc
//
// ------------------------------------------------------------
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>
#include <iostream>
#include <string>
#include <vector>
11
#include <memory>
12
//#include "ugblock.h"
Phillip Lino Rall's avatar
Phillip Lino Rall committed
13
#include "source/ugblock2D.h"
14
//#include "source/ugblock2D3D.h"
Phillip Lino Rall's avatar
Phillip Lino Rall committed
15
16
17
18
19


using std::complex;
using namespace ::_COLSAMM_;

20
/*
21
std::complex<double> gauss(double x, double y) {
22
    //gauss electric fielöd
23
24
    double k = 2.0 * M_PI / lambda;
    double waist = radiusGauss * sqrt(1+pow(distanceFromWaist / rayleighrange,2));
25
    if (curvature == 0.0 || std::isnan(curvature))
26
27
28
29
30
    {
        return exp(-(x*x+y*y)/(waist*waist));
    }
    else
    {
31
//        return exp(-(x*x+y*y)/(waist*waist))*expi(-1.0 * k * (x*x+y*y) / (2.0 * curvature));
32
33
    }
}
34
*/
35
36


37
38
double fRealPart(std::complex< double > x) {
   return x.real();
39
40
}

41
42
double fImagPart(std::complex< double > x) {
   return x.imag();
43
44
}

45
46
47
std::complex< double > fexpi(double x) {
   std::complex< double > I(0.0,1.0);
   return exp(I*x);
48
49
}

50
51
double fexp(double x) {
   return exp(x);
52
53
}

54
55
56
57
58
59
double SG_extern;
double stretch_extern;
double rSG(double x, double y) {
     double r = sqrt(x*x+y*y);     
     r = r / stretch_extern;
     return pow(r,SG_extern);
60
}
Phillip Lino Rall's avatar
Phillip Lino Rall committed
61

Blue Bird's avatar
Blue Bird committed
62
int main(int argc, char** argv) {
63
    std::ofstream DATEI;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
64

65
66
67
68
69
70
71
72
73
74
75
76
    double lambda   = 1064e-6;  //[mm]

    
    Function2d1< double, std::complex< double > > realPart(fRealPart);
    Function2d1< double, std::complex< double > > imagPart(fImagPart);
    
    Function2d1< std::complex< double >, double > Expi(fexpi);
    Function2d1< double, double > Exp(fexp);    
    Function2d2< double, double > powSG(rSG);      
    
    double radiusGeo = 0.1;
//    double radiusGeo = 1.0;    
Phillip Lino Rall's avatar
Phillip Lino Rall committed
77
    Rechteck geo(-radiusGeo, -radiusGeo, radiusGeo, radiusGeo);
78

79
80
81
82
83
84
85
86
    double w  =  0.0705;
    stretch_extern = 1.41421;
//    double w  =  0.5;    
    double SG =  15.6;
//    double SG =  2.0;
    SG_extern = SG;
    double R = 2.03;
    
Blue Bird's avatar
Blue Bird committed
87
    double wavenumber = 2.0 * M_PI / lambda;
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    int depth = 8;
    
    VariableFFT  testU (depth, depth, geo);
    Blockgrid2D* bg = testU.Give_blockgrid();
    
    Variable2D<double>   RealPart(*bg);    
    Variable2D<double>   ImagPart(*bg);    
    
    X_coordinate2d X(*bg);
    Y_coordinate2d Y(*bg);
    
    testU = Exp(-powSG(X/w,Y/w));
//    testU = Exp(-powSG(X,Y)/(w*w));

    testU = testU * Expi(-wavenumber*(X*X+Y*Y)/(2.0*R) );
    
//    testU = Y;

   DATEI.open("testU.vtk");
   testU.Print_VTK(DATEI);
   DATEI.close();

   RealPart = realPart(testU);
   ImagPart = imagPart(testU);

   DATEI.open("realU.vtk");
   RealPart.Print_VTK(DATEI);
   DATEI.close();

   DATEI.open("imagU.vtk");
   ImagPart.Print_VTK(DATEI);
   DATEI.close();
   
Phillip Lino Rall's avatar
Phillip Lino Rall committed
121
122
}