1 #ifndef ABLATELIBRARY_FIELD_HPP
2 #define ABLATELIBRARY_FIELD_HPP
10 namespace ablate::domain {
12 enum class FieldLocation { SOL, AUX };
13 enum class FieldType { FVM, FEM };
15 struct FieldDescription;
18 const std::string name;
19 const PetscInt numberComponents;
20 const std::vector<std::string> components;
26 const PetscInt subId = PETSC_DEFAULT;
29 const PetscInt offset = PETSC_DEFAULT;
31 const enum FieldLocation location = FieldLocation::SOL;
34 const enum FieldType type;
37 const std::set<std::string> tags;
39 static Field FromFieldDescription(
const FieldDescription& fieldDescription, PetscInt
id, PetscInt subId = PETSC_DEFAULT, PetscInt offset = PETSC_DEFAULT);
41 [[nodiscard]]
Field CreateSubField(PetscInt subId, PetscInt offset)
const;
44 [[nodiscard]]
inline bool Tagged(std::string_view tag)
const {
45 return std::any_of(tags.begin(), tags.end(), [tag](
const auto& tagItem) { return tagItem == tag; });
53 [[nodiscard]]
Field Rename(std::string newName)
const;
60 [[nodiscard]]
inline std::size_t
ComponentIndex(std::string_view search)
const {
61 auto it = std::find_if(components.begin(), components.end(), [search](
const auto& component) { return component == search; });
64 if (it != components.end()) {
65 return std::distance(components.begin(), it);
67 throw std::invalid_argument(std::string(
"Cannot locate component ") + std::string(search) +
" in field " + name);
79 std::istream& operator>>(std::istream& is, FieldLocation& v);
80 std::istream& operator>>(std::istream& is, FieldType& v);
Definition: fieldDescription.hpp:20
Field Rename(std::string newName) const
Definition: field.cpp:53
std::size_t ComponentIndex(std::string_view search) const
Definition: field.hpp:60
std::size_t ComponentOffset(std::string_view search) const
Definition: field.hpp:76