File: kernelGeoid.cpp

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (147 lines) | stat: -rw-r--r-- 3,910 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***********************************************/
/**
* @file kernelGeoid.cpp
*
* @brief Integral kernel of geoid computation.
* (= Poisson Kern * gamma).
* @see Kernel
*
* @author Torsten Mayer-Guerr
* @date 2003-09-20
*
*/
/***********************************************/

#include "base/import.h"
#include "base/planets.h"
#include "classes/gravityfield/gravityfield.h"
#include "classes/kernel/kernel.h"
#include "classes/kernel/kernelGeoid.h"

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

Vector KernelGeoid::coefficients(Vector3d const &q, UInt degree) const
{
  try
  {
    if(degree==INFINITYDEGREE)
      throw(Exception("INFINITYDEGREE requested"));

    Vector  k(degree+1);
    Double *kn = k.field();
    Double gamma = Planets::normalGravity(q);
    for(UInt n=0; n<=degree; n++)
      *kn++ = gamma;

    return k;
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

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

Vector KernelGeoid::inverseCoefficients(Vector3d const &p, UInt degree, Bool /*interior*/) const
{
  try
  {
    if(degree==INFINITYDEGREE)
      throw(Exception("INFINITYDEGREE requested"));

    Vector  k(degree+1);
    Double *kn = k.field();
    Double gamma = Planets::normalGravity(p);
    for(UInt n=0; n<=degree; n++)
      *kn++ = 1./gamma;

    return k;
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

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

Double KernelGeoid::kernel(Vector3d const &p, Vector3d const &q) const
{
  Vector3d diff  = p-q;
  Double r       = p.r();
  Double R       = q.r();
  Double l       = diff.r();

  return Planets::normalGravity(q) * R*(r*r-R*R)/(l*l*l);
}

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

Double KernelGeoid::radialDerivative(Vector3d const &p, Vector3d const &q) const
{
  Vector3d diff  = p-q;
  Double r       = p.r();
  Double R       = q.r();
  Double l       = diff.r();
  Double cos_psi = (R*R+r*r-l*l)/(2*R*r);
  Double dl_dr   = (r-R*cos_psi)/l;

  return Planets::normalGravity(q) * R*(2*r*l-(r*r-R*R)*3*dl_dr)/(l*l*l*l);
}

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

Vector3d KernelGeoid::gradient(Vector3d const &p, Vector3d const &q) const
{
  Vector3d diff  = p-q;
  Double r       = p.r();
  Double l       = diff.r();
  Double R       = q.r();

  return Planets::normalGravity(q) * (2/(l*l*l)*p - 3*(r*r-R*R)/(l*l*l*l*l)*diff);
}

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

Tensor3d KernelGeoid::gradientGradient(const Vector3d &p, const Vector3d &q) const
{
  Tensor3d tns;

  Vector3d diff = p-q;
  Double r      = p.r();
  Double R      = q.r();
  Double l      = diff.r();
  Double l2     = l*l;
  Double l3     = l2*l;
  Double l5     = l3*l2;
  Double l7     = l5*l2;
  Double term   = r*r-R*R;

  tns.xx() =  2.0/l3 - 12.0*p.x()*diff.x()/l5 + 15*term*diff.x()*diff.x()/l7 - 3.0*term/l5;
  tns.yy() =  2.0/l3 - 12.0*p.y()*diff.y()/l5 + 15*term*diff.y()*diff.y()/l7 - 3.0*term/l5;
  tns.zz() =  2.0/l3 - 12.0*p.z()*diff.z()/l5 + 15*term*diff.z()*diff.z()/l7 - 3.0*term/l5;
  tns.xy() = -6.0*(p.x()*diff.y()+p.y()*diff.x())/l5 + 15.0*term*diff.x()*diff.y()/l7;
  tns.xz() = -6.0*(p.x()*diff.z()+p.z()*diff.x())/l5 + 15.0*term*diff.x()*diff.z()/l7;
  tns.yz() = -6.0*(p.y()*diff.z()+p.z()*diff.y())/l5 + 15.0*term*diff.y()*diff.z()/l7;

  return Planets::normalGravity(q) * tns;
}

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

Double KernelGeoid::inverseKernel(Vector3d const &p, Vector3d const &q, const Kernel &kernel) const
{
  // geoid = potential/gamma
  return (1./Planets::normalGravity(p)) * kernel.kernel(p, q);
}

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

Double KernelGeoid::inverseKernel(const Time &time, const Vector3d &p, const GravityfieldBase &field) const
{
  // geoid = potential/gamma
  return (1./Planets::normalGravity(p)) * field.potential(time, p);
}

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