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 ()
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::OutputFileBase
 OutputFileBase (FieldSharedPtr f)
 
virtual ~OutputFileBase ()
 
virtual void Process (po::variables_map &vm)
 Write fld to output file. More...
 
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)
 
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 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 OutputFromPts (po::variables_map &vm)
 Write from pts to output file. More...
 
virtual void OutputFromExp (po::variables_map &vm)
 Write from m_exp to output file. More...
 
virtual void OutputFromData (po::variables_map &vm)
 Write from data to output file. More...
 
virtual fs::path GetPath (std::string &filename, po::variables_map &vm)
 
virtual fs::path GetFullOutName (std::string &filename, po::variables_map &vm)
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 

Private Member Functions

std::string GetIOFormat ()
 

Additional Inherited Members

- 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
FieldSharedPtr m_f
 Field object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. 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.

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

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

◆ ~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.

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

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

◆ GetFullOutName()

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

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 150 of file OutputFld.cpp.

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

Referenced by GetModuleName().

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

◆ GetIOFormat()

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

Definition at line 174 of file OutputFld.cpp.

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

Referenced by GetModuleName(), OutputFromData(), and OutputFromExp().

175 {
176  std::string iofmt("Xml");
177  if(m_f->m_session)
178  {
179  if (m_f->m_session->DefinesSolverInfo("IOFormat"))
180  {
181  iofmt = m_f->m_session->GetSolverInfo("IOFormat");
182  }
183  if (m_f->m_session->DefinesCmdLineArgument("io-format"))
184  {
185  iofmt =
186  m_f->m_session->GetCmdLineArgument<std::string>("io-format");
187  }
188  }
189  if(m_config["format"].m_beenSet)
190  {
191  iofmt = m_config["format"].as<string>();
192  }
193  return iofmt;
194 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.

◆ GetModuleName()

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

Reimplemented from Nektar::FieldUtils::OutputFileBase.

Definition at line 60 of file OutputFld.h.

References GetFullOutName(), GetIOFormat(), GetPath(), OutputFromData(), OutputFromExp(), and OutputFromPts().

61  {
62  return "OutputFld";
63  }

◆ GetPath()

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

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 143 of file OutputFld.cpp.

Referenced by GetModuleName().

145 {
146  boost::ignore_unused(vm);
147  return fs::path(filename);
148 }

◆ OutputFromData()

void Nektar::FieldUtils::OutputFld::OutputFromData ( po::variables_map &  vm)
protectedvirtual

Write from data to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 128 of file OutputFld.cpp.

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

Referenced by GetModuleName().

129 {
130  boost::ignore_unused(vm);
131 
132  // Extract the output filename and extension
133  string filename = m_config["outfile"].as<string>();
134  // Set up FieldIO object.
137  GetIOFormat(), m_f->m_comm, true);
138 
139  fld->Write(filename, m_f->m_fielddef, m_f->m_data,
140  m_f->m_fieldMetaDataMap);
141 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
Definition: FieldIO.cpp:72
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:306
FieldSharedPtr m_f
Field object.

◆ OutputFromExp()

void Nektar::FieldUtils::OutputFld::OutputFromExp ( po::variables_map &  vm)
protectedvirtual

Write from m_exp to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 77 of file OutputFld.cpp.

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

Referenced by GetModuleName().

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

◆ OutputFromPts()

void Nektar::FieldUtils::OutputFld::OutputFromPts ( po::variables_map &  vm)
protectedvirtual

Write from pts to output file.

Implements Nektar::FieldUtils::OutputFileBase.

Definition at line 70 of file OutputFld.cpp.

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

Referenced by GetModuleName().

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

Member Data Documentation

◆ m_className

ModuleKey Nektar::FieldUtils::OutputFld::m_className
static
Initial value:

Definition at line 55 of file OutputFld.h.