Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::NekOptimize::GlobalOptParam Class Reference

Processes global optimisation parameters from a session. More...

#include <GlobalOptimizationParameters.h>

Public Member Functions

 GlobalOptParam (const int nel)
 Default constructor requires nel be given.
 GlobalOptParam (const LibUtilities::SessionReaderSharedPtr &pSession, const int dim, const Array< OneD, const int > &NumShapeElements)
 Read optimisation parameters from a given file.
bool DoGlobalMatOp (const StdRegions::MatrixType i) const
 For a given matrix type, determines if the operation should be done globally.
const Array< OneD, const bool > & DoBlockMatOp (const StdRegions::MatrixType i) const
 For a given matrix type, determines if the operation should be done with a block matrix.
const Array< OneD, const
LibUtilities::ShapeType > & 
GetShapeList () const
const Array< OneD, const int > & GetShapeNumElements () const

Private Member Functions

 GlobalOptParam ()
 Default constructor should not be called.

Private Attributes

Array< OneD, bool > m_doGlobalMatOp
 Flags indicating if different matrices should be evaluated globally.
Array< OneD, Array< OneD, bool > > m_doBlockMatOp
 Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.
Array< OneD,
LibUtilities::ShapeType
m_shapeList
 A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for the block matrices.
Array< OneD, const int > m_shapeNumElements
 A list of number of elements contained within each shape type.

Detailed Description

Processes global optimisation parameters from a session.

Global optimisation parameters determines how the various matrices in the spectral/hp element formulation are evaluated. For details see the page on optimisation Optimisation.

Definition at line 76 of file GlobalOptimizationParameters.h.

Constructor & Destructor Documentation

Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( const int  nel)

Default constructor requires nel be given.

No global optimisation parameters present.

Definition at line 57 of file GlobalOptimizationParameters.cpp.

References m_doBlockMatOp, and Nektar::NekOptimize::SIZE_OptimizeOperationType.

:
{
Array<OneD, bool> set_false(1,false);
m_doBlockMatOp = Array<OneD, Array<OneD, bool > >
}
Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( const LibUtilities::SessionReaderSharedPtr pSession,
const int  dim,
const Array< OneD, const int > &  NumShapeElements 
)

Read optimisation parameters from a given file.

Read global optimisation parameters from a file and set up flags.

Parameters
fileNameFile to read parameters from.

Definition at line 71 of file GlobalOptimizationParameters.cpp.

References ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, m_doBlockMatOp, m_doGlobalMatOp, m_shapeList, m_shapeNumElements, Nektar::NekOptimize::OptimizationOperationTypeMap, and Nektar::NekOptimize::SIZE_OptimizeOperationType.

