Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 ASSERTL0, Nektar::LibUtilities::FieldIO::CreateDefault(), 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;
72 }
LibUtilities::FieldIOSharedPtr m_fld
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Filter.cpp:52
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:84
static boost::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
Definition: FieldIO.cpp:181
Nektar::FilterCheckpointCellModel::~FilterCheckpointCellModel ( )

Definition at line 74 of file FilterCheckpointCellModel.cpp.

75 {
76 
77 }

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(), and CellMLToNektar.cellml_metadata::p.

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 135 of file FilterCheckpointCellModel.cpp.

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

Implements Nektar::SolverUtils::Filter.

Definition at line 79 of file FilterCheckpointCellModel.cpp.

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

82 {
83  ASSERTL0(m_cell.get(), "Cell model has not been set by EquationSystem "
84  "class. Use SetCellModel on this filter to achieve this.");
85 
86  m_index = 0;
87  m_outputIndex = 0;
88 
89  v_Update(pFields, 0.0);
90 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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 142 of file FilterCheckpointCellModel.cpp.

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

Implements Nektar::SolverUtils::Filter.

Definition at line 92 of file FilterCheckpointCellModel.cpp.

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

Referenced by v_Initialise().

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