Nektar++
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::FieldUtils::InputModule Class Reference

Abstract base class for input modules. More...

#include <Module.h>

Inheritance diagram for Nektar::FieldUtils::InputModule:
[legend]

Public Member Functions

 InputModule (FieldSharedPtr p_m)
 
FIELD_UTILS_EXPORT void AddFile (std::string fileType, std::string fileName)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
virtual void Process (po::variables_map &vm)=0
 
virtual std::string GetModuleName ()=0
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()=0
 
FIELD_UTILS_EXPORT void RegisterConfig (std::string key, std::string value="")
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static FIELD_UTILS_EXPORT std::string GuessFormat (std::string fileName)
 Tries to guess the format of the input file. More...
 

Protected Member Functions

void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Protected Attributes

std::set< std::string > m_allowedFiles
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

Abstract base class for input modules.

Input modules should read the contents of #fldFile in the Process() function and populate the members of #m. Typically any given module should populate Mesh::expDim, Mesh::spaceDim, Mesh::node and Mesh::element, then call the protected ProcessX functions to generate edges, faces, etc.

Definition at line 226 of file FieldUtils/Module.h.

Constructor & Destructor Documentation

◆ InputModule()

Nektar::FieldUtils::InputModule::InputModule ( FieldSharedPtr  p_m)

Definition at line 62 of file FieldUtils/Module.cpp.

References Nektar::FieldUtils::Module::m_config.

62  : Module(m)
63 {
64  m_config["infile"] = ConfigOption(false, "", "Input filename.");
65 }
std::map< std::string, ConfigOption > m_config
List of configuration values.

Member Function Documentation

◆ AddFile()

void Nektar::FieldUtils::InputModule::AddFile ( std::string  fileType,
std::string  fileName 
)

Definition at line 72 of file FieldUtils/Module.cpp.

References Nektar::FieldUtils::Module::m_f.

Referenced by main().

73 {
74  // Check to see if this file type is allowed
75  if (m_allowedFiles.count(fileType) == 0)
76  {
77  cerr << "File type " << fileType << " not supported for this "
78  << "module." << endl;
79  }
80 
81  m_f->m_inputfiles[fileType].push_back(fileName);
82 }
std::set< std::string > m_allowedFiles
FieldSharedPtr m_f
Field object.

◆ GuessFormat()

string Nektar::FieldUtils::InputModule::GuessFormat ( std::string  fileName)
static

Tries to guess the format of the input file.

Definition at line 156 of file FieldUtils/Module.cpp.

157 {
158  // Read first 64 bytes of data, assuming input is this long.
159  ifstream inFile(filename.c_str(), ios::binary);
160  vector<char> data(64, 0);
161  inFile.read(&data[0], 64);
162 
163  string check(&data[0], 64);
164 
165  // Nek5000 format: first four characters are: #std
166  if (check.compare(0, 4, "#std") == 0)
167  {
168  inFile.close();
169  return "fld5000";
170  }
171 
172  // Semtex format: first line should contain the string "Session" at
173  // character 27.
174  if (check.compare(26, 7, "Session") == 0)
175  {
176  inFile.close();
177  return "fldsem";
178  }
179 
180  // Otherwise don't really know -- try to guess from file extension.
181  inFile.close();
182  return "";
183 }

◆ PrintSummary()

void Nektar::FieldUtils::InputModule::PrintSummary ( )
protected

Print summary of elements.

Print a brief summary of information.

Definition at line 188 of file FieldUtils/Module.cpp.

References Nektar::FieldUtils::Module::m_f.

189 {
190  cout << "Field size = " << m_f->m_data[0].size() * sizeof(NekDouble)
191  << endl;
192 }
double NekDouble
FieldSharedPtr m_f
Field object.

Member Data Documentation

◆ m_allowedFiles

std::set<std::string> Nektar::FieldUtils::InputModule::m_allowedFiles
protected