File: kernelEvaluate.cpp

package info (click to toggle)
groops 0%2Bgit20240830%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 11,052 kB
  • sloc: cpp: 134,939; fortran: 1,569; makefile: 20
file content (75 lines) | stat: -rw-r--r-- 2,535 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***********************************************/
/**
* @file kernelEvaluate.cpp
*
* @brief Compute kernel values for distant angles.
*
* @author Torsten Mayer-Guerr
* @date 2017-05-30
*/
/***********************************************/

// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Compute \configClass{kernel}{kernelType} values for distant angles.
The main purpose is for visualization with \program{PlotGraph}.
)";

/***********************************************/

#include "programs/program.h"
#include "files/fileMatrix.h"
#include "classes/kernel/kernel.h"

/***** CLASS ***********************************/

/** @brief Compute kernel values for distant angles.
* @ingroup programsGroup */
class KernelEvaluate
{
public:
  void run(Config &config, Parallel::CommunicatorPtr comm);
};

GROOPS_REGISTER_PROGRAM(KernelEvaluate, SINGLEPROCESS, "Compute kernel values for distant angles", Misc)

/***********************************************/

void KernelEvaluate::run(Config &config, Parallel::CommunicatorPtr /*comm*/)
{
  try
  {
    FileName  fileNameOut;
    KernelPtr kernel;
    Angle     minv, maxv, sampling;
    Double    R, H;

    readConfig(config, "outputfileMatrix", fileNameOut, Config::MUSTSET,  "", "matrix with first column the angle [degree], second the kernel value");
    readConfig(config, "kernel",           kernel,      Config::MUSTSET,  "", "");
    readConfig(config, "minAngle",         minv,        Config::DEFAULT,  "-180", "[degree]");
    readConfig(config, "maxAngle",         maxv,        Config::DEFAULT,  "180",  "[degree]");
    readConfig(config, "sampling",         sampling,    Config::DEFAULT,  "1",    "[degree]");
    readConfig(config, "height",           H,           Config::DEFAULT,  "0",    "evaluate at R+height [m]");
    readConfig(config, "R",                R,           Config::DEFAULT,  STRING_DEFAULT_R,  "reference radius");
    if(isCreateSchema(config)) return;

    const UInt count = static_cast<UInt>((maxv-minv)/sampling+1);
    Matrix A(count, 2);
    Single::forEach(count, [&](UInt i)
    {
      const Double psi = std::min(Double(maxv), minv + i*Double(sampling));
      A(i,0) = psi*RAD2DEG;
      A(i,1) = kernel->kernel(Vector3d((R+H)*sin(psi), 0, (R+H)*cos(psi)), Vector3d(0, 0, R));
    });

    logStatus<<"writing output file <"<<fileNameOut<<">"<<Log::endl;
    writeFileMatrix(fileNameOut, A);
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/