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 ...@@ -14,4 +14,3 @@ IndentCaseLabels: true
Standard: Cpp03 Standard: Cpp03
AccessModifierOffset: -4 AccessModifierOffset: -4
BinPackParameters: false BinPackParameters: false
BinPackArguments: false
This diff is collapsed.
...@@ -34,16 +34,15 @@ ...@@ -34,16 +34,15 @@
#define NEKTAR_FIELD_UTILS_DECLSPEC_H #define NEKTAR_FIELD_UTILS_DECLSPEC_H
#if defined(_MSC_VER) #if defined(_MSC_VER)
#ifdef FIELD_UTILS_EXPORTS #ifdef FIELD_UTILS_EXPORTS
#define FIELD_UTILS_EXPORT _declspec(dllexport) #define FIELD_UTILS_EXPORT _declspec(dllexport)
#else
#define FIELD_UTILS_EXPORT _declspec(dllimport)
#endif
#else #else
#define FIELD_UTILS_EXPORT #define FIELD_UTILS_EXPORT _declspec(dllimport)
#endif
#else
#define FIELD_UTILS_EXPORT
#endif #endif
#define LOKI_CLASS_LEVEL_THREADING #define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_FIELD_UTILS_DECLSPEC_H #endif // NEKTAR_FIELD_UTILS_DECLSPEC_H
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream> #include <iostream>
#include <string>
using namespace std; using namespace std;
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <LibUtilities/BasicUtils/PtsField.h> #include <LibUtilities/BasicUtils/PtsField.h>
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <tinyxml.h> #include <tinyxml.h>
...@@ -51,9 +51,9 @@ namespace FieldUtils ...@@ -51,9 +51,9 @@ namespace FieldUtils
ModuleKey InputDat::m_className[1] = { ModuleKey InputDat::m_className[1] = {
GetModuleFactory().RegisterCreatorFunction( GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "dat"), ModuleKey(eInputModule, "dat"),
InputDat::create, InputDat::create,
"Reads Tecplot dat file for FE block triangular format."), "Reads Tecplot dat file for FE block triangular format."),
}; };
/** /**
...@@ -65,7 +65,6 @@ InputDat::InputDat(FieldSharedPtr f) : InputModule(f) ...@@ -65,7 +65,6 @@ InputDat::InputDat(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("dat"); m_allowedFiles.insert("dat");
} }
/** /**
* *
*/ */
...@@ -73,29 +72,27 @@ InputDat::~InputDat() ...@@ -73,29 +72,27 @@ InputDat::~InputDat()
{ {
} }
/** /**
* *
*/ */
void InputDat::Process(po::variables_map &vm) 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; cout << "Processing input dat file" << endl;
} }
} }
string line, word, tag; string line, word, tag;
std::ifstream datFile; std::ifstream datFile;
stringstream s; stringstream s;
// Open the file stream. // Open the file stream.
string fname = m_f->m_inputfiles["dat"][0]; string fname = m_f->m_inputfiles["dat"][0];
datFile.open(fname.c_str()); datFile.open(fname.c_str());
if (!datFile.good()) if (!datFile.good())
{ {
...@@ -111,17 +108,18 @@ void InputDat::Process(po::variables_map &vm) ...@@ -111,17 +108,18 @@ void InputDat::Process(po::variables_map &vm)
{ {
getline(datFile, line); 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++; pos++;
// note this expects a comma separated list but // note this expects a comma separated list but
// does not work for white space separated lists! // does not work for white space separated lists!
bool valid = ParseUtils::GenerateOrderedStringVector( bool valid = ParseUtils::GenerateOrderedStringVector(
line.substr(pos).c_str(), fieldNames); line.substr(pos).c_str(), fieldNames);
ASSERTL0(valid,"Unable to process list of field variable in " ASSERTL0(valid, "Unable to process list of field variable in "
" VARIABLES list: "+ line.substr(pos)); " VARIABLES list: " +
line.substr(pos));
// remove coordinates from fieldNames // remove coordinates from fieldNames
fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim); fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim);
...@@ -141,9 +139,9 @@ void InputDat::Process(po::variables_map &vm) ...@@ -141,9 +139,9 @@ void InputDat::Process(po::variables_map &vm)
{ {
getline(datFile, line); getline(datFile, line);
if((line.find("ZONE") != string::npos)|| if ((line.find("ZONE") != string::npos) ||
(line.find("Zone") != string::npos)|| (line.find("Zone") != string::npos) ||
(line.find("zone") != string::npos)) (line.find("zone") != string::npos))
{ {
ReadTecplotFEBlockZone(datFile, line, pts, ptsConn); ReadTecplotFEBlockZone(datFile, line, pts, ptsConn);
} }
...@@ -151,88 +149,81 @@ void InputDat::Process(po::variables_map &vm) ...@@ -151,88 +149,81 @@ void InputDat::Process(po::variables_map &vm)
datFile.close(); datFile.close();
m_f->m_fieldPts = m_f->m_fieldPts = MemoryManager<LibUtilities::PtsField>::AllocateSharedPtr(
MemoryManager<LibUtilities::PtsField>::AllocateSharedPtr( dim, fieldNames, pts);
dim, fieldNames, pts);
m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsTriBlock); m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsTriBlock);
m_f->m_fieldPts->SetConnectivity(ptsConn); m_f->m_fieldPts->SetConnectivity(ptsConn);
} }
/** /**
* *
*/ */
void InputDat::ReadTecplotFEBlockZone( void InputDat::ReadTecplotFEBlockZone(std::ifstream &datFile,
std::ifstream &datFile, string &line,
string &line, Array<OneD, Array<OneD, NekDouble> > &pts,
Array<OneD, Array<OneD, NekDouble> > &pts, vector<Array<OneD, int> > &ptsConn)
vector<Array<OneD, int> > &ptsConn)
{ {
ASSERTL0(line.find("FEBlock") != string::npos, ASSERTL0(line.find("FEBlock") != string::npos,
"Routine only set up for FEBLock format"); "Routine only set up for FEBLock format");
ASSERTL0(line.find("ET") != string::npos, ASSERTL0(line.find("ET") != string::npos, "Routine only set up TRIANLES");
"Routine only set up TRIANLES");
// read the number of nodes // read the number of nodes
stringstream s; stringstream s;
string tag; string tag;
int start,end; int start, end;
s.clear(); s.clear();
s.str(line); s.str(line);
tag = s.str(); tag = s.str();
// read the number of vertices // read the number of vertices
start = tag.find("N="); start = tag.find("N=");
end = tag.find_first_of(',',start); end = tag.find_first_of(',', start);
int nvert = atoi(tag.substr(start+2,end).c_str()); int nvert = atoi(tag.substr(start + 2, end).c_str());
// read the number of elements // read the number of elements
start = tag.find("E="); start = tag.find("E=");
end = tag.find_first_of(',',start); end = tag.find_first_of(',', start);
int nelmt = atoi(tag.substr(start+2,end).c_str()); int nelmt = atoi(tag.substr(start + 2, end).c_str());
// set-up or extend m_pts array; // set-up or extend m_pts array;
int norigpts = pts[0].num_elements(); int norigpts = pts[0].num_elements();
int totfields = pts.num_elements(); int totfields = pts.num_elements();
Array<OneD, Array<OneD, NekDouble> > origpts(totfields); 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]; origpts[i] = pts[i];
pts[i] = Array<OneD, NekDouble>(norigpts + nvert); pts[i] = Array<OneD, NekDouble>(norigpts + nvert);
} }
NekDouble value; 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]; pts[n][i] = origpts[n][i];
} }
for(int i = 0; i < nvert; ++i) for (int i = 0; i < nvert; ++i)
{ {
datFile >> value; datFile >> value;
pts[n][norigpts+i] = value; pts[n][norigpts + i] = value;
} }
} }
// read connectivity and add to list // read connectivity and add to list
int intvalue; int intvalue;
Array<OneD, int> conn(3*nelmt); Array<OneD, int> conn(3 * nelmt);
for(int i = 0; i < 3*nelmt; ++i) for (int i = 0; i < 3 * nelmt; ++i)
{ {
datFile >> intvalue; 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; conn[i] = norigpts + intvalue;
} }
ptsConn.push_back(conn); ptsConn.push_back(conn);
getline(datFile, line); getline(datFile, line);
} }
} }
} }
...@@ -46,30 +46,30 @@ namespace FieldUtils ...@@ -46,30 +46,30 @@ namespace FieldUtils
/// Input module for Xml files. /// Input module for Xml files.
class InputDat : public InputModule class InputDat : public InputModule
{ {
public: public:
InputDat(FieldSharedPtr f); InputDat(FieldSharedPtr f);
virtual ~InputDat(); virtual ~InputDat();
virtual void Process(po::variables_map &vm); virtual void Process(po::variables_map &vm);
/// Creates an instance of this class /// Creates an instance of this class
static ModuleSharedPtr create(FieldSharedPtr f) static ModuleSharedPtr create(FieldSharedPtr f)
{ {
return MemoryManager<InputDat>::AllocateSharedPtr(f); return MemoryManager<InputDat>::AllocateSharedPtr(f);
} }
/// %ModuleKey for class. /// %ModuleKey for class.
static ModuleKey m_className[]; static ModuleKey m_className[];
virtual std::string GetModuleName() virtual std::string GetModuleName()
{ {
return "InputDat"; return "InputDat";
} }
private: private:
void ReadTecplotFEBlockZone(std::ifstream &datFile, string &line, void ReadTecplotFEBlockZone(std::ifstream &datFile,
Array<OneD, Array<OneD, NekDouble> > &pts, string &line,
vector<Array<OneD, int> > &ptsConn); Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn);
}; };
} }
} }
#endif #endif
...@@ -33,15 +33,15 @@ ...@@ -33,15 +33,15 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream> #include <iostream>
#include <string>
using namespace std; using namespace std;
#include "InputFld.h" #include "InputFld.h"
using namespace Nektar; using namespace Nektar;
static std::string npts = LibUtilities::SessionReader::RegisterCmdLineArgument( static std::string npts = LibUtilities::SessionReader::RegisterCmdLineArgument(
"NumberOfPoints","n","Define number of points to dump output"); "NumberOfPoints", "n", "Define number of points to dump output");
namespace Nektar namespace Nektar
{ {
...@@ -50,19 +50,17 @@ namespace FieldUtils ...@@ -50,19 +50,17 @@ namespace FieldUtils
ModuleKey InputFld::m_className[4] = { ModuleKey InputFld::m_className[4] = {
GetModuleFactory().RegisterCreatorFunction( GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "fld"), InputFld::create, ModuleKey(eInputModule, "fld"), InputFld::create, "Reads Fld file."),
"Reads Fld file."), GetModuleFactory().RegisterCreatorFunction(ModuleKey(eInputModule, "chk"),
GetModuleFactory().RegisterCreatorFunction( InputFld::create,
ModuleKey(eInputModule, "chk"), InputFld::create, "Reads checkpoint file."),
"Reads checkpoint file."), GetModuleFactory().RegisterCreatorFunction(ModuleKey(eInputModule, "rst"),
InputFld::create,
"Reads restart file."),
GetModuleFactory().RegisterCreatorFunction( GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "rst"), InputFld::create, ModuleKey(eInputModule, "bse"),
"Reads restart file."), InputFld::create,
GetModuleFactory().RegisterCreatorFunction( "Reads stability base-flow file.")};
ModuleKey(eInputModule, "bse"), InputFld::create,
"Reads stability base-flow file.")
};
/** /**
* @brief Set up InputFld object. * @brief Set up InputFld object.
...@@ -76,7 +74,6 @@ InputFld::InputFld(FieldSharedPtr f) : InputModule(f) ...@@ -76,7 +74,6 @@ InputFld::InputFld(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("bse"); m_allowedFiles.insert("bse");
} }
/** /**
* *
*/ */
...@@ -84,29 +81,28 @@ InputFld::~InputFld() ...@@ -84,29 +81,28 @@ InputFld::~InputFld()
{ {
} }
/** /**
* *
*/ */
void InputFld::Process(po::variables_map &vm) void InputFld::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 fld file" << endl; cout << "Processing input fld file" << endl;
} }
} }
int i,j; int i, j;
string fldending; string fldending;
//Determine appropriate field input // Determine appropriate field input
if(m_f->m_inputfiles.count("fld") != 0) if (m_f->m_inputfiles.count("fld") != 0)
{ {
fldending = "fld"; fldending = "fld";
} }
else if(m_f->m_inputfiles.count("chk") != 0) else if (m_f->m_inputfiles.count("chk") != 0)
{ {
fldending = "chk"; fldending = "chk";
} }
...@@ -120,26 +116,27 @@ void InputFld::Process(po::variables_map &vm) ...@@ -120,26 +116,27 @@ void InputFld::Process(po::variables_map &vm)
} }
else else
{ {
ASSERTL0(false,"no input file found"); ASSERTL0(false, "no input file found");
} }
if(!m_f->m_fld) if (!m_f->m_fld)
{ {
if(m_f->m_session) if (m_f->m_session)
{ {
m_f->m_fld = MemoryManager<LibUtilities::FieldIO> m_f->m_fld =
::AllocateSharedPtr(m_f->m_session->GetComm()); MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(
m_f->m_session->GetComm());
} }
else // serial communicator else // serial communicator
{ {
LibUtilities::CommSharedPtr c = LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0); LibUtilities::CommSharedPtr c =
m_f->m_fld = MemoryManager<LibUtilities::FieldIO> LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
::AllocateSharedPtr(c); m_f->m_fld =
MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(c);
} }
} }
if (m_f->m_graph)
if(m_f->m_graph)
{ {
if (m_f->m_data.size() == 0) if (m_f->m_data.size() == 0)
{ {
...@@ -147,20 +144,20 @@ void InputFld::Process(po::variables_map &vm) ...@@ -147,20 +144,20 @@ void InputFld::Process(po::variables_map &vm)
// expansion list but it is re-arranged in expansion) // expansion list but it is re-arranged in expansion)
const SpatialDomains::ExpansionMap &expansions = const SpatialDomains::ExpansionMap &expansions =
m_f->m_graph->GetExpansions(); m_f->m_graph->GetExpansions();
// if Range has been speficied it is possible to have a // if Range has been speficied it is possible to have a
// partition which is empty so check this and return if // partition which is empty so check this and return if
// no elements present. // no elements present.