Nektar++
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::ArtificialDiffusion Class Referenceabstract

Encapsulates the artificial diffusion used in shock capture. More...

#include <ArtificialDiffusion.h>

Inheritance diagram for Nektar::ArtificialDiffusion:
[legend]

Public Member Functions

virtual ~ArtificialDiffusion ()
 
void DoArtificialDiffusion (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Apply the artificial diffusion. More...
 
void DoArtificialDiffusionCoeff (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Apply the artificial diffusion the outarray is in coeff space. More...
 
void GetArtificialViscosity (const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)
 Calculate the artificial viscosity. More...
 

Protected Member Functions

 ArtificialDiffusion (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const int spacedim)
 Constructor. More...
 
virtual void v_DoArtificialDiffusion (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual void v_DoArtificialDiffusionCoeff (const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual void v_GetArtificialViscosity (const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)=0
 
void GetFluxVector (const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &viscousTensor)
 Return the flux vector for the artificial viscosity operator. More...
 

Protected Attributes

LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
Array< OneD, MultiRegions::ExpListSharedPtrm_fields
 Array of fields. More...
 
VariableConverterSharedPtr m_varConv
 Auxiliary object to convert variables. More...
 
SolverUtils::DiffusionSharedPtr m_diffusion
 LDG Diffusion operator. More...
 
NekDouble m_mu0
 Constant scaling. More...
 

Detailed Description

Encapsulates the artificial diffusion used in shock capture.

Definition at line 69 of file ArtificialDiffusion.h.

Constructor & Destructor Documentation

◆ ~ArtificialDiffusion()

virtual Nektar::ArtificialDiffusion::~ArtificialDiffusion ( )
inlinevirtual

Definition at line 72 of file ArtificialDiffusion.h.

73 {
74 }

◆ ArtificialDiffusion()

Nektar::ArtificialDiffusion::ArtificialDiffusion ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const int  spacedim 
)
protected

Constructor.

Definition at line 48 of file ArtificialDiffusion.cpp.

52 : m_session(pSession), m_fields(pFields)
53{
54 // Create auxiliary object to convert variables
56 spacedim);
57
61 m_diffusion->InitObject(m_session, m_fields);
62
63 // Get constant scaling
64 m_session->LoadParameter("mu0", m_mu0, 1.0);
65}
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
NekDouble m_mu0
Constant scaling.
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
void GetFluxVector(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &viscousTensor)
Return the flux vector for the artificial viscosity operator.
SolverUtils::DiffusionSharedPtr m_diffusion
LDG Diffusion operator.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
DiffusionFactory & GetDiffusionFactory()
Definition: Diffusion.cpp:39

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::SolverUtils::GetDiffusionFactory(), GetFluxVector(), m_diffusion, m_fields, m_mu0, m_session, and m_varConv.

Member Function Documentation

◆ DoArtificialDiffusion()

void Nektar::ArtificialDiffusion::DoArtificialDiffusion ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)

Apply the artificial diffusion.

Definition at line 70 of file ArtificialDiffusion.cpp.

73{
74 v_DoArtificialDiffusion(inarray, outarray);
75}
virtual void v_DoArtificialDiffusion(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)

References v_DoArtificialDiffusion().

◆ DoArtificialDiffusionCoeff()

void Nektar::ArtificialDiffusion::DoArtificialDiffusionCoeff ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)

Apply the artificial diffusion the outarray is in coeff space.

Definition at line 106 of file ArtificialDiffusion.cpp.

109{
110 v_DoArtificialDiffusionCoeff(inarray, outarray);
111}
virtual void v_DoArtificialDiffusionCoeff(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)

References v_DoArtificialDiffusionCoeff().

◆ GetArtificialViscosity()

void Nektar::ArtificialDiffusion::GetArtificialViscosity ( const Array< OneD, Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  mu 
)

Calculate the artificial viscosity.

Definition at line 142 of file ArtificialDiffusion.cpp.

145{
146 v_GetArtificialViscosity(physfield, mu);
147}
virtual void v_GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)=0

References v_GetArtificialViscosity().

Referenced by GetFluxVector().

◆ GetFluxVector()

void Nektar::ArtificialDiffusion::GetFluxVector ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &  qfield,
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &  viscousTensor 
)
protected

