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

#include <FilterModalEnergy.h>

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

Public Member Functions

SOLVER_UTILS_EXPORT FilterModalEnergy (const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
SOLVER_UTILS_EXPORT ~FilterModalEnergy ()
- 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.

Static Public Attributes

static std::string className = GetFilterFactory().RegisterCreatorFunction("ModalEnergy", FilterModalEnergy::create)
 Name of the class.

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 ()
NekDouble L2Error (const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, unsigned int field, const NekDouble &time)
void SetUpBaseFields (SpatialDomains::MeshGraphSharedPtr &mesh)
void ImportFldBase (std::string pInfile, SpatialDomains::MeshGraphSharedPtr pGraph)

Private Attributes

enum MultiRegions::ProjectionType m_projectionType
Array< OneD,
MultiRegions::ExpListSharedPtr
m_base
LibUtilities::FieldIOSharedPtr m_fld
vector< unsigned int > m_boundaryRegionsIdList
 ID's of boundary regions where we want the forces.
vector< bool > m_boundaryRegionIsInList
 Determines if a given Boundary Region is in m_boundaryRegionsIdList.
unsigned int m_index
unsigned int m_outputFrequency
unsigned int m_outputPlane
 plane to take history point from if using a homogeneous1D expansion
bool m_isHomogeneous1D
bool m_isHomogeneous2D
bool m_PertEnergy
int m_npointsZ
int m_nproc
std::string m_outputFile
std::ofstream m_outputStream
LibUtilities::BasisSharedPtr m_homogeneousBasis
std::string m_BoundaryString
int m_nplanes
int m_NumQuadPointsError
bool m_SingleMode
bool m_HalfMode
bool m_MultipleModes
bool m_useFFT
NekDouble m_LhomZ
bool m_homogen_dealiasing

Friends

class MemoryManager< FilterModalEnergy >

Additional Inherited Members

- Protected Attributes inherited from Nektar::SolverUtils::Filter
LibUtilities::SessionReaderSharedPtr m_session

Detailed Description

Definition at line 57 of file FilterModalEnergy.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file FilterModalEnergy.cpp.

References ASSERTL0, m_fld, m_isHomogeneous1D, m_isHomogeneous2D, m_LhomZ, m_NumQuadPointsError, m_outputFile, m_outputFrequency, m_outputPlane, m_PertEnergy, and Nektar::SolverUtils::Filter::m_session.

:
Filter(pSession)
{
if (pParams.find("OutputFile") == pParams.end())
{
m_outputFile = m_session->GetSessionName();
}
else
{
ASSERTL0(!(pParams.find("OutputFile")->second.empty()),
"Missing parameter 'OutputFile'.");
m_outputFile = pParams.find("OutputFile")->second;
}
if (!(m_outputFile.length() >= 4
&& m_outputFile.substr(m_outputFile.length() - 4) == ".mdl"))
{
m_outputFile += ".mdl";
}
if (pParams.find("OutputFrequency") == pParams.end())
{
}
else
{
atoi(pParams.find("OutputFrequency")->second.c_str());
}
m_session->MatchSolverInfo("Homogeneous", "1D",
m_session->MatchSolverInfo("Homogeneous", "2D",
m_session->MatchSolverInfo("CalculatePerturbationEnergy", "True",
m_PertEnergy, false);
m_session->LoadParameter ("NumQuadPointsError",
{
m_session->LoadParameter("LZ", m_LhomZ);
if (pParams.find("OutputPlane") == pParams.end())
{
}
else
{
atoi(pParams.find("OutputPlane")->second.c_str());
}
}
}
Nektar::SolverUtils::FilterModalEnergy::~FilterModalEnergy ( )

Definition at line 113 of file FilterModalEnergy.cpp.

{
}

Member Function Documentation

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

Creates an instance of this class.

Definition at line 63 of file FilterModalEnergy.h.

{
AllocateSharedPtr(pSession, pParams);
//p->InitObject();
return p;
}
void Nektar::SolverUtils::FilterModalEnergy::ImportFldBase ( std::string  pInfile,
SpatialDomains::MeshGraphSharedPtr  pGraph 
)
protected

Definition at line 510 of file FilterModalEnergy.cpp.

References ASSERTL1, m_base, m_fld, and Nektar::SolverUtils::Filter::m_session.

Referenced by v_Update().

{
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
//Get Homogeneous
m_fld->Import(pInfile,FieldDef,FieldData);
int nvar = m_session->GetVariables().size();
if(m_session->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = m_session->GetSolverInfo("HOMOGENEOUS");
}
// copy FieldData into m_fields
for(int j = 0; j < nvar; ++j)
{
for(int i = 0; i < FieldDef.size(); ++i)
{
bool flag = FieldDef[i]->m_fields[j] ==
m_session->GetVariable(j);
ASSERTL1(flag, (std::string("Order of ") + pInfile
+ std::string(" data and that defined in "
"m_boundaryconditions differs")).c_str());
m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
FieldDef[i]->m_fields[j],
m_base[j]->UpdateCoeffs());
}
}
}
NekDouble Nektar::SolverUtils::FilterModalEnergy::L2Error ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
unsigned int  field,
const NekDouble time 
)
protected

Definition at line 272 of file FilterModalEnergy.cpp.

References m_NumQuadPointsError.

Referenced by v_Update().

{
NekDouble L2error = -1.0;
LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
{
if(pFields[field]->GetPhysState() == false)
{
pFields[field]->BwdTrans(pFields[field]->GetCoeffs(),
pFields[field]->UpdatePhys());
}
}
L2error = pFields[field]->L2(pFields[field]->GetPhys());
return L2error;
}
void Nektar::SolverUtils::FilterModalEnergy::SetUpBaseFields ( SpatialDomains::MeshGraphSharedPtr mesh)
protected

Definition at line 293 of file FilterModalEnergy.cpp.

References ASSERTL0, Nektar::MultiRegions::eDiscontinuous, Nektar::LibUtilities::eFourier, Nektar::LibUtilities::eFourierEvenlySpaced, Nektar::LibUtilities::eFourierHalfModeRe, Nektar::LibUtilities::eFourierSingleModeSpaced, Nektar::MultiRegions::eGalerkin, Nektar::MultiRegions::eMixed_CG_Discontinuous, m_base, m_HalfMode, m_homogen_dealiasing, m_isHomogeneous1D, m_LhomZ, m_MultipleModes, m_npointsZ, m_projectionType, Nektar::SolverUtils::Filter::m_session, m_SingleMode, and m_useFFT.

Referenced by v_Update().

{
int i;
int m_expdim = graphShrPtr->GetMeshDimension();
//definition of the projection tipe:
if(m_session->DefinesSolverInfo("PROJECTION"))
{
std::string ProjectStr = m_session->GetSolverInfo("PROJECTION");
if((ProjectStr == "Continuous") || (ProjectStr == "Galerkin")
|| (ProjectStr == "CONTINUOUS") || (ProjectStr == "GALERKIN"))
{
}
else if((ProjectStr == "MixedCGDG")||(ProjectStr == "Mixed_CG_Discontinuous"))
{
}
else if(ProjectStr == "DisContinuous")
{
}
else
{
ASSERTL0(false,"PROJECTION value not recognised");
}
}
else
{
cerr << "Projection type not specified in SOLVERINFO,"
"defaulting to continuous Galerkin" << endl;
}
if(m_session->DefinesSolverInfo("ModeType"))
{
m_session->MatchSolverInfo("ModeType", "SingleMode",
m_SingleMode, false);
m_session->MatchSolverInfo("ModeType", "HalfMode",
m_HalfMode, false);
m_session->MatchSolverInfo("ModeType", "MultipleModes",
m_MultipleModes, false);
}
m_session->MatchSolverInfo("USEFFT","FFTW",m_useFFT,false);
m_session->MatchSolverInfo("DEALIASING","True",m_homogen_dealiasing,false);
if(m_homogen_dealiasing == false)
{
m_session->MatchSolverInfo("DEALIASING","On",m_homogen_dealiasing,false);
}
// Stability Analysis flags
if(m_session->DefinesSolverInfo("ModeType"))
{
{
}
else if(m_HalfMode)
{
}
else if(m_MultipleModes)
{
m_npointsZ = m_session->GetParameter("HomModesZ");
}
else
{
ASSERTL0(false, "SolverInfo ModeType not valid");
}
}
else
{
m_npointsZ = m_session->GetParameter("HomModesZ");
}
{
switch (m_expdim)
{
case 1:
{
for(i = 0; i < m_base.num_elements(); i++)
{
m_session->GetVariable(0));
}
}
break;
case 2:
{
{
{
m_npointsZ,PkeyZ);
for(i = 0 ; i < m_base.num_elements(); i++)
{
m_base[i]->SetWaveSpace(true);
}
}
else if(m_HalfMode)
{
//1 plane field (half mode expansion)
m_npointsZ,PkeyZ);
for(i = 0 ; i < m_base.num_elements(); i++)
{
m_base[i]->SetWaveSpace(true);
}
}
else
{
PkeyZ);
for(i = 0 ; i < m_base.num_elements(); i++)
{
m_base[i]->SetWaveSpace(false);
}
}
}
else
{
i = 0;
m_session->GetVariable(i));
m_base[0]=firstbase;
for(i = 1 ; i < m_base.num_elements(); i++)
{
::AllocateSharedPtr(*firstbase,graphShrPtr,
m_session->GetVariable(i));
}
}
}
break;
case 3:
{
m_session->GetVariable(0));
m_base[0] = firstbase;
for(i = 1 ; i < m_base.num_elements(); i++)
{
::AllocateSharedPtr(*firstbase, graphShrPtr,
m_session->GetVariable(0));
}
}
break;
default:
ASSERTL0(false,"Expansion dimension not recognised");
break;
}
}
else
{
switch(m_expdim)
{
case 1:
{
// need to use zero for variable as may be more base
// flows than variables
for(i = 0 ; i < m_base.num_elements(); i++)
{
::AllocateSharedPtr(m_session, graphShrPtr,
m_session->GetVariable(0));
}
break;
}
case 2:
{
for(i = 0 ; i < m_base.num_elements(); i++)
{
::DisContField2D>::AllocateSharedPtr(m_session,graphShrPtr,
m_session->GetVariable(0));
}
break;
}
case 3:
ASSERTL0(false, "3 D not set up");
default:
ASSERTL0(false, "Expansion dimension not recognised");
break;
}
}
}
void Nektar::SolverUtils::FilterModalEnergy::v_Finalise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 262 of file FilterModalEnergy.cpp.

