Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::InputXml Class Reference

#include <InputXml.h>

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

Public Member Functions

 InputXml (FieldSharedPtr f)
 Set up InputXml object. More...
 
virtual ~InputXml ()
 
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...
 

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 49 of file InputXml.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputXml::InputXml ( FieldSharedPtr  f)

Set up InputXml object.

Definition at line 64 of file InputXml.cpp.

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

64  : InputModule(f)
65 {
66  m_allowedFiles.insert("xml");
67  m_allowedFiles.insert("xml.gz");
68  m_allowedFiles.insert("fld"); // these files could be allowed with xml files
69  m_allowedFiles.insert("chk");
70  m_allowedFiles.insert("rst");
71 }
Nektar::Utilities::InputXml::~InputXml ( )
virtual

Definition at line 77 of file InputXml.cpp.

78 {
79 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 57 of file InputXml.h.

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

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

Implements Nektar::Utilities::Module.

Definition at line 85 of file InputXml.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::ParseUtils::GenerateUnOrderedVector(), Nektar::Utilities::Module::m_f, Nektar::Utilities::Module::m_requireEquiSpaced, Nektar::SpatialDomains::NullDomainRangeShPtr, Nektar::SpatialDomains::MeshGraph::Read(), Nektar::LibUtilities::ShapeTypeMap, and Nektar::LibUtilities::SIZE_ShapeType.

86 {
87 
88  if(m_f->m_verbose)
89  {
90  cout << "Processing input xml file" << endl;
91  }
92  // check to see if fld file defined so can use in
93  // expansion defintion if required
94  string fldending;
95  bool fldfilegiven = true;
96 
97  //Determine appropriate field input
98  if(m_f->m_inputfiles.count("fld") != 0)
99  {
100  fldending = "fld";
101  }
102  else if(m_f->m_inputfiles.count("chk") != 0)
103  {
104  fldending = "chk";
105  }
106  else if (m_f->m_inputfiles.count("rst") != 0)
107  {
108  fldending = "rst";
109  }
110  else
111  {
112  fldfilegiven = false;
113  }
114 
115  string xml_ending = "xml";
116  string xml_gz_ending = "xml.gz";
117 
118 
119  std::vector<std::string> files;
120  // load .xml ending
121  for (int i = 0; i < m_f->m_inputfiles[xml_ending].size(); ++i)
122  {
123  files.push_back(m_f->m_inputfiles[xml_ending][i]);
124  }
125 
126  // load any .xml.gz endings
127  for (int j =0; j < m_f->m_inputfiles[xml_gz_ending].size(); ++j)
128  {
129  files.push_back(m_f->m_inputfiles[xml_gz_ending][j]);
130  }
131 
134 
135 
136  // define range to process output
137  if(vm.count("range"))
138  {
139  vector<NekDouble> values;
141  vm["range"].as<string>().c_str(), values),
142  "Failed to interpret range string");
143 
144  ASSERTL0(values.size() > 1,
145  "Do not have minimum values of xmin,xmax");
146  ASSERTL0(values.size() % 2 == 0,
147  "Do not have an even number of range values");
148 
149  int nvalues = values.size()/2;
152 
153  rng->m_doZrange = false;
154  rng->m_doYrange = false;
155  rng->m_checkShape = false;
156 
157  switch(nvalues)
158  {
159  case 3:
160  rng->m_doZrange = true;
161  rng->m_zmin = values[4];
162  rng->m_zmax = values[5];
163  case 2:
164  rng->m_doYrange = true;
165  rng->m_ymin = values[2];
166  rng->m_ymax = values[3];
167  case 1:
168  rng->m_doXrange = true;
169  rng->m_xmin = values[0];
170  rng->m_xmax = values[1];
171  break;
172  default:
173  ASSERTL0(false,"too many values specfied in range");
174  }
175  }
176 
177  // define range to only take a single shape.
178  if(vm.count("onlyshape"))
179  {
181  {
184  rng->m_doXrange = false;
185  rng->m_doYrange = false;
186  rng->m_doZrange = false;
187  }
188 
189  rng->m_checkShape = true;
190 
191  string shapematch =
192  boost::to_upper_copy(vm["onlyshape"].as<string>());
193  int i;
194  for(i = 0; i < LibUtilities::SIZE_ShapeType; ++i)
195  {
196  string shapeval = LibUtilities::ShapeTypeMap[i];
197  boost::to_upper(shapeval);
198  if(shapematch.compare(shapeval) == 0)
199  {
200  rng->m_shapeType = (LibUtilities::ShapeType)i;
201  break;
202  }
203  }
204  ASSERTL0(i != LibUtilities::SIZE_ShapeType,
205  "Failed to find shape type in -onlyshape command line "
206  "argument");
207  }
208 
209 
210  if(m_f->m_verbose)
211  {
212  string firstarg = "FieldConvert";
213  string verbose = "-v";
214  char **argv;
215  argv = (char**)malloc(2*sizeof(char*));
216  argv[0] = (char *)malloc(firstarg.size()*sizeof(char));
217  argv[1] = (char *)malloc(verbose.size()*sizeof(char));
218 
219  sprintf(argv[0],"%s",firstarg.c_str());
220  sprintf(argv[1],"%s",verbose.c_str());
221 
223  CreateInstance(2, (char **)argv, files, m_f->m_comm);
224  }
225  else
226  {
228  CreateInstance(0, 0, files, m_f->m_comm);
229  }
230 
231  m_f->m_graph = SpatialDomains::MeshGraph::Read(m_f->m_session,rng);
233  ::AllocateSharedPtr(m_f->m_session->GetComm());
234 
235  // currently load all field (possibly could read data from
236  // expansion list but it is re-arranged in expansion)
237  const SpatialDomains::ExpansionMap &expansions = m_f->m_graph->GetExpansions();
238 
239  // if Range has been speficied it is possible to have a
240  // partition which is empty so ccheck this and return if
241  // no elements present.
242  if(!expansions.size())
243  {
244  return;
245  }
246 
247  m_f->m_exp.resize(1);
248 
249  // load fielddef if fld file is defined This gives
250  // precedence to Homogeneous definition in fld file
251  int NumHomogeneousDir = 0;
252  if(fldfilegiven)
253  {
254  m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],m_f->m_fielddef);
255  NumHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
256 
257  //----------------------------------------------
258  // Set up Expansion information to use mode order from field
259  m_f->m_graph->SetExpansions(m_f->m_fielddef);
260  }
261  else
262  {
263  if(m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
264  {
265  std::string HomoStr = m_f->m_session->GetSolverInfo("HOMOGENEOUS");
266 
267  if((HomoStr == "HOMOGENEOUS1D") || (HomoStr == "Homogeneous1D")
268  || (HomoStr == "1D") || (HomoStr == "Homo1D"))
269  {
270  NumHomogeneousDir = 1;
271  }
272  if((HomoStr == "HOMOGENEOUS2D") || (HomoStr == "Homogeneous2D")
273  || (HomoStr == "2D") || (HomoStr == "Homo2D"))
274  {
275  NumHomogeneousDir = 2;
276  }
277  }
278  }
279 
280  // reset expansion defintion to use equispaced points if required.
281  if(m_requireEquiSpaced) // set up points to be equispaced
282  {
283  int nPointsNew = 0;
284 
285  if(vm.count("output-points"))
286  {
287  nPointsNew = vm["output-points"].as<int>();
288  }
289 
290 
291  m_f->m_graph->SetExpansionsToEvenlySpacedPoints(nPointsNew);
292  }
293 
294  m_f->m_exp[0] = m_f->SetUpFirstExpList(NumHomogeneousDir,fldfilegiven);
295 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:119
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
FieldSharedPtr m_f
Field object.
const char *const ShapeTypeMap[]
Definition: ShapeType.hpp:66
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
boost::shared_ptr< DomainRange > DomainRangeShPtr
Definition: MeshGraph.h:154
static DomainRangeShPtr NullDomainRangeShPtr
Definition: MeshGraph.h:155
static bool GenerateUnOrderedVector(const char *const str, std::vector< NekDouble > &vec)
Definition: ParseUtils.hpp:127
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:171

Member Data Documentation

ModuleKey Nektar::Utilities::InputXml::m_className
static
Initial value:

ModuleKey for class.

Definition at line 62 of file InputXml.h.