Return the flux vector for the artificial viscosity operator.

Definition at line 152 of file ArtificialDiffusion.cpp.

156{
157 unsigned int nDim = qfield.size();
158 unsigned int nConvectiveFields = qfield[0].size();
159 unsigned int nPts = qfield[0][0].size();
160
161 // Get Artificial viscosity
162 Array<OneD, NekDouble> mu{nPts, 0.0};
163 GetArtificialViscosity(inarray, mu);
164
165 // Compute viscous tensor
166 for (unsigned int j = 0; j < nDim; ++j)
167 {
168 for (unsigned int i = 0; i < nConvectiveFields; ++i)
169 {
170 Vmath::Vmul(nPts, qfield[j][i], 1, mu, 1, viscousTensor[j][i], 1);
171 }
172 }
173}
void GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &mu)
Calculate the artificial viscosity.
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

References GetArtificialViscosity(), and Vmath::Vmul().

Referenced by ArtificialDiffusion().

◆ v_DoArtificialDiffusion()

void Nektar::ArtificialDiffusion::v_DoArtificialDiffusion ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Definition at line 80 of file ArtificialDiffusion.cpp.

83{
84 int nvariables = inarray.size();
85 int npoints = m_fields[0]->GetNpoints();
86
87 Array<OneD, Array<OneD, NekDouble>> outarrayDiff(nvariables);
88
89 for (int i = 0; i < nvariables; ++i)
90 {
91 outarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
92 }
93
94 m_diffusion->Diffuse(nvariables, m_fields, inarray, outarrayDiff);
95
96 for (int i = 0; i < nvariables; ++i)
97 {
98 Vmath::Vadd(npoints, outarray[i], 1, outarrayDiff[i], 1, outarray[i],
99 1);
100 }
101}
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

References m_diffusion, m_fields, and Vmath::Vadd().

Referenced by DoArtificialDiffusion().

◆ v_DoArtificialDiffusionCoeff()

void Nektar::ArtificialDiffusion::v_DoArtificialDiffusionCoeff ( const Array< OneD, const Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Definition at line 116 of file ArtificialDiffusion.cpp.

119{
120 size_t nvariables = inarray.size();
121 size_t ncoeffs = m_fields[0]->GetNcoeffs();
122
123 Array<OneD, Array<OneD, NekDouble>> outarrayDiff{nvariables};
124
125 for (size_t i = 0; i < nvariables; ++i)
126 {
127 outarrayDiff[i] = Array<OneD, NekDouble>{ncoeffs, 0.0};
128 }
129
130 m_diffusion->DiffuseCoeffs(nvariables, m_fields, inarray, outarrayDiff);
131
132 for (size_t i = 0; i < nvariables; ++i)
133 {
134 Vmath::Vadd(ncoeffs, outarray[i], 1, outarrayDiff[i], 1, outarray[i],
135 1);
136 }
137}

References m_diffusion, m_fields, and Vmath::Vadd().

Referenced by DoArtificialDiffusionCoeff().

◆ v_GetArtificialViscosity()

virtual void Nektar::ArtificialDiffusion::v_GetArtificialViscosity ( const Array< OneD, Array< OneD, NekDouble > > &  physfield,
Array< OneD, NekDouble > &  mu 
)
protectedpure virtual

Member Data Documentation

◆ m_diffusion

SolverUtils::DiffusionSharedPtr Nektar::ArtificialDiffusion::m_diffusion
protected

◆ m_fields

Array<OneD, MultiRegions::ExpListSharedPtr> Nektar::ArtificialDiffusion::m_fields
protected

◆ m_mu0

NekDouble Nektar::ArtificialDiffusion::m_mu0
protected

Constant scaling.

Definition at line 101 of file ArtificialDiffusion.h.

Referenced by ArtificialDiffusion(), and Nektar::NonSmoothShockCapture::v_GetArtificialViscosity().

◆ m_session

LibUtilities::SessionReaderSharedPtr Nektar::ArtificialDiffusion::m_session
protected

Session reader.

Definition at line 93 of file ArtificialDiffusion.h.

Referenced by ArtificialDiffusion(), and Nektar::NonSmoothShockCapture::NonSmoothShockCapture().

◆ m_varConv

VariableConverterSharedPtr Nektar::ArtificialDiffusion::m_varConv
protected