Commit 18ebba85 authored by Zhenguo Yan's avatar Zhenguo Yan

TMP

parent 34e8eb90
......@@ -35,6 +35,8 @@
#ifndef NEKTAR_SOLVERUTILS_DIFFUSIONWEAKDG
#define NEKTAR_SOLVERUTILS_DIFFUSIONWEAKDG
#include <boost/core/ignore_unused.hpp>
#include <SolverUtils/Diffusion/Diffusion.h>
namespace Nektar
......@@ -46,95 +48,66 @@ namespace Nektar
public:
static DiffusionSharedPtr create(std::string diffType)
{
boost::ignore_unused(diffType);
return DiffusionSharedPtr(new DiffusionLDG());
}
static std::string type;
protected:
DiffusionLDG();
std::string m_shockCaptureType;
std::string m_shockCaptureType;
/// Coefficient of penalty term
NekDouble m_C11;
Array<OneD, Array<OneD, NekDouble> > m_traceNormals;
LibUtilities::SessionReaderSharedPtr m_session;
virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
virtual void v_Diffuse(
const int nConvective,
const std::size_t nConvective,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
virtual void v_Diffuse_coeff(
const int nConvective,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
void v_DiffuseCalculateDerivative(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
const Array<OneD, Array<OneD, NekDouble> > &pFwd,
const Array<OneD, Array<OneD, NekDouble> > &pBwd);
void v_DiffuseVolumeFlux(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble>> &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &VolumeFlux,
Array< OneD, int > &nonZeroIndex) ;
void v_DiffuseTraceFlux(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble>> &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &VolumeFlux,
Array<OneD, Array<OneD, NekDouble> > &TraceFlux,
const Array<OneD, Array<OneD, NekDouble>> &pFwd,
const Array<OneD, Array<OneD, NekDouble>> &pBwd,
Array< OneD, int > &nonZeroIndex);
virtual void v_NumFluxforScalar(
void NumFluxforScalar(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &ufield,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&uflux,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
virtual void v_WeakPenaltyforScalar(
void ApplyScalarBCs(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const int var,
const std::size_t var,
const Array<OneD, const NekDouble> &ufield,
const Array<OneD, const NekDouble> &uplus,
const Array<OneD, const NekDouble> &Fwd,
const Array<OneD, const NekDouble> &Bwd,
Array<OneD, NekDouble> &penaltyflux);
virtual void v_NumFluxforVector(
void NumFluxforVector(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &ufield,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&qfield,
Array<OneD, Array<OneD, NekDouble> > &qflux);
virtual void v_WeakPenaltyforVector(
void ApplyVectorBCs(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const int var,
const int dir,
const std::size_t var,
const std::size_t dir,
const Array<OneD, const NekDouble> &qfield,
const Array<OneD, const NekDouble> &qtemp,
Array<OneD, NekDouble> &penaltyflux,
NekDouble C11);
};
const Array<OneD, const NekDouble> &qFwd,
const Array<OneD, const NekDouble> &qBwd,
Array<OneD, NekDouble> &penaltyflux);
};
}
}
#endif
......@@ -35,8 +35,13 @@
#ifndef NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_DIFFUSIONLDGNS
#define NEKTAR_SOLVERS_COMPRESSIBLEFLOWSOLVER_DIFFUSIONLDGNS
#include <boost/core/ignore_unused.hpp>
#include <SolverUtils/Diffusion/Diffusion.h>
#include <CompressibleFlowSolver/Misc/EquationOfState.h>
#include <LocalRegions/Expansion3D.h>
#include <LocalRegions/Expansion2D.h>
using namespace Nektar::SolverUtils;
......@@ -47,6 +52,7 @@ namespace Nektar
public:
static DiffusionSharedPtr create(std::string diffType)
{
boost::ignore_unused(diffType);
return DiffusionSharedPtr(new DiffusionLDGNS());
}
......@@ -55,6 +61,12 @@ namespace Nektar
protected:
DiffusionLDGNS();
/// Penalty coefficient for LDGNS
NekDouble m_C11;
/// h scaling for penalty term
Array<OneD, NekDouble> m_traceOneOverH;
Array<OneD, Array<OneD, NekDouble> > m_traceVel;
Array<OneD, Array<OneD, NekDouble> > m_traceNormals;
LibUtilities::SessionReaderSharedPtr m_session;
......@@ -66,82 +78,50 @@ namespace Nektar
Array<OneD, Array<OneD, NekDouble> > m_homoDerivs;
int m_spaceDim;
int m_diffDim;
std::size_t m_spaceDim;
std::size_t m_diffDim;
virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
virtual void v_Diffuse(
const int nConvective,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
virtual void v_DiffuseCalculateDerivative(
const int nConvective,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
virtual void v_DiffuseVolumeFlux(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble>> &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &VolumeFlux,
Array< OneD, int > &nonZeroIndex) ;
virtual void v_DiffuseTraceFlux(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble>> &inarray,
Array<OneD,Array<OneD, Array<OneD, NekDouble> > > &inarrayderivative,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &VolumeFlux,
Array<OneD, Array<OneD, NekDouble> > &TraceFlux,
const Array<OneD, Array<OneD, NekDouble>> &pFwd,
const Array<OneD, Array<OneD, NekDouble>> &pBwd,
Array< OneD, int > &nonZeroIndex);
virtual void v_Diffuse_coeff(
const int nConvectiveFields,
const std::size_t nConvective,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
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);
const Array<OneD, Array<OneD, NekDouble> > &pFwd,
const Array<OneD, Array<OneD, NekDouble> > &pBwd);
virtual void v_NumericalFluxO1(
void NumericalFluxO1(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
&numericalFluxO1,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
const Array<OneD, Array<OneD, NekDouble> > &pFwd,
const Array<OneD, Array<OneD, NekDouble> > &pBwd);
virtual void v_WeakPenaltyO1(
void ApplyBCsO1(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
const Array<OneD, Array<OneD, NekDouble> > &uplus,
Array<OneD, Array<OneD, NekDouble> > &penaltyfluxO1);
const Array<OneD, Array<OneD, NekDouble> > &pFwd,
const Array<OneD, Array<OneD, NekDouble> > &pBwd,
Array<OneD, Array<OneD, NekDouble> > &flux01);
virtual void v_NumericalFluxO2(
void NumericalFluxO2(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &ufield,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&qfield,
Array<OneD, Array<OneD, NekDouble> > &qflux);
Array<OneD, Array<OneD, NekDouble> > &qflux,
const Array<OneD, Array<OneD, NekDouble> > &pFwd,
const Array<OneD, Array<OneD, NekDouble> > &pBwd);
virtual void v_WeakPenaltyO2(
void ApplyBCsO2(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const int var,
const int dir,
const std::size_t var,
const std::size_t dir,
const Array<OneD, const NekDouble> &qfield,
const Array<OneD, const NekDouble> &qtemp,
const Array<OneD, const NekDouble> &qFwd,
const Array<OneD, const NekDouble> &qBwd,
Array<OneD, NekDouble> &penaltyflux);
virtual void v_SetHomoDerivs(
......
......@@ -79,8 +79,10 @@ namespace Nektar
.CreateInstance(eosType, m_session);
// Viscosity
int nPts = m_fields[0]->GetNpoints();
m_session->LoadSolverInfo("ViscosityType", m_ViscosityType, "Constant");
m_session->LoadParameter ("mu", m_mu, 1.78e-05);
m_session->LoadParameter ("mu", m_muRef, 1.78e-05);
m_mu = Array<OneD, NekDouble>(nPts, m_muRef);
// Thermal conductivity or Prandtl
if( m_session->DefinesParameter("thermalConductivity"))
......@@ -89,16 +91,18 @@ namespace Nektar
"Cannot define both Pr and thermalConductivity.");
m_session->LoadParameter ("thermalConductivity",
m_thermalConductivity);
m_Prandtl = m_Cp * m_mu / m_thermalConductivity;
m_thermalConductivityRef);
m_Prandtl = m_Cp * m_muRef / m_thermalConductivityRef;
}
else
{
m_session->LoadParameter ("Pr", m_Prandtl, 0.72);
m_thermalConductivity = m_Cp * m_mu / m_Prandtl;
m_thermalConductivityRef = m_Cp * m_muRef / m_Prandtl;
}
m_thermalConductivity =
Array<OneD, NekDouble>(nPts, m_thermalConductivityRef);
string diffName, advName;
string diffName;
m_session->LoadSolverInfo("DiffusionType", diffName, "LDGNS");
m_diffusion = SolverUtils::GetDiffusionFactory()
......@@ -215,6 +219,7 @@ namespace Nektar
Array<OneD, Array<OneD, NekDouble> > inFwd(nvariables-1);
Array<OneD, Array<OneD, NekDouble> > inBwd(nvariables-1);
for (i = 0; i < nvariables-1; ++i)
{
inarrayDiff[i] = Array<OneD, NekDouble>(npoints);
......@@ -233,7 +238,7 @@ namespace Nektar
m_varConv->GetVelocityVector(inarray, inarrayDiff);
// Repeat calculation for trace space
if (pFwd == NullNekDoubleArrayofArray ||
if (pFwd == NullNekDoubleArrayofArray ||
pBwd == NullNekDoubleArrayofArray)
{
inFwd = NullNekDoubleArrayofArray;
......@@ -262,12 +267,6 @@ namespace Nektar
outarray[i], 1,
outarray[i], 1);
}
if (m_shockCaptureType != "Off")
{
// Get min h/p
m_artificialDiffusion->SetElmtHP(GetElmtMinHP());
m_artificialDiffusion->DoArtificialDiffusion(inarray, outarray);
}
}
}
......@@ -314,6 +313,7 @@ namespace Nektar
Array<OneD, Array<OneD, NekDouble> > inFwd(nvariables-1);
Array<OneD, Array<OneD, NekDouble> > inBwd(nvariables-1);
for (i = 0; i < nvariables-1; ++i)
{
inarrayDiff[i] = Array<OneD, NekDouble>(npoints);
......@@ -332,7 +332,7 @@ namespace Nektar
m_varConv->GetVelocityVector(inarray, inarrayDiff);
// Repeat calculation for trace space
if (pFwd == NullNekDoubleArrayofArray ||
if (pFwd == NullNekDoubleArrayofArray ||
pBwd == NullNekDoubleArrayofArray)
{
inFwd = NullNekDoubleArrayofArray;
......@@ -351,12 +351,12 @@ namespace Nektar
}
// Diffusion term in physical rhs form
m_diffusion->Diffuse_coeff(nvariables, m_fields, inarrayDiff, outarrayDiff,
m_diffusion->Diffuse(nvariables, m_fields, inarrayDiff, outarrayDiff,
inFwd, inBwd);
for (i = 0; i < nvariables; ++i)
{
Vmath::Vadd(ncoeffs,
Vmath::Vadd(npoints,
outarrayDiff[i], 1,
outarray[i], 1,
outarray[i], 1);
......@@ -1137,4 +1137,72 @@ namespace Nektar
}
/**
* @brief Return the penalty vector for the LDGNS diffusion problem.
*/
void NavierStokesCFE::v_GetFluxPenalty(
const Array<OneD, Array<OneD, NekDouble> > &uFwd,
const Array<OneD, Array<OneD, NekDouble> > &uBwd,
Array<OneD, Array<OneD, NekDouble> > &penaltyCoeff)
{
unsigned int nTracePts = uFwd[0].num_elements();
// Compute average temperature
unsigned int nVariables = uFwd.num_elements();
Array<OneD, NekDouble> tAve{nTracePts, 0.0};
Vmath::Svtsvtp(nTracePts, 0.5, uFwd[nVariables-1], 1,
0.5, uBwd[nVariables-1], 1, tAve, 1);
// Get average viscosity and thermal conductivity
Array<OneD, NekDouble> muAve{nTracePts, 0.0};
Array<OneD, NekDouble> tcAve{nTracePts, 0.0};
GetViscosityAndThermalCondFromTemp(tAve, muAve, tcAve);
// Compute penalty term
for (int i = 0; i < nVariables; ++i)
{
// Get jump of u variables
Vmath::Vsub(nTracePts, uFwd[i], 1, uBwd[i], 1, penaltyCoeff[i], 1);
// Multiply by variable coefficient = {coeff} ( u^+ - u^- )
if ( i < nVariables-1 )
{
Vmath::Vmul(nTracePts, muAve, 1, penaltyCoeff[i], 1,
penaltyCoeff[i], 1);
}
else
{
Vmath::Vmul(nTracePts, tcAve, 1, penaltyCoeff[i], 1,
penaltyCoeff[i], 1);
}
}
}
/**
* @brief Update viscosity
* todo: add artificial viscosity here
*/
void NavierStokesCFE::GetViscosityAndThermalCondFromTemp(
const Array<OneD, NekDouble> &temperature,
Array<OneD, NekDouble> &mu,
Array<OneD, NekDouble> &thermalCond)
{
int nPts = temperature.num_elements();
// Variable viscosity through the Sutherland's law
if (m_ViscosityType == "Variable")
{
m_varConv->GetDynamicViscosity(temperature, mu);
}
else
{
Vmath::Fill(nPts, m_muRef, mu, 1);
}
NekDouble tRa = m_Cp / m_Prandtl;
Vmath::Smul(nPts, tRa, mu, 1, thermalCond, 1);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment