Blame view

src/ExternLib/KT17/KT17.hh 5.17 KB
8336362b   Furkan   FOr now
1
2
3
4
5
6
7
8
9
/*
 * File:   KT17.hh
 * Author: Furkan - AKKA I&S
 *
 * Created on January 19, 2022, 4:14 PM
 */
#ifndef KT17_HH
#define KT17_HH

3e353d23   Furkan   Process creadted ...
10
#include "libkt/libkt.h" // If we name it this way
8336362b   Furkan   FOr now
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include "Parameter.hh"
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "Operation.hh"
#include <vector>

using namespace std;

namespace AMDA
{
    namespace Parameters
    {
        template <typename DataType, class TOutputParamData>
        class KT17 : public Operation
        {
        public:
3e353d23   Furkan   Process creadted ...
28
29
30
            KT17(Process &pProcess, ParamDataSpec<vector<DataType>> &paramInput, string outputCoord)
                : Operation(pProcess), _paramInput(paramInput), _outputCoord(outputCoord),
                  _paramOutput(new TOutputParamData())
8336362b   Furkan   FOr now
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
            {
                _paramDataOutput = _paramOutput;
            }

            virtual ~KT17()
            {
            }
            void write(ParamDataIndexInfo &pParamDataIndexInfo)
            {
                for (unsigned int _index = pParamDataIndexInfo._startIndex;
                     _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
                     ++_index)
                {
                    vector<DataType> in = _paramInput.getDataList()[_index];
                    if (in[0] == 0)
                        in[0] = 1e-31;
8336362b   Furkan   FOr now
47
48
49
50
51
52
                    double crtTime = _paramInput.getTime(_index);
                    vector<DataType> outputBxyz, outputBrtp;
                    outputBxyz.resize(3);
                    outputBrtp.resize(3);
                    DataType outputBm;
                    /* Creation of the output vectors */
3e353d23   Furkan   Process creadted ...
53
                    if (_outputCoord == "proc")
8336362b   Furkan   FOr now
54
                    {
3e353d23   Furkan   Process creadted ...
55
56
                        cout << "HOLLA" << endl;
                        //GetJupiterField(in, true, outputBxyz);
8336362b   Furkan   FOr now
57
58
59
60
61
62
63
64
                    }

                    outputBm = sqrt(outputBrtp[0] * outputBrtp[0] + outputBrtp[1] * outputBrtp[1] + outputBrtp[2] * outputBrtp[2]);

                    _paramOutput->pushTime(crtTime);
                    pushResult(outputBrtp, outputBm, outputBxyz);
                }
            }
3e353d23   Furkan   Process creadted ...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
            // int GetJupiterField(vector<DataType> &inputCartCoord, bool SetCartOut, vector<DataType> &outputB) // To change ofc
            // {
            //     /* set the model */
            //     _internalModel.SetModel(_modelname.c_str());

            //     /* set intput and output coordinates */
            //     _internalModel.SetCartIn(true);
            //     _internalModel.SetCartOut(SetCartOut);

            //     /* output field */
            //     double Br, Bt, Bp;
            //     _internalModel.Field(inputCartCoord[0], inputCartCoord[1], inputCartCoord[2], &Br, &Bt, &Bp);

            //     /* Con2020 calculation to add if necessary */
            //     double Be0, Be1, Be2;
            //     if (_addCon2020 > 0)
            //     {
            //         _con2020.SetCartIn(true);
            //         _con2020.SetCartOut(SetCartOut);
            //         switch (_addCon2020)
            //         {
            //         case 1:
            //             _con2020.SetEqType("analytic");  // Fast
            //             break;
            //         case 2:
            //             _con2020.SetEqType("integral");  // Slow
            //             break;
            //         case 3:
            //             _con2020.SetEqType("hybrid");    // In between
            //             break;

            //         default:
            //             _con2020.SetEqType("analytic");
            //             break;
            //         }
            //         _con2020.Field(inputCartCoord[0], inputCartCoord[1], inputCartCoord[2], &Be0, &Be1, &Be2);
            //     }
            //     else
            //     {
            //         Be0 = 0.0;
            //         Be1 = 0.0;
            //         Be2 = 0.0;
            //     }

            //     outputB[0] = Br + Be0;
            //     outputB[1] = Bt + Be1;
            //     outputB[2] = Bp + Be2;

            //     return true;
            // }
8336362b   Furkan   FOr now
115
116
117
118
119

        protected:
            virtual void
            pushResult(vector<DataType> field_pol, DataType magnitude_, vector<DataType> field_cart) = 0;
            ParamDataSpec<std::vector<DataType>> &_paramInput;
8336362b   Furkan   FOr now
120
            string _outputCoord;
3e353d23   Furkan   Process creadted ...
121
122
            TOutputParamData *_paramOutput;
            
8336362b   Furkan   FOr now
123
124
125
126
127
128
129
130
131
132
        };

        template <typename DataType>
        class KT17Proc : public KT17<DataType, ParamDataSpec<vector<DataType>>>
        {
        public:
            /**
             * @brief Constructor.
             * @details Create the ParamData type of the input ParamData.
             */
3e353d23   Furkan   Process creadted ...
133
            KT17Proc(Process &pProcess, ParamDataSpec<vector<DataType>> &paramInput) : KT17<DataType, ParamDataSpec<vector<DataType>>>(pProcess, paramInput, "proc")
8336362b   Furkan   FOr now
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
            {
            }

            virtual ~KT17Proc()
            {
            }

        protected:
            virtual void pushResult(vector<DataType> /*_fieldPol*/, DataType /*magnitude_*/, vector<DataType> _fieldCart)
            {
                KT17<DataType, ParamDataSpec<vector<DataType>>>::_paramOutput->getDataList().push_back(_fieldCart);
            }
        };
    }
}
#endif /* KT17.hh */