Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | List of all members
Nektar::FieldUtils::OutputFld Class Reference

Output to fld format. More...

#include <OutputFld.h>

Inheritance diagram for Nektar::FieldUtils::OutputFld:
[legend]

Public Member Functions

 OutputFld (FieldSharedPtr f)
 
virtual ~OutputFld ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
virtual ~OutputFileBase ()
 
- 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 std::string v_GetModuleName () override
 
virtual void v_OutputFromPts (po::variables_map &vm) override
 Write from pts to output file. More...
 
virtual void v_OutputFromExp (po::variables_map &vm) override
 Write from m_exp to output file. More...
 
virtual void v_OutputFromData (po::variables_map &vm) override
 Write from data to output file. More...
 
virtual fs::path v_GetPath (std::string &filename, po::variables_map &vm) override
 
virtual fs::path v_GetFullOutName (std::string &filename, po::variables_map &vm) override
 
- Protected Member Functions inherited from Nektar::FieldUtils::OutputFileBase
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
 
virtual void v_OutputFromPts (po::variables_map &vm)=0
 Write from pts to output file. More...
 
virtual void v_OutputFromExp (po::variables_map &vm)=0
 Write from m_exp to output file. More...
 
virtual void v_OutputFromData (po::variables_map &vm)=0
 Write from data to output file. More...
 
virtual fs::path v_GetPath (std::string &filename, po::variables_map &vm)
 
fs::path GetPath (std::string &filename, po::variables_map &vm)
 
virtual fs::path v_GetFullOutName (std::string &filename, po::variables_map &vm)
 
fs::path GetFullOutName (std::string &filename, po::variables_map &vm)
 
- 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 ()
 

Private Member Functions

std::string GetIOFormat ()
 

Additional Inherited Members

- Public Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputFileBase
bool m_requireEquiSpaced
 
- 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

Output to fld format.

Definition at line 47 of file OutputFld.h.

Constructor & Destructor Documentation

◆ OutputFld()

Nektar::FieldUtils::OutputFld::OutputFld ( FieldSharedPtr  f)

Definition at line 60 of file OutputFld.cpp.

61{
62 m_config["format"] =
63 ConfigOption(false, "Xml", "Output format of field file");
64}
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:263

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

◆ ~OutputFld()

Nektar::FieldUtils::OutputFld::~OutputFld ( )
virtual

Definition at line 66 of file OutputFld.cpp.

67{
68}

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 51 of file OutputFld.h.

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

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

◆ GetIOFormat()

std::string Nektar::FieldUtils::OutputFld::GetIOFormat ( )
private

Definition at line 171 of file OutputFld.cpp.

172{
173 std::string iofmt("Xml");
174 if (m_f->m_session)
175 {
176 if (m_f->m_session->DefinesSolverInfo("IOFormat"))
177 {
178 iofmt = m_f->m_session->GetSolverInfo("IOFormat");
179 }
180 if (m_f->m_session->DefinesCmdLineArgument("io-format"))
181 {
182 iofmt =
183 m_f->m_session->GetCmdLineArgument<std::string>("io-format");
184 }
185 }
186 if (m_config["format"].m_beenSet)
187 {
188 iofmt = m_config["format"].as<string>();
189 }
190 return iofmt;
191}
FieldSharedPtr m_f
Field object.
Definition: Module.h:234

References Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::Module::m_f.

Referenced by v_OutputFromData(), and v_OutputFromExp().

◆ v_GetFullOutName()

fs::path Nektar::FieldUtils::OutputFld::v_GetFullOutName ( std::string &  filename,
po::variables_map &  vm 
)
overrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 147 of file OutputFld.cpp.

149{
150 boost::ignore_unused(vm);
151
152 int nprocs = m_f->m_comm->GetSpaceComm()->GetSize();
153 fs::path specPath(filename), fulloutname;
154 if (nprocs == 1)
155 {
156 fulloutname = specPath;
157 }
158 else
159 {
160 // Guess at filename that might belong to this process.
161 boost::format pad("P%1$07d.%2$s");
162 pad % m_f->m_comm->GetSpaceComm()->GetRank() % "fld";
163
164 // Generate full path name
165 fs::path poutfile(pad.str());
166 fulloutname = specPath / poutfile;
167 }
168 return fulloutname;
169}

