Skip to content

Commit

Permalink
Make the advected field type array non-const (#644)
Browse files Browse the repository at this point in the history
# Make the advected field type array non-const
## Fixes #643 

The DynamicsKernel::fieldType map is decalred const. That's not very
useful for a member variable that should be read and written.

Should also fix the deleted constructor problem for the Intel compiler.
  • Loading branch information
timspainNERSC authored Aug 23, 2024
2 parents f30b10b + 0ec2840 commit 3c9863e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dynamics/src/include/DynamicsKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ template <int DGadvection, int DGstress> class DynamicsKernel {
} else {
// All other fields get shoved in a (labelled) bucket
DGModelArray::ma2dg(data, advectedFields[name]);
// …and have their type annotated
fieldType[name] = data.getType();
}
}

Expand Down Expand Up @@ -140,6 +142,7 @@ template <int DGadvection, int DGstress> class DynamicsKernel {
data.resize();
return DGModelArray::dg2ma(cice, data);
} else {
// Use the stored array type to ensure the returned data has the correct type
ModelArray::Type type = fieldType.at(name);
ModelArray data(type);
data.resize();
Expand Down Expand Up @@ -214,7 +217,7 @@ template <int DGadvection, int DGstress> class DynamicsKernel {
std::unordered_map<std::string, DGVector<DGadvection>> advectedFields;

// A map from field name to the type of
const std::unordered_map<std::string, ModelArray::Type> fieldType;
std::unordered_map<std::string, ModelArray::Type> fieldType;
};

}
Expand Down

0 comments on commit 3c9863e

Please # to comment.