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>
......@@ -65,7 +65,6 @@ InputDat::InputDat(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("dat");
}
/**
*
*/
......@@ -73,16 +72,15 @@ 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;
}
......@@ -95,7 +93,6 @@ void InputDat::Process(po::variables_map &vm)
// Open the file stream.
string fname = m_f->m_inputfiles["dat"][0];
datFile.open(fname.c_str());
if (!datFile.good())
{
......@@ -111,7 +108,7 @@ 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('=');
pos++;
......@@ -120,8 +117,9 @@ void InputDat::Process(po::variables_map &vm)
// 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));
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,8 +139,8 @@ void InputDat::Process(po::variables_map &vm)
{
getline(datFile, line);
if((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,33 +149,29 @@ void InputDat::Process(po::variables_map &vm)
datFile.close();
m_f->m_fieldPts =
MemoryManager<LibUtilities::PtsField>::AllocateSharedPtr(
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,
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);
......@@ -185,54 +179,51 @@ void InputDat::ReadTecplotFEBlockZone(
// 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());
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());
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);
}
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,7 +46,7 @@ namespace FieldUtils
/// Input module for Xml files.
class InputDat : public InputModule
{
public:
public:
InputDat(FieldSharedPtr f);
virtual ~InputDat();
virtual void Process(po::variables_map &vm);
......@@ -64,12 +64,12 @@ class InputDat : public InputModule
return "InputDat";
}
private:
void ReadTecplotFEBlockZone(std::ifstream &datFile, string &line,
private:
void ReadTecplotFEBlockZone(std::ifstream &datFile,
string &line,
Array<OneD, Array<OneD, NekDouble> > &pts,
vector<Array<OneD, int> > &ptsConn);
};
}
}
#endif
......@@ -33,15 +33,15 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
#include <string>
using namespace std;
#include "InputFld.h"
using namespace Nektar;
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
{
......@@ -50,19 +50,17 @@ namespace FieldUtils
ModuleKey InputFld::m_className[4] = {
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "fld"), InputFld::create,
"Reads Fld file."),
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "chk"), InputFld::create,
ModuleKey(eInputModule, "fld"), InputFld::create, "Reads Fld file."),
GetModuleFactory().RegisterCreatorFunction(ModuleKey(eInputModule, "chk"),
InputFld::create,
"Reads checkpoint file."),
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "rst"), InputFld::create,
GetModuleFactory().RegisterCreatorFunction(ModuleKey(eInputModule, "rst"),
InputFld::create,
"Reads restart file."),
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eInputModule, "bse"), InputFld::create,
"Reads stability base-flow file.")
};
ModuleKey(eInputModule, "bse"),
InputFld::create,
"Reads stability base-flow file.")};
/**
* @brief Set up InputFld object.
......@@ -76,7 +74,6 @@ InputFld::InputFld(FieldSharedPtr f) : InputModule(f)
m_allowedFiles.insert("bse");
}
/**
*
*/
......@@ -84,29 +81,28 @@ InputFld::~InputFld()
{
}
/**
*
*/
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;
}
}
int i,j;
int i, j;
string fldending;
//Determine appropriate field input
if(m_f->m_inputfiles.count("fld") != 0)
// Determine appropriate field input
if (m_f->m_inputfiles.count("fld") != 0)
{
fldending = "fld";
}
else if(m_f->m_inputfiles.count("chk") != 0)
else if (m_f->m_inputfiles.count("chk") != 0)
{
fldending = "chk";
}
......@@ -120,26 +116,27 @@ void InputFld::Process(po::variables_map &vm)
}
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>
::AllocateSharedPtr(m_f->m_session->GetComm());
m_f->m_fld =
MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(
m_f->m_session->GetComm());
}
else // serial communicator
{
LibUtilities::CommSharedPtr c = LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
m_f->m_fld = MemoryManager<LibUtilities::FieldIO>
::AllocateSharedPtr(c);
LibUtilities::CommSharedPtr c =
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
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)
{
......@@ -153,14 +150,14 @@ void InputFld::Process(po::variables_map &vm)
// partition which is empty so check this and return if
// no elements present.
if(!expansions.size())
if (!expansions.size())
{
return;
}
m_f->m_exp.resize(1);
Array<OneD,int> ElementGIDs(expansions.size());
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
i = 0;
......@@ -172,30 +169,25 @@ void InputFld::Process(po::variables_map &vm)
m_f->m_fielddef.clear();
m_f->m_data.clear();
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap,
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0], m_f->m_fielddef,
m_f->m_data, m_f->m_fieldMetaDataMap,
ElementGIDs);
}
}
else // load all data.
{
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap);
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0], m_f->m_fielddef,
m_f->m_data, m_f->m_fieldMetaDataMap);
}
// if m_exp defined presume we want to load all field into expansions
if(m_f->m_exp.size())
if (m_f->m_exp.size())
{
int nfields,nstrips;
int nfields, nstrips;
m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
if(vm.count("useSessionVariables"))
if (vm.count("useSessionVariables"))
{
nfields = m_f->m_session->GetVariables().size();
}
......@@ -204,40 +196,34 @@ void InputFld::Process(po::variables_map &vm)
nfields = m_f->m_fielddef[0]->m_fields.size();
}
m_f->m_exp.resize(nfields*nstrips);
m_f->m_exp.resize(nfields * nstrips);
vector<string> vars = m_f->m_session->GetVariables();
// declare other fields;
for (int s = 0; s < nstrips; ++s) //homogeneous strip varient
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (i = 0; i < nfields; ++i)
{
if(i < vars.size())
if (i < vars.size())
{
// check to see if field already defined
if(!m_f->m_exp[s*nfields+i])
if (!m_f->m_exp[s * nfields + i])
{
m_f->m_exp[s*nfields+i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
vars[i]);
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[i]);
}
}
else
{
if(vars.size())
if (vars.size())
{
m_f->m_exp[s*nfields+i] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
vars[0]);
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[0]);
}
else
{
m_f->m_exp[s*nfields+i] =
m_f->AppendExpList(
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
}
}
......@@ -245,35 +231,36 @@ void InputFld::Process(po::variables_map &vm)
}
// Extract data to coeffs and bwd transform
for(int s = 0; s < nstrips; ++s) //homogeneous strip varient
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (j = 0; j < nfields; ++j)
{
for (i = 0; i < m_f->m_data.size()/nstrips; ++i)
for (i = 0; i < m_f->m_data.size() / nstrips; ++i)
{
m_f->m_exp[s*nfields+j]->
ExtractDataToCoeffs(m_f->m_fielddef[i*nstrips+s],
m_f->m_data[i*nstrips+s],
m_f->m_fielddef[i*nstrips+s]
->m_fields[j],
m_f->m_exp[s*nfields+j]->UpdateCoeffs());
m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
m_f->m_fielddef[i * nstrips + s],
m_f->m_data[i * nstrips + s],
m_f->m_fielddef[i * nstrips + s]->m_fields[j],
m_f->m_exp[s * nfields + j]->UpdateCoeffs());
}
m_f->m_exp[s*nfields+j]->BwdTrans(m_f->m_exp[s*nfields+j]->GetCoeffs(),
m_f->m_exp[s*nfields+j]->UpdatePhys());
m_f->m_exp[s * nfields + j]->BwdTrans(
m_f->m_exp[s * nfields + j]->GetCoeffs(),
m_f->m_exp[s * nfields + j]->UpdatePhys());
}
}
// reset output field in case Import loaded elements that are not
// in the expansion (because of range option of partitioning)
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
= m_f->m_exp[0]->GetFieldDefinitions();
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for (j = 0; j < nfields; ++j)
{
for (i = 0; i < FieldDef.size(); ++i)
{
FieldDef[i]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
}
}
......@@ -281,6 +268,5 @@ void InputFld::Process(po::variables_map &vm)
m_f->m_data = FieldData;
}
}
}
}
......@@ -48,7 +48,7 @@ namespace FieldUtils
*/
class InputFld : public InputModule
{
public:
public:
InputFld(FieldSharedPtr f);
virtual ~InputFld();
virtual void Process(po::variables_map &vm);
......@@ -66,9 +66,8 @@ class InputFld : public InputModule
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())
{