Nektar++
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:
[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 ()
 
virtual std::string GetModuleDescription ()
 
virtual ModulePriority GetModulePriority ()
 
- 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)
 
virtual ~Module ()=default
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
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 AddFile (std::string fileType, std::string fileName)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

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

Static Public Attributes

static ModuleKey m_className
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
std::ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 
std::set< std::string > m_allowedFiles
 List of allowed file formats. More...
 

Detailed Description

Definition at line 46 of file OutputInfo.h.

Constructor & Destructor Documentation

◆ OutputInfo()

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

Definition at line 57 of file OutputInfo.cpp.

57  : OutputModule(f)
58 {
59  m_config["nparts"] = ConfigOption(
60  false, "NotSet",
61  "Number of partitions over which to create the info file");
62 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:233
OutputModule(FieldSharedPtr p_f)
Definition: Module.cpp:68

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

◆ ~OutputInfo()

Nektar::FieldUtils::OutputInfo::~OutputInfo ( )
virtual

Definition at line 64 of file OutputInfo.cpp.

65 {
66 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 50 of file OutputInfo.h.

51  {
53  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

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

◆ GetModuleDescription()

virtual std::string Nektar::FieldUtils::OutputInfo::GetModuleDescription ( )
inlinevirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 67 of file OutputInfo.h.

68  {
69  return "Writing Info file";
70  }

◆ GetModuleName()

virtual std::string Nektar::FieldUtils::OutputInfo::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 62 of file OutputInfo.h.

63  {
64  return "OutputInfo";
65  }

◆ GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::OutputInfo::GetModulePriority ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 72 of file OutputInfo.h.

73  {
74  return eOutput;
75  }

References Nektar::FieldUtils::eOutput.

◆ Process()

void Nektar::FieldUtils::OutputInfo::Process ( po::variables_map &  vm)
virtual

Write fld to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 68 of file OutputInfo.cpp.

69 {
70  boost::ignore_unused(vm);
71 
72  // Extract the output filename and extension
73  string filename = m_config["outfile"].as<string>();
74 
75  // partition mesh
76  ASSERTL0(m_config["nparts"].as<string>().compare("NotSet") != 0,
77  "Need to specify nparts for info output");
78  int nparts = m_config["nparts"].as<int>();
79 
80  // Input/output file
81  LibUtilities::CommSharedPtr c = m_f->m_comm;
82  std::shared_ptr<LibUtilities::FieldIOXml> fldXml =
83  std::static_pointer_cast<LibUtilities::FieldIOXml>(
84  LibUtilities::GetFieldIOFactory().CreateInstance("Xml", c, true));
85 
86  // open file and setup meta data.
87  fs::path pinfilename(filename);
88  std::vector<std::string> filenames;
89  std::vector<std::vector<unsigned int> > ElementIDs;
90 
91  for (int p = 0; p < nparts; ++p)
92  {
93  boost::format pad("P%1$07d.%2$s");
94  pad % p % "fld";
95  std::string s = pad.str();
96 
97  fs::path fullpath = pinfilename / s;
98  string fname = LibUtilities::PortablePath(fullpath);
99  if(!fs::exists(fname))
100  {
101  continue;
102  }
105 
106  std::vector<LibUtilities::FieldDefinitionsSharedPtr> fielddefs;
107  std::vector<unsigned int> PartElmtIDs;
108 
109  // read in header of partition if it exists
110  fldXml->ImportFieldDefs(dataSource,fielddefs,false);
111 
112  // create ElmenetIDs list then use
113  for(int i = 0; i < fielddefs.size(); ++i)
114  {
115  for(int j = 0; j < fielddefs[i]->m_elementIDs.size(); ++j)
116  {
117  PartElmtIDs.push_back(fielddefs[i]->m_elementIDs[j]);
118  }
119  }
120 
121  ElementIDs.push_back(PartElmtIDs);
122  filenames.push_back(s);
123  }
124 
125  // Write the Info.xml file
126  string infofile =
127  LibUtilities::PortablePath(pinfilename / fs::path("Info.xml"));
128 
129  fldXml->WriteMultiFldFileIDs(infofile,filenames, ElementIDs);
130 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
FieldSharedPtr m_f
Field object.
Definition: Module.h:230
static DataSourceSharedPtr create(const std::string &fn)
Create a new XML data source based on the filename.
Definition: FieldIOXml.h:92
std::shared_ptr< DataSource > DataSourceSharedPtr
Definition: FieldIO.h:79
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
Definition: FileSystem.cpp:41
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
Definition: FieldIO.cpp:72
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54

References ASSERTL0, Nektar::LibUtilities::XmlDataSource::create(), CellMLToNektar.pycml::format, Nektar::LibUtilities::GetFieldIOFactory(), Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, CellMLToNektar.cellml_metadata::p, and Nektar::LibUtilities::PortablePath().

Member Data Documentation

◆ m_className

ModuleKey Nektar::FieldUtils::OutputInfo::m_className
static
Initial value:
=
"Writes an Info file.")
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: OutputInfo.h:50
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:290
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49

Definition at line 54 of file OutputInfo.h.