Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Nektar::ForcingQuasi1D Class Reference

#include <ForcingQuasi1D.h>

Inheritance diagram for Nektar::ForcingQuasi1D:
[legend]

Static Public Member Functions

static SolverUtils::ForcingSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::SolverUtils::Forcing
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtrLoad (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

virtual void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
 
virtual 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) override
 
- Protected Member Functions inherited from Nektar::SolverUtils::Forcing
SOLVER_UTILS_EXPORT Forcing (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
 Constructor. More...
 
virtual SOLVER_UTILS_EXPORT void v_PreApply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble &time)
 
virtual SOLVER_UTILS_EXPORT void v_ApplyCoeff (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble &time)
 
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, std::string pName, bool pCache=false)
 Get a SessionFunction by name. More...
 
SOLVER_UTILS_EXPORT void EvaluateTimeFunction (LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
 
SOLVER_UTILS_EXPORT void EvaluateTimeFunction (const NekDouble pTime, const LibUtilities::EquationSharedPtr &pEqn, Array< OneD, NekDouble > &pArray)
 

Private Member Functions

 ForcingQuasi1D (const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation)
 

Private Attributes

Array< OneD, NekDoublem_geomFactor
 
VariableConverterSharedPtr m_varConv
 

Friends

class MemoryManager< ForcingQuasi1D >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::SolverUtils::Forcing
virtual SOLVER_UTILS_EXPORT ~Forcing ()
 
SOLVER_UTILS_EXPORT void InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
 Initialise the forcing object. More...
 
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. More...
 
SOLVER_UTILS_EXPORT void PreApply (const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble &time)
 Change the advection velocity before applying the forcing. For example, subtracting the frame velocity from the advection velocity in the MovingRefercenceFrame. More...
 
SOLVER_UTILS_EXPORT void ApplyCoeff (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. More...
 
SOLVER_UTILS_EXPORT const Array< OneD, const Array< OneD, NekDouble > > & GetForces ()
 
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > & UpdateForces ()
 
- Protected Attributes inherited from Nektar::SolverUtils::Forcing
LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
const std::weak_ptr< EquationSystemm_equ
 Weak pointer to equation system using this forcing. More...
 
Array< OneD, Array< OneD, NekDouble > > m_Forcing
 Evaluated forcing function. More...
 
int m_NumVariable
 Number of variables. More...
 
std::map< std::string, SolverUtils::SessionFunctionSharedPtrm_sessionFunctions
 Map of known SessionFunctions. More...
 

Detailed Description

Definition at line 44 of file ForcingQuasi1D.h.

Constructor & Destructor Documentation

◆ ForcingQuasi1D()

Nektar::ForcingQuasi1D::ForcingQuasi1D ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< SolverUtils::EquationSystem > &  pEquation 
)
private

Definition at line 47 of file ForcingQuasi1D.cpp.

50  : Forcing(pSession, pEquation)
51 {
52 }
SOLVER_UTILS_EXPORT Forcing(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
Constructor.
Definition: Forcing.cpp:50

Member Function Documentation

◆ create()

static SolverUtils::ForcingSharedPtr Nektar::ForcingQuasi1D::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const std::weak_ptr< SolverUtils::EquationSystem > &  pEquation,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file ForcingQuasi1D.h.

55  {
58  pEquation);
59  p->InitObject(pFields, pNumForcingFields, pForce);
60  return p;
61  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
Definition: Forcing.h:52

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

◆ v_Apply()

void Nektar::ForcingQuasi1D::v_Apply ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  fields,
const Array< OneD, Array< OneD, NekDouble >> &  inarray,
Array< OneD, Array< OneD, NekDouble >> &  outarray,
const NekDouble time 
)
overrideprotectedvirtual

Implements Nektar::SolverUtils::Forcing.

Definition at line 122 of file ForcingQuasi1D.cpp.

126 {
127  boost::ignore_unused(time);
128 
129  int nPoints = pFields[0]->GetTotPoints();
130 
131  // Get (E+p)
132  Array<OneD, NekDouble> tmp(nPoints, 0.0);
133  m_varConv->GetPressure(inarray, tmp);
134  Vmath::Vadd(nPoints, tmp, 1, inarray[2], 1, tmp, 1);
135 
136  // F-rho = -Ax/A *rhou
137  Vmath::Vmul(nPoints, m_geomFactor, 1, inarray[1], 1, m_Forcing[0], 1);
138 
139  // F-rhou = -Ax/A *rhou*u
140  Vmath::Vmul(nPoints, m_geomFactor, 1, inarray[1], 1, m_Forcing[1], 1);
141  Vmath::Vmul(nPoints, m_Forcing[1], 1, inarray[1], 1, m_Forcing[1], 1);
142  Vmath::Vdiv(nPoints, m_Forcing[1], 1, inarray[0], 1, m_Forcing[1], 1);
143 
144  // F-E = -Ax/A *(E+p)*u
145  Vmath::Vmul(nPoints, m_geomFactor, 1, inarray[1], 1, m_Forcing[2], 1);
146  Vmath::Vmul(nPoints, m_Forcing[2], 1, tmp, 1, m_Forcing[2], 1);
147  Vmath::Vdiv(nPoints, m_Forcing[2], 1, inarray[0], 1, m_Forcing[2], 1);
148 
149  // Apply forcing
150  for (int i = 0; i < m_NumVariable; i++)
151  {
152  Vmath::Vadd(nPoints, outarray[i], 1, m_Forcing[i], 1, outarray[i], 1);
153  }
154 }
VariableConverterSharedPtr m_varConv
Array< OneD, NekDouble > m_geomFactor
int m_NumVariable
Number of variables.
Definition: Forcing.h:122
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:120
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:209
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:359
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:284

References Nektar::SolverUtils::Forcing::m_Forcing, m_geomFactor, Nektar::SolverUtils::Forcing::m_NumVariable, m_varConv, Vmath::Vadd(), Vmath::Vdiv(), and Vmath::Vmul().

◆ v_InitObject()

void Nektar::ForcingQuasi1D::v_InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const unsigned int &  pNumForcingFields,
const TiXmlElement *  pForce 
)
overrideprotectedvirtual

