Debian Codegraph @

src/atlas/field/Halo.cc

raw
1 /*
2 * (C) Copyright 2025 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/library/config.h"
12 #include "atlas/util/Metadata.h"
13 #include "atlas/field/detail/FieldImpl.h"
14 #include "atlas/functionspace/FunctionSpace.h"
15
16 namespace atlas {
17 namespace field {
18
19 Halo::Halo(field::FieldImpl& f) :
20 functionspace::HaloDescription(f.functionspace().halo_description()),
21 field_(f) {
22 }
23
24 bool Halo::updated() const {
25 return field_.metadata().getBool("halo_updated", false);
26 }
27
28 void Halo::updated(bool v) {
29 field_.metadata().set("halo_updated", v);
30 }
31
32 void Halo::update() {
33 field_.haloExchange();
34 }
35
36 void Halo::update(const eckit::Parametrisation& config) {
37 std::string execution_space{"host"};
38 config.get("execution_space", execution_space);
39 bool on_device = (execution_space == "device");
40 field_.haloExchange(on_device);
41 }
42
43 bool Halo::appended() const {
44 auto size = field_.functionspace().size();
45 return contiguous() && (end() == size);
46 }
47
48 // ------------------------------------------------------------------
49
50 } // namespace field
51 } // namespace atlas