6 #include "includes/global_variables.h"
7 #include "includes/kratos_export_api.h"
8 #include "includes/model_part.h"
9 #include "utilities/model_part_utils.h"
26 template <
class TEntityProxy>
30 using UnqualifiedContainer = std::conditional_t<
31 std::is_same_v<typename TEntityProxy::UnqualifiedEntity,Node>,
32 ModelPart::NodesContainerType,
34 std::is_same_v<typename TEntityProxy::UnqualifiedEntity,Element>,
35 ModelPart::ElementsContainerType,
37 std::is_same_v<typename TEntityProxy::UnqualifiedEntity,Condition>,
38 ModelPart::ConditionsContainerType,
44 constexpr
static bool IsMutable = TEntityProxy::IsMutable;
46 using WrappedIterator = std::conditional_t<IsMutable,
47 typename UnqualifiedContainer::iterator,
48 typename UnqualifiedContainer::const_iterator>;
50 template <
bool TMutable>
54 using Wrapped = std::conditional_t<TMutable,
55 typename UnqualifiedContainer::iterator,
56 typename UnqualifiedContainer::const_iterator>;
61 using pointer = std::conditional_t<TMutable,
65 using reference = std::conditional_t<TMutable,
69 using difference_type = std::ptrdiff_t;
71 using iterator_category = std::random_access_iterator_tag;
73 Iterator() noexcept =
default;
75 Iterator(Wrapped It) noexcept : mWrapped(It) {}
79 Iterator& operator++() noexcept {++mWrapped;
return *
this;}
81 Iterator operator++(
int) noexcept {Iterator copy(mWrapped); ++mWrapped;
return copy;}
83 Iterator& operator--() noexcept {--mWrapped;
return *
this;}
85 Iterator operator--(
int) noexcept {Iterator copy(mWrapped); --mWrapped;
return copy;}
87 Iterator& operator+=(difference_type Rhs) noexcept {mWrapped += Rhs;
return *
this;}
89 Iterator& operator-=(difference_type Rhs) noexcept {mWrapped -= Rhs;
return *
this;}
91 Iterator operator+(difference_type Rhs)
const noexcept {Iterator copy(mWrapped); copy += Rhs;
return copy;}
93 Iterator operator-(difference_type Rhs)
const noexcept {Iterator copy(mWrapped); copy -= Rhs;
return copy;}
95 difference_type operator-(Iterator Rhs)
const noexcept {
return mWrapped - Rhs.mWrapped;}
97 bool operator==(Iterator Rhs)
const noexcept {
return mWrapped == Rhs.mWrapped;}
99 bool operator!=(Iterator Rhs)
const noexcept {
return mWrapped != Rhs.mWrapped;}
101 bool operator<(Iterator Rhs)
const noexcept {
return mWrapped < Rhs.mWrapped;}
103 bool operator>(Iterator Rhs)
const noexcept {
return mWrapped > Rhs.mWrapped;}
105 bool operator<=(Iterator Rhs)
const noexcept {
return mWrapped <= Rhs.mWrapped;}
107 bool operator>=(Iterator Rhs)
const noexcept {
return mWrapped >= Rhs.mWrapped;}
138 bool empty() const noexcept {
return this->size() == 0;}
153 WrappedIterator mBegin, mEnd;
158 #define WRAPP_DEFINE_CONTAINER_PROXY_FACTORY(TLocation) \
161 inline auto MakeProxy<TLocation,ModelPart>(const ModelPart& rModelPart) \
163 const auto& r_container = ModelPartUtils::GetContainer<TLocation>(rModelPart); \
164 return ContainerProxy<EntityProxy<TLocation,false>>(r_container.begin(), \
165 r_container.end()); \
169 inline auto MakeProxy<TLocation,ModelPart>(ModelPart& rModelPart) \
171 auto& r_container = ModelPartUtils::GetContainer<TLocation>(rModelPart); \
172 return ContainerProxy<EntityProxy<TLocation,true>>(r_container.begin(), \
173 r_container.end()); \
184 #undef WRAPP_DEFINE_CONTAINER_PROXY_FACTORY
#define WRAPP_DEFINE_CONTAINER_PROXY_FACTORY(TLocation)
Definition: ContainerProxy.hpp:158
A view with a uniform interface for ModelPart::NodesContainerType, ModelPart::ElementsContainerType,...
Definition: ContainerProxy.hpp:28
size_type size() const noexcept
Definition: ContainerProxy.hpp:136
const_iterator::value_type at(size_type Index) const noexcept
Definition: ContainerProxy.hpp:132
const_iterator begin() const noexcept
Definition: ContainerProxy.hpp:142
bool empty() const noexcept
Definition: ContainerProxy.hpp:138
Iterator< IsMutable > iterator
Definition: ContainerProxy.hpp:113
iterator::value_type operator[](size_type Index) noexcept
Definition: ContainerProxy.hpp:130
const_iterator end() const noexcept
Definition: ContainerProxy.hpp:148
iterator begin() noexcept
Definition: ContainerProxy.hpp:144
const_iterator::value_type operator[](size_type Index) const noexcept
Definition: ContainerProxy.hpp:128
const_iterator cend() const noexcept
Definition: ContainerProxy.hpp:146
Iterator< false > const_iterator
Definition: ContainerProxy.hpp:115
iterator::value_type at(size_type Index) noexcept
Definition: ContainerProxy.hpp:134
typename iterator::value_type value_type
Definition: ContainerProxy.hpp:119
const_iterator cbegin() const noexcept
Definition: ContainerProxy.hpp:140
std::size_t size_type
Definition: ContainerProxy.hpp:117
ContainerProxy() noexcept=default
iterator end() noexcept
Definition: ContainerProxy.hpp:150
Wrapper class providing a uniform interface for historical/non-historical Node, Element,...
Definition: EntityProxy.hpp:48
Definition: MPIUtils.hpp:9