3#if (COUPLING_MD_ERROR == COUPLING_MD_YES)
22 if constexpr (std::is_same_v<
unsigned int,
typename CellIndex<dim, traits...>::value_T>) {
27#if (COUPLING_MD_ERROR == COUPLING_MD_YES)
28 if (!IndexingService<dim>::getInstance().isInitialized()) {
29 throw std::runtime_error(std::string(
"coupling::indexing::convertToScalar: IndexingService not initialized! "));
31 for (
unsigned d = 0; d < dim; d++)
34 ss <<
"ERROR: Indexing: Cannot convert this vector index to scalar." << std::endl;
35 ss <<
"Faulty Index = " << index.get() << std::endl;
36 ss <<
"My rank = " << IndexingService<dim>::getInstance().getRank() << std::endl;
37 ss <<
"Index type = " << index.TNAME << std::endl;
38 throw std::runtime_error(ss.str());
42 unsigned int i{
static_cast<unsigned int>(index.get()[dim - 1])};
43 for (
int d = dim - 2; d > -1; d--) {
44 i = (
CellIndex<dim, traits...>::numberCellsInDomain[d]) * i +
static_cast<unsigned int>(index.get()[d]);
62template <
unsigned int dim, IndexTrait... traits> tarch::la::Vector<dim, int> convertToVector(
const CellIndex<dim, traits...>& index) {
63 if constexpr (std::is_same_v<tarch::la::Vector<dim, int>,
typename CellIndex<dim, traits...>::value_T>) {
69#if (COUPLING_MD_ERROR == COUPLING_MD_YES)
70 if (!IndexingService<dim>::getInstance().isInitialized()) {
71 throw std::runtime_error(std::string(
"coupling::indexing::convertToVector: IndexingService not initialized! "));
75 tarch::la::Vector<dim, int> i{0};
76 unsigned int i_sca{index.get()};
77 for (
int d = dim - 1; d > 0; d--) {
78 i[d] =
static_cast<int>(i_sca /
CellIndex<dim, traits...>::divisionFactor[d]);
Definition CellIndex.h:85
static tarch::la::Vector< dim, unsigned int > divisionFactor
Definition CellIndex.h:276
static tarch::la::Vector< dim, unsigned int > numberCellsInDomain
Definition CellIndex.h:264
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15