Commit 83e294f0 authored by Luca Bertagna's avatar Luca Bertagna
Browse files

Using a "switch" statement rather than "if...else if..." in the setSpace method

Note: if P1Bubble are selected, the code will use P2.
parent ece3b8e0
......@@ -1635,138 +1635,147 @@ template <typename MeshType, typename MapType>
inline void
FESpace<MeshType, MapType>::setSpace ( const std::string& space, UInt dimension )
{
if (dimension == 1)
switch (dimension)
{
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feSegP0;
M_Qr = &quadRuleSeg1pt;
M_bdQr = &quadRuleNode1pt;
case P1 :
M_refFE = &feSegP1;
M_Qr = &quadRuleSeg2pt;
M_bdQr = &quadRuleNode1pt;
break;
case P1_HIGH :
M_refFE = &feSegP1;
M_Qr = &quadRuleSeg3pt;
M_bdQr = &quadRuleNode1pt;
break;
case P1Bubble :
case P2 :
M_refFE = &feSegP2;
M_Qr = &quadRuleSeg3pt;
M_bdQr = &quadRuleNode1pt;
break;
case P2_HIGH :
M_refFE = &feSegP2;
M_Qr = &quadRuleSeg4pt;
M_bdQr = &quadRuleNode1pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
}
else if (dimension == 2)
{
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feTriaP0;
M_Qr = &quadRuleTria3pt;
M_bdQr = &quadRuleSeg2pt;
case P1 :
M_refFE = &feTriaP1;
M_Qr = &quadRuleTria3pt;
M_bdQr = &quadRuleSeg2pt;
break;
case P1_HIGH :
M_refFE = &feTriaP1;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg3pt;
break;
case P1Bubble :
M_refFE = &feTriaP1bubble;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg2pt;
break;
case P2 :
M_refFE = &feTriaP2;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg3pt;
break;
case P2_HIGH :
M_refFE = &feTriaP2;
M_Qr = &quadRuleTria7pt;
M_bdQr = &quadRuleSeg3pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
}
else
{
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feTetraP0;
M_Qr = &quadRuleTetra4pt;
M_bdQr = &quadRuleTria3pt;
break;
case P1 :
M_refFE = &feTetraP1;
M_Qr = &quadRuleTetra4pt;
M_bdQr = &quadRuleTria3pt;
break;
case P1_HIGH :
M_refFE = &feTetraP1;
M_Qr = &quadRuleTetra15pt;
M_bdQr = &quadRuleTria4pt;
break;
case P1Bubble :
M_refFE = &feTetraP1bubble;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria3pt;
break;
case P2 :
M_refFE = &feTetraP2;
M_Qr = &quadRuleTetra15pt;
M_bdQr = &quadRuleTria4pt;
break;
case P2_HIGH :
M_refFE = &feTetraP2;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria4pt;
break;
case P2Bubble :
M_refFE = &feTetraP2tilde;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria4pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
// 1D case
case 1:
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feSegP0;
M_Qr = &quadRuleSeg1pt;
M_bdQr = &quadRuleNode1pt;
case P1 :
M_refFE = &feSegP1;
M_Qr = &quadRuleSeg2pt;
M_bdQr = &quadRuleNode1pt;
break;
case P1_HIGH :
M_refFE = &feSegP1;
M_Qr = &quadRuleSeg3pt;
M_bdQr = &quadRuleNode1pt;
break;
// In 1D, P1Bubble are "somehow" equivalent to P2, so just use those (same pattern, same dimension of the system).
case P1Bubble :
case P2 :
M_refFE = &feSegP2;
M_Qr = &quadRuleSeg3pt;
M_bdQr = &quadRuleNode1pt;
break;
case P2_HIGH :
M_refFE = &feSegP2;
M_Qr = &quadRuleSeg4pt;
M_bdQr = &quadRuleNode1pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
break;
// 2D case
case 2:
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feTriaP0;
M_Qr = &quadRuleTria3pt;
M_bdQr = &quadRuleSeg2pt;
case P1 :
M_refFE = &feTriaP1;
M_Qr = &quadRuleTria3pt;
M_bdQr = &quadRuleSeg2pt;
break;
case P1_HIGH :
M_refFE = &feTriaP1;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg3pt;
break;
case P1Bubble :
M_refFE = &feTriaP1bubble;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg2pt;
break;
case P2 :
M_refFE = &feTriaP2;
M_Qr = &quadRuleTria6pt;
M_bdQr = &quadRuleSeg3pt;
break;
case P2_HIGH :
M_refFE = &feTriaP2;
M_Qr = &quadRuleTria7pt;
M_bdQr = &quadRuleSeg3pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
break;
// 3D case
case 3:
switch ( M_spaceMap[space] )
{
case P0 :
M_refFE = &feTetraP0;
M_Qr = &quadRuleTetra4pt;
M_bdQr = &quadRuleTria3pt;
break;
case P1 :
M_refFE = &feTetraP1;
M_Qr = &quadRuleTetra4pt;
M_bdQr = &quadRuleTria3pt;
break;
case P1_HIGH :
M_refFE = &feTetraP1;
M_Qr = &quadRuleTetra15pt;
M_bdQr = &quadRuleTria4pt;
break;
case P1Bubble :
M_refFE = &feTetraP1bubble;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria3pt;
break;
case P2 :
M_refFE = &feTetraP2;
M_Qr = &quadRuleTetra15pt;
M_bdQr = &quadRuleTria4pt;
break;
case P2_HIGH :
M_refFE = &feTetraP2;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria4pt;
break;
case P2Bubble :
M_refFE = &feTetraP2tilde;
M_Qr = &quadRuleTetra64pt;
M_bdQr = &quadRuleTria4pt;
break;
default :
std::cout << "!!! WARNING: Space " << space << "not implemented for " << dimension << "D FESpaces!" << std::endl;
break;
}
break;
// Other dimensions not supported
default:
ERROR_MSG("Error! This dimension is not supported by LifeV.\n");
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment