Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::OutputPts Class Reference

Converter from fld to pts. More...

#include <OutputPts.h>

Inheritance diagram for Nektar::FieldUtils::OutputPts:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::OutputPts:
Collaboration graph
[legend]

Public Member Functions

 OutputPts (FieldSharedPtr f)
 
virtual ~OutputPts ()
 
virtual void Process (po::variables_map &vm)
 Write fld to output file. More...
 
virtual std::string GetModuleName ()
 
- 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 (string key, 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 bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey m_className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::OutputModule
ofstream m_fldFile
 Output stream. More...
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

Converter from fld to pts.

Definition at line 48 of file OutputPts.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::OutputPts::OutputPts ( FieldSharedPtr  f)

Definition at line 52 of file OutputPts.cpp.

52  : OutputModule(f)
53 {
54 }
Nektar::FieldUtils::OutputPts::~OutputPts ( )
virtual

Definition at line 56 of file OutputPts.cpp.

57 {
58 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::FieldUtils::OutputPts::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 52 of file OutputPts.h.

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

53  {
55  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::OutputPts::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file OutputPts.h.

65  {
66  return "OutputPts";
67  }
void Nektar::FieldUtils::OutputPts::Process ( po::variables_map &  vm)
virtual

Write fld to output file.

Implements Nektar::FieldUtils::Module.

Definition at line 60 of file OutputPts.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CellMLToNektar.enum::answer, Nektar::FieldUtils::Module::m_config, Nektar::FieldUtils::Module::m_f, Nektar::LibUtilities::NullPtsField, Nektar::LibUtilities::ReduceSum, Nektar::LibUtilities::PtsIO::Write(), and CellMLToNektar.CellMLToNektar::writefile().

61 {
62  // Extract the output filename and extension
63  string filename = m_config["outfile"].as<string>();
64 
65  if (m_f->m_verbose)
66  {
67  if (m_f->m_comm->TreatAsRankZero())
68  {
69  cout << "OutputPts: Writing file..." << endl;
70  }
71  }
72 
73  fs::path writefile(filename);
74  int writepts = 1;
75  if (fs::exists(writefile) && (vm.count("forceoutput") == 0))
76  {
77  LibUtilities::CommSharedPtr comm = m_f->m_comm;
78  int rank = comm->GetRank();
79  writepts = 0; // set to zero for reduce all to be correct.
80 
81  if (rank == 0)
82  {
83  string answer;
84  cout << "Did you wish to overwrite " << filename << " (y/n)? ";
85  getline(cin, answer);
86  if (answer.compare("y") == 0)
87  {
88  writepts = 1;
89  }
90  else
91  {
92  cout << "Not writing file " << filename
93  << " because it already exists" << endl;
94  }
95  }
96 
97  comm->AllReduce(writepts, LibUtilities::ReduceSum);
98  }
99 
100  if (writepts)
101  {
102  LibUtilities::PtsIO ptsIO(m_f->m_comm);
103  LibUtilities::PtsFieldSharedPtr fPts = m_f->m_fieldPts;
104  if(m_f->m_fieldPts == LibUtilities::NullPtsField)
105  {
106  Array<OneD, Array<OneD, NekDouble> > tmp(
107  m_f->m_exp[0]->GetCoordim(0) +
108  m_f->m_fielddef[0]->m_fields.size());
109 
110  switch (m_f->m_exp[0]->GetCoordim(0))
111  {
112  case 1:
113  tmp[0] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
114  m_f->m_exp[0]->GetCoords(tmp[0]);
115  break;
116 
117  case 2:
118  tmp[1] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
119  tmp[0] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
120  m_f->m_exp[0]->GetCoords(tmp[0], tmp[1]);
121  break;
122 
123  case 3:
124  tmp[2] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
125  tmp[1] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
126  tmp[0] = Array<OneD, NekDouble>(m_f->m_exp[0]->GetTotPoints());
127  m_f->m_exp[0]->GetCoords(tmp[0], tmp[1], tmp[2]);
128  break;
129  }
130 
131  for (int i = 0; i < m_f->m_fielddef[0]->m_fields.size(); ++i)
132  {
133  tmp[i + m_f->m_exp[0]->GetCoordim(0)] =
134  m_f->m_exp[i]->GetPhys();
135  }
136  fPts =
138  m_f->m_exp[0]->GetCoordim(0),
139  m_f->m_fielddef[0]->m_fields,
140  tmp);
141  }
142  ptsIO.Write(filename, fPts);
143  }
144 }
map< string, ConfigOption > m_config
List of configuration values.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:178
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:179
FieldSharedPtr m_f
Field object.

Member Data Documentation

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

Definition at line 56 of file OutputPts.h.