References m_outputStream.

{
if (pFields[0]->GetComm()->GetRank() == 0)
{
m_outputStream.close();
}
}
void Nektar::SolverUtils::FilterModalEnergy::v_Initialise ( const Array< OneD, const MultiRegions::ExpListSharedPtr > &  pFields,
const NekDouble time 
)
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 121 of file FilterModalEnergy.cpp.

References m_isHomogeneous1D, m_outputFile, m_outputStream, and v_Update().

{
LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
if (vComm->GetRank() == 0)
{
// Open output stream
{
m_outputStream << "# Time, Fourier Mode, Energy ";
m_outputStream << endl;
}
else
{
m_outputStream << "# Time, Energy ";
m_outputStream << endl;
}
}
v_Update(pFields, time);
}
bool Nektar::SolverUtils::FilterModalEnergy::v_IsTimeDependent ( )
protectedvirtual

Implements Nektar::SolverUtils::Filter.

Definition at line 546 of file FilterModalEnergy.cpp.

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

Implements Nektar::SolverUtils::Filter.

Definition at line 152 of file FilterModalEnergy.cpp.

References ASSERTL0, ImportFldBase(), L2Error(), m_base, m_index, m_isHomogeneous1D, m_isHomogeneous2D, m_npointsZ, m_outputFrequency, m_outputStream, m_PertEnergy, Nektar::SolverUtils::Filter::m_session, Nektar::SpatialDomains::MeshGraph::Read(), SetUpBaseFields(), Vmath::Vadd(), and Vmath::Vsub().

