Debian Codegraph @

src/atlas/functionspace/NodeColumns.h

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 #pragma once
12
13 #include "atlas/functionspace/FunctionSpace.h"
14 #include "atlas/functionspace/detail/FunctionSpaceImpl.h"
15 #include "atlas/library/config.h"
16 #include "atlas/mesh.h"
17 #include "atlas/option.h"
18
19 // ----------------------------------------------------------------------------
20 // Forward declarations
21
22 namespace atlas {
23 namespace array {
24 class ArrayShape;
25 }
26
27 namespace mesh {
28 class Nodes;
29 }
30 } // namespace atlas
31
32 namespace atlas {
33 class FieldSet;
34 }
35
36 namespace atlas {
37 namespace parallel {
38 class HaloExchange;
39 class GatherScatter;
40 class Checksum;
41 } // namespace parallel
42 } // namespace atlas
43
44 namespace atlas {
45 namespace functionspace {
46 namespace detail {
47
48 // ----------------------------------------------------------------------------
49
50 class NodeColumns : public functionspace::FunctionSpaceImpl {
51 public:
52 NodeColumns(Mesh mesh, const eckit::Configuration&);
53 NodeColumns(Mesh mesh);
54
55 ~NodeColumns() override;
56
57 static std::string static_type() { return "NodeColumns"; }
58 std::string type() const override { return static_type(); }
59
60 std::string distribution() const override;
61
62 idx_t nb_nodes() const;
63 idx_t nb_nodes_global() const; // All MPI ranks will have same output
64
65 const Mesh& mesh() const { return mesh_; }
66
67 idx_t levels() const { return nb_levels_; }
68
69 mesh::Nodes& nodes() const { return nodes_; }
70
71 // -- Field creation methods
72
73 using FunctionSpaceImpl::createField;
74
75 /// @brief Create a field
76 Field createField(const eckit::Configuration&) const override;
77
78 Field createField(const Field&, const eckit::Configuration&) const override;
79
80 // -- Parallelisation aware methods
81
82 const mesh::Halo& halo() const { return halo_; }
83
84 void haloExchange(const FieldSet&, bool on_device = false) const override;
85 void haloExchange(const Field&, bool on_device = false) const override;
86 const parallel::HaloExchange& halo_exchange() const;
87
88 void adjointHaloExchange(const FieldSet&, bool on_device = false) const override;
89 void adjointHaloExchange(const Field&, bool on_device = false) const override;
90
91 void gather(const FieldSet&, FieldSet&) const override;
92 void gather(const Field&, Field&) const override;
93 const parallel::GatherScatter& gather() const override;
94
95 void scatter(const FieldSet&, FieldSet&) const override;
96 void scatter(const Field&, Field&) const override;
97 const parallel::GatherScatter& scatter() const override;
98
99 std::string checksum(const FieldSet&) const;
100 std::string checksum(const Field&) const;
101 const parallel::Checksum& checksum() const;
102
103 /// @brief Compute sum of scalar field
104 /// @param [out] sum Scalar value containing the sum of the full 3D field
105 /// @param [out] N Number of values that are contained in the sum
106 /// (nodes*levels)
107 template <typename Value>
108 void sum(const Field&, Value& sum, idx_t& N) const;
109
110 // /// @brief Compute sum of field for each variable
111 // /// @param [out] sum For each field-variable, the sum of the full 3D
112 // field
113 // /// @param [out] N Number of values that are contained in the sum
114 // (nodes*levels)
115 // template< typename Value >
116 // void sum( const Field&, std::vector<Value>& sum, idx_t& N ) const;
117
118 /// @brief Compute sum of field for each vertical level separately
119 /// @param [out] sum Field of dimension of input without the nodes index
120 /// @param [out] N Number of nodes used to sum each level
121 void sumPerLevel(const Field&, Field& sum, idx_t& N) const;
122
123 /// @brief Compute order independent sum of scalar field
124 /// @param [out] sum Scalar value containing the sum of the full 3D field
125 /// @param [out] N Number of values that are contained in the sum
126 /// (nodes*levels)
127 template <typename Value>
128 void orderIndependentSum(const Field&, Value& sum, idx_t& N) const;
129
130 // /// @brief Compute order independent sum of field for each variable
131 // /// @param [out] sum For each field-variable, the sum of the full 3D
132 // field
133 // /// @param [out] N Number of values that are contained in the sum
134 // (nodes*levels)
135 // template< typename Value >
136 // void orderIndependentSum( const Field&, std::vector<Value>&, idx_t& N )
137 // const;
138
139 /// @brief Compute order independent sum of field for each vertical level
140 /// separately
141 /// @param [out] sum Field of dimension of input without the nodes index
142 /// @param [out] N Number of nodes used to sum each level
143 void orderIndependentSumPerLevel(const Field&, Field& sum, idx_t& N) const;
144
145 /// @brief Compute minimum of scalar field
146 template <typename Value>
147 void minimum(const Field&, Value& minimum) const;
148
149 /// @brief Compute maximum of scalar field
150 template <typename Value>
151 void maximum(const Field&, Value& maximum) const;
152
153 // /// @brief Compute minimum of field for each field-variable
154 // template< typename Value >
155 // void minimum( const Field&, std::vector<Value>& ) const;
156
157 // /// @brief Compute maximum of field for each field-variable
158 // template< typename Value >
159 // void maximum( const Field&, std::vector<Value>& ) const;
160
161 /// @brief Compute minimum of field for each vertical level separately
162 /// @param [out] min Field of dimension of input without the nodes index
163 void minimumPerLevel(const Field&, Field& min) const;
164
165 /// @brief Compute maximum of field for each vertical level separately
166 /// @param [out] max Field of dimension of input without the nodes index
167 void maximumPerLevel(const Field&, Field& max) const;
168
169 /// @brief Compute minimum of scalar field, as well as the global index and
170 /// level.
171 template <typename Value>
172 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx) const;
173
174 /// @brief Compute maximum of scalar field, as well as the global index and
175 /// level.
176 template <typename Value>
177 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx) const;
178
179 /// @brief Compute minimum of scalar field, as well as the global index and
180 /// level.
181 template <typename Value>
182 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx, idx_t& level) const;
183
184 /// @brief Compute maximum of scalar field, as well as the global index and
185 /// level.
186 template <typename Value>
187 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx, idx_t& level) const;
188
189 /// @brief Compute minimum of field for each field-variable, as well as the
190 /// global indices and levels.
191 template <typename Vector>
192 void minimumAndLocation(const Field&, Vector& minimum, std::vector<gidx_t>& glb_idx) const;
193
194 /// @brief Compute maximum of field for each field-variable, as well as the
195 /// global indices and levels.
196 template <typename Vector>
197 void maximumAndLocation(const Field&, Vector& maximum, std::vector<gidx_t>& glb_idx) const;
198
199 /// @brief Compute minimum of field for each field-variable, as well as the
200 /// global indices and levels.
201 template <typename Vector>
202 void minimumAndLocation(const Field&, Vector& minimum, std::vector<gidx_t>& glb_idx,
203 std::vector<idx_t>& level) const;
204
205 /// @brief Compute maximum of field for each field-variable, as well as the
206 /// global indices and levels.
207 template <typename Vector>
208 void maximumAndLocation(const Field&, Vector& maximum, std::vector<gidx_t>& glb_idx,
209 std::vector<idx_t>& level) const;
210
211 /// @brief Compute minimum and its location of a field for each vertical level
212 /// separately
213 void minimumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
214
215 /// @brief Compute maximum and its location of a field for each vertical level
216 /// separately
217 void maximumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
218
219 /// @brief Compute mean value of scalar field
220 /// @param [out] mean Mean value
221 /// @param [out] N Number of value used to create the mean
222 template <typename Value>
223 void mean(const Field&, Value& mean, idx_t& N) const;
224
225 // /// @brief Compute mean value of field for each field-variable
226 // /// @param [out] mean Mean values for each variable
227 // /// @param [out] N Number of values used to create the means
228 // template< typename Value >
229 // void mean( const Field&, std::vector<Value>& mean, idx_t& N ) const;
230
231 /// @brief Compute mean values of field for vertical level separately
232 /// @param [out] mean Field of dimension of input without the nodes index
233 /// @param [out] N Number of values used to create the means
234 void meanPerLevel(const Field&, Field& mean, idx_t& N) const;
235
236 /// @brief Compute mean value and standard deviation of scalar field
237 /// @param [out] mean Mean value
238 /// @param [out] stddev Standard deviation
239 /// @param [out] N Number of value used to create the mean
240 template <typename Value>
241 void meanAndStandardDeviation(const Field&, Value& mean, Value& stddev, idx_t& N) const;
242
243 // /// @brief Compute mean values and standard deviations of scalar field
244 // for each field-variable
245 // /// @param [out] mean Mean values for each field-variable
246 // /// @param [out] stddev Standard deviation for each field-variable
247 // /// @param [out] N Number of value used to create the means
248 // template< typename Value >
249 // void meanAndStandardDeviation( const Field&, std::vector<Value>& mean,
250 // std::vector<Value>& stddev, idx_t& N ) const;
251
252 /// @brief Compute mean values and standard deviations of field for vertical
253 /// level separately
254 /// @param [out] mean Field of dimension of input without the nodes index
255 /// @param [out] stddev Field of dimension of input without the nodes index
256 /// @param [out] N Number of values used to create the means
257 void meanAndStandardDeviationPerLevel(const Field&, Field& mean, Field& stddev, idx_t& N) const;
258
259 virtual idx_t size() const override { return nb_nodes_; }
260
261 idx_t part() const override { return mesh_.part(); }
262
263 idx_t nb_parts() const override { return mesh_.nb_parts(); }
264
265 const Grid& grid() const override;
266
267 Field lonlat() const override { return nodes_.lonlat(); }
268
269 Field ghost() const override { return nodes_.ghost(); }
270
271 Field global_index() const override { return nodes_.global_index(); }
272
273 Field remote_index() const override { return nodes_.remote_index(); }
274
275 Field partition() const override { return nodes_.partition(); }
276
277 const util::PartitionPolygon& polygon(idx_t halo = 0) const override { return mesh_.polygon(halo); }
278
279 const util::PartitionPolygons& polygons() const override { return mesh_.polygons(); }
280
281 const Projection& projection() const override { return mesh_.projection(); }
282
283 std::string mpi_comm() const override { return mesh_.mpi_comm(); }
284
285 private: // methods
286 void constructor();
287
288 idx_t config_nb_nodes(const eckit::Configuration&) const;
289 array::DataType config_datatype(const eckit::Configuration&) const;
290 std::string config_name(const eckit::Configuration&) const;
291 idx_t config_levels(const eckit::Configuration&) const;
292 array::ArrayShape config_shape(const eckit::Configuration&) const;
293 void set_field_metadata(const eckit::Configuration&, Field&) const;
294
295 virtual size_t footprint() const override { return 0; }
296
297 private: // data
298 mutable Grid grid_;
299 Mesh mesh_; // non-const because functionspace may modify mesh
300 mesh::Nodes& nodes_; // non-const because functionspace may modify mesh
301 mesh::Halo halo_;
302 idx_t nb_levels_;
303 idx_t nb_nodes_;
304 mutable idx_t nb_nodes_global_{-1};
305
306 mutable util::ObjectHandle<parallel::GatherScatter> gather_scatter_; // without ghost
307 mutable util::ObjectHandle<parallel::HaloExchange> halo_exchange_;
308 mutable util::ObjectHandle<parallel::Checksum> checksum_;
309
310 private:
311 template <typename Value>
312 struct FieldStatisticsT {
313 FieldStatisticsT(const NodeColumns*);
314 void sum(const Field&, Value& sum, idx_t& N) const;
315 void orderIndependentSum(const Field&, Value& sum, idx_t& N) const;
316 void minimum(const Field&, Value& minimum) const;
317 void maximum(const Field&, Value& maximum) const;
318 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx) const;
319 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx) const;
320 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx, idx_t& level) const;
321 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx, idx_t& level) const;
322 void mean(const Field&, Value& mean, idx_t& N) const;
323 void meanAndStandardDeviation(const Field&, Value& mean, Value& stddev, idx_t& N) const;
324 const NodeColumns& functionspace;
325 };
326
327 template <typename Vector>
328 struct FieldStatisticsVectorT {
329 FieldStatisticsVectorT(const NodeColumns*);
330 void sum(const Field&, Vector& sum, idx_t& N) const;
331 void orderIndependentSum(const Field&, Vector&, idx_t& N) const;
332 void minimum(const Field&, Vector&) const;
333 void maximum(const Field&, Vector&) const;
334 void minimumAndLocation(const Field&, Vector& minimum, std::vector<gidx_t>& glb_idx) const;
335 void maximumAndLocation(const Field&, Vector& maximum, std::vector<gidx_t>& glb_idx) const;
336 void minimumAndLocation(const Field&, Vector& minimum, std::vector<gidx_t>& glb_idx,
337 std::vector<idx_t>& level) const;
338 void maximumAndLocation(const Field&, Vector& maximum, std::vector<gidx_t>& glb_idx,
339 std::vector<idx_t>& level) const;
340 void mean(const Field&, Vector& mean, idx_t& N) const;
341 void meanAndStandardDeviation(const Field&, Vector& mean, Vector& stddev, idx_t& N) const;
342 const NodeColumns& functionspace;
343 };
344
345 struct FieldStatistics {
346 FieldStatistics(const NodeColumns*);
347 void sumPerLevel(const Field&, Field& sum, idx_t& N) const;
348 void orderIndependentSumPerLevel(const Field&, Field& sum, idx_t& N) const;
349 void minimumPerLevel(const Field&, Field& min) const;
350 void maximumPerLevel(const Field&, Field& max) const;
351 void minimumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
352 void maximumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
353 void meanPerLevel(const Field&, Field& mean, idx_t& N) const;
354 void meanAndStandardDeviationPerLevel(const Field&, Field& mean, Field& stddev, idx_t& N) const;
355 const NodeColumns& functionspace;
356 };
357
358 template <typename T>
359 struct FieldStatisticsSelector {
360 using type =
361 typename std::conditional<std::is_pod<T>::value, FieldStatisticsT<T>, FieldStatisticsVectorT<T>>::type;
362 };
363 };
364
365 // -------------------------------------------------------------------
366
367 template <typename Value>
368 void NodeColumns::sum(const Field& field, Value& sum, idx_t& N) const {
369 typename FieldStatisticsSelector<Value>::type(this).sum(field, sum, N);
370 }
371
372 inline void NodeColumns::sumPerLevel(const Field& field, Field& sum, idx_t& N) const {
373 FieldStatistics(this).sumPerLevel(field, sum, N);
374 }
375
376 template <typename Value>
377 void NodeColumns::orderIndependentSum(const Field& field, Value& sum, idx_t& N) const {
378 typename FieldStatisticsSelector<Value>::type(this).orderIndependentSum(field, sum, N);
379 }
380
381 inline void NodeColumns::orderIndependentSumPerLevel(const Field& field, Field& sum, idx_t& N) const {
382 FieldStatistics(this).orderIndependentSumPerLevel(field, sum, N);
383 }
384
385 template <typename Value>
386 void NodeColumns::minimum(const Field& field, Value& minimum) const {
387 typename FieldStatisticsSelector<Value>::type(this).minimum(field, minimum);
388 }
389
390 template <typename Value>
391 void NodeColumns::maximum(const Field& field, Value& maximum) const {
392 typename FieldStatisticsSelector<Value>::type(this).maximum(field, maximum);
393 }
394
395 inline void NodeColumns::minimumPerLevel(const Field& field, Field& minimum) const {
396 return FieldStatistics(this).minimumPerLevel(field, minimum);
397 }
398
399 inline void NodeColumns::maximumPerLevel(const Field& field, Field& maximum) const {
400 FieldStatistics(this).maximumPerLevel(field, maximum);
401 }
402
403 template <typename Value>
404 void NodeColumns::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx) const {
405 FieldStatisticsT<Value>(this).minimumAndLocation(field, minimum, glb_idx);
406 }
407
408 template <typename Value>
409 void NodeColumns::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx) const {
410 FieldStatisticsT<Value>(this).maximumAndLocation(field, maximum, glb_idx);
411 }
412
413 template <typename Value>
414 void NodeColumns::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx, idx_t& level) const {
415 FieldStatisticsT<Value>(this).minimumAndLocation(field, minimum, glb_idx, level);
416 }
417
418 template <typename Value>
419 void NodeColumns::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx, idx_t& level) const {
420 FieldStatisticsT<Value>(this).maximumAndLocation(field, maximum, glb_idx, level);
421 }
422
423 template <typename Vector>
424 void NodeColumns::minimumAndLocation(const Field& field, Vector& minimum, std::vector<gidx_t>& glb_idx) const {
425 FieldStatisticsVectorT<Vector>(this).minimumAndLocation(field, minimum, glb_idx);
426 }
427
428 template <typename Vector>
429 void NodeColumns::maximumAndLocation(const Field& field, Vector& maximum, std::vector<gidx_t>& glb_idx) const {
430 FieldStatisticsVectorT<Vector>(this).maximumAndLocation(field, maximum, glb_idx);
431 }
432
433 template <typename Vector>
434 void NodeColumns::minimumAndLocation(const Field& field, Vector& minimum, std::vector<gidx_t>& glb_idx,
435 std::vector<idx_t>& level) const {
436 FieldStatisticsVectorT<Vector>(this).minimumAndLocation(field, minimum, glb_idx, level);
437 }
438
439 template <typename Vector>
440 void NodeColumns::maximumAndLocation(const Field& field, Vector& maximum, std::vector<gidx_t>& glb_idx,
441 std::vector<idx_t>& level) const {
442 FieldStatisticsVectorT<Vector>(this).maximumAndLocation(field, maximum, glb_idx, level);
443 }
444
445 inline void NodeColumns::minimumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const {
446 FieldStatistics(this).minimumAndLocationPerLevel(field, column, glb_idx);
447 }
448
449 inline void NodeColumns::maximumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const {
450 FieldStatistics(this).maximumAndLocationPerLevel(field, column, glb_idx);
451 }
452
453 template <typename Value>
454 void NodeColumns::mean(const Field& field, Value& mean, idx_t& N) const {
455 typename FieldStatisticsSelector<Value>::type(this).mean(field, mean, N);
456 }
457
458 inline void NodeColumns::meanPerLevel(const Field& field, Field& mean, idx_t& N) const {
459 FieldStatistics(this).meanPerLevel(field, mean, N);
460 }
461
462 template <typename Value>
463 void NodeColumns::meanAndStandardDeviation(const Field& field, Value& mean, Value& stddev, idx_t& N) const {
464 typename FieldStatisticsSelector<Value>::type(this).meanAndStandardDeviation(field, mean, stddev, N);
465 }
466
467 inline void NodeColumns::meanAndStandardDeviationPerLevel(const Field& field, Field& mean, Field& stddev,
468 idx_t& N) const {
469 FieldStatistics(this).meanAndStandardDeviationPerLevel(field, mean, stddev, N);
470 }
471
472 } // namespace detail
473
474 // -------------------------------------------------------------------
475
476 class NodeColumns : public FunctionSpace {
477 public:
478 using Implementation = detail::NodeColumns;
479
480 public:
481 NodeColumns();
482 NodeColumns(const FunctionSpace&);
483
484 NodeColumns(Mesh mesh);
485 NodeColumns(Mesh mesh, const eckit::Configuration&);
486
487 static std::string type() { return detail::NodeColumns::static_type(); }
488
489 operator bool() const { return valid(); }
490 bool valid() const { return functionspace_; }
491
492 idx_t nb_nodes() const;
493 idx_t nb_nodes_global() const; // All MPI ranks will have same output
494
495 const Mesh& mesh() const;
496
497 idx_t levels() const;
498
499 mesh::Nodes& nodes() const;
500
501 // -- Parallelisation aware methods
502
503 const mesh::Halo& halo() const;
504
505 void haloExchange(const FieldSet&, bool on_device = false) const;
506 void haloExchange(const Field&, bool on_device = false) const;
507 const parallel::HaloExchange& halo_exchange() const;
508
509 std::string checksum(const FieldSet&) const;
510 std::string checksum(const Field&) const;
511 const parallel::Checksum& checksum() const;
512
513 /// @brief Compute sum of scalar field
514 /// @param [out] sum Scalar value containing the sum of the full 3D field
515 /// @param [out] N Number of values that are contained in the sum
516 /// (nodes*levels)
517 template <typename Value>
518 void sum(const Field&, Value& sum, idx_t& N) const;
519
520 // /// @brief Compute sum of field for each variable
521 // /// @param [out] sum For each field-variable, the sum of the full 3D
522 // field
523 // /// @param [out] N Number of values that are contained in the sum
524 // (nodes*levels)
525 // template< typename Value >
526 // void sum( const Field&, std::vector<Value>& sum, idx_t& N ) const;
527
528 /// @brief Compute sum of field for each vertical level separately
529 /// @param [out] sum Field of dimension of input without the nodes index
530 /// @param [out] N Number of nodes used to sum each level
531 void sumPerLevel(const Field&, Field& sum, idx_t& N) const;
532
533 /// @brief Compute order independent sum of scalar field
534 /// @param [out] sum Scalar value containing the sum of the full 3D field
535 /// @param [out] N Number of values that are contained in the sum
536 /// (nodes*levels)
537 template <typename Value>
538 void orderIndependentSum(const Field&, Value& sum, idx_t& N) const;
539
540 // /// @brief Compute order independent sum of field for each variable
541 // /// @param [out] sum For each field-variable, the sum of the full 3D
542 // field
543 // /// @param [out] N Number of values that are contained in the sum
544 // (nodes*levels)
545 // template< typename Value >
546 // void orderIndependentSum( const Field&, std::vector<Value>&, idx_t& N )
547 // const;
548
549 /// @brief Compute order independent sum of field for each vertical level
550 /// separately
551 /// @param [out] sum Field of dimension of input without the nodes index
552 /// @param [out] N Number of nodes used to sum each level
553 void orderIndependentSumPerLevel(const Field&, Field& sum, idx_t& N) const;
554
555 /// @brief Compute minimum of scalar field
556 template <typename Value>
557 void minimum(const Field&, Value& minimum) const;
558
559 /// @brief Compute maximum of scalar field
560 template <typename Value>
561 void maximum(const Field&, Value& maximum) const;
562
563 // /// @brief Compute minimum of field for each field-variable
564 // template< typename Value >
565 // void minimum( const Field&, std::vector<Value>& ) const;
566
567 // /// @brief Compute maximum of field for each field-variable
568 // template< typename Value >
569 // void maximum( const Field&, std::vector<Value>& ) const;
570
571 /// @brief Compute minimum of field for each vertical level separately
572 /// @param [out] min Field of dimension of input without the nodes index
573 void minimumPerLevel(const Field&, Field& min) const;
574
575 /// @brief Compute maximum of field for each vertical level separately
576 /// @param [out] max Field of dimension of input without the nodes index
577 void maximumPerLevel(const Field&, Field& max) const;
578
579 /// @brief Compute minimum of scalar field, as well as the global index and
580 /// level.
581 template <typename Value>
582 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx) const;
583
584 /// @brief Compute maximum of scalar field, as well as the global index and
585 /// level.
586 template <typename Value>
587 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx) const;
588
589 /// @brief Compute minimum of scalar field, as well as the global index and
590 /// level.
591 template <typename Value>
592 void minimumAndLocation(const Field&, Value& minimum, gidx_t& glb_idx, idx_t& level) const;
593
594 /// @brief Compute maximum of scalar field, as well as the global index and
595 /// level.
596 template <typename Value>
597 void maximumAndLocation(const Field&, Value& maximum, gidx_t& glb_idx, idx_t& level) const;
598
599 /// @brief Compute minimum of field for each field-variable, as well as the
600 /// global indices and levels.
601 template <typename Value>
602 void minimumAndLocation(const Field&, std::vector<Value>& minimum, std::vector<gidx_t>& glb_idx) const;
603
604 /// @brief Compute maximum of field for each field-variable, as well as the
605 /// global indices and levels.
606 template <typename Value>
607 void maximumAndLocation(const Field&, std::vector<Value>& maximum, std::vector<gidx_t>& glb_idx) const;
608
609 /// @brief Compute minimum of field for each field-variable, as well as the
610 /// global indices and levels.
611 template <typename Value>
612 void minimumAndLocation(const Field&, std::vector<Value>& minimum, std::vector<gidx_t>& glb_idx,
613 std::vector<idx_t>& level) const;
614
615 /// @brief Compute maximum of field for each field-variable, as well as the
616 /// global indices and levels.
617 template <typename Value>
618 void maximumAndLocation(const Field&, std::vector<Value>& maximum, std::vector<gidx_t>& glb_idx,
619 std::vector<idx_t>& level) const;
620
621 /// @brief Compute minimum and its location of a field for each vertical level
622 /// separately
623 void minimumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
624
625 /// @brief Compute maximum and its location of a field for each vertical level
626 /// separately
627 void maximumAndLocationPerLevel(const Field&, Field& column, Field& glb_idx) const;
628
629 /// @brief Compute mean value of scalar field
630 /// @param [out] mean Mean value
631 /// @param [out] N Number of value used to create the mean
632 template <typename Value>
633 void mean(const Field&, Value& mean, idx_t& N) const;
634
635 // /// @brief Compute mean value of field for each field-variable
636 // /// @param [out] mean Mean values for each variable
637 // /// @param [out] N Number of values used to create the means
638 // template< typename Value >
639 // void mean( const Field&, std::vector<Value>& mean, idx_t& N ) const;
640
641 /// @brief Compute mean values of field for vertical level separately
642 /// @param [out] mean Field of dimension of input without the nodes index
643 /// @param [out] N Number of values used to create the means
644 void meanPerLevel(const Field&, Field& mean, idx_t& N) const;
645
646 /// @brief Compute mean value and standard deviation of scalar field
647 /// @param [out] mean Mean value
648 /// @param [out] stddev Standard deviation
649 /// @param [out] N Number of value used to create the mean
650 template <typename Value>
651 void meanAndStandardDeviation(const Field&, Value& mean, Value& stddev, idx_t& N) const;
652
653 // /// @brief Compute mean values and standard deviations of scalar field
654 // for each field-variable
655 // /// @param [out] mean Mean values for each field-variable
656 // /// @param [out] stddev Standard deviation for each field-variable
657 // /// @param [out] N Number of value used to create the means
658 // template< typename Value >
659 // void meanAndStandardDeviation( const Field&, std::vector<Value>& mean,
660 // std::vector<Value>& stddev, idx_t& N ) const;
661
662 /// @brief Compute mean values and standard deviations of field for vertical
663 /// level separately
664 /// @param [out] mean Field of dimension of input without the nodes index
665 /// @param [out] stddev Field of dimension of input without the nodes index
666 /// @param [out] N Number of values used to create the means
667 void meanAndStandardDeviationPerLevel(const Field&, Field& mean, Field& stddev, idx_t& N) const;
668
669 private:
670 const detail::NodeColumns* functionspace_;
671 };
672
673 // -------------------------------------------------------------------
674
675 inline idx_t NodeColumns::levels() const {
676 return functionspace_->levels();
677 }
678
679 template <typename Value>
680 void NodeColumns::sum(const Field& field, Value& sum, idx_t& N) const {
681 functionspace_->sum(field, sum, N);
682 }
683
684 inline void NodeColumns::sumPerLevel(const Field& field, Field& sum, idx_t& N) const {
685 functionspace_->sumPerLevel(field, sum, N);
686 }
687
688 template <typename Value>
689 void NodeColumns::orderIndependentSum(const Field& field, Value& sum, idx_t& N) const {
690 functionspace_->orderIndependentSum(field, sum, N);
691 }
692
693 inline void NodeColumns::orderIndependentSumPerLevel(const Field& field, Field& sum, idx_t& N) const {
694 functionspace_->orderIndependentSumPerLevel(field, sum, N);
695 }
696
697 template <typename Value>
698 void NodeColumns::minimum(const Field& field, Value& minimum) const {
699 functionspace_->minimum(field, minimum);
700 }
701
702 template <typename Value>
703 void NodeColumns::maximum(const Field& field, Value& maximum) const {
704 functionspace_->maximum(field, maximum);
705 }
706
707 inline void NodeColumns::minimumPerLevel(const Field& field, Field& minimum) const {
708 return functionspace_->minimumPerLevel(field, minimum);
709 }
710
711 inline void NodeColumns::maximumPerLevel(const Field& field, Field& maximum) const {
712 functionspace_->maximumPerLevel(field, maximum);
713 }
714
715 template <typename Value>
716 void NodeColumns::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx) const {
717 functionspace_->minimumAndLocation(field, minimum, glb_idx);
718 }
719
720 template <typename Value>
721 void NodeColumns::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx) const {
722 functionspace_->maximumAndLocation(field, maximum, glb_idx);
723 }
724
725 template <typename Value>
726 void NodeColumns::minimumAndLocation(const Field& field, Value& minimum, gidx_t& glb_idx, idx_t& level) const {
727 functionspace_->minimumAndLocation(field, minimum, glb_idx, level);
728 }
729
730 template <typename Value>
731 void NodeColumns::maximumAndLocation(const Field& field, Value& maximum, gidx_t& glb_idx, idx_t& level) const {
732 functionspace_->maximumAndLocation(field, maximum, glb_idx, level);
733 }
734
735 template <typename Value>
736 void NodeColumns::minimumAndLocation(const Field& field, std::vector<Value>& minimum,
737 std::vector<gidx_t>& glb_idx) const {
738 functionspace_->minimumAndLocation(field, minimum, glb_idx);
739 }
740
741 template <typename Value>
742 void NodeColumns::maximumAndLocation(const Field& field, std::vector<Value>& maximum,
743 std::vector<gidx_t>& glb_idx) const {
744 functionspace_->maximumAndLocation(field, maximum, glb_idx);
745 }
746
747 template <typename Value>
748 void NodeColumns::minimumAndLocation(const Field& field, std::vector<Value>& minimum, std::vector<gidx_t>& glb_idx,
749 std::vector<idx_t>& level) const {
750 functionspace_->minimumAndLocation(field, minimum, glb_idx, level);
751 }
752
753 template <typename Value>
754 void NodeColumns::maximumAndLocation(const Field& field, std::vector<Value>& maximum, std::vector<gidx_t>& glb_idx,
755 std::vector<idx_t>& level) const {
756 functionspace_->maximumAndLocation(field, maximum, glb_idx, level);
757 }
758
759 inline void NodeColumns::minimumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const {
760 functionspace_->minimumAndLocationPerLevel(field, column, glb_idx);
761 }
762
763 inline void NodeColumns::maximumAndLocationPerLevel(const Field& field, Field& column, Field& glb_idx) const {
764 functionspace_->maximumAndLocationPerLevel(field, column, glb_idx);
765 }
766
767 template <typename Value>
768 void NodeColumns::mean(const Field& field, Value& mean, idx_t& N) const {
769 functionspace_->mean(field, mean, N);
770 }
771
772 inline void NodeColumns::meanPerLevel(const Field& field, Field& mean, idx_t& N) const {
773 functionspace_->meanPerLevel(field, mean, N);
774 }
775
776 template <typename Value>
777 void NodeColumns::meanAndStandardDeviation(const Field& field, Value& mean, Value& stddev, idx_t& N) const {
778 functionspace_->meanAndStandardDeviation(field, mean, stddev, N);
779 }
780
781 inline void NodeColumns::meanAndStandardDeviationPerLevel(const Field& field, Field& mean, Field& stddev,
782 idx_t& N) const {
783 functionspace_->meanAndStandardDeviationPerLevel(field, mean, stddev, N);
784 }
785
786 // -------------------------------------------------------------------
787
788 } // namespace functionspace
789 } // namespace atlas