16#ifndef PECLET_CORE_FIELD_FIELD_SET_HPP
17#define PECLET_CORE_FIELD_FIELD_SET_HPP
22#include <unordered_map>
53 return recs_.at(
name);
60 return recs_.at(
name);
63 bool has(
const std::string&
name)
const {
return recs_.find(
name) != recs_.end(); }
66 auto it = recs_.find(
name);
67 if (
it == recs_.end())
68 throw std::out_of_range(
"FieldSet: no field named '" +
name +
"'");
72 auto it = recs_.find(
name);
73 if (
it == recs_.end())
74 throw std::out_of_range(
"FieldSet: no field named '" +
name +
"'");
78 std::size_t
size()
const {
return recs_.size(); }
81 std::vector<std::string>
names()
const {
82 std::vector<std::string>
out;
83 out.reserve(recs_.size());
84 for (
const auto&
kv : recs_)
85 out.push_back(
kv.first);
86 std::sort(
out.begin(),
out.end());
91 std::unordered_map<std::string, FieldRec> recs_;
Name → FieldRec directory.
std::vector< std::string > names() const
Field names in a deterministic (sorted) order — the collective-safe enumeration.
bool has(const std::string &name) const
FieldRec & add(const std::string &name, std::size_t n, int ghost, Centering c=Centering::Cell)
Allocate a fresh zero-initialised device buffer of n elements and register it.
const FieldRec & at(const std::string &name) const
FieldRec & adopt(const std::string &name, View< double > v, int ghost, Centering c=Centering::Cell)
Register an existing buffer under name without taking ownership of its allocation.
FieldRec & at(const std::string &name)
Centering
Where a field's samples sit relative to a cell.
Kokkos::View< T *, MemSpace > View
1D device array.
One registered field: its flat x-fastest device buffer plus the metadata a consumer needs to exchange...