| 111 | } |
| 112 | |
| 113 | void FlagsTensorAdaptor::StoreData() |
| 114 | { |
| 115 | std::visit([this](auto pContainer) { |
| 116 | using container_type = BareType<decltype(*pContainer)>; |
| 117 | |
| 118 | if constexpr(IsInList<container_type, ModelPart::NodesContainerType, ModelPart::ConditionsContainerType, ModelPart::ElementsContainerType>) { |
| 119 | KRATOS_ERROR_IF_NOT(this->Size() == pContainer->size()) |
| 120 | << "Size mismatch [ Container size = " << pContainer->size() |
| 121 | << ", data span size = " << this->Size() << " ].\n"; |
| 122 | |
| 123 | auto span_itr = this->ViewData().data(); |
| 124 | |
| 125 | IndexPartition<IndexType>(pContainer->size()).for_each([this, span_itr, pContainer](const auto Index) { |
| 126 | const int value = *(span_itr + Index); |
| 127 | auto& r_entity = *(pContainer->begin() + Index); |
| 128 | switch (value) { |
| 129 | case 0: |
| 130 | case 1: |
| 131 | r_entity.Set(this->mFlags, value); |
| 132 | break; |
| 133 | case -1: |
| 134 | r_entity.Reset(this->mFlags); |
| 135 | break; |
| 136 | default: |
| 137 | KRATOS_ERROR << "Invalid flag status = " << value << " for " << ModelPart::Container<container_type>::GetEntityName() |
| 138 | << " with id " << r_entity.Id() << ". Flag tensor adaptor's internal storage should only have following values:" |
| 139 | << "\n\t -1 - The corresponding flag is not defined." |
| 140 | << "\n\t 0 - The corresponding flag is defined and false." |
| 141 | << "\n\t 1 - The corresponding flag is defined and true."; |
| 142 | break; |
| 143 | } |
| 144 | }); |
| 145 | } |
| 146 | }, this->GetContainer()); |
| 147 | } |
| 148 | |
| 149 | std::string FlagsTensorAdaptor::Info() const |
| 150 | { |