Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::SolverUtils::Forcing Class Reference

Defines a forcing term to be explicitly applied. More...

#include <Forcing.h>

Inheritance diagram for Nektar::SolverUtils::Forcing:
Inheritance graph
[legend]

Public Member Functions

SOLVER_UTILS_EXPORT void InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 Initialise the forcing object.
SOLVER_UTILS_EXPORT void Apply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
 Apply the forcing.

Static Public Member Functions

static SOLVER_UTILS_EXPORT
std::vector< ForcingSharedPtr
Load (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)

Protected Member Functions

SOLVER_UTILS_EXPORT Forcing (const LibUtilities::SessionReaderSharedPtr &)
 Constructor.
virtual SOLVER_UTILS_EXPORT void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)=0
virtual SOLVER_UTILS_EXPORT void v_Apply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)=0
void EvaluateFunction (Array< OneD, MultiRegions::ExpListSharedPtr > pFields, LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
void EvaluateTimeFunction (LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))

Protected Attributes

LibUtilities::SessionReaderSharedPtr m_session
 Session reader.
Array< OneD, Array< OneD,
NekDouble > > 
m_Forcing
 Evaluated forcing function.
int m_NumVariable
 Number of variables.

Detailed Description

Defines a forcing term to be explicitly applied.

Definition at line 70 of file Forcing.h.

Constructor & Destructor Documentation

Nektar::SolverUtils::Forcing::Forcing ( const LibUtilities::SessionReaderSharedPtr pSession)
protected

Constructor.

Definition at line 50 of file Forcing.cpp.

: m_session(pSession)
{
}

Member Function Documentation

void Nektar::SolverUtils::Forcing::Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)

Apply the forcing.

Parameters
fieldsExpansion lists corresponding to input arrays
inarrayu^n from previous timestep
outarrayoutput array to append forcing to

Definition at line 70 of file Forcing.cpp.

References v_Apply().

{
v_Apply(fields, inarray, outarray, time);
}
void Nektar::SolverUtils::Forcing::EvaluateFunction ( Array< OneD, MultiRegions::ExpListSharedPtr pFields,
LibUtilities::SessionReaderSharedPtr  pSession,
std::string  pFieldName,
Array< OneD, NekDouble > &  pArray,
const std::string &  pFunctionName,
NekDouble  pTime = NekDouble(0) 
)
protected

Definition at line 139 of file Forcing.cpp.

References ASSERTL0, Nektar::LibUtilities::eFunctionTypeExpression, Nektar::LibUtilities::eFunctionTypeFile, m_session, and Vmath::Zero().

Referenced by Nektar::SolverUtils::ForcingBody::v_InitObject(), and Nektar::SolverUtils::ForcingSponge::v_InitObject().

{
ASSERTL0(pSession->DefinesFunction(pFunctionName),
"Function '" + pFunctionName + "' does not exist.");
unsigned int nq = pFields[0]->GetNpoints();
if (pArray.num_elements() != nq)
{
pArray = Array<OneD, NekDouble> (nq);
}
vType = pSession->GetFunctionType(pFunctionName, pFieldName);
{
Array<OneD, NekDouble> x0(nq);
Array<OneD, NekDouble> x1(nq);
Array<OneD, NekDouble> x2(nq);
pFields[0]->GetCoords(x0, x1, x2);
pSession->GetFunction(pFunctionName, pFieldName);
ffunc->Evaluate(x0, x1, x2, pTime, pArray);
}
{
std::string filename = pSession->GetFunctionFilename(
pFunctionName,
pFieldName);
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
Vmath::Zero(vCoeffs.num_elements(), vCoeffs, 1);
fld->Import(filename, FieldDef, FieldData);
int idx = -1;
for (int i = 0; i < FieldDef.size(); ++i)
{
for (int j = 0; j < FieldDef[i]->m_fields.size(); ++j)
{
if (FieldDef[i]->m_fields[j] == pFieldName)
{
idx = j;
}
}
if (idx >= 0)
{
pFields[0]->ExtractDataToCoeffs(
FieldDef[i],
FieldData[i],
FieldDef[i]->m_fields[idx],
vCoeffs);
}
else
{
cout << "Field " + pFieldName + " not found." << endl;
}
}
pFields[0]->BwdTrans_IterPerExp(vCoeffs, pArray);
}
}
void Nektar::SolverUtils::Forcing::EvaluateTimeFunction ( LibUtilities::SessionReaderSharedPtr  pSession,
std::string  pFieldName,
Array< OneD, NekDouble > &  pArray,
const std::string &  pFunctionName,
NekDouble  pTime = NekDouble(0) 
)
protected

Definition at line 118 of file Forcing.cpp.

References ASSERTL0.

Referenced by Nektar::SolverUtils::ForcingSponge::v_Apply().

{
ASSERTL0(pSession->DefinesFunction(pFunctionName),
"Function '" + pFunctionName + "' does not exist.");
pSession->GetFunction(pFunctionName, pFieldName);
Array<OneD, NekDouble> x0(1,0.0);
Array<OneD, NekDouble> x1(1,0.0);
Array<OneD, NekDouble> x2(1,0.0);
ffunc->Evaluate(x0, x1, x2, pTime, pArray);
}
void Nektar::SolverUtils::Forcing::InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)

Initialise the forcing object.

Definition at line 56 of file Forcing.cpp.

References v_InitObject().

{
v_InitObject(pFields, pNumForcingFields, pForce);
}
vector< ForcingSharedPtr > Nektar::SolverUtils::Forcing::Load ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields = 0 
)
static

Definition at line 83 of file Forcing.cpp.

References Nektar::SolverUtils::GetForcingFactory().

Referenced by Nektar::IncNavierStokes::v_InitObject().

{
vector<ForcingSharedPtr> vForceList;
if (!pSession->DefinesElement("Nektar/Forcing"))
{
return vForceList;
}
TiXmlElement* vForcing = pSession->GetElement("Nektar/Forcing");
if (vForcing)
{
unsigned int vNumForcingFields = pNumForcingFields;
if (!pNumForcingFields)
{
vNumForcingFields = pFields.num_elements();
}
TiXmlElement* vForce = vForcing->FirstChildElement("FORCE");
while (vForce)
{
string vType = vForce->Attribute("TYPE");
vForceList.push_back(GetForcingFactory().CreateInstance(
vType, pSession, pFields,
vNumForcingFields, vForce));
vForce = vForce->NextSiblingElement("FORCE");
}
}
return vForceList;
}
virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Forcing::v_Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray,
const NekDouble time 
)
protectedpure virtual
virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Forcing::v_InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
protectedpure virtual

Member Data Documentation

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::Forcing::m_Forcing
protected
int Nektar::SolverUtils::Forcing::m_NumVariable
protected
LibUtilities::SessionReaderSharedPtr Nektar::SolverUtils::Forcing::m_session
protected