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)
 
 ~OutputFld () override
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
 ~OutputFileBase () 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

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

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
 
bool m_prohibitWrite = false
 
bool m_equispacedSetup = false
 
- 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 45 of file OutputFld.h.

Constructor & Destructor Documentation

◆ OutputFld()

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

Definition at line 57 of file OutputFld.cpp.

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

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

◆ ~OutputFld()

Nektar::FieldUtils::OutputFld::~OutputFld ( )
override

Definition at line 63 of file OutputFld.cpp.

64{
65}

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 49 of file OutputFld.h.

50 {
52 }
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 162 of file OutputFld.cpp.

163{
164 std::string iofmt("Xml");
165 if (m_f->m_session)
166 {
167 if (m_f->m_session->DefinesSolverInfo("IOFormat"))
168 {
169 iofmt = m_f->m_session->GetSolverInfo("IOFormat");
170 }
171 if (m_f->m_session->DefinesCmdLineArgument("io-format"))
172 {
173 iofmt =
174 m_f->m_session->GetCmdLineArgument<std::string>("io-format");
175 }
176 }
177 if (m_config["format"].m_beenSet)
178 {
179 iofmt = m_config["format"].as<string>();
180 }
181 return iofmt;
182}
FieldSharedPtr m_f
Field object.
Definition: Module.h:239

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 140 of file OutputFld.cpp.

142{
143 int nprocs = m_f->m_comm->GetSpaceComm()->GetSize();
144 fs::path specPath(filename), fulloutname;
145 if (nprocs == 1)
146 {
147 fulloutname = specPath;
148 }
149 else
150 {
151 // Guess at filename that might belong to this process.
152 boost::format pad("P%1$07d.%2$s");
153 pad % m_f->m_comm->GetSpaceComm()->GetRank() % "fld";
154
155 // Generate full path name
156 fs::path poutfile(pad.str());
157 fulloutname = specPath / poutfile;
158 }
159 return fulloutname;
160}

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

◆ v_GetModuleName()

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

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 59 of file OutputFld.h.

60 {
61 return "OutputFld";
62 }

◆ 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 134 of file OutputFld.cpp.

136{
137 return fs::path(filename);
138}

◆ 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 122 of file OutputFld.cpp.

123{
124 // Extract the output filename and extension
125 string filename = m_config["outfile"].as<string>();
126 // Set up FieldIO object.
129 m_f->m_comm, true);
130
131 fld->Write(filename, m_f->m_fielddef, m_f->m_data, m_f->m_fieldMetaDataMap);
132}
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:322
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
Definition: FieldIO.cpp:70

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 72 of file OutputFld.cpp.

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

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 67 of file OutputFld.cpp.

68{
69 NEKERROR(ErrorUtil::efatal, "OutputFld can't write using Pts information.");
70}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

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

Definition at line 53 of file OutputFld.h.