Referenced by v_Initialise().

{
// Only output every m_outputFrequency.
{
return;
}
LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
{
int colrank = vComm->GetColumnComm()->GetRank();
int nproc = vComm->GetColumnComm()->GetSize();
m_npointsZ = (m_session->GetParameter("HomModesZ"));
int locsize = m_npointsZ/nproc/2;
Array<OneD, NekDouble> energy (locsize,0.0);
Array<OneD, NekDouble> energy_tmp(locsize,0.0);
Array<OneD, NekDouble> tmp;
// Calculate the energy of the perturbation for stability
// analysis
{
SetUpBaseFields(graphShrPtr);
string file = m_session->GetFunctionFilename("BaseFlow", 0);
ImportFldBase(file,graphShrPtr);
for(int i = 0; i < pFields.num_elements()-1; ++i)
{
Vmath::Vsub(pFields[i]->GetNcoeffs(),
pFields[i]->GetCoeffs(),1,
m_base [i]->GetCoeffs(),1,
pFields[i]->UpdateCoeffs(),1);
energy_tmp = pFields[i]->HomogeneousEnergy();
Vmath::Vadd(locsize,energy_tmp,1,energy,1,energy,1);
Vmath::Vadd(pFields[i]->GetNcoeffs(),
pFields[i]->GetCoeffs(),1,
m_base[i]->GetCoeffs(),1,
pFields[i]->UpdateCoeffs(),1);
}
}
else
{
for(int i = 0; i < pFields.num_elements()-1; ++i)
{
energy_tmp =pFields[i]->HomogeneousEnergy();
Vmath::Vadd(locsize,energy_tmp,1,energy,1,energy,1);
}
}
// Send to root process.
if (colrank == 0)
{
int j, m = 0;
for (j = 0; j < energy.num_elements(); ++j, ++m)
{
m_outputStream << setw(10) << time
<< setw(5) << m
<< setw(18) << energy[j] << endl;
}
for (int i = 1; i < nproc; ++i)
{
vComm->GetColumnComm()->Recv(i, energy);
for (j = 0; j < energy.num_elements(); ++j, ++m)
{
m_outputStream << setw(10) << time
<< setw(5) << m
<< setw(18) << energy[j] << endl;
}
}
}
else
{
vComm->GetColumnComm()->Send(0, energy);
}
}
{
ASSERTL0(false,"3D Homogeneous 2D energy dumping not implemented yet");
}
else
{
NekDouble energy = 0.0;
for(int i = 0; i < pFields.num_elements()-1; ++i)
{
pFields[i]->SetPhysState(true);
NekDouble norm = L2Error(pFields,i, time);
energy += norm*norm;
}
m_outputStream << setprecision(6) << time;
m_outputStream.width(25);
m_outputStream << setprecision(8) << 0.5*energy;
m_outputStream << endl;
}
}

