Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
Nektar::SolverUtils::FilterCheckpoint Class Reference

#include <FilterCheckpoint.h>

Inheritance diagram for Nektar::SolverUtils::FilterCheckpoint:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SolverUtils::FilterCheckpoint:
Collaboration graph
[legend]

Public Member Functions

SOLVER_UTILS_EXPORT FilterCheckpoint (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
 
virtual SOLVER_UTILS_EXPORT ~FilterCheckpoint ()
 
- Public Member Functions inherited from Nektar::SolverUtils::Filter
SOLVER_UTILS_EXPORT Filter (const LibUtilities::SessionReaderSharedPtr &pSession)
 
virtual SOLVER_UTILS_EXPORT ~Filter ()
 
SOLVER_UTILS_EXPORT void Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT void Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT void Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
SOLVER_UTILS_EXPORT bool IsTimeDependent ()
 

Static Public Member Functions

static FilterSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

virtual void v_Initialise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Update (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual void v_Finalise (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
 
virtual bool v_IsTimeDependent ()
 

Private Attributes

unsigned int m_index
 
unsigned int m_outputIndex
 
unsigned int m_outputFrequency
 
std::string m_outputFile
 
LibUtilities::FieldIOSharedPtr m_fld
 

Friends

class MemoryManager< FilterCheckpoint >
 

Additional Inherited Members

- Public Types inherited from Nektar::SolverUtils::Filter
typedef std::map< std::string,
std::string > 
ParamMap
 
- Protected Attributes inherited from Nektar::SolverUtils::Filter
LibUtilities::SessionReaderSharedPtr m_session
 

Detailed Description

Definition at line 45 of file FilterCheckpoint.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::FilterCheckpoint::FilterCheckpoint ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)

Definition at line 46 of file FilterCheckpoint.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, m_fld, m_index, m_outputFile, m_outputFrequency, m_outputIndex, and Nektar::SolverUtils::Filter::m_session.

48  :
49  Filter(pSession)
50 {
51  ParamMap::const_iterator it;
52 
53  // OutputFile
54  it = pParams.find("OutputFile");
55  if (it == pParams.end())
56  {
57  m_outputFile = m_session->GetSessionName();
58  }
59  else
60  {
61  ASSERTL0(it->second.length() > 0, "Empty parameter 'OutputFile'.");
62  m_outputFile = it->second;
63  }
64 
65  // OutputFrequency
66  ASSERTL0(it != pParams.end(), "Missing parameter 'OutputFrequency'.");
67  LibUtilities::Equation equ(m_session, it->second);
68  m_outputFrequency = floor(equ.Evaluate());
69 
70  m_outputIndex = 0;
71  m_index = 0;
73  ::AllocateSharedPtr(pSession->GetComm());
74 
75 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Filter.cpp:52
LibUtilities::FieldIOSharedPtr m_fld
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
Nektar::SolverUtils::FilterCheckpoint::~FilterCheckpoint ( )
virtual

Definition at line 77 of file FilterCheckpoint.cpp.

78 {
79 
80 }

Member Function Documentation

static FilterSharedPtr Nektar::SolverUtils::FilterCheckpoint::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::map< std::string, std::string > &  pParams 
)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file FilterCheckpoint.h.

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

53  {
55  ::AllocateSharedPtr(pSession, pParams);
56  //p->InitObject();
57  return p;
58  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:50
void Nektar::SolverUtils::FilterCheckpoint::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 123 of file FilterCheckpoint.cpp.

126 {
127 
128 }
void Nektar::SolverUtils::FilterCheckpoint::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 82 of file FilterCheckpoint.cpp.

References m_index, and m_outputIndex.

85 {
86  m_index = 0;
87  m_outputIndex = 0;
88 }
bool Nektar::SolverUtils::FilterCheckpoint::v_IsTimeDependent ( )
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 130 of file FilterCheckpoint.cpp.

131 {
132  return true;
133 }
void Nektar::SolverUtils::FilterCheckpoint::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 90 of file FilterCheckpoint.cpp.

References m_fld, m_index, m_outputFile, m_outputFrequency, m_outputIndex, and Nektar::SolverUtils::Filter::m_session.

93 {
94  m_index++;
95  if (m_index % m_outputFrequency > 0)
96  {
97  return;
98  }
99 
100  std::stringstream vOutputFilename;
101  vOutputFilename << m_outputFile << "_" << m_outputIndex << ".chk";
102 
103  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
104  = pFields[0]->GetFieldDefinitions();
105  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
106 
107  // copy Data into FieldData and set variable
108  for(int j = 0; j < pFields.num_elements(); ++j)
109  {
110  for(int i = 0; i < FieldDef.size(); ++i)
111  {
112  // Could do a search here to find correct variable
113  FieldDef[i]->m_fields.push_back(m_session->GetVariable(j));
114  pFields[0]->AppendFieldData(FieldDef[i],
115  FieldData[i],
116  pFields[j]->UpdateCoeffs());
117  }
118  }
119  m_fld->Write(vOutputFilename.str(),FieldDef,FieldData);
120  m_outputIndex++;
121 }
LibUtilities::FieldIOSharedPtr m_fld
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84

Friends And Related Function Documentation

friend class MemoryManager< FilterCheckpoint >
friend

Definition at line 48 of file FilterCheckpoint.h.

Member Data Documentation

std::string Nektar::SolverUtils::FilterCheckpoint::className
static
Initial value:

Name of the class.

Definition at line 61 of file FilterCheckpoint.h.

LibUtilities::FieldIOSharedPtr Nektar::SolverUtils::FilterCheckpoint::m_fld
private

Definition at line 85 of file FilterCheckpoint.h.

Referenced by FilterCheckpoint(), and v_Update().

unsigned int Nektar::SolverUtils::FilterCheckpoint::m_index
private

Definition at line 81 of file FilterCheckpoint.h.

Referenced by FilterCheckpoint(), v_Initialise(), and v_Update().

std::string Nektar::SolverUtils::FilterCheckpoint::m_outputFile
private

Definition at line 84 of file FilterCheckpoint.h.

Referenced by FilterCheckpoint(), and v_Update().

unsigned int Nektar::SolverUtils::FilterCheckpoint::m_outputFrequency
private

Definition at line 83 of file FilterCheckpoint.h.

Referenced by FilterCheckpoint(), and v_Update().

unsigned int Nektar::SolverUtils::FilterCheckpoint::m_outputIndex
private

Definition at line 82 of file FilterCheckpoint.h.

Referenced by FilterCheckpoint(), v_Initialise(), and v_Update().