Implements Nektar::SolverUtils::Forcing.

Definition at line 54 of file ForcingQuasi1D.cpp.

57 {
58  m_NumVariable = pNumForcingFields;
59  m_varConv =
61 
62  ASSERTL0(pFields[0]->GetGraph()->GetSpaceDimension() == 1,
63  "ForcingQuasi1D requires a 1D problem.");
64 
65  const TiXmlElement *funcNameElmt = pForce->FirstChildElement("AREAFCN");
66  if (!funcNameElmt)
67  {
68  ASSERTL0(funcNameElmt,
69  "Requires AREAFCN tag "
70  "specifying function name which prescribes nozzle area.");
71  }
72 
73  string funcName = funcNameElmt->GetText();
74  ASSERTL0(m_session->DefinesFunction(funcName),
75  "Function '" + funcName + "' not defined.");
76 
77  // Evaluate geometrical term -Ax/A for forcing
78  m_geomFactor = Array<OneD, NekDouble>(pFields[0]->GetTotPoints(), 0.0);
79  Array<OneD, NekDouble> tmp(pFields[0]->GetTotPoints(), 0.0);
80 
81  std::string sFieldStr = m_session->GetVariable(0);
82  ASSERTL0(m_session->DefinesFunction(funcName, sFieldStr),
83  "Variable '" + sFieldStr + "' not defined.");
84  GetFunction(pFields, m_session, funcName, true)
85  ->Evaluate(sFieldStr, m_geomFactor, 0.0);
86 
87  // Check if DADXFCN is defined
88  const TiXmlElement *dAFuncNameElmt = pForce->FirstChildElement("DADXFCN");
89  if (dAFuncNameElmt)
90  {
91  funcName = dAFuncNameElmt->GetText();
92  ASSERTL0(m_session->DefinesFunction(funcName),
93  "Function '" + funcName + "' not defined.");
94  ASSERTL0(m_session->DefinesFunction(funcName, sFieldStr),
95  "Variable '" + sFieldStr + "' not defined.");
96  GetFunction(pFields, m_session, funcName, true)
97  ->Evaluate(sFieldStr, tmp, 0.0);
98  }
99  else
100  {
101  // Numerically evaluate dA/dX
102  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0], m_geomFactor,
103  tmp);
104  }
105 
106  Vmath::Vdiv(pFields[0]->GetTotPoints(), tmp, 1, m_geomFactor, 1,
107  m_geomFactor, 1);
108  Vmath::Neg(pFields[0]->GetTotPoints(), m_geomFactor, 1);
109 
110  // Project m_geomFactor to solution space
111  Array<OneD, NekDouble> tmpCoeff(pFields[0]->GetNcoeffs(), 0.0);
112  pFields[0]->FwdTransLocalElmt(m_geomFactor, tmpCoeff);
113  pFields[0]->BwdTrans(tmpCoeff, m_geomFactor);
114 
115  m_Forcing = Array<OneD, Array<OneD, NekDouble>>(m_NumVariable);
116  for (int i = 0; i < m_NumVariable; ++i)
117  {
118  m_Forcing[i] = Array<OneD, NekDouble>(pFields[0]->GetTotPoints(), 0.0);
119  }
120 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, std::string pName, bool pCache=false)
Get a SessionFunction by name.
Definition: Forcing.cpp:190
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:116
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:91
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:518

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::MultiRegions::DirCartesianMap, Nektar::SolverUtils::Forcing::GetFunction(), Nektar::SolverUtils::Forcing::m_Forcing, m_geomFactor, Nektar::SolverUtils::Forcing::m_NumVariable, Nektar::SolverUtils::Forcing::m_session, m_varConv, Vmath::Neg(), and Vmath::Vdiv().

Friends And Related Function Documentation

◆ MemoryManager< ForcingQuasi1D >

friend class MemoryManager< ForcingQuasi1D >
friend

Definition at line 1 of file ForcingQuasi1D.h.

Member Data Documentation

◆ className

std::string Nektar::ForcingQuasi1D::className
static
Initial value:
=
"Quasi1D", ForcingQuasi1D::create, "Quasi-1D nozzle Forcing")
static SolverUtils::ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:44

Name of the class.

Definition at line 64 of file ForcingQuasi1D.h.

◆ m_geomFactor

Array<OneD, NekDouble> Nektar::ForcingQuasi1D::m_geomFactor
private

Definition at line 82 of file ForcingQuasi1D.h.

Referenced by v_Apply(), and v_InitObject().

◆ m_varConv

VariableConverterSharedPtr Nektar::ForcingQuasi1D::m_varConv
private

Definition at line 83 of file ForcingQuasi1D.h.

Referenced by v_Apply(), and v_InitObject().