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

Input module for Xml files. More...

#include <InputDat.h>

Inheritance diagram for Nektar::Utilities::InputDat:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::InputDat:
Collaboration graph
[legend]

Public Member Functions

 InputDat (FieldSharedPtr f)
 Set up InputDat object.
virtual ~InputDat ()
virtual void Process (po::variables_map &vm)
- Public Member Functions inherited from Nektar::Utilities::InputModule
 InputModule (FieldSharedPtr p_m)
void AddFile (string fileType, string fileName)
 InputModule (MeshSharedPtr p_m)
void OpenStream ()
 Open a file for input.
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
void RegisterConfig (string key, string value)
 Register a configuration option with a module.
void PrintConfig ()
 Print out all configuration options for a module.
void SetDefaults ()
 Sets default configuration options for those which have not been set.
bool GetRequireEquiSpaced (void)
void SetRequireEquiSpaced (bool pVal)
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 Module (MeshSharedPtr p_m)
virtual void Process ()=0
void RegisterConfig (string key, string value)
void PrintConfig ()
void SetDefaults ()
MeshSharedPtr GetMesh ()
virtual void ProcessVertices ()
 Extract element vertices.

Static Public Member Functions

static ModuleSharedPtr create (FieldSharedPtr f)
 Creates an instance of this class.

Static Public Attributes

static ModuleKey m_className []
 ModuleKey for class.

Private Member Functions

void ReadTecplotFEBlockZone (std::ifstream &datFile, string &line)

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::InputModule
void PrintSummary ()
 Print summary of elements.
void PrintSummary ()
 Print summary of elements.
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
std::ifstream m_mshFile
 Input stream.

Detailed Description

Input module for Xml files.

Definition at line 47 of file InputDat.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputDat::InputDat ( FieldSharedPtr  f)

Set up InputDat object.

Definition at line 60 of file InputDat.cpp.

References Nektar::Utilities::InputModule::m_allowedFiles.

{
m_allowedFiles.insert("dat");
}
Nektar::Utilities::InputDat::~InputDat ( )
virtual

Definition at line 66 of file InputDat.cpp.

{
}

Member Function Documentation

static ModuleSharedPtr Nektar::Utilities::InputDat::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file InputDat.h.

void Nektar::Utilities::InputDat::Process ( po::variables_map &  vm)
virtual

Implements Nektar::Utilities::Module.

Definition at line 73 of file InputDat.cpp.

References ASSERTL0, Nektar::Utilities::ePtsTriBlock, Nektar::ParseUtils::GenerateOrderedStringVector(), Nektar::Utilities::Module::m_f, and ReadTecplotFEBlockZone().

{
if(m_f->m_verbose)
{
cout << "Processing input dat file" << endl;
}
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())
{
cerr << "Error opening file: " << fname << endl;
abort();
}
// read variables
while (!datFile.eof())
{
getline(datFile, line);
if(line.find("VARIABLES") != string::npos)
{
vector<string> variables;
std::size_t pos = line.find('=');
pos++;
// note this expects a comma separated list but
// does not work for white space separated lists!
line.substr(pos).c_str(), variables);
ASSERTL0(valid,"Unable to process list of field variable in "
" VARIABLES list: "+ line.substr(pos));
// currently assum there are x y and z coordinates
for(int i = 3; i < variables.size(); ++i)
{
m_f->m_fieldPts->m_fields.push_back(variables[i]);
}
break;
}
}
// set up basic parameters
m_f->m_fieldPts->m_ptsDim = 3;
m_f->m_fieldPts->m_nFields = m_f->m_fieldPts->m_fields.size();
m_f->m_fieldPts->m_pts = Array<OneD, Array<OneD, NekDouble> > (
m_f->m_fieldPts->m_nFields +
m_f->m_fieldPts->m_ptsDim);
m_f->m_fieldPts->m_ptype = ePtsTriBlock;
// read zones
while (!datFile.eof())
{
getline(datFile, line);
if((line.find("ZONE") != string::npos)||
(line.find("Zone") != string::npos)||
(line.find("zone") != string::npos))
{
ReadTecplotFEBlockZone(datFile,line);
}
}
datFile.close();
}
void Nektar::Utilities::InputDat::ReadTecplotFEBlockZone ( std::ifstream &  datFile,
string &  line 
)
private

Definition at line 149 of file InputDat.cpp.

References ASSERTL0, and Nektar::Utilities::Module::m_f.

Referenced by Process().

{
ASSERTL0(line.find("FEBlock") != string::npos,
"Routine only set up for FEBLock format");
ASSERTL0(line.find("ET") != string::npos,
"Routine only set up TRIANLES");
// read the number of nodes
stringstream s;
string tag;
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());
// 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());
// set-up or extend m_pts array;
int norigpts = m_f->m_fieldPts->m_pts[0].num_elements();
int totfields = m_f->m_fieldPts->m_pts.num_elements();
Array<OneD, Array<OneD, NekDouble> > origpts(totfields);
for(int i = 0; i < totfields; ++i)
{
origpts[i] = m_f->m_fieldPts->m_pts[i];
m_f->m_fieldPts->m_pts[i] =
Array<OneD, NekDouble>(norigpts + nvert);
}
NekDouble value;
for(int n = 0; n < totfields; ++n)
{
for(int i = 0; i < norigpts; ++i)
{
m_f->m_fieldPts->m_pts[n][i] = origpts[n][i];
}
for(int i = 0; i < nvert; ++i)
{
datFile >> value;
m_f->m_fieldPts->m_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)
{
datFile >> intvalue;
intvalue -=1; // decrement intvalue by 1 for c array convention
conn[i] = norigpts + intvalue;
}
m_f->m_fieldPts->m_ptsConn.push_back(conn);
getline(datFile, line);
}

Member Data Documentation

ModuleKey Nektar::Utilities::InputDat::m_className
static
Initial value:
{
"Reads Tecplot dat file for FE block triangular format."),
}

ModuleKey for class.

Definition at line 60 of file InputDat.h.