PRISMS-PF Manual
Loading...
Searching...
No Matches
field_attributes.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2026 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#pragma once
5
6#include <deal.II/base/exceptions.h>
7
10
12
13#include <prismspf/config.h>
14
15#include <map>
16#include <string>
17#include <vector>
18
20
26{
31 std::string _name = "",
32 TensorRank _field_type = TensorRank::Scalar,
33 BoundaryConditionSet _boundary_conditions = BoundaryConditionSet(),
34 bool _is_nucleation_rate_variable = false,
35 std::vector<Types::Index> _nucleating_field_indices = std::vector<Types::Index>())
36 : name(std::move(_name))
37 , field_type(_field_type)
38 , boundary_conditions(std::move(_boundary_conditions))
39 , is_nucleation_rate_variable(_is_nucleation_rate_variable)
40 , nucleating_field_indices(std::move(_nucleating_field_indices))
41 {}
42
46 std::string name;
47
52
57
62
66 std::vector<Types::Index> nucleating_field_indices;
67};
68
72inline std::map<std::string, Types::Index>
73field_index_map(const std::vector<FieldAttributes> &fields)
74{
75 std::map<std::string, Types::Index> map;
76 for (unsigned int i = 0; i < fields.size(); ++i)
77 {
78 AssertThrow(map.find(fields[i].name) == map.end(),
79 dealii::ExcMessage(
80 "The names of the fields are not unique. This is not allowed."));
81 map[fields[i].name] = i;
82 }
83 return map;
84}
85
89inline std::map<std::string, FieldAttributes>
90field_map(const std::vector<FieldAttributes> &fields)
91{
92 std::map<std::string, FieldAttributes> map;
93 for (const FieldAttributes &field : fields)
94 {
95 AssertThrow(map.find(field.name) == map.end(),
96 dealii::ExcMessage(
97 "The names of the fields are not unique. This is not allowed."));
98 map[field.name] = field;
99 }
100 return map;
101}
102
103// TODO: Submit a PR/issue to dealii to make operator| constexpr.
104// constexpr EvalFlags values_and_gradients = EvalFlags::values |
105// EvalFlags::gradients;
106
107PRISMS_PF_END_NAMESPACE
std::map< std::string, Types::Index > field_index_map(const std::vector< FieldAttributes > &fields)
Make a map that maps field names to field indices.
Definition field_attributes.h:73
std::map< std::string, FieldAttributes > field_map(const std::vector< FieldAttributes > &fields)
Make a map that maps field names to field attributes.
Definition field_attributes.h:90
Definition conditional_ostreams.cc:20
Definition vectorized_operations.h:17
Definition constraint_parameters.h:73
Structure to hold the attributes of a field. This includes things like the name, rank,...
Definition field_attributes.h:26
TensorRank field_type
Field type (Scalar/Vector).
Definition field_attributes.h:51
std::vector< Types::Index > nucleating_field_indices
If this is a nucleation rate, the indices of the nucleating fields.
Definition field_attributes.h:66
FieldAttributes(std::string _name="", TensorRank _field_type=TensorRank::Scalar, BoundaryConditionSet _boundary_conditions=BoundaryConditionSet(), bool _is_nucleation_rate_variable=false, std::vector< Types::Index > _nucleating_field_indices=std::vector< Types::Index >())
Constructor.
Definition field_attributes.h:30
bool is_nucleation_rate_variable
Is a nucleation rate.
Definition field_attributes.h:61
BoundaryConditionSet boundary_conditions
Field type (Scalar/Vector).
Definition field_attributes.h:56
std::string name
Field name.
Definition field_attributes.h:46
TensorRank
Tensor rank of the field.
Definition type_enums.h:52
@ Scalar
Definition type_enums.h:54