From d82b8ebc46ea6d217529de38d09900e06f700b51 Mon Sep 17 00:00:00 2001
From: Phillip Laptop <phillip.lino.rall@fau.de>
Date: Wed, 2 Dec 2020 08:47:00 +0100
Subject: [PATCH] fft example with amplification

---
 program/source/grid/examples_ug_optics.cc  | 49 ++++++++++++++++------
 program/source/math_lib/math_lib.h         |  5 +++
 program2D/source/grid/interpolation2D_cc.h |  3 +-
 3 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/program/source/grid/examples_ug_optics.cc b/program/source/grid/examples_ug_optics.cc
index f16199a..a4de5fb 100644
--- a/program/source/grid/examples_ug_optics.cc
+++ b/program/source/grid/examples_ug_optics.cc
@@ -111,6 +111,12 @@ D3vector transform_right_lens_diag_NW_quad ( double t1, double t2, double* point
     x = x*t2;
     double y = R_global_data*(cos ( t1*0.5*M_PI )- ( 1-t1 )) ;
     y = y*t2;
+
+//    if (t1 == 0.75 && t2 == 1.0)
+//    {
+//        std::cout << "break";
+//    }
+
     double actualX = 0             +  r_global_data * t1 + 0                             * t2 + (R_global_data-r_global_data) * t1 * t2;
     double actualY = r_global_data -  r_global_data * t1 + (R_global_data-r_global_data) * t2 - (R_global_data-r_global_data) * t1 * t2;
 
@@ -279,6 +285,8 @@ D3vector transform_right_lens_diag_SW_quad ( double t1, double t2, double* point
     double temp = t1;
     t1 = t2;
     t2 = temp;
+    //test
+    t1 = 1.0 - t1;
     double t = t2;
     double x = -R_global_data *( sin ( t1*0.5*M_PI )-t1);
     x = x*t2;
@@ -317,6 +325,8 @@ D3vector transform_left_lens_diag_SW_quad ( double t1, double t2, double* pointe
     t1 = t2;
     t2 = temp;
     double t = t2;
+    //test
+    t1 = 1.0 - t1;
     double x = -R_global_data *( sin ( t1*0.5*M_PI )-t1);
     x = x*t2;
     double y = -R_global_data *(cos ( t1*0.5*M_PI )- ( 1-t1 )) ;
@@ -353,6 +363,9 @@ D3vector transform_left_lens_diag_SE_quad ( double t1, double t2, double* pointe
     t1 = t2;
     t2 = temp;
     double t = t2;
+
+    //test
+    t1 = 1.0 - t1;
     double x =R_global_data * ( sin ( t1*0.5*M_PI )-t1);
     x = x*t2;
     double y = -R_global_data *(cos ( t1*0.5*M_PI )- ( 1-t1 )) ;
@@ -361,7 +374,7 @@ D3vector transform_left_lens_diag_SE_quad ( double t1, double t2, double* pointe
     double actualX = 0             +  r_global_data * t1 + 0                             * t2 + (R_global_data-r_global_data) * t1 * t2;
     double actualY = r_global_data -  r_global_data * t1 + (R_global_data-r_global_data) * t2 - (R_global_data-r_global_data) * t1 * t2;
     actualY = -actualY;
-
+    //actualX = -actualX;
     double sign = (curvatureLeft_global_data > 0) ? 1 : ((curvatureLeft_global_data < 0) ? -1 : 0)  ;
     double radiusSquared = ((x+actualX)*(x+actualX)+(y+actualY)*(y+actualY));
 
@@ -370,6 +383,9 @@ D3vector transform_left_lens_diag_SE_quad ( double t1, double t2, double* pointe
      if (std::isnan(z))
      {z = 0;}
 
+//     temp = x;
+//     x = y;
+//     y = temp;
      return D3vector ( x,y,z);
 }
 
@@ -388,14 +404,21 @@ D3vector transform_right_lens_diag_SE_quad ( double t1, double t2, double* point
     t1 = t2;
     t2 = temp;
     double t = t2;
+    //test
+    t1 = 1.0 - t1;
     double x =R_global_data * ( sin ( t1*0.5*M_PI )-t1);
     x = x*t2;
     double y = -R_global_data *(cos ( t1*0.5*M_PI )- ( 1-t1 )) ;
     y = y*t2;
 
+//    if (t1 == 0.75 && t2 == 1.0)
+//    {
+//        std::cout << "break";
+//    }
     double actualX = 0             +  r_global_data * t1 + 0                             * t2 + (R_global_data-r_global_data) * t1 * t2;
     double actualY = r_global_data -  r_global_data * t1 + (R_global_data-r_global_data) * t2 - (R_global_data-r_global_data) * t1 * t2;
     actualY = -actualY;
+    //actualX = -actualX;
     double sign = (curvatureRight_global_data > 0) ? 1 : ((curvatureRight_global_data < 0) ? -1 : 0)  ;
 
     double z = offsetZ_global_data+
@@ -403,10 +426,13 @@ D3vector transform_right_lens_diag_SE_quad ( double t1, double t2, double* point
                            ((x+actualX)*(x+actualX)+(y+actualY)*(y+actualY)))
                       + sign*(-curvatureRight_global_data +( (1-t)*(thickness_global_data-z_right_inner_global_data) + t * (thickness_global_data-z_right_outer_global_data)))));
 
-
     if (std::isnan(z))
     {
     z = 0;}
+//    temp = x;
+//    x = y;
+//    y = temp;
+
     return D3vector ( x,y,z);
 
 }
@@ -427,6 +453,7 @@ D3vector transform_left_lens_diag_NE_quad ( double t1, double t2, double* pointe
     t1 = t2;
     t2 = temp;
     double t = t2;
+    t1 = 1.0 - t1;
 
     double x = R_global_data * ( sin ( t1*0.5*M_PI )-t1);
 
@@ -641,7 +668,7 @@ D3vector transform_right_lens_diag_NE_quad ( double t1, double t2, double* point
     t1 = t2;
     t2 = temp;
     double t = t2;
-
+    t1 = 1.0 - t1;
     double x = R_global_data * ( sin ( t1*0.5*M_PI )-t1);
 
     x = x*t2;
@@ -1167,15 +1194,7 @@ D3vector transform_right_lens_diag_NE_quad_cut ( double t1, double t2, double* p
     if (std::isnan(x) || std::isnan(y) || std::isnan(z))
     {   z = 0;}
 
-//    std::cout << "transform_right_lens_diag_NE_quad_cut ";
-//    D3vector ( x,y,z).Print();
-//    std::cout << std::endl;
-//    double actualZ =  offsetZ_global_data+
-//            sign*(  ( sqrt(pow(curvatureRight_global_data,2)-
-//                           radiusSquared)
-//                      + sign*(-curvatureRight_global_data))) ;
-//    return D3vector (actualX, actualY,actualZ );
-    //return D3vector ( xT,yT,z);
+
     return D3vector ( x,y,z);
     //return D3vector ( (1-t2) * xAdd,(1-t2) * yAdd,z);
     return D3vector ( 0,0,z);
@@ -1726,6 +1745,7 @@ Lens_Geometry_Quad::Lens_Geometry_Quad(double Radius, double thickness, double c
   Set_transformation_face(4,5,12,13,transform_diag_inner_faces_NE_quad);
   Set_transformation_face(3,5,11,13,transform_outer_boundary_NW); //transform_outer_boundary_NW
   Set_transformation_face(10,11,12,13,transform_right_lens_diag_NW_quad); //transform_right_lens_diag_NW_quad
+  //Set_transformation_face(10,11,12,13,transform_quadrangle_NULL); //transform_right_lens_diag_NW_quad
 
   //bottom-west block: corner ids: 4 5 6 7 12 13 14 15
   //eher: S-W-BLOCK
@@ -1744,7 +1764,7 @@ Lens_Geometry_Quad::Lens_Geometry_Quad(double Radius, double thickness, double c
   Set_transformation_face(6,7,14,15,transform_diag_inner_faces_NE_quad);
   Set_transformation_face(1,7,9,15,transform_outer_boundary_SE);
   Set_transformation_face(8,9,14,15,transform_right_lens_diag_SE_quad);
-
+  //Set_transformation_face(8,9,14,15,transform_quadrangle_NULL);
 
 
   construction_done();
@@ -1764,6 +1784,9 @@ Lens_Geometry_cutted_edges::Lens_Geometry_cutted_edges(double RadiusLeft, double
     {
         cutRight = true;
     }
+
+    assert(!cutLeft || (curvatureLeft < 0 && cutLeft)  && "Assertion failed! If left side of lens is cutted, its curvature must be negative (convex)!");
+    assert(!cutRight || (curvatureRight < 0 && cutRight)  && "Assertion failed! If right side of lens is cutted, its curvature must be negative (convex)!");
     if (MechanicalRadiusLeft < RadiusLeft)
     {
         std::cout << "warning : mech radius < radius\n set to radiusLeft";
diff --git a/program/source/math_lib/math_lib.h b/program/source/math_lib/math_lib.h
index 419718c..755bdfa 100644
--- a/program/source/math_lib/math_lib.h
+++ b/program/source/math_lib/math_lib.h
@@ -54,6 +54,7 @@ class D3vector {
   D3vector() : x(0), y(0), z(0) {};
   ~D3vector(){};
   void Print();
+  void PrintCoordinatesOnly();
   void Print(std::ofstream *Datei);
   void operator=(const D3vector& v) { x=v.x; y=v.y; z=v.z; }
   void operator+=(const D3vector& v) { x+=v.x; y+=v.y; z+=v.z; }
@@ -565,6 +566,10 @@ inline void D3vector::Print() {
   std::cout << "Coordinate: " << x << ", " << y << ", " << z << ";\n";
 }
 
+inline void D3vector::PrintCoordinatesOnly() {
+  std::cout << x << "," << y << "," << z;
+}
+
 inline void D3vector::Print(std::ofstream *Datei) {
   *Datei  << x << " " << y << " " << z;
 }
diff --git a/program2D/source/grid/interpolation2D_cc.h b/program2D/source/grid/interpolation2D_cc.h
index 62aa2f7..c9fd360 100644
--- a/program2D/source/grid/interpolation2D_cc.h
+++ b/program2D/source/grid/interpolation2D_cc.h
@@ -30,10 +30,11 @@
 #else
   #ifdef WIN32
     #include <array>
+    using std::array;
   #else
     #include <tr1/array>
+using std::tr1::array;
   #endif
-  using std::tr1::array;
 #endif
   
 #endif // _NOARRAYLIB  
-- 
GitLab