19 #include "eckit/config/Configuration.h" 24 #include "oops/util/abor1_cpp.h" 25 #include "oops/util/Logger.h" 31 : resol_(resol.npoints()), x_(resol_)
34 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = 0.0;
38 : resol_(resol.npoints()), x_(resol_)
42 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = other.
x_[jj];
46 : resol_(other.resol_), x_(resol_)
50 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = other.
x_[jj];
52 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = 0.0;
57 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = 0.0;
62 std::vector<int> ixdir(config.getIntVector(
"ixdir"));
65 ASSERT(ixdir.size() > 0);
66 for (
unsigned int jj = 0; jj < ixdir.size(); ++jj) {
67 ASSERT(ixdir[jj] <
resol_);
71 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = 0.0;
72 for (
unsigned int jj = 0; jj < ixdir.size(); ++jj)
x_[ixdir[jj]] = 1.0;
76 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = 0.0;
77 if (
conf.has(
"mean")) {
78 const double zz =
conf.getDouble(
"mean");
79 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = zz;
81 if (
conf.has(
"sinus")) {
82 const double zz =
conf.getDouble(
"sinus");
83 const double pi = std::acos(-1.0);
84 const double dx = 2.0 *
pi /
static_cast<double>(
resol_);
85 for (
int jj = 0; jj < resol_; ++jj) x_[jj] += zz * std::sin(static_cast<double>(jj) * dx);
87 if (
conf.has(
"dirac")) {
88 const int ii =
conf.getInt(
"dirac");
91 oops::Log::trace() <<
"FieldL95::generate " <<
x_[28] <<
", " <<
x_[29] << std::endl;
96 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = rhs.
x_[jj];
102 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] += rhs.
x_[jj];
108 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] -= rhs.
x_[jj];
113 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] *= fact;
120 for (
int jj = 0; jj <
resol_; ++jj) {
121 x_[jj] = x1.
x_[jj] - x2.
x_[jj];
127 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] += zz * rhs.
x_[jj];
133 for (
int jj = 0; jj <
resol_; ++jj) zz +=
x_[jj] * other.
x_[jj];
139 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] *= rhs.
x_[jj];
143 static std::mt19937 generator(1);
144 static std::normal_distribution<double> distribution(0.0, 1.0);
145 for (
int jj = 0; jj <
resol_; ++jj)
x_[jj] = distribution(generator);
149 const double dres =
static_cast<double>(
resol_);
150 for (
size_t jobs = 0; jobs < locs.
size(); ++jobs) {
151 int ii = round(locs[jobs] * dres);
152 ASSERT(ii >= 0 && ii <=
resol_);
160 const double dres =
static_cast<double>(
resol_);
163 for (
size_t jobs = 0; jobs < locs.
size(); ++jobs) {
164 int ii = round(locs[jobs] * dres);
165 ASSERT(ii >= 0 && ii <=
resol_);
172 ABORT(
"FieldL95 unstructured grid setup not implemented.");
176 ABORT(
"FieldL95 conversion to unstructured grid not implemented.");
180 ABORT(
"FieldL95 conversion from unstructured grid not implemented.");
184 for (
int jj = 0; jj < resol_; ++jj) fin >>
x_[jj];
188 fout.precision(std::numeric_limits<double>::digits10);
189 for (
int jj = 0; jj <
resol_; ++jj) fout <<
x_[jj] <<
" ";
194 for (
int jj = 0; jj <
resol_; ++jj) zz +=
x_[jj] *
x_[jj];
203 for (
int jj = 0; jj <
resol_; ++jj) {
204 if (
x_[jj] < zmin) zmin =
x_[jj];
205 if (
x_[jj] > zmax) zmax =
x_[jj];
209 os <<
" Min=" << zmin <<
", Max=" << zmax <<
", Average=" << zavg;
GomL95 class to handle locations for L95 model.
void interp(const LocsL95 &, GomL95 &) const
Interpolate to given location.
void ug_coord(oops::UnstructuredGrid &, const int &) const
Unstructured grid.
void field_to_ug(oops::UnstructuredGrid &, const int &) const
FieldL95 & operator-=(const FieldL95 &)
FieldL95(const Resolution &)
Constructors and basic operators.
subroutine, public copy(self, rhs)
void diff(const FieldL95 &, const FieldL95 &)
void interpAD(const LocsL95 &, const GomL95 &)
void print(std::ostream &) const
void dirac(const eckit::Configuration &)
LocsL95 class to handle locations for L95 model.
void field_from_ug(const oops::UnstructuredGrid &)
void zero()
Linear algebra.
void read(std::ifstream &)
Utilities.
The namespace for the L95 model.
void schur(const FieldL95 &)
double dot_product_with(const FieldL95 &) const
FieldL95 & operator*=(const double &)
FieldL95 & operator+=(const FieldL95 &)
void generate(const eckit::Configuration &)
void write(std::ofstream &) const
void axpy(const double &, const FieldL95 &)
FieldL95 & operator=(const FieldL95 &)
Class to represent fields for the L95 model.