16#ifndef PECLET_CORE_FIELD_FIELD_SET_HPP
17#define PECLET_CORE_FIELD_FIELD_SET_HPP
22#include <unordered_map>
54 return recs_.at(
name);
61 return recs_.at(
name);
64 bool has(
const std::string&
name)
const {
return recs_.find(
name) != recs_.end(); }
67 auto it = recs_.find(
name);
68 if (
it == recs_.end())
69 throw std::out_of_range(
"FieldSet: no field named '" +
name +
"'");
73 auto it = recs_.find(
name);
74 if (
it == recs_.end())
75 throw std::out_of_range(
"FieldSet: no field named '" +
name +
"'");
79 std::size_t
size()
const {
return recs_.size(); }
82 std::vector<std::string>
names()
const {
83 std::vector<std::string>
out;
84 out.reserve(recs_.size());
85 for (
const auto&
kv : recs_)
86 out.push_back(
kv.first);
87 std::sort(
out.begin(),
out.end());
92 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...