Debian Codegraph @

src/atlas/util/function/VortexRollup.cc

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #include "atlas/util/Constants.h"
12 #include "atlas/util/Earth.h"
13
14 #include "atlas/util/function/VortexRollup.h"
15
16 namespace atlas {
17
18 namespace util {
19
20 namespace function {
21
22 double vortex_rollup(double lon, double lat, double t) {
23 lon *= Constants::degreesToRadians();
24 lat *= Constants::degreesToRadians();
25
26 auto sqr = [](const double x) { return x * x; };
27 auto sech = [](const double x) { return 1. / std::cosh(x); };
28 constexpr double two_pi = 2. * M_PI;
29 const double lambda_prime = std::atan2(-std::cos(lon - two_pi * t), std::tan(lat));
30 const double rho = 3. * std::sqrt(1. - sqr(std::cos(lat)) * sqr(std::sin(lon - two_pi * t)));
31 double omega = 0.;
32 double a = Earth::radius();
33 if (rho != 0.) {
34 omega = 0.5 * 3 * std::sqrt(3) * a * two_pi * sqr(sech(rho)) * std::tanh(rho) / rho;
35 }
36 return -std::tanh(0.2 * rho * std::sin(lambda_prime - omega / a * t));
37 }
38
39 } // namespace function
40
41 } // namespace util
42
43 } // namespace atlas