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)
 
 ~OutputInfo () override
 
- 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 ()
 
std::vector< ModuleKeyGetModulePrerequisites ()
 
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

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

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 44 of file OutputInfo.h.

Constructor & Destructor Documentation

◆ OutputInfo()

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

Definition at line 53 of file OutputInfo.cpp.

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

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

◆ ~OutputInfo()

Nektar::FieldUtils::OutputInfo::~OutputInfo ( )
override

Definition at line 60 of file OutputInfo.cpp.

61{
62}

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

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

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

◆ v_GetModuleDescription()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 66 of file OutputInfo.h.

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

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 61 of file OutputInfo.h.

62 {
63 return "OutputInfo";
64 }

◆ v_GetModulePriority()

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

Reimplemented from Nektar::FieldUtils::Module.

Definition at line 71 of file OutputInfo.h.

72 {
73 return eOutput;
74 }

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 64 of file OutputInfo.cpp.

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

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:48
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47

Definition at line 52 of file OutputInfo.h.