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::FilterCheckpointCellModel Class Reference

#include <FilterCheckpointCellModel.h>

Inheritance diagram for Nektar::FilterCheckpointCellModel:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FilterCheckpointCellModel:
Collaboration graph
[legend]

Public Member Functions

 FilterCheckpointCellModel (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
 
 ~FilterCheckpointCellModel ()
 
void SetCellModel (CellModelSharedPtr &pCellModel)
 
- 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 SolverUtils::FilterSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &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
 
CellModelSharedPtr m_cell
 
LibUtilities::FieldIOSharedPtr m_fld
 

Friends

class MemoryManager< FilterCheckpointCellModel >
 

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 FilterCheckpointCellModel.h.

Constructor & Destructor Documentation

Nektar::FilterCheckpointCellModel::FilterCheckpointCellModel ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)

Definition at line 44 of file FilterCheckpointCellModel.cpp.

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

46  :
47  Filter(pSession)
48 {
49  ParamMap::const_iterator it;
50 
51  // OutputFile
52  it = pParams.find("OutputFile");
53  if (it == pParams.end())
54  {
55  m_outputFile = m_session->GetSessionName();
56  }
57  else
58  {
59  ASSERTL0(it->second.length() > 0, "Missing parameter 'OutputFile'.");
60  m_outputFile = it->second;
61  }
62 
63  // OutputFrequency
64  it = pParams.find("OutputFrequency");
65  ASSERTL0(it != pParams.end(), "Missing parameter 'OutputFrequency'.");
66  LibUtilities::Equation equ(m_session, it->second);
67  m_outputFrequency = floor(equ.Evaluate());
68 
69  m_outputIndex = 0;
70  m_index = 0;
73 
74 }
LibUtilities::FieldIOSharedPtr m_fld
#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::SessionReaderSharedPtr m_session
Definition: Filter.h:84
Nektar::FilterCheckpointCellModel::~FilterCheckpointCellModel ( )

Definition at line 76 of file FilterCheckpointCellModel.cpp.

77 {
78 
79 }

Member Function Documentation

static SolverUtils::FilterSharedPtr Nektar::FilterCheckpointCellModel::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const ParamMap pParams 
)
inlinestatic

Creates an instance of this class.

Definition at line 51 of file FilterCheckpointCellModel.h.

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

53  {
56  ::AllocateSharedPtr(pSession, pParams);
57  //p->InitObject();
58  return p;
59  }
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::FilterCheckpointCellModel::SetCellModel ( CellModelSharedPtr pCellModel)
inline
void Nektar::FilterCheckpointCellModel::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 137 of file FilterCheckpointCellModel.cpp.

140 {
141 
142 }
void Nektar::FilterCheckpointCellModel::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 81 of file FilterCheckpointCellModel.cpp.

References ASSERTL0, m_cell, m_index, m_outputIndex, and v_Update().

84 {
85  ASSERTL0(m_cell.get(), "Cell model has not been set by EquationSystem "
86  "class. Use SetCellModel on this filter to achieve this.");
87 
88  m_index = 0;
89  m_outputIndex = 0;
90 
91  v_Update(pFields, 0.0);
92 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
bool Nektar::FilterCheckpointCellModel::v_IsTimeDependent ( )
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 144 of file FilterCheckpointCellModel.cpp.

145 {
146  return true;
147 }
void Nektar::FilterCheckpointCellModel::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 94 of file FilterCheckpointCellModel.cpp.

References m_cell, m_fld, m_index, m_outputFile, m_outputFrequency, and m_outputIndex.

Referenced by v_Initialise().

97 {
98  if (m_index++ % m_outputFrequency > 0)
99  {
100  return;
101  }
102 
103  std::stringstream vOutputFilename;
104  vOutputFilename << m_outputFile << "_" << m_outputIndex << ".chk";
105 
106  SpatialDomains::MeshGraphSharedPtr vGraph = pFields[0]->GetGraph();
107 
108  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
109  = pFields[0]->GetFieldDefinitions();
110  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
111 
112  // copy Data into FieldData and set variable
113  std::string varName;
114  for(int j = 1; j < m_cell->GetNumCellVariables(); ++j)
115  {
116  varName = m_cell->GetCellVarName(j);
117 
118  for(int i = 0; i < FieldDef.size(); ++i)
119  {
120  // Retrieve data from cell model
121  Array<OneD, NekDouble> data = m_cell->GetCellSolutionCoeffs(j);
122 
123  // Could do a search here to find correct variable
124  FieldDef[i]->m_fields.push_back(varName);
125  pFields[0]->AppendFieldData(FieldDef[i], FieldData[i], data);
126  }
127  }
128 
129  // Update time in field info if required
130  LibUtilities::FieldMetaDataMap fieldMetaDataMap;
131  fieldMetaDataMap["Time"] = boost::lexical_cast<std::string>(time);
132 
133  m_fld->Write(vOutputFilename.str(),FieldDef,FieldData,fieldMetaDataMap);
134  m_outputIndex++;
135 }
LibUtilities::FieldIOSharedPtr m_fld
std::map< std::string, std::string > FieldMetaDataMap
Definition: FieldIO.h:53
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442

Friends And Related Function Documentation

friend class MemoryManager< FilterCheckpointCellModel >
friend

Definition at line 48 of file FilterCheckpointCellModel.h.

Member Data Documentation

std::string Nektar::FilterCheckpointCellModel::className
static
Initial value:

Name of the class.

Definition at line 62 of file FilterCheckpointCellModel.h.

CellModelSharedPtr Nektar::FilterCheckpointCellModel::m_cell
private

Definition at line 91 of file FilterCheckpointCellModel.h.

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

LibUtilities::FieldIOSharedPtr Nektar::FilterCheckpointCellModel::m_fld
private

Definition at line 92 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_index
private

Definition at line 87 of file FilterCheckpointCellModel.h.

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

std::string Nektar::FilterCheckpointCellModel::m_outputFile
private

Definition at line 90 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_outputFrequency
private

Definition at line 89 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_outputIndex
private

Definition at line 88 of file FilterCheckpointCellModel.h.

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