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:
[legend]

Public Member Functions

 FilterCheckpointCellModel (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation, const ParamMap &pParams)
 
 ~FilterCheckpointCellModel () override
 
void SetCellModel (CellModelSharedPtr &pCellModel)
 
- Public Member Functions inherited from Nektar::SolverUtils::Filter
SOLVER_UTILS_EXPORT Filter (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
 
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 std::weak_ptr< SolverUtils::EquationSystem > &pEquation, 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

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

Private Attributes

size_t m_index
 
size_t m_outputIndex
 
size_t 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
 
const std::weak_ptr< EquationSystemm_equ
 

Detailed Description

Definition at line 44 of file FilterCheckpointCellModel.h.

Constructor & Destructor Documentation

◆ FilterCheckpointCellModel()

Nektar::FilterCheckpointCellModel::FilterCheckpointCellModel ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< SolverUtils::EquationSystem > &  pEquation,
const ParamMap pParams 
)

Definition at line 43 of file FilterCheckpointCellModel.cpp.

47 : Filter(pSession, pEquation)
48{
49 // OutputFile
50 auto it = pParams.find("OutputFile");
51 if (it == pParams.end())
52 {
53 m_outputFile = m_session->GetSessionName();
54 }
55 else
56 {
57 ASSERTL0(it->second.length() > 0, "Missing parameter 'OutputFile'.");
58 m_outputFile = it->second;
59 }
60
61 // OutputFrequency
62 it = pParams.find("OutputFrequency");
63 ASSERTL0(it != pParams.end(), "Missing parameter 'OutputFrequency'.");
64 LibUtilities::Equation equ(m_session->GetInterpreter(), it->second);
65 m_outputFrequency = floor(equ.Evaluate());
66
67 m_outputIndex = 0;
68 m_index = 0;
70}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
LibUtilities::FieldIOSharedPtr m_fld
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
Definition: FieldIO.cpp:195
LibUtilities::SessionReaderSharedPtr m_session
Definition: Filter.h:83
SOLVER_UTILS_EXPORT Filter(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
Definition: Filter.cpp:45

References ASSERTL0, Nektar::LibUtilities::FieldIO::CreateDefault(), Nektar::LibUtilities::Equation::Evaluate(), m_fld, m_index, m_outputFile, m_outputFrequency, m_outputIndex, and Nektar::SolverUtils::Filter::m_session.

◆ ~FilterCheckpointCellModel()

Nektar::FilterCheckpointCellModel::~FilterCheckpointCellModel ( )
override

Definition at line 72 of file FilterCheckpointCellModel.cpp.

73{
74}

Member Function Documentation

◆ create()

static SolverUtils::FilterSharedPtr Nektar::FilterCheckpointCellModel::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< SolverUtils::EquationSystem > &  pEquation,
const ParamMap pParams 
)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file FilterCheckpointCellModel.h.

54 {
57 pSession, pEquation, pParams);
58 return p;
59 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Filter > FilterSharedPtr
A shared pointer to a Driver object.
Definition: Filter.h:51

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ SetCellModel()

void Nektar::FilterCheckpointCellModel::SetCellModel ( CellModelSharedPtr pCellModel)
inline

Definition at line 70 of file FilterCheckpointCellModel.h.

71 {
72 m_cell = pCellModel;
73 }

References m_cell.

◆ v_Finalise()

void Nektar::FilterCheckpointCellModel::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 133 of file FilterCheckpointCellModel.cpp.

137{
138}

◆ v_Initialise()

void Nektar::FilterCheckpointCellModel::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 76 of file FilterCheckpointCellModel.cpp.

79{
80 ASSERTL0(m_cell.get(),
81 "Cell model has not been set by EquationSystem "
82 "class. Use SetCellModel on this filter to achieve this.");
83
84 m_index = 0;
85 m_outputIndex = 0;
86
87 v_Update(pFields, 0.0);
88}
void v_Update(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override

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

◆ v_IsTimeDependent()

bool Nektar::FilterCheckpointCellModel::v_IsTimeDependent ( )
overrideprotectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 140 of file FilterCheckpointCellModel.cpp.

141{
142 return true;
143}

◆ v_Update()

void Nektar::FilterCheckpointCellModel::v_Update ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
overrideprotectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 90 of file FilterCheckpointCellModel.cpp.

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

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

Referenced by v_Initialise().

Friends And Related Function Documentation

◆ MemoryManager< FilterCheckpointCellModel >

friend class MemoryManager< FilterCheckpointCellModel >
friend

Definition at line 1 of file FilterCheckpointCellModel.h.

Member Data Documentation

◆ className

std::string Nektar::FilterCheckpointCellModel::className
static
Initial value:
=
"CheckpointCellModel", FilterCheckpointCellModel::create)
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation, const ParamMap &pParams)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
FilterFactory & GetFilterFactory()
Definition: Filter.cpp:39

Name of the class.

Definition at line 62 of file FilterCheckpointCellModel.h.

◆ m_cell

CellModelSharedPtr Nektar::FilterCheckpointCellModel::m_cell
private

Definition at line 92 of file FilterCheckpointCellModel.h.

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

◆ m_fld

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

Definition at line 93 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

◆ m_index

size_t Nektar::FilterCheckpointCellModel::m_index
private

Definition at line 88 of file FilterCheckpointCellModel.h.

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

◆ m_outputFile

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

Definition at line 91 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

◆ m_outputFrequency

size_t Nektar::FilterCheckpointCellModel::m_outputFrequency
private

Definition at line 90 of file FilterCheckpointCellModel.h.

Referenced by FilterCheckpointCellModel(), and v_Update().

◆ m_outputIndex

size_t Nektar::FilterCheckpointCellModel::m_outputIndex
private

Definition at line 89 of file FilterCheckpointCellModel.h.

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