Nektar++
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. More...
 
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. More...
 
- 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. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
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. More...
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey m_className []
 ModuleKey for class. More...
 

Private Member Functions

void ReadTecplotFEBlockZone (std::ifstream &datFile, string &line, Array< OneD, Array< OneD, NekDouble > > &pts, vector< Array< OneD, int > > &ptsConn)
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::InputModule
void PrintSummary ()
 Print summary of elements. More...
 
void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
 
std::ifstream m_mshFile
 Input stream. More...
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 

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 63 of file InputDat.cpp.

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

63  : InputModule(f)
64 {
65  m_allowedFiles.insert("dat");
66 }
Nektar::Utilities::InputDat::~InputDat ( )
virtual

Definition at line 72 of file InputDat.cpp.

73 {
74 }

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.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

56  {
58  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::InputDat::Process ( po::variables_map &  vm)
virtual

Implements Nektar::Utilities::Module.

Definition at line 80 of file InputDat.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::ePtsTriBlock, Nektar::ParseUtils::GenerateOrderedStringVector(), Nektar::Utilities::Module::m_f, and ReadTecplotFEBlockZone().

81 {
82 
83  if(m_f->m_verbose)
84  {
85  cout << "Processing input dat file" << endl;
86  }
87 
88  string line, word, tag;
89  std::ifstream datFile;
90  stringstream s;
91 
92  // Open the file stream.
93  string fname = m_f->m_inputfiles["dat"][0];
94 
95 
96  datFile.open(fname.c_str());
97  if (!datFile.good())
98  {
99  cerr << "Error opening file: " << fname << endl;
100  abort();
101  }
102 
103  // read variables
104  // currently assum there are x y and z coordinates
105  int dim = 3;
106  vector<string> fieldNames;
107  while (!datFile.eof())
108  {
109  getline(datFile, line);
110 
111  if(line.find("VARIABLES") != string::npos)
112  {
113  std::size_t pos = line.find('=');
114  pos++;
115 
116  // note this expects a comma separated list but
117  // does not work for white space separated lists!
119  line.substr(pos).c_str(), fieldNames);
120  ASSERTL0(valid,"Unable to process list of field variable in "
121  " VARIABLES list: "+ line.substr(pos));
122 
123  // remove coordinates from fieldNames
124  fieldNames.erase(fieldNames.begin(), fieldNames.begin() + dim);
125 
126  break;
127  }
128  }
129 
130  // set up basic parameters
131  int nfields = fieldNames.size();
132  int totvars = dim + nfields;
133  Array<OneD, Array<OneD, NekDouble> > pts(totvars);
134  vector<Array<OneD, int> > ptsConn;
135 
136  // read zones
137  while (!datFile.eof())
138  {
139  getline(datFile, line);
140 
141  if((line.find("ZONE") != string::npos)||
142  (line.find("Zone") != string::npos)||
143  (line.find("zone") != string::npos))
144  {
145  ReadTecplotFEBlockZone(datFile, line, pts, ptsConn);
146  }
147  }
148 
149  datFile.close();
150 
151  m_f->m_fieldPts =
153  dim, fieldNames, pts);
154  m_f->m_fieldPts->SetPtsType(LibUtilities::ePtsTriBlock);
155  m_f->m_fieldPts->SetConnectivity(ptsConn);
156 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static bool GenerateOrderedStringVector(const char *const str, std::vector< std::string > &vec)
Definition: ParseUtils.hpp:142
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
FieldSharedPtr m_f
Field object.
void ReadTecplotFEBlockZone(std::ifstream &datFile, string &line, Array< OneD, Array< OneD, NekDouble > > &pts, vector< Array< OneD, int > > &ptsConn)
Definition: InputDat.cpp:162
void Nektar::Utilities::InputDat::ReadTecplotFEBlockZone ( std::ifstream &  datFile,
string &  line,
Array< OneD, Array< OneD, NekDouble > > &  pts,
vector< Array< OneD, int > > &  ptsConn 
)
private

Definition at line 162 of file InputDat.cpp.

References ASSERTL0.

Referenced by Process().

167 {
168  ASSERTL0(line.find("FEBlock") != string::npos,
169  "Routine only set up for FEBLock format");
170  ASSERTL0(line.find("ET") != string::npos,
171  "Routine only set up TRIANLES");
172 
173  // read the number of nodes
174 
175  stringstream s;
176  string tag;
177  int start,end;
178 
179  s.clear();
180  s.str(line);
181  tag = s.str();
182 
183  // read the number of vertices
184  start = tag.find("N=");
185  end = tag.find_first_of(',',start);
186  int nvert = atoi(tag.substr(start+2,end).c_str());
187 
188  // read the number of elements
189  start = tag.find("E=");
190  end = tag.find_first_of(',',start);
191  int nelmt = atoi(tag.substr(start+2,end).c_str());
192 
193  // set-up or extend m_pts array;
194  int norigpts = pts[0].num_elements();
195  int totfields = pts.num_elements();
196  Array<OneD, Array<OneD, NekDouble> > origpts(totfields);
197  for(int i = 0; i < totfields; ++i)
198  {
199  origpts[i] = pts[i];
200  pts[i] = Array<OneD, NekDouble>(norigpts + nvert);
201  }
202 
203  NekDouble value;
204  for(int n = 0; n < totfields; ++n)
205  {
206 
207  for(int i = 0; i < norigpts; ++i)
208  {
209  pts[n][i] = origpts[n][i];
210  }
211  for(int i = 0; i < nvert; ++i)
212  {
213  datFile >> value;
214  pts[n][norigpts+i] = value;
215  }
216  }
217 
218  // read connectivity and add to list
219  int intvalue;
220  Array<OneD, int> conn(3*nelmt);
221  for(int i = 0; i < 3*nelmt; ++i)
222  {
223  datFile >> intvalue;
224  intvalue -=1; // decrement intvalue by 1 for c array convention
225  conn[i] = norigpts + intvalue;
226  }
227  ptsConn.push_back(conn);
228 
229  getline(datFile, line);
230 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
double NekDouble

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.