Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.
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.
- 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.

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

Constructor & Destructor Documentation

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

Set up InputXml object.

Definition at line 62 of file InputXml.cpp.

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

{
m_allowedFiles.insert("xml");
m_allowedFiles.insert("xml.gz");
m_allowedFiles.insert("fld"); // these files could be allowed with xml files
m_allowedFiles.insert("chk");
m_allowedFiles.insert("rst");
}
Nektar::Utilities::InputXml::~InputXml ( )
virtual

Definition at line 71 of file InputXml.cpp.

{
}

Member Function Documentation

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

Creates an instance of this class.

Definition at line 56 of file InputXml.h.

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

Implements Nektar::Utilities::Module.

Definition at line 78 of file InputXml.cpp.

References 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.

{
if(m_f->m_verbose)
{
cout << "Processing input xml file" << endl;
}
// check to see if fld file defined so can use in
// expansion defintion if required
string fldending;
bool fldfilegiven = true;
//Determine appropriate field input
if(m_f->m_inputfiles.count("fld") != 0)
{
fldending = "fld";
}
else if(m_f->m_inputfiles.count("chk") != 0)
{
fldending = "chk";
}
else if (m_f->m_inputfiles.count("rst") != 0)
{
fldending = "rst";
}
else
{
fldfilegiven = false;
}
string xml_ending = "xml";
string xml_gz_ending = "xml.gz";
std::vector<std::string> files;
// load .xml ending
for (int i = 0; i < m_f->m_inputfiles[xml_ending].size(); ++i)
{
files.push_back(m_f->m_inputfiles[xml_ending][i]);
}
// load any .xml.gz endings
for (int j =0; j < m_f->m_inputfiles[xml_gz_ending].size(); ++j)
{
files.push_back(m_f->m_inputfiles[xml_gz_ending][j]);
}
// define range to process output
if(vm.count("range"))
{
vector<NekDouble> values;
vm["range"].as<string>().c_str(), values),
"Failed to interpret range string");
ASSERTL0(values.size() > 1,
"Do not have minimum values of xmin,xmax");
ASSERTL0(values.size() % 2 == 0,
"Do not have an even number of range values");
int nvalues = values.size()/2;
rng->m_doZrange = false;
rng->m_doYrange = false;
rng->m_checkShape = false;
switch(nvalues)
{
case 3:
rng->m_doZrange = true;
rng->m_zmin = values[4];
rng->m_zmax = values[5];
case 2:
rng->m_doYrange = true;
rng->m_ymin = values[2];
rng->m_ymax = values[3];
case 1:
rng->m_doXrange = true;
rng->m_xmin = values[0];
rng->m_xmax = values[1];
break;
default:
ASSERTL0(false,"too many values specfied in range");
}
}
// define range to only take a single shape.
if(vm.count("onlyshape"))
{
{
rng->m_doXrange = false;
rng->m_doYrange = false;
rng->m_doZrange = false;
}
rng->m_checkShape = true;
string shapematch =
boost::to_upper_copy(vm["onlyshape"].as<string>());
int i;
for(i = 0; i < LibUtilities::SIZE_ShapeType; ++i)
{
string shapeval = LibUtilities::ShapeTypeMap[i];
boost::to_upper(shapeval);
if(shapematch.compare(shapeval) == 0)
{
rng->m_shapeType = (LibUtilities::ShapeType)i;
break;
}
}
ASSERTL0(i != LibUtilities::SIZE_ShapeType,
"Failed to find shape type in -onlyshape command line "
"argument");
}
if(m_f->m_verbose)
{
string firstarg = "FieldConvert";
string verbose = "-v";
char **argv;
argv = (char**)malloc(2*sizeof(char*));
argv[0] = (char *)malloc(firstarg.size()*sizeof(char));
argv[1] = (char *)malloc(verbose.size()*sizeof(char));
sprintf(argv[0],"%s",firstarg.c_str());
sprintf(argv[1],"%s",verbose.c_str());
CreateInstance(2, (char **)argv, files, m_f->m_comm);
}
else
{
CreateInstance(0, 0, files, m_f->m_comm);
}
m_f->m_graph = SpatialDomains::MeshGraph::Read(m_f->m_session,rng);
::AllocateSharedPtr(m_f->m_session->GetComm());
// currently load all field (possibly could read data from
// expansion list but it is re-arranged in expansion)
const SpatialDomains::ExpansionMap &expansions = m_f->m_graph->GetExpansions();
// if Range has been speficied it is possible to have a
// partition which is empty so ccheck this and return if
// no elements present.
if(!expansions.size())
{
return;
}
m_f->m_exp.resize(1);
// load fielddef if fld file is defined This gives
// precedence to Homogeneous definition in fld file
int NumHomogeneousDir = 0;
if(fldfilegiven)
{
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],m_f->m_fielddef);
NumHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
//----------------------------------------------
// Set up Expansion information to use mode order from field
m_f->m_graph->SetExpansions(m_f->m_fielddef);
}
else
{
if(m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = m_f->m_session->GetSolverInfo("HOMOGENEOUS");
if((HomoStr == "HOMOGENEOUS1D") || (HomoStr == "Homogeneous1D")
|| (HomoStr == "1D") || (HomoStr == "Homo1D"))
{
NumHomogeneousDir = 1;
}
if((HomoStr == "HOMOGENEOUS2D") || (HomoStr == "Homogeneous2D")
|| (HomoStr == "2D") || (HomoStr == "Homo2D"))
{
NumHomogeneousDir = 2;
}
}
}
// reset expansion defintion to use equispaced points if required.
if(m_requireEquiSpaced) // set up points to be equispaced
{
int nPointsNew = 0;
if(vm.count("output-points"))
{
nPointsNew = vm["output-points"].as<int>();
}
m_f->m_graph->SetExpansionsToEvenlySpacedPoints(nPointsNew);
}
m_f->m_exp[0] = m_f->SetUpFirstExpList(NumHomogeneousDir,fldfilegiven);
}

Member Data Documentation

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

ModuleKey for class.

Definition at line 61 of file InputXml.h.