Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::OutputInfo Class Reference

#include <OutputInfo.h>

Inheritance diagram for Nektar::FieldUtils::OutputInfo:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::OutputInfo:
Collaboration graph
[legend]

Public Member Functions

 OutputInfo (FieldSharedPtr f)
 
virtual ~OutputInfo ()
 
virtual void Process (po::variables_map &vm)
 Write fld to output file. More...
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputModule
 OutputModule (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, 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 bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey m_className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

Definition at line 47 of file OutputInfo.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::OutputInfo::OutputInfo ( FieldSharedPtr  f)

Definition at line 56 of file OutputInfo.cpp.

56  : OutputModule(f)
57 {
58 }
Nektar::FieldUtils::OutputInfo::~OutputInfo ( )
virtual

Definition at line 60 of file OutputInfo.cpp.

61 {
62 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::FieldUtils::OutputInfo::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file OutputInfo.h.

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

52  {
54  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::OutputInfo::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 63 of file OutputInfo.h.

64  {
65  return "OutputInfo";
66  }
void Nektar::FieldUtils::OutputInfo::Process ( po::variables_map &  vm)
virtual

Write fld to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file OutputInfo.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), CellMLToNektar.pycml::format, Nektar::LibUtilities::GetCommFactory(), Nektar::LibUtilities::GetFieldIOFactory(), Nektar::LibUtilities::GetMeshPartitionFactory(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, and Nektar::LibUtilities::FieldIOXml::WriteMultiFldFileIDs().

65 {
66  // Extract the output filename and extension
67  string filename = m_config["outfile"].as<string>();
68  int i;
69 
70  if (m_f->m_verbose)
71  {
72  cout << "OutputInfo: Writing Info file..." << endl;
73  }
74 
75  // partition mesh
76  ASSERTL0(vm.count("nprocs") > 0,
77  "--nprocs nust be specified with info output");
78 
79  int nprocs = vm["nprocs"].as<int>();
80 
81  LibUtilities::CommSharedPtr vComm = boost::shared_ptr<FieldConvertComm>(
82  new FieldConvertComm(0, NULL, nprocs, 0));
83  vComm->SplitComm(1, nprocs);
84 
85  // define new session with psuedo parallel communicator
86  string xml_ending = "xml";
87  string xml_gz_ending = "xml.gz";
88 
89  std::vector<std::string> files;
90  // load .xml ending
91  for (int i = 0; i < m_f->m_inputfiles[xml_ending].size(); ++i)
92  {
93  files.push_back(m_f->m_inputfiles[xml_ending][i]);
94  }
95 
96  // load any .xml.gz endings
97  for (int j = 0; j < m_f->m_inputfiles[xml_gz_ending].size(); ++j)
98  {
99  files.push_back(m_f->m_inputfiles[xml_gz_ending][j]);
100  }
101 
103  boost::shared_ptr<LibUtilities::SessionReader>(
104  new LibUtilities::SessionReader(0, 0, files, vComm));
105  vSession->SetUpXmlDoc();
106 
107  // Default partitioner to use is Metis. Use Scotch as default
108  // if it is installed. Override default with command-line flags
109  // if they are set.
110  string vPartitionerName = "Metis";
111  if (LibUtilities::GetMeshPartitionFactory().ModuleExists("Scotch"))
112  {
113  vPartitionerName = "Scotch";
114  }
115  if (vSession->DefinesCmdLineArgument("use-metis"))
116  {
117  vPartitionerName = "Metis";
118  }
119  if (vSession->DefinesCmdLineArgument("use-scotch"))
120  {
121  vPartitionerName = "Scotch";
122  }
123 
124  LibUtilities::MeshPartitionSharedPtr vMeshPartition =
126  vSession);
127 
128  vMeshPartition->PartitionMesh(nprocs, true);
129 
130  // get hold of local partition ids
131  std::vector<std::vector<unsigned int> > ElementIDs(nprocs);
132 
133  // Populate the list of element ID lists from all processes
134  for (i = 0; i < nprocs; ++i)
135  {
136  std::vector<unsigned int> tmp;
137  vMeshPartition->GetElementIDs(i, tmp);
138  ElementIDs[i] = tmp;
139  }
140 
141  // Set up output names
142  std::vector<std::string> filenames;
143  for (int i = 0; i < nprocs; ++i)
144  {
145  boost::format pad("P%1$07d.fld");
146  pad % i;
147  filenames.push_back(pad.str());
148  }
149 
150  // Write the output file
151  LibUtilities::CommSharedPtr c = m_f->m_session ? m_f->m_session->GetComm() :
153  boost::shared_ptr<LibUtilities::FieldIOXml> fldXml =
154  boost::static_pointer_cast<LibUtilities::FieldIOXml>(
156  fldXml->WriteMultiFldFileIDs(filename, filenames, ElementIDs);
157 }
map< string, ConfigOption > m_config
List of configuration values.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
boost::shared_ptr< MeshPartition > MeshPartitionSharedPtr
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
Definition: FieldIO.cpp:74
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
CommFactory & GetCommFactory()
Definition: Comm.cpp:61
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
MeshPartitionFactory & GetMeshPartitionFactory()
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::OutputInfo::m_className
static
Initial value:

Definition at line 55 of file OutputInfo.h.