References CellMLToNektar.pycml::format, and Nektar::FieldUtils::Module::m_f.

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 61 of file OutputFld.h.

62 {
63 return "OutputFld";
64 }

◆ v_GetPath()

fs::path Nektar::FieldUtils::OutputFld::v_GetPath ( std::string &  filename,
po::variables_map &  vm 
)
overrideprotectedvirtual

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 141 of file OutputFld.cpp.

142{
143 boost::ignore_unused(vm);
144 return fs::path(filename);
145}

◆ v_OutputFromData()

void Nektar::FieldUtils::OutputFld::v_OutputFromData ( po::variables_map &  vm)
overrideprotectedvirtual

Write from data to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 127 of file OutputFld.cpp.

128{
129 boost::ignore_unused(vm);
130
131 // Extract the output filename and extension
132 string filename = m_config["outfile"].as<string>();
133 // Set up FieldIO object.
136 m_f->m_comm, true);
137
138 fld->Write(filename, m_f->m_fielddef, m_f->m_data, m_f->m_fieldMetaDataMap);
139}
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:327
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
Definition: FieldIO.cpp:72

References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetFieldIOFactory(), GetIOFormat(), Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::Module::m_f.

◆ v_OutputFromExp()

void Nektar::FieldUtils::OutputFld::v_OutputFromExp ( po::variables_map &  vm)
overrideprotectedvirtual

Write from m_exp to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 76 of file OutputFld.cpp.

77{
78 boost::ignore_unused(vm);
79 ASSERTL0(m_f->m_variables.size(), "OutputFld: need input data.")
80
81 // Extract the output filename and extension
82 string filename = m_config["outfile"].as<string>();
83
84 // Set up FieldIO object.
85 LibUtilities::FieldIOSharedPtr fld =
86 LibUtilities::GetFieldIOFactory().CreateInstance(GetIOFormat(),
87 m_f->m_comm, true);
88
89 int i, j, s;
90 int nfields = m_f->m_variables.size();
91 int nstrips;
92 m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
93
94 if (m_f->m_exp[0]->GetNumElmts() != 0)
95 {
96 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
97 m_f->m_exp[0]->GetFieldDefinitions();
98 std::vector<std::vector<NekDouble>> FieldData(FieldDef.size());
99 for (s = 0; s < nstrips; ++s)
100 {
101 for (j = 0; j < nfields; ++j)
102 {
103 for (i = 0; i < FieldDef.size() / nstrips; ++i)
104 {
105 int n = s * FieldDef.size() / nstrips + i;
106
107 FieldDef[n]->m_fields.push_back(m_f->m_variables[j]);
108 m_f->m_exp[s * nfields + j]->AppendFieldData(
109 FieldDef[n], FieldData[n],
110 m_f->m_exp[s * nfields + j]->UpdateCoeffs());
111 }
112 }
113 }
114 fld->Write(filename, FieldDef, FieldData, m_f->m_fieldMetaDataMap,
115 false);
116 }
117 else
118 {
119 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
120 std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
121 std::vector<std::vector<NekDouble>> FieldData =
122 std::vector<std::vector<NekDouble>>();
123 fld->Write(filename, FieldDef, FieldData, m_f->m_fieldMetaDataMap);
124 }
125}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetFieldIOFactory(), GetIOFormat(), Nektar::FieldUtils::Module::m_config, and Nektar::FieldUtils::Module::m_f.

◆ v_OutputFromPts()

void Nektar::FieldUtils::OutputFld::v_OutputFromPts ( po::variables_map &  vm)
overrideprotectedvirtual

Write from pts to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 70 of file OutputFld.cpp.

71{
72 boost::ignore_unused(vm);
73 NEKERROR(ErrorUtil::efatal, "OutputFld can't write using Pts information.");
74}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209

References Nektar::ErrorUtil::efatal, and NEKERROR.

Member Data Documentation

◆ m_className

ModuleKey Nektar::FieldUtils::OutputFld::m_className
static
Initial value:
= {
"Writes a Fld file."),
"Writes a Fld file."),
}
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Definition: OutputFld.h:51
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 55 of file OutputFld.h.