Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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 ()
 
- 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
 
void Process (po::variables_map &vm)
 
std::string GetModuleName ()
 
std::string GetModuleDescription ()
 
const ConfigOptionGetConfigOption (const std::string &key) const
 
ModulePriority GetModulePriority ()
 
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
 

Protected Member Functions

virtual void v_Process (po::variables_map &vm) override
 Write fld to output file. More...
 
virtual std::string v_GetModuleName () override
 
virtual std::string v_GetModuleDescription () override
 
virtual ModulePriority v_GetModulePriority () override
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- 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 56 of file OutputInfo.cpp.

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

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

◆ ~OutputInfo()

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

Definition at line 63 of file OutputInfo.cpp.

64 {
65 }

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().

◆ v_GetModuleDescription()

virtual std::string Nektar::FieldUtils::OutputInfo::v_GetModuleDescription ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 68 of file OutputInfo.h.

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

◆ v_GetModuleName()

virtual std::string Nektar::FieldUtils::OutputInfo::v_GetModuleName ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 63 of file OutputInfo.h.

64  {
65  return "OutputInfo";
66  }

◆ v_GetModulePriority()

virtual ModulePriority Nektar::FieldUtils::OutputInfo::v_GetModulePriority ( )
inlineoverrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 73 of file OutputInfo.h.

74  {
75  return eOutput;
76  }

References Nektar::FieldUtils::eOutput.

◆ v_Process()

void Nektar::FieldUtils::OutputInfo::v_Process ( po::variables_map &  vm)
overrideprotectedvirtual

Write fld to output file.

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 67 of file OutputInfo.cpp.

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

Definition at line 54 of file OutputInfo.h.