Friends And Related Function Documentation

friend class MemoryManager< FilterModalEnergy >
friend

Definition at line 60 of file FilterModalEnergy.h.

Member Data Documentation

std::string Nektar::SolverUtils::FilterModalEnergy::className = GetFilterFactory().RegisterCreatorFunction("ModalEnergy", FilterModalEnergy::create)
static

Name of the class.

Definition at line 74 of file FilterModalEnergy.h.

Array<OneD, MultiRegions::ExpListSharedPtr> Nektar::SolverUtils::FilterModalEnergy::m_base
private

Definition at line 95 of file FilterModalEnergy.h.

Referenced by ImportFldBase(), SetUpBaseFields(), and v_Update().

vector<bool> Nektar::SolverUtils::FilterModalEnergy::m_boundaryRegionIsInList
private

Determines if a given Boundary Region is in m_boundaryRegionsIdList.

Definition at line 102 of file FilterModalEnergy.h.

vector<unsigned int> Nektar::SolverUtils::FilterModalEnergy::m_boundaryRegionsIdList
private

ID's of boundary regions where we want the forces.

Definition at line 99 of file FilterModalEnergy.h.

std::string Nektar::SolverUtils::FilterModalEnergy::m_BoundaryString
private

Definition at line 116 of file FilterModalEnergy.h.

