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

#include <ForcingAxiSymmetric.h>

Inheritance diagram for Nektar::ForcingAxiSymmetric:
[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

void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
 
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_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
 
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

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

Private Attributes

Array< OneD, NekDoublem_geomFactor
 
VariableConverterSharedPtr m_varConv
 

Friends

class MemoryManager< ForcingAxiSymmetric >
 

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 ForcingAxiSymmetric.h.

Constructor & Destructor Documentation

◆ ForcingAxiSymmetric()

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

Definition at line 46 of file ForcingAxiSymmetric.cpp.

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

Member Function Documentation

◆ create()

static SolverUtils::ForcingSharedPtr Nektar::ForcingAxiSymmetric::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 ForcingAxiSymmetric.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:53

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

◆ v_Apply()

void Nektar::ForcingAxiSymmetric::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 95 of file ForcingAxiSymmetric.cpp.

100{
101 int nPoints = pFields[0]->GetTotPoints();
102
103 // Get (E+p)
104 Array<OneD, NekDouble> tmp(nPoints, 0.0);
105 m_varConv->GetPressure(inarray, tmp);
106 Vmath::Vadd(nPoints, tmp, 1, inarray[m_NumVariable - 1], 1, tmp, 1);
107
108 // F-rho = -1/r *rhou
109 Vmath::Vmul(nPoints, m_geomFactor, 1, inarray[1], 1, m_Forcing[0], 1);
110
111 // F-rhou_r = -1/r *rhou_r * u_r and F-rhou_y = -1/r *rhou_y * u_r
112 for (int i = 1; i < 3; ++i)
113 {
114 Vmath::Vmul(nPoints, inarray[1], 1, inarray[i], 1, m_Forcing[i], 1);
115 Vmath::Vdiv(nPoints, m_Forcing[i], 1, inarray[0], 1, m_Forcing[i], 1);
116 Vmath::Vmul(nPoints, m_Forcing[i], 1, m_geomFactor, 1, m_Forcing[i], 1);
117 }
118
119 // F-E = -1/r *(E+p)*u
120 Vmath::Vmul(nPoints, inarray[1], 1, tmp, 1, m_Forcing[m_NumVariable - 1],
121 1);
122 Vmath::Vdiv(nPoints, m_Forcing[m_NumVariable - 1], 1, inarray[0], 1,
123 m_Forcing[m_NumVariable - 1], 1);
124 Vmath::Vmul(nPoints, m_Forcing[m_NumVariable - 1], 1, m_geomFactor, 1,
125 m_Forcing[m_NumVariable - 1], 1);
126
127 // Swirl
128 if (m_NumVariable == 5)
129 {
130 // F-rhou_r -= (-1/r) * rho * u_theta * u_theta
131 Vmath::Vmul(nPoints, inarray[3], 1, inarray[3], 1, tmp, 1);
132 Vmath::Vdiv(nPoints, tmp, 1, inarray[0], 1, tmp, 1);
133 Vmath::Vmul(nPoints, tmp, 1, m_geomFactor, 1, tmp, 1);
134 Vmath::Vsub(nPoints, m_Forcing[1], 1, tmp, 1, m_Forcing[1], 1);
135
136 // F-rhou_theta = 2 * (-1/r *rhou_theta * u_r)
137 Vmath::Vmul(nPoints, inarray[1], 1, inarray[3], 1, m_Forcing[3], 1);
138 Vmath::Vdiv(nPoints, m_Forcing[3], 1, inarray[0], 1, m_Forcing[3], 1);
139 Vmath::Vmul(nPoints, m_Forcing[3], 1, m_geomFactor, 1, m_Forcing[3], 1);
140 Vmath::Smul(nPoints, 2.0, m_Forcing[3], 1, m_Forcing[3], 1);
141 }
142
143 // Apply forcing
144 for (int i = 0; i < m_NumVariable; i++)
145 {
146 Vmath::Vadd(nPoints, outarray[i], 1, m_Forcing[i], 1, outarray[i], 1);
147 }
148}
VariableConverterSharedPtr m_varConv
Array< OneD, NekDouble > m_geomFactor
int m_NumVariable
Number of variables.
Definition: Forcing.h:121
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:119
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.hpp:72
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.hpp:180
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100
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.hpp:126
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.hpp:220

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

◆ v_InitObject()

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

Implements Nektar::SolverUtils::Forcing.

Definition at line 53 of file ForcingAxiSymmetric.cpp.

57{
58 int spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
59 int nPoints = pFields[0]->GetTotPoints();
60
61 m_NumVariable = pNumForcingFields;
63 spacedim);
64
65 // Get coordinates
66 Array<OneD, Array<OneD, NekDouble>> coords(3);
67 for (int i = 0; i < 3; i++)
68 {
69 coords[i] = Array<OneD, NekDouble>(nPoints);
70 }
71 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
72
73 // Calculate fac = -1/r if r!=0, fac = 0 if r == 0
74 m_geomFactor = Array<OneD, NekDouble>(nPoints);
75 for (int i = 0; i < nPoints; ++i)
76 {
77 if (coords[0][i] < NekConstants::kNekZeroTol)
78 {
79 m_geomFactor[i] = 0;
80 }
81 else
82 {
83 m_geomFactor[i] = -1.0 / coords[0][i];
84 }
85 }
86
87 // Project m_geomFactor to solution space
88 m_Forcing = Array<OneD, Array<OneD, NekDouble>>(m_NumVariable);
89 for (int i = 0; i < m_NumVariable; ++i)
90 {
91 m_Forcing[i] = Array<OneD, NekDouble>(pFields[0]->GetTotPoints(), 0.0);
92 }
93}
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:115
static const NekDouble kNekZeroTol

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::NekConstants::kNekZeroTol, Nektar::SolverUtils::Forcing::m_Forcing, m_geomFactor, Nektar::SolverUtils::Forcing::m_NumVariable, Nektar::SolverUtils::Forcing::m_session, and m_varConv.

Friends And Related Function Documentation

◆ MemoryManager< ForcingAxiSymmetric >

friend class MemoryManager< ForcingAxiSymmetric >
friend

Definition at line 1 of file ForcingAxiSymmetric.h.

Member Data Documentation

◆ className

std::string Nektar::ForcingAxiSymmetric::className
static
Initial value:
=
"AxiSymmetric", ForcingAxiSymmetric::create,
"Forcing for axi-symmetric flow (around x=0)")
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.
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:42

Name of the class.

Definition at line 64 of file ForcingAxiSymmetric.h.

◆ m_geomFactor

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

Definition at line 82 of file ForcingAxiSymmetric.h.

Referenced by v_Apply(), and v_InitObject().

◆ m_varConv

VariableConverterSharedPtr Nektar::ForcingAxiSymmetric::m_varConv
private

Definition at line 83 of file ForcingAxiSymmetric.h.

Referenced by v_Apply(), and v_InitObject().