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. More...
 
virtual ~InputDat ()
 
virtual void Process (po::variables_map &vm)
 
virtual std::string GetModuleName ()
 
- 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 (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
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...
 
virtual void ClearElementLinks ()
 

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 ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::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...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. 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.
virtual std::string Nektar::Utilities::InputDat::GetModuleName ( )
inlinevirtual

Implements Nektar::Utilities::Module.

Definition at line 62 of file InputDat.h.

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

References ASSERTL0.

Referenced by Process().

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