LibUtilities::FieldIOSharedPtr Nektar::SolverUtils::FilterModalEnergy::m_fld
private

Definition at line 96 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and ImportFldBase().

bool Nektar::SolverUtils::FilterModalEnergy::m_HalfMode
private

Definition at line 120 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

bool Nektar::SolverUtils::FilterModalEnergy::m_homogen_dealiasing
private

Definition at line 124 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

LibUtilities::BasisSharedPtr Nektar::SolverUtils::FilterModalEnergy::m_homogeneousBasis
private

Definition at line 115 of file FilterModalEnergy.h.

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_index
private

Definition at line 103 of file FilterModalEnergy.h.

Referenced by v_Update().

bool Nektar::SolverUtils::FilterModalEnergy::m_isHomogeneous1D
private

Definition at line 108 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), SetUpBaseFields(), v_Initialise(), and v_Update().

bool Nektar::SolverUtils::FilterModalEnergy::m_isHomogeneous2D
private

Definition at line 109 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

NekDouble Nektar::SolverUtils::FilterModalEnergy::m_LhomZ
private

Definition at line 123 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and SetUpBaseFields().

bool Nektar::SolverUtils::FilterModalEnergy::m_MultipleModes
private

Definition at line 121 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

int Nektar::SolverUtils::FilterModalEnergy::m_nplanes
private

Definition at line 117 of file FilterModalEnergy.h.

int Nektar::SolverUtils::FilterModalEnergy::m_npointsZ
private

Definition at line 111 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields(), and v_Update().

int Nektar::SolverUtils::FilterModalEnergy::m_nproc
private

Definition at line 112 of file FilterModalEnergy.h.

int Nektar::SolverUtils::FilterModalEnergy::m_NumQuadPointsError
private

Definition at line 118 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and L2Error().

std::string Nektar::SolverUtils::FilterModalEnergy::m_outputFile
private

Definition at line 113 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Initialise().

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_outputFrequency
private

Definition at line 104 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

unsigned int Nektar::SolverUtils::FilterModalEnergy::m_outputPlane
private

plane to take history point from if using a homogeneous1D expansion

Definition at line 107 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy().

std::ofstream Nektar::SolverUtils::FilterModalEnergy::m_outputStream
private

Definition at line 114 of file FilterModalEnergy.h.

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

bool Nektar::SolverUtils::FilterModalEnergy::m_PertEnergy
private

Definition at line 110 of file FilterModalEnergy.h.

Referenced by FilterModalEnergy(), and v_Update().

enum MultiRegions::ProjectionType Nektar::SolverUtils::FilterModalEnergy::m_projectionType
private

Definition at line 94 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

bool Nektar::SolverUtils::FilterModalEnergy::m_SingleMode
private

Definition at line 119 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().

bool Nektar::SolverUtils::FilterModalEnergy::m_useFFT
private

Definition at line 122 of file FilterModalEnergy.h.

Referenced by SetUpBaseFields().