From 916159832d4d1074fff2cbbd7f5f7610e496a920 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 12 Jul 2020 22:08:16 -0400 Subject: [PATCH] Fix GeneralDataStorage::get_[or_add_]object_with_name for ICC --- .../deal.II/algorithms/general_data_storage.h | 50 +++++++++++++ .../general_data_storage_01.output.intel | 75 +++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 tests/algorithms/general_data_storage_01.output.intel diff --git a/include/deal.II/algorithms/general_data_storage.h b/include/deal.II/algorithms/general_data_storage.h index bdff0a196f..9b59a0f9ad 100644 --- a/include/deal.II/algorithms/general_data_storage.h +++ b/include/deal.II/algorithms/general_data_storage.h @@ -248,6 +248,17 @@ public: Arg & argument, Args &... arguments); + /** + * Return a reference to the object with given name. If the object does + * not exist, then the input @p arguments will be used to construct an object + * of the given @p Type and a reference to this new object then be returned. + * + * Same as above for a single argument. + */ + template + Type & + get_or_add_object_with_name(const std::string &name, Arg &argument); + /** * Return a reference to the object with given name. If the object does * not exist, then the input @p arguments will be used to construct an object @@ -264,6 +275,17 @@ public: Arg && argument, Args &&... arguments); + /** + * Return a reference to the object with given name. If the object does + * not exist, then the input @p arguments will be used to construct an object + * of the given @p Type and a reference to this new object then be returned. + * + * Same as above for a single argument. + */ + template + Type & + get_or_add_object_with_name(const std::string &name, Arg &&argument); + /** * Same as above for default constructors. */ @@ -452,6 +474,20 @@ GeneralDataStorage::get_object_with_name(const std::string &name) const } + +template +Type & +GeneralDataStorage::get_or_add_object_with_name(const std::string &name, + Arg & argument) +{ + if (!stores_object_with_name(name)) + add_unique_copy(name, Type(argument)); + + return get_object_with_name(name); +} + + + template Type & GeneralDataStorage::get_or_add_object_with_name(const std::string &name, @@ -465,6 +501,20 @@ GeneralDataStorage::get_or_add_object_with_name(const std::string &name, } + +template +Type & +GeneralDataStorage::get_or_add_object_with_name(const std::string &name, + Arg && argument) +{ + if (!stores_object_with_name(name)) + add_unique_copy(name, Type(std::forward(argument))); + + return get_object_with_name(name); +} + + + template Type & GeneralDataStorage::get_or_add_object_with_name(const std::string &name, diff --git a/tests/algorithms/general_data_storage_01.output.intel b/tests/algorithms/general_data_storage_01.output.intel new file mode 100644 index 0000000000..9f73245519 --- /dev/null +++ b/tests/algorithms/general_data_storage_01.output.intel @@ -0,0 +1,75 @@ + +DEAL::Add by copy +DEAL::Size: 2 +DEAL::Add by reference +DEAL::Size: 2 +DEAL::Add or construct +DEAL::Size: 1 +DEAL::Merge +DEAL::Data pre-merge: +DEAL::value double +DEAL::Size: 1 +DEAL::Data 2 pre-merge: +DEAL::value double +DEAL::value_2 double +DEAL::Size: 2 +DEAL::Data post-merge: +DEAL::value double +DEAL::value_2 double +DEAL::Size: 2 +DEAL::Ambiguous construction +DEAL::Try to overwrite existing entry: Copy +DEAL:: +-------------------------------------------------------- +An error occurred in file in function + void dealii::GeneralDataStorage::add_unique_copy(const std::__cxx11::basic_string, std::allocator> &, const Type &) [with Type = double] +The violated condition was: + !stores_object_with_name(name) +Additional information: + An entry with the name value already exists. +-------------------------------------------------------- + +DEAL::Try to overwrite existing entry: Reference +DEAL:: +-------------------------------------------------------- +An error occurred in file in function + void dealii::GeneralDataStorage::add_unique_reference(const std::__cxx11::basic_string, std::allocator> &, Type &) [with Type = const double] +The violated condition was: + !stores_object_with_name(name) +Additional information: + An entry with the name value already exists. +-------------------------------------------------------- + +DEAL::Fetch non-existing entry +DEAL:: +-------------------------------------------------------- +An error occurred in file in function + Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string, std::allocator> &) [with Type = double] +The violated condition was: + stores_object_with_name(name) +Additional information: + No entry with the name value exists. +-------------------------------------------------------- + +DEAL::Access removed entry (reference) +DEAL:: +-------------------------------------------------------- +An error occurred in file in function + Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string, std::allocator> &) [with Type = double] +The violated condition was: + stores_object_with_name(name) +Additional information: + No entry with the name value exists. +-------------------------------------------------------- + +DEAL::Access removed entry (copy) +DEAL:: +-------------------------------------------------------- +An error occurred in file in function + Type &dealii::GeneralDataStorage::get_object_with_name(const std::__cxx11::basic_string, std::allocator> &) [with Type = double] +The violated condition was: + stores_object_with_name(name) +Additional information: + No entry with the name value exists. +-------------------------------------------------------- + -- 2.39.5