Commit ad6e7524 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Merge branch 'master' into tidy/incns

Conflicts:
	solvers/IncNavierStokesSolver/EquationSystems/IncNavierStokes.h
	solvers/IncNavierStokesSolver/EquationSystems/VelocityCorrectionScheme.cpp
parents 965c0d55 773c9de3
......@@ -95,6 +95,7 @@ INPUT = ./ \
../../../library/SpatialDomains/ \
../../../library/LocalRegions/ \
../../../library/MultiRegions/ \
../../../library/SolverUtils/ \
../../../solvers/ \
../../../utilities/
INPUT_ENCODING = UTF-8
......
......@@ -38,6 +38,8 @@
#include <LibUtilities/BasicUtils/VmathArray.hpp>
using namespace std;
namespace DBUtils
{
using namespace Nektar;
......@@ -62,7 +64,7 @@ namespace DBUtils
{
ASSERTL1(stop <= in.num_elements(), "Stop value is outside array range ");
for(i = start; i < in.num_elements(); ++i)
for(i = start; i < stop; ++i)
{
cout << in[i] << endl;
}
......@@ -158,7 +160,7 @@ namespace DBUtils
const int n,
Array<OneD, const T> &in,
std::ostream &out,
MultiRegions::AssemblyMapSharedPtr &map)
MultiRegions::AssemblyMapCGSharedPtr &map)
{
Array<OneD, NekDouble> vExchange(1);
Array<OneD, int> m_map = map->GetGlobalToUniversalMapUnique();
......
......@@ -66,7 +66,7 @@ namespace Nektar
m_numFields(0),
m_fieldNameToId(),
m_comm(pSession->GetComm()),
m_weightingRequired(true)
m_weightingRequired(false)
{
ReadConditions(pSession);
ReadGeometry(pSession);
......@@ -237,6 +237,19 @@ namespace Nektar
// Read mesh vertices
vSubElement = pSession->GetElement("Nektar/Geometry/Vertex");
// Retrieve any VERTEX attributes specifying mesh transforms
std::string attr[] = {"XSCALE", "YSCALE", "ZSCALE",
"XMOVE", "YMOVE", "ZMOVE" };
for (i = 0; i < 6; ++i)
{
const char *val = vSubElement->Attribute(attr[i].c_str());
if (val)
{
m_vertexAttributes[attr[i]] = std::string(val);
}
}
x = vSubElement->FirstChildElement();
i = 0;
while(x)
......@@ -452,9 +465,9 @@ namespace Nektar
if (solverPropertyUpper == "WEIGHTPARTITIONS")
{
if (propertyValueUpper == "UNIFORM")
if (propertyValueUpper != "UNIFORM")
{
m_weightingRequired = false;
m_weightingRequired = true;
}
return;
}
......@@ -595,10 +608,12 @@ namespace Nektar
{
int acnt = 0;
int vcnt = 0;
int nWeight = m_weightingRequired ? 2*nGraphVerts*m_numFields
: nGraphVerts;
BoostAdjacencyIterator adjvertit, adjvertit_end;
Array<OneD, int> xadj(nGraphVerts+1,0);
Array<OneD, int> adjncy(2*nGraphEdges);
Array<OneD, int> vwgt(2*nGraphVerts*m_numFields, 1);
Array<OneD, int> vwgt(nWeight, 1);
Array<OneD, int> vsize(nGraphVerts, 1);
for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
vertit != vertit_end;
......@@ -621,6 +636,10 @@ namespace Nektar
vwgt[pGraph[*vertit].id * m_numFields + i] = pGraph[*vertit].weight[i];
}
}
else
{
vwgt[pGraph[*vertit].id] = 1;
}
}
// Call Metis and partition graph
......@@ -635,7 +654,7 @@ namespace Nektar
if(m_comm->GetColumnComm()->GetRank() == 0)
{
// Attempt partitioning using METIS.
int ncon = 2*m_numFields;
int ncon = m_weightingRequired ? 2*m_numFields : 1;
Metis::PartGraphVKway(nGraphVerts, ncon, xadj, adjncy, vwgt, vsize, npart, vol, part);
// Check METIS produced a valid partition and fix if not.
CheckPartitions(part);
......@@ -754,6 +773,7 @@ namespace Nektar
std::map<int, MeshVertex> vVertices;
std::map<int, MeshEntity>::iterator vIt;
std::map<int, MeshVertex>::iterator vVertIt;
std::map<std::string, std::string>::iterator vAttrIt;
// Populate lists of elements, edges and vertices required.
for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
......@@ -822,6 +842,14 @@ namespace Nektar
vVertex->LinkEndChild(x);
}
// Apply transformation attributes to VERTEX section
for (vAttrIt = m_vertexAttributes.begin();
vAttrIt != m_vertexAttributes.end();
++ vAttrIt)
{
vVertex->SetAttribute(vAttrIt->first, vAttrIt->second);
}
if (m_dim >= 2)
{
for (vIt = vEdges.begin(); vIt != vEdges.end(); vIt++)
......
......@@ -184,6 +184,7 @@ namespace Nektar
std::map<MeshCurvedKey, MeshCurved> m_meshCurved;
std::map<int, MeshEntity> m_meshComposites;
std::vector<unsigned int> m_domain;
std::map<std::string, std::string> m_vertexAttributes;
// hierarchial mapping: composite id -> field name -> integer list
// of directional nummodes described by expansion type clause.
......
......@@ -129,6 +129,17 @@ namespace Nektar
SolverInfoMap SessionReader::m_solverInfoDefaults;
/**
* List of values for GlobalSysSoln parameters to be used to override
* details given in SolverInfo
*
* This list is populated by ReadGlobalSysSoln if the
* GLOBALSYSSOLNINFO section is defined in the input file.
* This List allows for details to define for the Global Sys
* solver for each variable.
*/
GloSysSolnInfoList SessionReader::m_gloSysSolnList;
/**
* Lists the possible command-line argument which can be specified for
* this executable.
......@@ -664,6 +675,50 @@ namespace Nektar
}
/**
*
*/
bool SessionReader::DefinesGlobalSysSolnInfo(const std::string &pVariable,
const std::string &pProperty) const
{
GloSysSolnInfoList::const_iterator iter = m_gloSysSolnList.find(pVariable);
if(iter == m_gloSysSolnList.end())
{
return false;
}
std::string vProperty = boost::to_upper_copy(pProperty);
GloSysInfoMap::const_iterator iter1 = iter->second.find(vProperty);
if(iter1 == iter->second.end())
{
return false;
}
return true;
}
/**
*
*/
const std::string &SessionReader::GetGlobalSysSolnInfo(const std::string &pVariable, const std::string &pProperty) const
{
GloSysSolnInfoList::const_iterator iter;
ASSERTL0( (iter = m_gloSysSolnList.find(pVariable)) != m_gloSysSolnList.end(),
"Failed to find variable in GlobalSysSolnInfoList");
std::string vProperty = boost::to_upper_copy(pProperty);
GloSysInfoMap::const_iterator iter1;
ASSERTL0( (iter1 = iter->second.find(vProperty)) != iter->second.end(),
"Failed to find property: " + vProperty + " in GlobalSysSolnInfoList");
return iter1->second;
}
/**
*
*/
......@@ -778,6 +833,18 @@ namespace Nektar
}
/**
*
*/
void SessionReader::SetVariable(const unsigned int &idx,
std::string newname)
{
ASSERTL0(idx < m_variables.size(), "Variable index out of range.");
m_variables[idx] = newname;
}
/**
*
*/
......@@ -1175,11 +1242,12 @@ namespace Nektar
FirstChildElement("CONDITIONS").Element();
// Read the various sections of the CONDITIONS block
ReadParameters (e);
ReadSolverInfo (e);
ReadExpressions(e);
ReadVariables (e);
ReadFunctions (e);
ReadParameters (e);
ReadSolverInfo (e);
ReadGlobalSysSolnInfo (e);
ReadExpressions (e);
ReadVariables (e);
ReadFunctions (e);
e = docHandle.FirstChildElement("NEKTAR").
FirstChildElement("GEOMETRY").Element();
......@@ -1413,15 +1481,18 @@ namespace Nektar
}
}
if (m_verbose && m_parameters.size() > 0)
if (m_verbose && m_parameters.size() > 0 && m_comm)
{
cout << "Parameters:" << endl;
ParameterMap::iterator x;
for (x = m_parameters.begin(); x != m_parameters.end(); ++x)
if(m_comm->GetRank() == 0)
{
cout << "\t" << x->first << " = " << x->second << endl;
cout << "Parameters:" << endl;
ParameterMap::iterator x;
for (x = m_parameters.begin(); x != m_parameters.end(); ++x)
{
cout << "\t" << x->first << " = " << x->second << endl;
}
cout << endl;
}
cout << endl;
}
}
......@@ -1510,13 +1581,146 @@ namespace Nektar
if (m_verbose && m_solverInfo.size() > 0 && m_comm)
{
cout << "Solver Info:" << endl;
SolverInfoMap::iterator x;
for (x = m_solverInfo.begin(); x != m_solverInfo.end(); ++x)
if(m_comm->GetRank() == 0)
{
cout << "Solver Info:" << endl;
SolverInfoMap::iterator x;
for (x = m_solverInfo.begin(); x != m_solverInfo.end(); ++x)
{
cout << "\t" << x->first << " = " << x->second << endl;
}
cout << endl;
}
}
}
/**
*
*/
void SessionReader::ReadGlobalSysSolnInfo(TiXmlElement *conditions)
{
m_gloSysSolnList.clear();
if (!conditions)
{
return;
}
TiXmlElement *GlobalSys =
conditions->FirstChildElement("GLOBALSYSSOLNINFO");
if(!GlobalSys)
{
return;
}
TiXmlElement *VarInfo = GlobalSys->FirstChildElement("V");
while (VarInfo)
{
ASSERTL0(VarInfo->Attribute("VAR"),
"Missing VAR in attribute of GobalSysSolnInfo section."
"File: '" + m_filename + ", line: " +
boost::lexical_cast<string>(GlobalSys->Row()));
std::string VarList = VarInfo->Attribute("VAR");
// generate a list of variables.
std::vector<std::string> varStrings;
bool valid = ParseUtils::GenerateOrderedStringVector(
VarList.c_str(),varStrings);
ASSERTL0(valid,"Unable to process list of variable in "
"GlobalSysSolnInfo data, File '" + m_filename +
", line: " +
boost::lexical_cast<string>(GlobalSys->Row()));
if(varStrings.size())
{
TiXmlElement *SysSolnInfo = VarInfo->FirstChildElement("I");
while (SysSolnInfo)
{
// read the property name
ASSERTL0(SysSolnInfo->Attribute("PROPERTY"),
"Missing PROPERTY attribute in "
"GlobalSysSolnInfo section. File: '" +
m_filename + "', line: " +
boost::lexical_cast<string>(VarInfo->Row()));
std::string SysSolnProperty =
SysSolnInfo->Attribute("PROPERTY");
ASSERTL0(!SysSolnProperty.empty(),
"GlobalSysSolnIno properties must have a "
"non-empty name for variable(s) : '" +
VarList + ". File: '" + m_filename + ", line: "
+ boost::lexical_cast<string>(VarInfo->Row()));
// make sure that solver property is capitalised
std::string SysSolnPropertyUpper =
boost::to_upper_copy(SysSolnProperty);
// read the value
ASSERTL0(SysSolnInfo->Attribute("VALUE"),
"Missing VALUE attribute in GlobalSysSolnInfo "
"section. File: '" + m_filename + "', line: "
+ boost::lexical_cast<string>(VarInfo->Row()));
std::string SysSolnValue =
SysSolnInfo->Attribute("VALUE");
ASSERTL0(!SysSolnValue.empty(),
"GlobalSysSolnInfo properties must have a "
"non-empty value. File: '" + m_filename +
"', line: "
+ boost::lexical_cast<string>(VarInfo->Row()));
// Store values under variable map.
for(int i = 0; i < varStrings.size(); ++i)
{
GloSysSolnInfoList::iterator x;
if ((x = m_gloSysSolnList.find(varStrings[i])) ==
m_gloSysSolnList.end())
{
(m_gloSysSolnList[varStrings[i]])[
SysSolnPropertyUpper] = SysSolnValue;
}
else
{
x->second[SysSolnPropertyUpper] = SysSolnValue;
}
}
SysSolnInfo = SysSolnInfo->NextSiblingElement("I");
}
VarInfo = VarInfo->NextSiblingElement("V");
}
}
if (m_verbose && m_gloSysSolnList.size() > 0 && m_comm)
{
if(m_comm->GetRank() == 0)
{
cout << "\t" << x->first << " = " << x->second << endl;
cout << "GlobalSysSoln Info:" << endl;
GloSysSolnInfoList::iterator x;
for (x = m_gloSysSolnList.begin();
x != m_gloSysSolnList.end();
++x)
{
cout << "\t Variable: " << x->first << endl;
GloSysInfoMap::iterator y;
for (y = x->second.begin(); y != x->second.end(); ++y)
{
cout << "\t\t " << y->first << " = " << y->second
<< endl;
}
}
cout << endl;
}
cout << endl;
}
}
......@@ -1582,16 +1786,19 @@ namespace Nektar
}
}
if (m_verbose && m_geometricInfo.size() > 0)
if (m_verbose && m_geometricInfo.size() > 0 && m_comm)
{
cout << "Geometric Info:" << endl;
GeometricInfoMap::iterator x;
for (x = m_geometricInfo.begin();
x != m_geometricInfo.end(); ++x)
if(m_comm->GetRank() == 0)
{
cout << "\t" << x->first << " = " << x->second << endl;
cout << "Geometric Info:" << endl;
GeometricInfoMap::iterator x;
for (x = m_geometricInfo.begin();
x != m_geometricInfo.end(); ++x)
{
cout << "\t" << x->first << " = " << x->second << endl;
}
cout << endl;
}
cout << endl;
}
}
......
......@@ -63,7 +63,7 @@ namespace Nektar
typedef std::map<std::string, std::string> TagMap;
typedef std::map<std::string, std::string> FilterParams;
typedef std::vector<
std::pair<std::string, FilterParams> > FilterMap;
std::pair<std::string, FilterParams> > FilterMap;
struct CmdLineArg
{
......@@ -71,10 +71,13 @@ namespace Nektar
std::string description;
};
typedef std::map<std::string, CmdLineArg> CmdLineArgMap;
typedef std::map<std::string, CmdLineArg> CmdLineArgMap;
typedef std::map<std::string, int> EnumMap;
typedef std::map<std::string, EnumMap> EnumMapList;
typedef std::map<std::string, int> EnumMap;
typedef std::map<std::string, EnumMap> EnumMapList;
typedef std::map<std::string, std::string> GloSysInfoMap;
typedef std::map<std::string, GloSysInfoMap> GloSysSolnInfoList;
enum FunctionType
{
......@@ -223,9 +226,13 @@ namespace Nektar
/// Returns the value of the specified solver info property.
LIB_UTILITIES_EXPORT const std::string& GetSolverInfo(
const std::string &pProperty) const;
/// Returns the value of the specified solver info property.
/// Returns the value of the specified solver info property as enum
template<typename T>
inline const T GetSolverInfoAsEnum(const std::string &pName) const;
/// Returns the value of the specified property and value as enum
template<typename T>
inline const T GetValueAsEnum(const std::string &pName,
const std::string &vValue) const;
/// Check for and load a solver info property.
LIB_UTILITIES_EXPORT void LoadSolverInfo(
const std::string &name,
......@@ -253,9 +260,19 @@ namespace Nektar
int pEnumValue);
/// Registers the default string value of a solver info property.
LIB_UTILITIES_EXPORT inline static std::string
RegisterDefaultSolverInfo(
RegisterDefaultSolverInfo(
const std::string &pName,
const std::string &pValue);
/* ----GlobalSysSolnInfo ----- */
LIB_UTILITIES_EXPORT bool DefinesGlobalSysSolnInfo(
const std::string &variable,
const std::string &property) const;
LIB_UTILITIES_EXPORT const std::string& GetGlobalSysSolnInfo(
const std::string &variable,
const std::string &property) const;
/* ------ GEOMETRIC INFO ------ */
/// Checks if a geometric info property is defined.
......@@ -287,6 +304,10 @@ namespace Nektar
/// Returns the name of the variable specified by the given index.
LIB_UTILITIES_EXPORT const std::string& GetVariable(
const unsigned int &idx) const;
LIB_UTILITIES_EXPORT void SetVariable(
const unsigned int &idx,
std::string newname);
/// Returns the names of all variables.
LIB_UTILITIES_EXPORT std::vector<std::string> GetVariables() const;
......@@ -399,12 +420,14 @@ namespace Nektar
/// bcs.
BndRegionOrdering m_bndRegOrder;
/// String to enumeration map for Solver Info parameters.
LIB_UTILITIES_EXPORT static EnumMapList m_enums;
LIB_UTILITIES_EXPORT static EnumMapList m_enums;
/// Default solver info options.
LIB_UTILITIES_EXPORT static SolverInfoMap m_solverInfoDefaults;
LIB_UTILITIES_EXPORT static SolverInfoMap m_solverInfoDefaults;
/// CmdLine argument map.
LIB_UTILITIES_EXPORT static CmdLineArgMap m_cmdLineArguments;
LIB_UTILITIES_EXPORT static CmdLineArgMap m_cmdLineArguments;
/// GlobalSysSoln Info map.
LIB_UTILITIES_EXPORT static GloSysSolnInfoList m_gloSysSolnList;
/// Main constructor
LIB_UTILITIES_EXPORT SessionReader(
int argc,
......@@ -447,6 +470,9 @@ namespace Nektar
LIB_UTILITIES_EXPORT void ReadParameters(TiXmlElement *conditions);
/// Reads the SOLVERINFO section of the XML document.
LIB_UTILITIES_EXPORT void ReadSolverInfo(TiXmlElement *conditions);
/// Reads the GLOBALSYSSOLNINFO section of the XML document.
LIB_UTILITIES_EXPORT void ReadGlobalSysSolnInfo(
TiXmlElement *conditions);
/// Reads the GEOMETRICINFO section of the XML document.
LIB_UTILITIES_EXPORT void ReadGeometricInfo(TiXmlElement *geometry);
/// Reads the EXPRESSIONS section of the XML document.
......@@ -487,20 +513,44 @@ namespace Nektar
const std::string &pName) const
{
std::string vName = boost::to_upper_copy(pName);
ASSERTL0(DefinesSolverInfo(vName),
ASSERTL0(DefinesSolverInfo(vName),
"Solver info '" + pName + "' not defined.");
std::string vValue = GetSolverInfo(vName);
EnumMapList::iterator x;
ASSERTL0((x = m_enums.find(vName)) != m_enums.end(),
"Enum for SolverInfo property '" + pName + "' not found.");
EnumMap::iterator y;
ASSERTL0((y = x->second.find(vValue)) != x->second.end(),
"Value of SolverInfo property '" + pName + "' is invalid.");
"Value of SolverInfo property '" + pName +
"' is invalid.");
return T(y->second);
}
/**
*
*/
template<typename T>
inline const T SessionReader::GetValueAsEnum(const std::string &pName,
const std::string &pValue) const
{
std::string vName = boost::to_upper_copy(pName);
EnumMapList::iterator x;
ASSERTL0((x = m_enums.find(vName)) != m_enums.end(),
"Enum for property '" + pName + "' not found.");
EnumMap::iterator y;
ASSERTL0((y = x->second.find(pValue)) != x->second.end(),
"Value of property '" + pValue + "' is invalid.");
return T(y->second);
}
/**
* A set of valid values for a given solver info property may be
* registered using this function. It must be called statically during