Changed: Using switch statement instead of a static map and find in

DomainDecomposition::setupNodeNumbers. The map-initializers do not
compile in gcc 4.6 which I still use for debugging.
This commit is contained in:
Knut Morten Okstad 2016-10-03 05:26:14 +02:00
parent ff76b83c98
commit ff557f5f86

View File

@ -12,7 +12,6 @@
//============================================================================== //==============================================================================
#include "DomainDecomposition.h" #include "DomainDecomposition.h"
#include "ASMbase.h"
#include "ASMstruct.h" #include "ASMstruct.h"
#include "ASM2D.h" #include "ASM2D.h"
#include "ASM3D.h" #include "ASM3D.h"
@ -20,12 +19,10 @@
#include "ProcessAdm.h" #include "ProcessAdm.h"
#include "SAMpatch.h" #include "SAMpatch.h"
#include "SIMbase.h" #include "SIMbase.h"
#include "IFEM.h"
#include "Utilities.h" #include "Utilities.h"
#include "Vec3.h" #include "Vec3.h"
#include <cassert> #include "IFEM.h"
#include <numeric> #include <numeric>
#include <iostream>
//! \brief Iterator for matching nodes on edges/faces with a given orientation and index. //! \brief Iterator for matching nodes on edges/faces with a given orientation and index.
@ -302,39 +299,35 @@ void DomainDecomposition::setupNodeNumbers(int basis, IntVec& lNodes,
{ {
if (basis != 0) // specified base if (basis != 0) // specified base
cbasis = utl::getDigits(basis); cbasis = utl::getDigits(basis);
else if (dim == 0 || (dim == 1 && pch->getNoSpaceDim() == 3)) { else if (dim == 0 || (dim == 1 && pch->getNoSpaceDim() == 3))
// need to expand to all bases for corners and edges // need to expand to all bases for corners and edges
for (size_t b = 1; b <= pch->getNoBasis(); ++b) for (size_t b = 1; b <= pch->getNoBasis(); ++b)
cbasis.insert(b); cbasis.insert(b);
} else // directly add nodes, cbasis remains empty else // directly add nodes, cbasis remains empty
pch->getBoundaryNodes(lidx, lNodes); pch->getBoundaryNodes(lidx, lNodes);
const ASM2D* pch2D = dynamic_cast<const ASM2D*>(pch); const ASM2D* pch2D = dynamic_cast<const ASM2D*>(pch);
const ASM3D* pch3D = dynamic_cast<const ASM3D*>(pch); const ASM3D* pch3D = dynamic_cast<const ASM3D*>(pch);
for (auto& it2 : cbasis) { for (const int& it2 : cbasis)
if (dim == 0) { if (dim == 0) {
int node = 0; int node = 0;
if (pch2D) { if (pch2D)
static std::map<int, std::array<int,2>> vmap2D switch (lidx) {
{{1, {-1, -1}}, case 1: node = pch2D->getCorner(-1,-1, it2); break;
{2, { 1, -1}}, case 2: node = pch2D->getCorner( 1,-1, it2); break;
{3, {-1, 1}}, case 3: node = pch2D->getCorner(-1, 1, it2); break;
{4, { 1, 1}}}; case 4: node = pch2D->getCorner( 1, 1, it2); break;
auto itc = vmap2D.find(lidx); }
node = pch2D->getCorner(itc->second[0], itc->second[1], it2); else if (pch3D)
} else if (pch3D) { switch (lidx) {
static std::map<int, std::array<int,3>> vmap3D case 1: node = pch3D->getCorner(-1,-1,-1, it2); break;
{{1, {-1, -1, -1}}, case 2: node = pch3D->getCorner( 1,-1,-1, it2); break;
{2, { 1, -1, -1}}, case 3: node = pch3D->getCorner(-1, 1,-1, it2); break;
{3, {-1, 1, -1}}, case 4: node = pch3D->getCorner( 1, 1,-1, it2); break;
{4, { 1, 1, -1}}, case 5: node = pch3D->getCorner(-1,-1, 1, it2); break;
{5, {-1, -1, 1}}, case 6: node = pch3D->getCorner( 1,-1, 1, it2); break;
{6, { 1, -1, 1}}, case 7: node = pch3D->getCorner(-1, 1, 1, it2); break;
{7, {-1, 1, 1}}, case 8: node = pch3D->getCorner( 1, 1, 1, it2); break;
{8, { 1, 1, 1}}};
auto itc = vmap3D.find(lidx);
node = pch3D->getCorner(itc->second[0], itc->second[1],
itc->second[2], it2);
} }
lNodes.push_back(pch->getNodeID(node)); lNodes.push_back(pch->getNodeID(node));
} else if (dim == 1 && pch3D) { } else if (dim == 1 && pch3D) {
@ -343,7 +336,6 @@ void DomainDecomposition::setupNodeNumbers(int basis, IntVec& lNodes,
lNodes.push_back(pch->getNodeID(it)); lNodes.push_back(pch->getNodeID(it));
} else } else
pch->getBoundaryNodes(lidx, lNodes, it2); pch->getBoundaryNodes(lidx, lNodes, it2);
}
} }