:
{
int i;
int numShapes = 0;
TiXmlDocument& doc = pSession->GetDocument();
m_shapeNumElements = NumShapeElements;
switch (dim)
{
case 1:
numShapes = 1;
ASSERTL0(false,"Needs setting up for dimension 1");
break;
case 2:
numShapes = 2;
m_shapeList = Array<OneD, LibUtilities::ShapeType>(numShapes);
m_shapeList[1] = LibUtilities::eQuadrilateral;
break;
case 3:
numShapes = 4;
m_shapeList = Array<OneD, LibUtilities::ShapeType>(numShapes);
m_shapeList[0] = LibUtilities::eTetrahedron;
m_shapeList[1] = LibUtilities::ePyramid;
m_shapeList[2] = LibUtilities::ePrism;
m_shapeList[3] = LibUtilities::eHexahedron;
break;
}
m_doBlockMatOp = Array<OneD, Array<OneD,bool> > (SIZE_OptimizeOperationType);
for(i = 0; i < SIZE_OptimizeOperationType; ++i)
{
m_doBlockMatOp[i] = Array<OneD, bool> (numShapes,false);
}
TiXmlHandle docHandle(&doc);
TiXmlElement* master
= docHandle.FirstChildElement("NEKTAR").Element();
ASSERTL0(master , "Unable to find NEKTAR tag in file.");
TiXmlElement* paramList
= docHandle.FirstChildElement("NEKTAR")
.FirstChildElement("GLOBALOPTIMIZATIONPARAMETERS")
.Element();
// If no global optimisation parameters set, we're done
if (!paramList)
{
return;
}
// Check if there is a reference an external file and if so, load it
TiXmlElement* source
= paramList->FirstChildElement("SOURCE");
if (source)
{
std::string sourceFile = source->Attribute("FILE");
TiXmlDocument docSource;
bool loadOkay = docSource.LoadFile(sourceFile);
ASSERTL0(loadOkay, (std::string("Unable to load file: ") +
sourceFile).c_str());
TiXmlHandle docSourceHandle(&docSource);
master = docHandle.FirstChildElement("NEKTAR").Element();
ASSERTL0(master , "Unable to find NEKTAR tag in file.");
paramList = docHandle.FirstChildElement("NEKTAR")
.FirstChildElement("GLOBALOPTIMIZATIONPARAMETERS")
.Element();
ASSERTL0(paramList, std::string("Specified source file '"
+ sourceFile + "' is missing an "
"GLOBALOPTIMIZATIONPARAMETERS tag.").c_str());
}
int n;
for(n = 0; n < SIZE_OptimizeOperationType; n++)
{
TiXmlElement* operationType = paramList->FirstChildElement(
if(operationType)
{
TiXmlElement* arrayElement = operationType
->FirstChildElement("DO_GLOBAL_MAT_OP");
if(arrayElement)
{
int value;
int err;
err = arrayElement->QueryIntAttribute("VALUE", &value);
ASSERTL0(err == TIXML_SUCCESS,(
std::string("Unable to read DO_GLOBAL_MAT_OP "
"attribute VALUE for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")
));
m_doGlobalMatOp[n] = (bool) value;
}
arrayElement
= operationType->FirstChildElement("DO_BLOCK_MAT_OP");
if(arrayElement)
{
int value;
int err;
switch (dim)
{
case 1:
break;
case 2:
err = arrayElement->QueryIntAttribute("TRI", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute TRI for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][0] = (bool) value;
err = arrayElement->QueryIntAttribute("QUAD", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute QUAD for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][1] = (bool) value;
break;
case 3:
err = arrayElement->QueryIntAttribute("TET", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute TET for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][0] = (bool) value;
err = arrayElement->QueryIntAttribute("PYR", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute PYR for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][1] = (bool) value;
err = arrayElement->QueryIntAttribute("PRISM", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute PRISM for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][2] = (bool) value;
err = arrayElement->QueryIntAttribute("HEX", &value);
ASSERTL0(err == TIXML_SUCCESS, (
std::string("Unable to read DO_BLOCK_MAT_OP "
"attribute HEX for ")
+ std::string(OptimizationOperationTypeMap[n])
+ std::string(".")));
m_doBlockMatOp[n][3] = (bool) value;
break;
break;
}
}
}
}
}
Nektar::NekOptimize::GlobalOptParam::GlobalOptParam ( )
inlineprivate

Default constructor should not be called.

Definition at line 101 of file GlobalOptimizationParameters.h.

{};

Member Function Documentation

const Array< OneD, const bool > & Nektar::NekOptimize::GlobalOptParam::DoBlockMatOp ( const StdRegions::MatrixType  i) const
inline

For a given matrix type, determines if the operation should be done with a block matrix.

Determines the elemental optimisation type enum, given the MatrixType and returns the corresponding entry in the table.

Parameters
iType of matrix.
Returns
True if this type of matrix should be evaluated in block form.

Definition at line 186 of file GlobalOptimizationParameters.h.

References ASSERTL0, Nektar::NekOptimize::eBwdTrans, Nektar::StdRegions::eBwdTrans, Nektar::StdRegions::eHelmholtz, Nektar::NekOptimize::eHelmholtzMatrixOp, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::NekOptimize::eHybridDGHelmBndLamMatrixOp, Nektar::NekOptimize::eIProductWRTBase, Nektar::StdRegions::eIProductWRTBase, Nektar::StdRegions::eLaplacian, Nektar::NekOptimize::eLaplacianMatrixOp, Nektar::StdRegions::eMass, Nektar::NekOptimize::eMassMatrixOp, and m_doBlockMatOp.

{
switch(i)
{
{
type = eBwdTrans;
}
break;
{
}
break;
{
type = eMassMatrixOp;
}
break;
{
}
break;
{
}
break;
{
}
break;
default:
{
ASSERTL0(false,"Optimisation suite not set up for this type"
" of matrix");
}
}
return m_doBlockMatOp[type];
}
bool Nektar::NekOptimize::GlobalOptParam::DoGlobalMatOp ( const StdRegions::MatrixType  i) const
inline

For a given matrix type, determines if the operation should be done globally.

Determines the elemental optimisation type enum, given the MatrixType and returns the corresponding entry in the table.

Parameters
iType of matrix.
Returns
True if this type of matrix should be evaluated globally.

Definition at line 135 of file GlobalOptimizationParameters.h.

References ASSERTL0, Nektar::NekOptimize::eBwdTrans, Nektar::StdRegions::eBwdTrans, Nektar::StdRegions::eHelmholtz, Nektar::NekOptimize::eHelmholtzMatrixOp, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::NekOptimize::eHybridDGHelmBndLamMatrixOp, Nektar::NekOptimize::eIProductWRTBase, Nektar::StdRegions::eIProductWRTBase, Nektar::StdRegions::eLaplacian, Nektar::NekOptimize::eLaplacianMatrixOp, Nektar::StdRegions::eMass, Nektar::NekOptimize::eMassMatrixOp, and m_doGlobalMatOp.

{
switch(i)
{
{
type = eBwdTrans;
}
break;
{
}
break;
{
type = eMassMatrixOp;
}
break;
{
}
break;
{
}
break;
{
}
break;
default:
{
ASSERTL0(false,"Optimisation suite not set up for this type"
" of matrix");
}
}
return m_doGlobalMatOp[type];
}
const Array< OneD, const LibUtilities::ShapeType > & Nektar::NekOptimize::GlobalOptParam::GetShapeList ( ) const
inline

Definition at line 236 of file GlobalOptimizationParameters.h.

References m_shapeList.

{
return m_shapeList;
}
const Array< OneD, const int > & Nektar::NekOptimize::GlobalOptParam::GetShapeNumElements ( ) const
inline

Definition at line 231 of file GlobalOptimizationParameters.h.

References m_shapeNumElements.

{
}

Member Data Documentation

Array<OneD, Array<OneD,bool> > Nektar::NekOptimize::GlobalOptParam::m_doBlockMatOp
private

Array of Flags of first dimension of the number of shapes within the space dimension, indicating if different matrices should be evaluated using a block matrix.

Definition at line 111 of file GlobalOptimizationParameters.h.

Referenced by DoBlockMatOp(), and GlobalOptParam().

Array<OneD,bool> Nektar::NekOptimize::GlobalOptParam::m_doGlobalMatOp
private

Flags indicating if different matrices should be evaluated globally.

Definition at line 101 of file GlobalOptimizationParameters.h.

Referenced by DoGlobalMatOp(), and GlobalOptParam().

Array<OneD, LibUtilities::ShapeType> Nektar::NekOptimize::GlobalOptParam::m_shapeList
private

A list ExpansionTypes indicating the order in which shapes are listed to call the appropriate key for the block matrices.

Definition at line 116 of file GlobalOptimizationParameters.h.

Referenced by GetShapeList(), and GlobalOptParam().

Array<OneD, const int> Nektar::NekOptimize::GlobalOptParam::m_shapeNumElements
private

A list of number of elements contained within each shape type.

Definition at line 119 of file GlobalOptimizationParameters.h.

Referenced by GetShapeNumElements(), and GlobalOptParam().