35#ifndef NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_EQUATIONSYSTEMS_NAVIERSTOKESCFE_H
36#define NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_EQUATIONSYSTEMS_NAVIERSTOKESCFE_H
109 const size_t nSpaceDim,
171 std::vector<std::string> &variables)
override;
174 std::enable_if_t<std::is_floating_point_v<T> ||
175 tinysimd::is_vector_floating_point_v<T>,
179 T &mu, T &thermalCond)
183 thermalCond = tRa * mu;
187 std::enable_if_t<std::is_floating_point_v<T> ||
188 tinysimd::is_vector_floating_point_v<T>,
196 mu =
m_varConv->GetDynamicViscosity(temperature);
213 std::enable_if_t<std::is_floating_point_v<T> ||
214 tinysimd::is_vector_floating_point_v<T>,
218 const unsigned short nDim,
const unsigned short FluxDirection,
219 const unsigned short DerivDirection,
222 const T *inaverg,
const T *injumpp,
const T &mu, T *outarray)
225 unsigned short nDim_plus_one = nDim + 1;
226 unsigned short FluxDirection_plus_one = FluxDirection + 1;
227 unsigned short DerivDirection_plus_one = DerivDirection + 1;
230 NekDouble one_minus_gammaoPr = 1.0 - gammaoPr;
233 constexpr NekDouble TwoThird = 2. * OneThird;
234 constexpr NekDouble FourThird = 4. * OneThird;
236 if (DerivDirection == FluxDirection)
242 T oneOrho = 1.0 / inaverg[0];
244 std::array<T, 3> u = {{0.0, 0.0, 0.0}};
245 std::array<T, 3> u2 = {{0.0, 0.0, 0.0}};
247 for (
unsigned short d = 0; d < nDim; ++d)
249 u[d] = inaverg[d + 1] * oneOrho;
255 T E_minus_u2sum = inaverg[nDim_plus_one];
256 E_minus_u2sum *= oneOrho;
257 E_minus_u2sum -= u2sum;
264 T tmp1 = OneThird * u2[FluxDirection] + u2sum;
265 tmp1 += gammaoPr * E_minus_u2sum;
268 T tmp2 = gammaoPr * injumpp[nDim_plus_one] - tmp1;
272 for (
unsigned short d = 0; d < nDim; ++d)
274 unsigned short d_plus_one = d + 1;
276 T outTmpD = injumpp[d_plus_one] - u[d] * injumpp[0];
279 T tmp3 = one_minus_gammaoPr * u[d];
280 outTmpE += tmp3 * injumpp[d_plus_one];
282 if (d == FluxDirection)
284 outTmpD *= FourThird;
285 T tmp4 = OneThird * u[FluxDirection];
286 outTmpE += tmp4 * injumpp[FluxDirection_plus_one];
289 outarray[d_plus_one] = outTmpD;
294 outarray[nDim_plus_one] = outTmpE;
302 T oneOrho = 1.0 / inaverg[0];
304 std::array<T, 3> u, u2;
306 for (
unsigned short d = 0; d < nDim; ++d)
308 unsigned short d_plus_one = d + 1;
309 u[d] = inaverg[d_plus_one] * oneOrho;
314 outarray[d_plus_one] = 0.0;
318 T E_minus_u2sum = inaverg[nDim_plus_one];
319 E_minus_u2sum *= oneOrho;
320 E_minus_u2sum -= u2sum;
327 T tmp1 = u[DerivDirection] * injumpp[0] -
328 injumpp[DerivDirection_plus_one];
330 outarray[FluxDirection_plus_one] = nu * tmp1;
333 injumpp[FluxDirection_plus_one] - u[FluxDirection] * injumpp[0];
334 outarray[DerivDirection_plus_one] = nu * tmp1;
336 tmp1 = OneThird * u[FluxDirection] * u[DerivDirection];
340 TwoThird * u[FluxDirection] * injumpp[DerivDirection_plus_one];
344 tmp1 = u[DerivDirection] * injumpp[FluxDirection_plus_one] - tmp1;
345 outarray[nDim_plus_one] = nu * tmp1;
353 template <
bool IS_TRACE>
360 size_t nConvectiveFields = inarray.size();
361 size_t nPts = inarray[0].size();
362 size_t n_nonZero = nConvectiveFields - 1;
365 constexpr unsigned short nOutMax = 3 - 2 * IS_TRACE;
366 constexpr unsigned short nVarMax = 5;
367 constexpr unsigned short nDimMax = 3;
375 m_varConv->GetTemperature(inarray, temperature);
377 thermalConductivity);
382 size_t sizeVec = (nPts / vec_t::width) * vec_t::width;
385 for (; p < sizeVec; p += vec_t::width)
388 alignas(vec_t::alignment) std::array<vec_t, nVarMax> inTmp,
390 alignas(vec_t::alignment) std::array<vec_t, nDimMax> normalTmp;
391 alignas(vec_t::alignment) std::array<vec_t, nVarMax * nOutMax>
395 for (
size_t f = 0; f < nConvectiveFields; ++f)
405 for (
size_t d = 0; d < nDim; ++d)
407 outArrTmp[f + nConvectiveFields * d] = 0.0;
413 for (
size_t d = 0; d < nDim; ++d)
423 for (
size_t nderiv = 0; nderiv < nDim; ++nderiv)
426 for (
size_t f = 0; f < nConvectiveFields; ++f)
428 qfieldsTmp[f].load(&(qfields[nderiv][f][p]),
432 for (
size_t d = 0; d < nDim; ++d)
435 nDim, d, nderiv, inTmp.data(), qfieldsTmp.data(), muV,
440 for (
size_t f = 0; f < nConvectiveFields; ++f)
442 outArrTmp[f] += normalTmp[d] * outTmp[f];
447 for (
size_t f = 0; f < nConvectiveFields; ++f)
449 outArrTmp[f + nConvectiveFields * d] += outTmp[f];
458 for (
size_t f = 0; f < nConvectiveFields; ++f)
465 for (
size_t d = 0; d < nDim; ++d)
467 for (
size_t f = 0; f < nConvectiveFields; ++f)
469 outArrTmp[f + nConvectiveFields * d].store(
477 for (; p < nPts; ++p)
479 std::array<NekDouble, nVarMax> inTmp, qfieldsTmp, outTmp;
480 std::array<NekDouble, nDimMax> normalTmp;
481 std::array<NekDouble, nVarMax * nOutMax> outArrTmp{{}};
483 for (
size_t f = 0; f < nConvectiveFields; ++f)
485 inTmp[f] = inarray[f][p];
493 for (
size_t d = 0; d < nDim; ++d)
495 outArrTmp[f + nConvectiveFields * d] = 0.0;
502 for (
size_t d = 0; d < nDim; ++d)
504 normalTmp[d] = normal[d][p];
511 for (
size_t nderiv = 0; nderiv < nDim; ++nderiv)
514 for (
size_t f = 0; f < nConvectiveFields; ++f)
516 qfieldsTmp[f] = qfields[nderiv][f][p];
519 for (
size_t d = 0; d < nDim; ++d)
522 nDim, d, nderiv, inTmp.data(), qfieldsTmp.data(), muS,
527 for (
size_t f = 0; f < nConvectiveFields; ++f)
529 outArrTmp[f] += normalTmp[d] * outTmp[f];
534 for (
size_t f = 0; f < nConvectiveFields; ++f)
536 outArrTmp[f + nConvectiveFields * d] += outTmp[f];
545 for (
size_t f = 0; f < nConvectiveFields; ++f)
547 outarray[0][f][p] = outArrTmp[f];
552 for (
size_t d = 0; d < nDim; ++d)
554 for (
size_t f = 0; f < nConvectiveFields; ++f)
557 outArrTmp[f + nConvectiveFields * d];
565 for (
int i = 1; i < n_nonZero + 1; ++i)
567 nonZeroIndex[n_nonZero - i] = nConvectiveFields - i;
VariableConverterSharedPtr m_varConv
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
EquationOfStateSharedPtr m_eos
Equation of system for computing temperature.
static std::string className
Name of class.
void CalcViscosity(const Array< OneD, const Array< OneD, NekDouble > > &inaverg, Array< OneD, NekDouble > &mu)
void GetDivCurlFromDvelT(const TensorOfArray3D< NekDouble > &pVarDer, Array< OneD, NekDouble > &div, Array< OneD, NekDouble > &curlSquare)
Get divergence and curl from velocity derivative tensor.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void v_InitObject(bool DeclareField=true) override
Initialization object for CompressibleFlowSystem class.
void GetDivCurlSquared(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &cnsVar, Array< OneD, NekDouble > &div, Array< OneD, NekDouble > &curlSquare, const Array< OneD, Array< OneD, NekDouble > > &cnsVarFwd, const Array< OneD, Array< OneD, NekDouble > > &cnsVarBwd)
Get divergence and curl squared.
void InitObject_Explicit()
void v_DoDiffusion(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const Array< OneD, Array< OneD, NekDouble > > &pFwd, const Array< OneD, Array< OneD, NekDouble > > &pBwd) override
std::string m_physicalSensorType
NekDouble m_thermalConductivityRef
bool m_is_mu_variable
flag to switch between constant viscosity and Sutherland an enum could be added for more options
void GetViscousFluxVectorConservVar(const size_t nDim, const Array< OneD, Array< OneD, NekDouble > > &inarray, const TensorOfArray3D< NekDouble > &qfields, TensorOfArray3D< NekDouble > &outarray, Array< OneD, int > &nonZeroIndex, const Array< OneD, Array< OneD, NekDouble > > &normal)
Return the flux vector for the IP diffusion problem, based on conservative variables.
void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables) override
bool m_is_shockCaptPhys
flag for shock capturing switch on/off an enum could be added for more options
MultiRegions::ContFieldSharedPtr m_C0ProjectExp
bool v_SupportsShockCaptType(const std::string type) const override
void GetViscousSymmtrFluxConservVar(const size_t nSpaceDim, const Array< OneD, Array< OneD, NekDouble > > &inaverg, const Array< OneD, Array< OneD, NekDouble > > &inarray, TensorOfArray3D< NekDouble > &outarray, Array< OneD, int > &nonZeroIndex, const Array< OneD, Array< OneD, NekDouble > > &normals)
Calculate and return the Symmetric flux in IP method.
void GetViscosityAndThermalCondFromTemp(const Array< OneD, NekDouble > &temperature, Array< OneD, NekDouble > &mu, Array< OneD, NekDouble > &thermalCond)
Update viscosity todo: add artificial viscosity here.
void C0Smooth(Array< OneD, NekDouble > &field)
~NavierStokesCFE() override=default
virtual void v_GetViscousFluxVector(const Array< OneD, const Array< OneD, NekDouble > > &physfield, TensorOfArray3D< NekDouble > &derivatives, TensorOfArray3D< NekDouble > &viscousTensor)
Return the flux vector for the LDG diffusion problem.
virtual void v_GetFluxPenalty(const Array< OneD, const Array< OneD, NekDouble > > &uFwd, const Array< OneD, const Array< OneD, NekDouble > > &uBwd, Array< OneD, Array< OneD, NekDouble > > &penaltyCoeff)
Return the penalty vector for the LDGNS diffusion problem.
void GetPhysicalAV(const Array< OneD, const Array< OneD, NekDouble > > &physfield)
void GetViscousFluxVectorConservVar(const size_t nDim, const Array< OneD, Array< OneD, NekDouble > > &inarray, const TensorOfArray3D< NekDouble > &qfields, TensorOfArray3D< NekDouble > &outarray, Array< OneD, int > &nonZeroIndex=NullInt1DArray, const Array< OneD, Array< OneD, NekDouble > > &normal=NullNekDoubleArrayOfArray)
bool m_is_diffIP
flag to switch between IP and LDG an enum could be added for more options
void Ducros(Array< OneD, NekDouble > &field)
void GetViscousFluxBilinearFormKernel(const unsigned short nDim, const unsigned short FluxDirection, const unsigned short DerivDirection, const T *inaverg, const T *injumpp, const T &mu, T *outarray)
Calculate diffusion flux using the Jacobian form.
void GetViscosityFromTempKernel(const T &temperature, T &mu)
void GetArtificialViscosity(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &muav)
void GetViscosityAndThermalCondFromTempKernel(const T &temperature, T &mu, T &thermalCond)
virtual void v_GetViscousFluxVectorDeAlias(const Array< OneD, const Array< OneD, NekDouble > > &physfield, TensorOfArray3D< NekDouble > &derivatives, TensorOfArray3D< NekDouble > &viscousTensor)
Return the flux vector for the LDG diffusion problem.
std::string m_ViscosityType
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
std::function< void(Array< OneD, Array< OneD, NekDouble > > &)> SpecialBndTreat
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
static Array< OneD, int > NullInt1DArray
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
std::shared_ptr< EquationOfState > EquationOfStateSharedPtr
A shared pointer to an equation of state object.
tinysimd::simd< NekDouble > vec_t
static constexpr struct tinysimd::is_not_aligned_t is_not_aligned
typename abi< ScalarType, width >::type simd