Commit 92a9d46b authored by Dave Moxey's avatar Dave Moxey

Run new FieldUtils library through clang-format

parent 38c18f5b
......@@ -14,4 +14,3 @@ IndentCaseLabels: true
Standard: Cpp03
AccessModifierOffset: -4
BinPackParameters: false
BinPackArguments: false
This diff is collapsed.
......@@ -34,16 +34,15 @@
#define NEKTAR_FIELD_UTILS_DECLSPEC_H
#if defined(_MSC_VER)
#ifdef FIELD_UTILS_EXPORTS
#define FIELD_UTILS_EXPORT _declspec(dllexport)
#else
#define FIELD_UTILS_EXPORT _declspec(dllimport)
#endif
#ifdef FIELD_UTILS_EXPORTS
#define FIELD_UTILS_EXPORT _declspec(dllexport)
#else
#define FIELD_UTILS_EXPORT
#define FIELD_UTILS_EXPORT _declspec(dllimport)
#endif
#else
#define FIELD_UTILS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_FIELD_UTILS_DECLSPEC_H
#endif // NEKTAR_FIELD_UTILS_DECLSPEC_H
......@@ -33,12 +33,12 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include <string>
using namespace std;
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <LibUtilities/BasicUtils/PtsField.h>
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <tinyxml.h>
......@@ -51,9 +51,9 @@ namespace FieldUtils
ModuleKey InputDat::m_className[1] = {
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "dat"),
InputDat::create,
"Reads Tecplot dat file for FE block triangular format."),
ModuleKey(eInputModule, "dat"),
InputDat::create,
"Reads Tecplot dat file for FE block triangular format."),
};
/**
......@@ -65,7 +65,6 @@ InputDat::InputDat(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("dat");
}
/**
*
*/
......@@ -73,29 +72,27 @@ InputDat::~InputDat()
{
}
/**
*
*/
void InputDat::Process(po::variables_map &vm)
{
if(m_f->m_verbose)
if (m_f->m_verbose)
{
if(m_f->m_comm->TreatAsRankZero())
if (m_f->m_comm->TreatAsRankZero())
{
cout << "Processing input dat file" << endl;
}
}
string line, word, tag;
string line, word, tag;
std::ifstream datFile;
stringstream s;
// Open the file stream.
string fname = m_f->m_inputfiles["dat"][0];
datFile.open(fname.c_str());
if (!datFile.good())
{
......@@ -111,17 +108,18 @@ void InputDat::Process(po::variables_map &vm)
{
getline(datFile, line);
if(line.find("VARIABLES") != string::npos)
if (line.find("VARIABLES") != string::npos)
{
std::size_t pos = line.find('=');
std::size_t pos = line.find('=');
pos++;
// note this expects a comma separated list but
// does not work for white space separated lists!
bool valid = ParseUtils::GenerateOrderedStringVector(
line.substr(pos).c_str(), fieldNames);
ASSERTL0(valid,"Unable to process list of field variable in "
" VARIABLES list: "+ line.substr(pos));
line.substr(pos).c_str(), fieldNames);
ASSERTL0(valid, "Unable to process list of field variable in "
" VARIABLES list: " +
line.substr(pos));
// remove coordinates from fieldNames
fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim);
......@@ -141,9 +139,9 @@ void InputDat::Process(po::variables_map &vm)
{
getline(datFile, line);
if((line.find("ZONE") != string::npos)||
(line.find("Zone") != string::npos)||
(line.find("zone") != string::npos))
if ((line.find("ZONE") != string::npos) ||
(line.find("Zone") != string::npos) ||
(line.find("zone") != string::npos))
{
ReadTecplotFEBlockZone(datFile, line, pts, ptsConn);
}
......@@ -151,88 +149,81 @@ void InputDat::Process(po::variables_map &vm)
datFile.close();
m_f->m_fieldPts =
MemoryManager<LibUtilities::PtsField>::AllocateSharedPtr(
dim, fieldNames, pts);
m_f->m_fieldPts = MemoryManager<LibUtilities::PtsField>::AllocateSharedPtr(
dim, fieldNames, pts);
m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsTriBlock);
m_f->m_fieldPts->SetConnectivity(ptsConn);
}
/**
*
*/
void InputDat::ReadTecplotFEBlockZone(
std::ifstream &datFile,
string &line,
Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn)
void InputDat::ReadTecplotFEBlockZone(std::ifstream &datFile,
string &line,
Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn)
{
ASSERTL0(line.find("FEBlock") != string::npos,
"Routine only set up for FEBLock format");
ASSERTL0(line.find("ET") != string::npos,
"Routine only set up TRIANLES");
ASSERTL0(line.find("ET") != string::npos, "Routine only set up TRIANLES");
// read the number of nodes
stringstream s;
string tag;
int start,end;
int start, end;
s.clear();
s.str(line);
tag = s.str();
// read the number of vertices
start = tag.find("N=");
end = tag.find_first_of(',',start);
int nvert = atoi(tag.substr(start+2,end).c_str());
start = tag.find("N=");
end = tag.find_first_of(',', start);
int nvert = atoi(tag.substr(start + 2, end).c_str());
// read the number of elements
start = tag.find("E=");
end = tag.find_first_of(',',start);
int nelmt = atoi(tag.substr(start+2,end).c_str());
start = tag.find("E=");
end = tag.find_first_of(',', start);
int nelmt = atoi(tag.substr(start + 2, end).c_str());
// set-up or extend m_pts array;
int norigpts = pts[0].num_elements();
int totfields = pts.num_elements();
Array<OneD, Array<OneD, NekDouble> > origpts(totfields);
for(int i = 0; i < totfields; ++i)
for (int i = 0; i < totfields; ++i)
{
origpts[i] = pts[i];
pts[i] = Array<OneD, NekDouble>(norigpts + nvert);
pts[i] = Array<OneD, NekDouble>(norigpts + nvert);
}
NekDouble value;
for(int n = 0; n < totfields; ++n)
for (int n = 0; n < totfields; ++n)
{
for(int i = 0; i < norigpts; ++i)
for (int i = 0; i < norigpts; ++i)
{
pts[n][i] = origpts[n][i];
}
for(int i = 0; i < nvert; ++i)
for (int i = 0; i < nvert; ++i)
{
datFile >> value;
pts[n][norigpts+i] = value;
pts[n][norigpts + i] = value;
}
}
// read connectivity and add to list
int intvalue;
Array<OneD, int> conn(3*nelmt);
for(int i = 0; i < 3*nelmt; ++i)
Array<OneD, int> conn(3 * nelmt);
for (int i = 0; i < 3 * nelmt; ++i)
{
datFile >> intvalue;
intvalue -=1; // decrement intvalue by 1 for c array convention
intvalue -= 1; // decrement intvalue by 1 for c array convention
conn[i] = norigpts + intvalue;
}
ptsConn.push_back(conn);
getline(datFile, line);
}
}
}
......@@ -46,30 +46,30 @@ namespace FieldUtils
/// Input module for Xml files.
class InputDat : public InputModule
{
public:
InputDat(FieldSharedPtr f);
virtual ~InputDat();
virtual void Process(po::variables_map &vm);
public:
InputDat(FieldSharedPtr f);
virtual ~InputDat();
virtual void Process(po::variables_map &vm);
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputDat>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputDat>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
virtual std::string GetModuleName()
{
return "InputDat";
}
virtual std::string GetModuleName()
{
return "InputDat";
}
private:
void ReadTecplotFEBlockZone(std::ifstream &datFile, string &line,
Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn);
private:
void ReadTecplotFEBlockZone(std::ifstream &datFile,
string &line,
Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn);
};
}
}
#endif
......@@ -48,27 +48,26 @@ namespace FieldUtils
*/
class InputFld : public InputModule
{
public:
InputFld(FieldSharedPtr f);
virtual ~InputFld();
virtual void Process(po::variables_map &vm);
public:
InputFld(FieldSharedPtr f);
virtual ~InputFld();
virtual void Process(po::variables_map &vm);
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputFld>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputFld>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
virtual std::string GetModuleName()
{
return "InputFld";
}
virtual std::string GetModuleName()
{
return "InputFld";
}
private:
private:
};
}
}
......
......@@ -33,12 +33,12 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include <string>
using namespace std;
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <LibUtilities/BasicUtils/PtsField.h>
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <tinyxml.h>
......@@ -56,7 +56,6 @@ ModuleKey InputPts::m_className[5] = {
ModuleKey(eInputModule, "pts.gz"), InputPts::create, "Reads Pts file."),
};
/**
* @brief Set up InputPts object.
*
......@@ -66,7 +65,6 @@ InputPts::InputPts(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("pts");
}
/**
*
*/
......@@ -74,7 +72,6 @@ InputPts::~InputPts()
{
}
/**
*
*/
......@@ -82,7 +79,7 @@ void InputPts::Process(po::variables_map &vm)
{
if (m_f->m_verbose)
{
if(m_f->m_comm->TreatAsRankZero())
if (m_f->m_comm->TreatAsRankZero())
{
cout << "Processing input pts file" << endl;
}
......@@ -90,21 +87,19 @@ void InputPts::Process(po::variables_map &vm)
string inFile = (m_f->m_inputfiles["pts"][0]).c_str();
if(m_f->m_session)
if (m_f->m_session)
{
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>::
AllocateSharedPtr(m_f->m_session->GetComm());
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(
m_f->m_session->GetComm());
}
else // serial communicator
{
LibUtilities::CommSharedPtr c = LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>
::AllocateSharedPtr(c);
LibUtilities::CommSharedPtr c =
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(c);
}
m_f->m_ptsIO->Import(inFile, m_f->m_fieldPts);
m_f->m_ptsIO->Import(inFile, m_f->m_fieldPts);
}
}
}
......@@ -43,33 +43,31 @@ namespace Nektar
namespace FieldUtils
{
/**
* Input module for Xml files.
*/
class InputPts : public InputModule
{
public:
InputPts(FieldSharedPtr f);
virtual ~InputPts();
virtual void Process(po::variables_map &vm);
public:
InputPts(FieldSharedPtr f);
virtual ~InputPts();
virtual void Process(po::variables_map &vm);
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputPts>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputPts>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
virtual std::string GetModuleName()
{
return "InputPts";
}
virtual std::string GetModuleName()
{
return "InputPts";
}
private:
private:
};
}
}
......
......@@ -48,27 +48,26 @@ namespace FieldUtils
*/
class InputXml : public InputModule
{
public:
InputXml(FieldSharedPtr f);
virtual ~InputXml();
virtual void Process(po::variables_map &vm);
public:
InputXml(FieldSharedPtr f);
virtual ~InputXml();
virtual void Process(po::variables_map &vm);
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputXml>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
/// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f)
{
return MemoryManager<InputXml>::AllocateSharedPtr(f);
}
/// %ModuleKey for class.
static ModuleKey m_className[];
virtual std::string GetModuleName()
{
return "InputXml";
}
virtual std::string GetModuleName()
{
return "InputXml";
}
private:
private:
};
}
}
......
......@@ -333,8 +333,8 @@ void Interpolator::Interpolate(
}
// Obtain Element and LocalCoordinate to interpolate
int elmtid = m_expInField[0]->GetExpIndex(
Scoords, Lcoords, NekConstants::kNekZeroTol);
int elmtid = m_expInField[0]->GetExpIndex(Scoords, Lcoords,
NekConstants::kNekZeroTol);
if (elmtid >= 0)
{
......@@ -410,8 +410,8 @@ void Interpolator::Interpolate(
}
// Obtain Element and LocalCoordinate to interpolate
int elmtid = m_expInField[0]->GetExpIndex(
coords, Lcoords, NekConstants::kNekZeroTol);
int elmtid = m_expInField[0]->GetExpIndex(coords, Lcoords,
NekConstants::kNekZeroTol);
if (elmtid >= 0)
{
......@@ -430,8 +430,8 @@ void Interpolator::Interpolate(
}
else
{
m_ptsOutField->SetPointVal(
m_ptsOutField->GetDim() + f, i, value);
m_ptsOutField->SetPointVal(m_ptsOutField->GetDim() + f, i,
value);
}
}
}
......@@ -600,7 +600,7 @@ void Interpolator::CalcW_Gauss(const PtsPoint &searchPt,
m_weights[searchPt.idx] = Array<OneD, float>(numPts, 0.0);
NekDouble wSum = 0.0;
NekDouble ts2 = 2 * sigmaNew * sigmaNew;
NekDouble ts2 = 2 * sigmaNew * sigmaNew;
for (int i = 0; i < numPts; ++i)
{
m_weights[searchPt.idx][i] =
......@@ -658,9 +658,9 @@ void Interpolator::CalcW_Linear(const PtsPoint &searchPt, int m_coordId)
break;
}
}
ASSERTL0(i != npts - 1,
"Failed to find coordinate " + boost::lexical_cast<string>(coord) +
" within provided input points");
ASSERTL0(i != npts - 1, "Failed to find coordinate " +
boost::lexical_cast<string>(coord) +
" within provided input points");
};
/**
......@@ -704,7 +704,7 @@ void Interpolator::CalcW_Shepard(const PtsPoint &searchPt)
// find nearest neighbours
vector<PtsPoint> neighbourPts;
int numPts = pow(double(2), m_ptsInField->GetDim());
numPts = min(numPts, int(m_ptsInField->GetNpoints() / 2));
numPts = min(numPts, int(m_ptsInField->GetNpoints() / 2));
FindNNeighbours(searchPt, neighbourPts, numPts);
m_neighInds[searchPt.idx] = Array<OneD, unsigned int>(numPts);
......@@ -824,9 +824,9 @@ void Interpolator::CalcW_Quadratic(const PtsPoint &searchPt, int m_coordId)
break;
}
}
ASSERTL0(i != npts - 1,
"Failed to find coordinate " + boost::lexical_cast<string>(coord) +
" within provided input points");
ASSERTL0(i != npts - 1, "Failed to find coordinate " +
boost::lexical_cast<string>(coord) +
" within provided input points");
};
void Interpolator::SetupTree()
......@@ -847,8 +847,7 @@ void Interpolator::SetupTree()
// remove duplicates from tree
for (std::vector<PtsPointPair>::iterator it = inPoints.begin();
it != inPoints.end();
++it)
it != inPoints.end(); ++it)
{
std::vector<PtsPointPair> result;
......@@ -862,8 +861,7 @@ void Interpolator::SetupTree()
// point
// from the tree
for (std::vector<PtsPointPair>::iterator it2 = result.begin();
it2 != result.end();
++it2)
it2 != result.end(); ++it2)
{
if ((*it).second != (*it2).second &&
bg::distance((*it).first, (*it2).first) <=
......@@ -890,8 +888,8 @@ void Interpolator::FindNNeighbours(const PtsPoint &searchPt,
const unsigned int numPts)
{
std::vector<PtsPointPair> result;
BPoint searchBPoint(
searchPt.coords[0], searchPt.coords[1], searchPt.coords[2]);
BPoint searchBPoint(searchPt.coords[0], searchPt.coords[1],
searchPt.coords[2]);
m_rtree->query(bgi::nearest(searchBPoint, numPts),
std::back_inserter(result));
......@@ -924,13 +922,11 @@ void Interpolator::FindNeighbours(const PtsPoint &searchPt,
const NekDouble dist,
const unsigned int maxPts)
{
BPoint searchBPoint(
searchPt.coords[0], searchPt.coords[1], searchPt.coords[2]);
BPoint bbMin(searchPt.coords[0] - dist,
searchPt.coords[1] - dist,
BPoint searchBPoint(searchPt.coords[0], searchPt.coords[1],
searchPt.coords[2]);
BPoint bbMin(searchPt.coords[0] - dist, searchPt.coords[1] - dist,
searchPt.coords[2] - dist);
BPoint bbMax(searchPt.coords[0] + dist,
searchPt.coords[1] + dist,