Blame view

src/ExternLib/KT17/KT17.hh 4.97 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

274e80eb   Erdogan Furkan   Final fixes for kt17
10
#include "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:
274e80eb   Erdogan Furkan   Final fixes for kt17
28
29
            KT17(Process &pProcess, ParamDataSpec<vector<DataType>> &paramInput, string coordRef, double rSun, double distIndex)
                : Operation(pProcess), _paramInput(paramInput),  _coordRef(coordRef), _rSun(rSun), _distIndex(distIndex),
3e353d23   Furkan   Process creadted ...
30
                  _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
                    double crtTime = _paramInput.getTime(_index);
fc7f9882   Erdogan Furkan   Kernel part for #...
48
                    vector<DataType> outputBxyz;
8336362b   Furkan   FOr now
49
                    outputBxyz.resize(3);
8336362b   Furkan   FOr now
50
                    DataType outputBm;
fc7f9882   Erdogan Furkan   Kernel part for #...
51

8336362b   Furkan   FOr now
52
                    /* Creation of the output vectors */
fc7f9882   Erdogan Furkan   Kernel part for #...
53
                    GetModelField(in,outputBxyz);
8336362b   Furkan   FOr now
54

fc7f9882   Erdogan Furkan   Kernel part for #...
55
                    outputBm = sqrt(outputBxyz[0] * outputBxyz[0] + outputBxyz[1] * outputBxyz[1] + outputBxyz[2] * outputBxyz[2]);
8336362b   Furkan   FOr now
56
57

                    _paramOutput->pushTime(crtTime);
fc7f9882   Erdogan Furkan   Kernel part for #...
58
                    pushResult(outputBxyz, outputBm);
8336362b   Furkan   FOr now
59
60
                }
            }
fc7f9882   Erdogan Furkan   Kernel part for #...
61
            int GetModelField(vector<DataType> &input, vector<DataType> &output){
e1fb3491   Furkan   #10412 - Working ...
62
63
                double Bx, By, Bz;
                double x,y,z;
fc7f9882   Erdogan Furkan   Kernel part for #...
64
65
66
67
68
69
70
71
72
73
74
75
76
                double* params=new double[2];
                double dz = 0.196;


                // Coeffs for the model
                if (!std::isnan(_rSun) && !std::isnan(_distIndex)){
                    params[0] = _rSun;
                    params[1] = _distIndex;
                }
                else{
                    params[0] = 0.427;
                    params[1] = 50.0;
                }
274e80eb   Erdogan Furkan   Final fixes for kt17
77
78
79
               
                x =  double(input[0]);
                y = double(input[1]);
fc7f9882   Erdogan Furkan   Kernel part for #...
80
81
82
83
84
                
                if(_coordRef == "MSO")
                    z = double(input[2])-dz;
                else if (_coordRef == "MSM")
                    z = double(input[2]);
3e353d23   Furkan   Process creadted ...
85

e1fb3491   Furkan   #10412 - Working ...
86
                // Call to the lib to compute
fc7f9882   Erdogan Furkan   Kernel part for #...
87
                ModelField(1,&x,&y,&z,1,2,&params,&Bx, &By,&Bz);
e1fb3491   Furkan   #10412 - Working ...
88
89
90
91
        
                output[0] = Bx;
                output[1] = By;
                output[2] = Bz;
3e353d23   Furkan   Process creadted ...
92

e1fb3491   Furkan   #10412 - Working ...
93
                free(params);
3e353d23   Furkan   Process creadted ...
94

e1fb3491   Furkan   #10412 - Working ...
95
96
                return true;
            }
8336362b   Furkan   FOr now
97
98
99

        protected:
            virtual void
fc7f9882   Erdogan Furkan   Kernel part for #...
100
            pushResult(vector<DataType> field_cart, DataType magnitude_) = 0;
8336362b   Furkan   FOr now
101
            ParamDataSpec<std::vector<DataType>> &_paramInput;
fc7f9882   Erdogan Furkan   Kernel part for #...
102
            std::string _coordRef;
fc7f9882   Erdogan Furkan   Kernel part for #...
103
104
            double _rSun;
            double _distIndex;
3e353d23   Furkan   Process creadted ...
105
106
            TOutputParamData *_paramOutput;
            
8336362b   Furkan   FOr now
107
108
109
        };

        template <typename DataType>
fc7f9882   Erdogan Furkan   Kernel part for #...
110
        class KT17Cart : public KT17<DataType, ParamDataSpec<vector<DataType>>>
8336362b   Furkan   FOr now
111
112
113
114
115
116
        {
        public:
            /**
             * @brief Constructor.
             * @details Create the ParamData type of the input ParamData.
             */
274e80eb   Erdogan Furkan   Final fixes for kt17
117
118
            KT17Cart(Process &pProcess, ParamDataSpec<vector<DataType>> &paramInput, string coordRef, double rSun, double distIndex) : 
                    KT17<DataType, ParamDataSpec<vector<DataType>>>(pProcess, paramInput, coordRef, rSun, distIndex){}
fc7f9882   Erdogan Furkan   Kernel part for #...
119
120
121
122
            virtual ~KT17Cart(){}
        protected:
            virtual void pushResult(vector<DataType> _fieldCart, DataType /*magnitude_*/){
                KT17<DataType, ParamDataSpec<vector<DataType>>>::_paramOutput->getDataList().push_back(_fieldCart);
8336362b   Furkan   FOr now
123
            }
fc7f9882   Erdogan Furkan   Kernel part for #...
124
        };
8336362b   Furkan   FOr now
125

8336362b   Furkan   FOr now
126

fc7f9882   Erdogan Furkan   Kernel part for #...
127
128
129
130
131
132
133
134
        template <typename DataType>
        class KT17Mag : public KT17<DataType, ParamDataSpec<DataType>>
        {
        public:
            /**
             * @brief Constructor.
             * @details Create the ParamData type of the input ParamData.
             */
274e80eb   Erdogan Furkan   Final fixes for kt17
135
136
            KT17Mag(Process &pProcess, ParamDataSpec<vector<DataType>> &paramInput, string coordRef, double rSun, double distIndex) : 
                    KT17<DataType, ParamDataSpec<DataType>>(pProcess, paramInput, coordRef, rSun, distIndex){}
fc7f9882   Erdogan Furkan   Kernel part for #...
137
            virtual ~KT17Mag(){}
8336362b   Furkan   FOr now
138
        protected:
fc7f9882   Erdogan Furkan   Kernel part for #...
139
140
            virtual void pushResult(vector<DataType> /*_fieldCart*/, DataType magnitude_){
                KT17<DataType, ParamDataSpec<DataType>>::_paramOutput->getDataList().push_back(magnitude_); 
8336362b   Furkan   FOr now
141
142
            }
        };
fc7f9882   Erdogan Furkan   Kernel part for #...
143

8336362b   Furkan   FOr now
144
145
146
    }
}
#endif /* KT17.hh */