Nektar++
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 std::map< std::string, std::string > &pParams)
 
 ~FilterCheckpointCellModel ()
 
void SetCellModel (CellModelSharedPtr &pCellModel)
 

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 = GetFilterFactory().RegisterCreatorFunction("CheckpointCellModel", FilterCheckpointCellModel::create)
 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 >
 

Detailed Description

Definition at line 47 of file FilterCheckpointCellModel.h.

Constructor & Destructor Documentation

Nektar::FilterCheckpointCellModel::FilterCheckpointCellModel ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::map< std::string, std::string > &  pParams 
)

Definition at line 42 of file FilterCheckpointCellModel.cpp.

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

44  :
45  Filter(pSession)
46  {
47  if (pParams.find("OutputFile") == pParams.end())
48  {
49  m_outputFile = m_session->GetSessionName();
50  }
51  else
52  {
53  ASSERTL0(!(pParams.find("OutputFile")->second.empty()),
54  "Missing parameter 'OutputFile'.");
55  m_outputFile = pParams.find("OutputFile")->second;
56  }
57  ASSERTL0(pParams.find("OutputFrequency") != pParams.end(),
58  "Missing parameter 'OutputFrequency'.");
59  m_outputFrequency = atoi(pParams.find("OutputFrequency")->second.c_str());
60  m_outputIndex = 0;
61  m_index = 0;
63 
64  }
LibUtilities::FieldIOSharedPtr m_fld
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:135
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Nektar::FilterCheckpointCellModel::~FilterCheckpointCellModel ( )

Definition at line 66 of file FilterCheckpointCellModel.cpp.

67  {
68 
69  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 53 of file FilterCheckpointCellModel.h.

55  {
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

Definition at line 123 of file FilterCheckpointCellModel.cpp.

124  {
125 
126  }
void Nektar::FilterCheckpointCellModel::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Definition at line 71 of file FilterCheckpointCellModel.cpp.

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

72  {
73  ASSERTL0(m_cell.get(), "Cell model has not been set by EquationSystem "
74  "class. Use SetCellModel on this filter to achieve this.");
75 
76  m_index = 0;
77  m_outputIndex = 0;
78 
79  v_Update(pFields, 0.0);
80  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:135
virtual void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
bool Nektar::FilterCheckpointCellModel::v_IsTimeDependent ( )
protectedvirtual

Definition at line 128 of file FilterCheckpointCellModel.cpp.

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

Definition at line 82 of file FilterCheckpointCellModel.cpp.

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

Referenced by v_Initialise().

83  {
84  if (m_index++ % m_outputFrequency > 0)
85  {
86  return;
87  }
88 
89  std::stringstream vOutputFilename;
90  vOutputFilename << m_outputFile << "_" << m_outputIndex << ".chk";
91 
92  SpatialDomains::MeshGraphSharedPtr vGraph = pFields[0]->GetGraph();
93 
94  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
95  = pFields[0]->GetFieldDefinitions();
96  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
97 
98  // copy Data into FieldData and set variable
99  std::string varName;
100  for(int j = 1; j < m_cell->GetNumCellVariables(); ++j)
101  {
102  varName = m_cell->GetCellVarName(j);
103 
104  for(int i = 0; i < FieldDef.size(); ++i)
105  {
106  // Retrieve data from cell model
107  Array<OneD, NekDouble> data = m_cell->GetCellSolutionCoeffs(j);
108 
109  // Could do a search here to find correct variable
110  FieldDef[i]->m_fields.push_back(varName);
111  pFields[0]->AppendFieldData(FieldDef[i], FieldData[i], data);
112  }
113  }
114 
115  // Update time in field info if required
116  LibUtilities::FieldMetaDataMap fieldMetaDataMap;
117  fieldMetaDataMap["Time"] = boost::lexical_cast<std::string>(time);
118 
119  m_fld->Write(vOutputFilename.str(),FieldDef,FieldData,fieldMetaDataMap);
120  m_outputIndex++;
121  }
LibUtilities::FieldIOSharedPtr m_fld
std::map< std::string, std::string > FieldMetaDataMap
Definition: FieldIO.h:65
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:432

Friends And Related Function Documentation

friend class MemoryManager< FilterCheckpointCellModel >
friend

Definition at line 50 of file FilterCheckpointCellModel.h.

Member Data Documentation

std::string Nektar::FilterCheckpointCellModel::className = GetFilterFactory().RegisterCreatorFunction("CheckpointCellModel", FilterCheckpointCellModel::create)
static

Name of the class.

Definition at line 62 of file FilterCheckpointCellModel.h.

CellModelSharedPtr Nektar::FilterCheckpointCellModel::m_cell
private

Definition at line 85 of file FilterCheckpointCellModel.h.

Referenced by v_Initialise(), and v_Update().

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

Definition at line 86 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_index
private

Definition at line 81 of file FilterCheckpointCellModel.h.

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

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

Definition at line 84 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_outputFrequency
private

Definition at line 83 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

unsigned int Nektar::FilterCheckpointCellModel::m_outputIndex
private

Definition at line 82 of file FilterCheckpointCellModel.h.

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