Commit 6cb5ebd5 authored by Giacomo Castiglioni's avatar Giacomo Castiglioni Committed by Dave Moxey

Fix/ldg penalty

parent 36b04d7e
...@@ -14,3 +14,6 @@ ThirdParty ...@@ -14,3 +14,6 @@ ThirdParty
*.pdf *.pdf
# Kdevelop project files # Kdevelop project files
*.kdev4 *.kdev4
# Sublime project files
*.sublime-project
*.sublime-workspace
...@@ -132,6 +132,7 @@ v5.0.0 ...@@ -132,6 +132,7 @@ v5.0.0
- Fix surface extraction, added regression test (!994) - Fix surface extraction, added regression test (!994)
- Fix 2D meshing running out of memory due to missing else (!1012) - Fix 2D meshing running out of memory due to missing else (!1012)
- Add support for .msh v4.1 file input (!1054) - Add support for .msh v4.1 file input (!1054)
- Added penalty term to LDG and LDGNS, slight generalization of LDG (!1080)
**FieldConvert**: **FieldConvert**:
- Add input module for Semtex field files (!777) - Add input module for Semtex field files (!777)
......
...@@ -11,14 +11,14 @@ The ADRSolver is designed to solve partial differential equations of the form: ...@@ -11,14 +11,14 @@ The ADRSolver is designed to solve partial differential equations of the form:
\begin{equation} \begin{equation}
\alpha \dfrac{\partial u}{\partial t} + \lambda u + \nu \nabla u + \epsilon \nabla \cdot (D \nabla u) = f \alpha \dfrac{\partial u}{\partial t} + \lambda u + \nu \nabla u + \epsilon \nabla \cdot (D \nabla u) = f
\end{equation} \end{equation}
in either discontinuous or continuous projections of the solution field. in either discontinuous or continuous projections of the solution field.
For a full list of the equations which are supported, and the capabilities of each equation, For a full list of the equations which are supported, and the capabilities of each equation,
see the table below. see the table below.
\begin{table}[h!] \begin{table}[h!]
\begin{center} \begin{center}
\tiny \tiny
\renewcommand\arraystretch{2.2} \renewcommand\arraystretch{2.2}
\begin{tabular}{llll} \begin{tabular}{llll}
\toprule \toprule
\textbf{Equation to solve} & \textbf{EquationType} & \textbf{Dimensions} & \textbf{Equation to solve} & \textbf{EquationType} & \textbf{Dimensions} &
...@@ -26,22 +26,22 @@ see the table below. ...@@ -26,22 +26,22 @@ see the table below.
\midrule \midrule
$u = f$ & $u = f$ &
\inltt{Projection} & All & Continuous/Discontinuous \\ \inltt{Projection} & All & Continuous/Discontinuous \\
$\nabla^2 u = 0$ & $\nabla^2 u = 0$ &
\inltt{Laplace} & All & Continuous/Discontinuous \\ \inltt{Laplace} & All & Continuous/Discontinuous \\
$\nabla^2 u = f$ & $\nabla^2 u = f$ &
\inltt{Poisson} & All & Continuous/Discontinuous \\ \inltt{Poisson} & All & Continuous/Discontinuous \\
$\nabla^2 u + \lambda u = f$ & $\nabla^2 u + \lambda u = f$ &
\inltt{Helmholtz} & All & Continuous/Discontinuous \\ \inltt{Helmholtz} & All & Continuous/Discontinuous \\
$\epsilon \nabla^2 u + \mathbf{V}\nabla u = f$ & $\epsilon \nabla^2 u + \mathbf{V}\nabla u = f$ &
\inltt{SteadyAdvectionDiffusion} & 2D only & Continuous/Discontinuous \\ \inltt{SteadyAdvectionDiffusion} & 2D only & Continuous/Discontinuous \\
$\epsilon \nabla^2 u + \lambda u = f$ & $\epsilon \nabla^2 u + \lambda u = f$ &
\inltt{SteadyDiffusionReaction} & 2D only & Continuous/Discontinuous \\ \inltt{SteadyDiffusionReaction} & 2D only & Continuous/Discontinuous \\
$\epsilon \nabla^2 u + \mathbf{V}\nabla u + \lambda u = f$ & $\epsilon \nabla^2 u + \mathbf{V}\nabla u + \lambda u = f$ &
\inltt{SteadyAdvectionDiffusionReaction} & 2D only & \inltt{SteadyAdvectionDiffusionReaction} & 2D only &
Continuous/Discontinuous \\ Continuous/Discontinuous \\
$ \dfrac{\partial u}{\partial t} + \mathbf{V}\nabla u = f$ & $ \dfrac{\partial u}{\partial t} + \mathbf{V}\nabla u = f$ &
\inltt{UnsteadyAdvection} & All & Continuous/Discontinuous \\ \inltt{UnsteadyAdvection} & All & Continuous/Discontinuous \\
$\dfrac{\partial u}{\partial t} = \epsilon \nabla^2 u$ & $\dfrac{\partial u}{\partial t} = \epsilon \nabla^2 u$ &
\inltt{UnsteadyDiffusion} & All & Continuous/Discontinuous \\ \inltt{UnsteadyDiffusion} & All & Continuous/Discontinuous \\
$\dfrac{\partial u}{\partial t} = \epsilon \nabla^2 u + R(u)$ & $\dfrac{\partial u}{\partial t} = \epsilon \nabla^2 u + R(u)$ &
\inltt{UnsteadyReactionDiffusion} & All & Continuous \\ \inltt{UnsteadyReactionDiffusion} & All & Continuous \\
...@@ -64,7 +64,7 @@ ADRSolver session.xml ...@@ -64,7 +64,7 @@ ADRSolver session.xml
\section{Session file configuration} \section{Session file configuration}
The type of equation which is to be solved is specified through the EquationType The type of equation which is to be solved is specified through the EquationType
SOLVERINFO option in the session file. This can be set as in table \ref{t:ADR1}. SOLVERINFO option in the session file. This can be set as in table \ref{t:ADR1}.
At present, the Steady non-symmetric solvers cannot be used in parallel. \\ At present, the Steady non-symmetric solvers cannot be used in parallel. \\
...@@ -76,7 +76,7 @@ The solver info are listed below: ...@@ -76,7 +76,7 @@ The solver info are listed below:
\item \textbf{TimeIntegrationMethod}: The following types of time integration methods have been tested with each solver: \item \textbf{TimeIntegrationMethod}: The following types of time integration methods have been tested with each solver:
\begin{center} \begin{center}
\footnotesize \footnotesize
\renewcommand\arraystretch{1.2} \renewcommand\arraystretch{1.2}
\begin{tabular}{lcccc} \begin{tabular}{lcccc}
\toprule \toprule
\textbf{EqType} & \textbf{Explicit} & \textbf{Diagonally Implicit} & \textbf{EqType} & \textbf{Explicit} & \textbf{Diagonally Implicit} &
...@@ -116,7 +116,7 @@ The solver info are listed below: ...@@ -116,7 +116,7 @@ The solver info are listed below:
\end{itemize} \end{itemize}
\item \textbf{DiffusionType}: \item \textbf{DiffusionType}:
\begin{itemize} \begin{itemize}
\item \inltt{LDG}. \item \inltt{LDG} (The penalty term is proportional to an optional parameter \inltt{LDGc11} which is by default set to one; proportionality to polynomial order can be manually imposed by setting the parameter \inltt{LDGc11} equal to $p^2$).
\end{itemize} \end{itemize}
\item \textbf{UpwindType}: \item \textbf{UpwindType}:
\begin{itemize} \begin{itemize}
...@@ -129,13 +129,13 @@ The solver info are listed below: ...@@ -129,13 +129,13 @@ The solver info are listed below:
The following parameters can be specified in the \inltt{PARAMETERS} section of The following parameters can be specified in the \inltt{PARAMETERS} section of
the session file: the session file:
\begin{itemize} \begin{itemize}
\item \inltt{epsilon}: sets the diffusion coefficient $\epsilon$.\\ \item \inltt{epsilon}: sets the diffusion coefficient $\epsilon$.\\
\textit{Can be used} in: SteadyDiffusionReaction, SteadyAdvectionDiffusionReaction, UnsteadyDiffusion, UnsteadyAdvectionDiffusion. \\ \textit{Can be used} in: SteadyDiffusionReaction, SteadyAdvectionDiffusionReaction, UnsteadyDiffusion, UnsteadyAdvectionDiffusion. \\
\textit{Default value}: 0. \textit{Default value}: 0.
\item \inltt{d00}, \inltt{d11}, \inltt{d22}: sets the diagonal entries of the \item \inltt{d00}, \inltt{d11}, \inltt{d22}: sets the diagonal entries of the
diffusion tensor $D$. \\ diffusion tensor $D$. \\
\textit{Can be used in}: UnsteadyDiffusion \\ \textit{Can be used in}: UnsteadyDiffusion \\
\textit{Default value}: All set to 1 (i.e. identity matrix). \textit{Default value}: All set to 1 (i.e. identity matrix).
\item \inltt{lambda}: sets the reaction coefficient $\lambda$. \\ \item \inltt{lambda}: sets the reaction coefficient $\lambda$. \\
\textit{Can be used in}: SteadyDiffusionReaction, Helmholtz, SteadyAdvectionDiffusionReaction\\ \textit{Can be used in}: SteadyDiffusionReaction, Helmholtz, SteadyAdvectionDiffusionReaction\\
\textit{Default value}: 0. \textit{Default value}: 0.
...@@ -215,7 +215,7 @@ and then define the actual advection function as ...@@ -215,7 +215,7 @@ and then define the actual advection function as
Two boundary regions are defined, one at each end of the domain, and periodicity Two boundary regions are defined, one at each end of the domain, and periodicity
is enforced is enforced
\begin{lstlisting}[style=XMLStyle] \begin{lstlisting}[style=XMLStyle]
<BOUNDARYREGIONS> <BOUNDARYREGIONS>
<B ID="0"> C[1] </B> <B ID="0"> C[1] </B>
<B ID="1"> C[2] </B> <B ID="1"> C[2] </B>
...@@ -268,7 +268,7 @@ We consider the elliptic partial differential equation: ...@@ -268,7 +268,7 @@ We consider the elliptic partial differential equation:
where $\nabla^2$ is the Laplacian and $\lambda$ is a real positive constant. where $\nabla^2$ is the Laplacian and $\lambda$ is a real positive constant.
\subsubsection{Input file} \subsubsection{Input file}
The input for this example is given in the example file The input for this example is given in the example file
\inlsh{Helmholtz2D\_modal.xml} \inlsh{Helmholtz2D\_modal.xml}
...@@ -300,7 +300,7 @@ basis with $7$ modes (maximum polynomial order is $6$). ...@@ -300,7 +300,7 @@ basis with $7$ modes (maximum polynomial order is $6$).
\end{lstlisting} \end{lstlisting}
Only one parameter is needed for this problem. In this example $\lambda = 1$ and Only one parameter is needed for this problem. In this example $\lambda = 1$ and
the Continuous Galerkin Method is used as projection scheme to solve the the Continuous Galerkin Method is used as projection scheme to solve the
Helmholtz equation, so we need to specify the following parameters and solver Helmholtz equation, so we need to specify the following parameters and solver
information. information.
\begin{lstlisting}[style=XMLStyle] \begin{lstlisting}[style=XMLStyle]
...@@ -331,7 +331,7 @@ region is then assigned an appropriate boundary condition. ...@@ -331,7 +331,7 @@ region is then assigned an appropriate boundary condition.
<D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" /> <D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" />
</REGION> </REGION>
<REGION REF="1"> <REGION REF="1">
<R VAR="u" VALUE="sin(PI*x)*sin(PI*y)-PI*sin(PI*x)*cos(PI*y)" <R VAR="u" VALUE="sin(PI*x)*sin(PI*y)-PI*sin(PI*x)*cos(PI*y)"
PRIMCOEFF="1" /> PRIMCOEFF="1" />
</REGION> </REGION>
<REGION REF="2"> <REGION REF="2">
...@@ -343,7 +343,7 @@ region is then assigned an appropriate boundary condition. ...@@ -343,7 +343,7 @@ region is then assigned an appropriate boundary condition.
</BOUNDARYCONDITIONS> </BOUNDARYCONDITIONS>
\end{lstlisting} \end{lstlisting}
We know that for $f = -(\lambda + 2 \pi^2)sin(\pi x)cos(\pi y)$, the exact We know that for $f = -(\lambda + 2 \pi^2)sin(\pi x)cos(\pi y)$, the exact
solution of the two-dimensional Helmholtz equation is $u = sin(\pi x)cos(\pi solution of the two-dimensional Helmholtz equation is $u = sin(\pi x)cos(\pi
y)$. These functions are defined specified to initialise the problem and verify y)$. These functions are defined specified to initialise the problem and verify
the correct solution is obtained by evaluating the $L_2$ and $L_{inf}$ errors. the correct solution is obtained by evaluating the $L_2$ and $L_{inf}$ errors.
...@@ -363,7 +363,7 @@ the correct solution is obtained by evaluating the $L_2$ and $L_{inf}$ errors. ...@@ -363,7 +363,7 @@ the correct solution is obtained by evaluating the $L_2$ and $L_{inf}$ errors.
ADRSolver Test_Helmholtz2D_modal.xml ADRSolver Test_Helmholtz2D_modal.xml
\end{lstlisting} \end{lstlisting}
This execution should print out a summary of input file, the $L_2$ and This execution should print out a summary of input file, the $L_2$ and
$L_{inf}$ errors and the time spent on the calculation. $L_{inf}$ errors and the time spent on the calculation.
\subsubsection{Post-processing} \subsubsection{Post-processing}
...@@ -417,9 +417,9 @@ Schmidt number (the relative thickness of the momentum to mass transfer boundary ...@@ -417,9 +417,9 @@ Schmidt number (the relative thickness of the momentum to mass transfer boundary
layer) is sufficiently large. The analytical solution for the non-dimensional layer) is sufficiently large. The analytical solution for the non-dimensional
mass transfer at the wall is given by: mass transfer at the wall is given by:
\begin{align*} \begin{align*}
S h(z) = \dfrac{2^{4/3}(Pe R/z)^{1/3}}{g^{1/3}\Gamma(4/3)} , S h(z) = \dfrac{2^{4/3}(Pe R/z)^{1/3}}{g^{1/3}\Gamma(4/3)} ,
\end{align*} \end{align*}
where $z$ is the streamwise coordinate, $R$ the pipe radius, $\Gamma(4/3)$ an incomplete where $z$ is the streamwise coordinate, $R$ the pipe radius, $\Gamma(4/3)$ an incomplete
Gamma function and $Pe$ the Peclet number given by: Gamma function and $Pe$ the Peclet number given by:
\begin{align*} \begin{align*}
Pe = \dfrac{2 U R}{\epsilon} Pe = \dfrac{2 U R}{\epsilon}
...@@ -538,7 +538,7 @@ flow), hence we can define this through an analytical function as follows: ...@@ -538,7 +538,7 @@ flow), hence we can define this through an analytical function as follows:
\end{lstlisting} \end{lstlisting}
We assume that the initial domain concentration is uniform everywhere and the We assume that the initial domain concentration is uniform everywhere and the
same as the inlet. This is defined by, same as the inlet. This is defined by,
\begin{lstlisting}[style=XMLStyle] \begin{lstlisting}[style=XMLStyle]
<FUNCTION NAME="InitialConditions"> <FUNCTION NAME="InitialConditions">
<E VAR="u" VALUE="1" /> <E VAR="u" VALUE="1" />
......
...@@ -272,7 +272,7 @@ Note that only \inltt{WeakDG} is fully supported, the other operators work only ...@@ -272,7 +272,7 @@ Note that only \inltt{WeakDG} is fully supported, the other operators work only
\item \inltt{DiffusionType} is the diffusion operator we want to use \item \inltt{DiffusionType} is the diffusion operator we want to use
for the Navier-Stokes equations: for the Navier-Stokes equations:
\begin{itemize} \begin{itemize}
\item \inltt{LDGNS} (LDG); \item \inltt{LDGNS} (LDG with primitive variables. The penalty term is inversely proportional to the element size, proportional to the local viscosity for the momentum equations and to the thermal conductivity for the energy equation, and proportional to an optional parameter \inltt{LDGNSc11} which is by default set to one; proportionality to polynomial order can be manually imposed by setting the parameter \inltt{LDGNSc11} equal to $p^2$);
\item \inltt{LFRDGNS} (Flux-Reconstruction recovering nodal DG scheme); \item \inltt{LFRDGNS} (Flux-Reconstruction recovering nodal DG scheme);
\item \inltt{LFRSDNS} (Flux-Reconstruction recovering a spectral difference (SD) scheme); \item \inltt{LFRSDNS} (Flux-Reconstruction recovering a spectral difference (SD) scheme);
\item \inltt{LFRHUNS} (Flux-Reconstruction recovering Huynh (G2) scheme); \item \inltt{LFRHUNS} (Flux-Reconstruction recovering Huynh (G2) scheme);
......
...@@ -43,16 +43,16 @@ namespace Nektar ...@@ -43,16 +43,16 @@ namespace Nektar
static DiffusionFactory instance; static DiffusionFactory instance;
return instance; return instance;
} }
void Diffusion::InitObject( void Diffusion::InitObject(
const LibUtilities::SessionReaderSharedPtr pSession, const LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields) Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{ {
v_InitObject(pSession, pFields); v_InitObject(pSession, pFields);
} }
void Diffusion::Diffuse( void Diffusion::Diffuse(
const int nConvectiveFields, const std::size_t nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields, const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray, const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray, Array<OneD, Array<OneD, NekDouble> > &outarray,
......
...@@ -52,23 +52,28 @@ namespace Nektar ...@@ -52,23 +52,28 @@ namespace Nektar
namespace SolverUtils namespace SolverUtils
{ {
typedef std::function<void ( typedef std::function<void (
const int, const Array<OneD, Array<OneD, NekDouble> > &,
const int, const Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&,
const Array<OneD, Array<OneD, NekDouble> >&, Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
Array<OneD, Array<OneD, NekDouble> >&, DiffusionFluxVecCB;
Array<OneD, Array<OneD, NekDouble> >&)> DiffusionFluxVecCB;
typedef std::function<void ( typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&, const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&, Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)> Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
DiffusionFluxVecCBNS; DiffusionFluxVecCBNS;
typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, NekDouble> >&)>
DiffusionFluxPenaltyNS;
typedef std::function<void ( typedef std::function<void (
const Array<OneD, Array<OneD, NekDouble> >&, const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, NekDouble >&)> Array<OneD, NekDouble >&)>
DiffusionArtificialDiffusion; DiffusionArtificialDiffusion;
class Diffusion class Diffusion
{ {
public: public:
...@@ -79,34 +84,33 @@ namespace Nektar ...@@ -79,34 +84,33 @@ namespace Nektar
SOLVER_UTILS_EXPORT void InitObject( SOLVER_UTILS_EXPORT void InitObject(
LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields); Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
SOLVER_UTILS_EXPORT void Diffuse( SOLVER_UTILS_EXPORT void Diffuse(
const int nConvectiveFields, const std::size_t nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields, const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray, const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray, Array<OneD, Array<OneD, NekDouble> > &outarray,
const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray, const Array<OneD, Array<OneD, NekDouble> > &pFwd = NullNekDoubleArrayofArray,
const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray); const Array<OneD, Array<OneD, NekDouble> > &pBwd = NullNekDoubleArrayofArray);
SOLVER_UTILS_EXPORT void FluxVec( SOLVER_UTILS_EXPORT void FluxVec(
Array<OneD, Array<OneD, Array<OneD, NekDouble> > > Array<OneD, Array<OneD, Array<OneD, NekDouble> > >
&fluxvector); &fluxvector);
template<typename FuncPointerT, typename ObjectPointerT> template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVector(FuncPointerT func, ObjectPointerT obj) void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
{ {
m_fluxVector = std::bind( m_fluxVector = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2, func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, std::placeholders::_4, std::placeholders::_3);
std::placeholders::_5);
} }
void SetFluxVectorVec(DiffusionFluxVecCB fluxVector) void SetFluxVector(DiffusionFluxVecCB fluxVector)
{ {
m_fluxVector = fluxVector; m_fluxVector = fluxVector;
} }
template<typename FuncPointerT, typename ObjectPointerT> template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVectorNS(FuncPointerT func, ObjectPointerT obj) void SetFluxVectorNS(FuncPointerT func, ObjectPointerT obj)
{ {
m_fluxVectorNS = std::bind( m_fluxVectorNS = std::bind(
...@@ -114,16 +118,22 @@ namespace Nektar ...@@ -114,16 +118,22 @@ namespace Nektar
std::placeholders::_3); std::placeholders::_3);
} }
void SetFluxVectorNS(DiffusionFluxVecCBNS fluxVector)
{
m_fluxVectorNS = fluxVector;
}
template<typename FuncPointerT, typename ObjectPointerT> template<typename FuncPointerT, typename ObjectPointerT>
void SetArtificialDiffusionVector(FuncPointerT func, ObjectPointerT obj) void SetFluxPenaltyNS(FuncPointerT func, ObjectPointerT obj)
{ {
m_ArtificialDiffusionVector = std::bind( m_fluxPenaltyNS = std::bind(
func, obj, std::placeholders::_1, std::placeholders::_2); func, obj, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
} }
void SetFluxVectorNS(DiffusionFluxVecCBNS fluxVector) void SetFluxPenaltyNS(DiffusionFluxPenaltyNS flux)
{ {
m_fluxVectorNS = fluxVector; m_fluxPenaltyNS = flux;
} }
inline void SetHomoDerivs(Array<OneD, Array<OneD, NekDouble> > &deriv) inline void SetHomoDerivs(Array<OneD, Array<OneD, NekDouble> > &deriv)
...@@ -135,11 +145,11 @@ namespace Nektar ...@@ -135,11 +145,11 @@ namespace Nektar
{ {
return v_GetFluxTensor(); return v_GetFluxTensor();
} }
protected: protected:
DiffusionFluxVecCB m_fluxVector; DiffusionFluxVecCB m_fluxVector;
DiffusionFluxVecCBNS m_fluxVectorNS; DiffusionFluxVecCBNS m_fluxVectorNS;
DiffusionArtificialDiffusion m_ArtificialDiffusionVector; DiffusionFluxPenaltyNS m_fluxPenaltyNS;
virtual void v_InitObject( virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::SessionReaderSharedPtr pSession,
...@@ -147,9 +157,9 @@ namespace Nektar ...@@ -147,9 +157,9 @@ namespace Nektar
{ {
boost::ignore_unused(pSession, pFields); boost::ignore_unused(pSession, pFields);
}; };
virtual void v_Diffuse( virtual void v_Diffuse(
const int nConvectiveFields, const std::size_t nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields, const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray, const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray, Array<OneD, Array<OneD, NekDouble> > &outarray,
...@@ -161,17 +171,17 @@ namespace Nektar ...@@ -161,17 +171,17 @@ namespace Nektar
{ {
boost::ignore_unused(deriv); boost::ignore_unused(deriv);
} }
virtual Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &v_GetFluxTensor() virtual Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &v_GetFluxTensor()
{ {
static Array<OneD, Array<OneD, Array<OneD, NekDouble> > > tmp; static Array<OneD, Array<OneD, Array<OneD, NekDouble> > > tmp;
return tmp; return tmp;
} }
}; };
/// A shared pointer to an EquationSystem object /// A shared pointer to an EquationSystem object
typedef std::shared_ptr<Diffusion> DiffusionSharedPtr; typedef std::shared_ptr<Diffusion> DiffusionSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived /// Datatype of the NekFactory used to instantiate classes derived
/// from the Diffusion class. /// from the Diffusion class.
typedef LibUtilities::NekFactory<std::string, Diffusion, std::string> DiffusionFactory; typedef LibUtilities::NekFactory<std::string, Diffusion, std::string> DiffusionFactory;
......
...@@ -72,7 +72,7 @@ namespace Nektar ...@@ -72,7 +72,7 @@ namespace Nektar
}; };
/** /**
* @brief Diffusion3DHomogeneous1D uses the 2D WeakDG approach * @brief Diffusion3DHomogeneous1D uses the 2D WeakDG approach
* to compute the diffusion term looping on the planes in the z * to compute the diffusion term looping on the planes in the z
* direction and adding the flux in z direction at the end. * direction and adding the flux in z direction at the end.
*/ */
...@@ -80,12 +80,12 @@ namespace Nektar ...@@ -80,12 +80,12 @@ namespace Nektar
{ {
// Strip trailing string "3DHomogeneous1D" to determine 2D diffusion // Strip trailing string "3DHomogeneous1D" to determine 2D diffusion
// type, and create a diffusion object for the plane. // type, and create a diffusion object for the plane.
string name = diffType.substr(0, diffType.length()-15); m_diffType = diffType.substr(0, diffType.length()-15);
m_planeDiff = GetDiffusionFactory().CreateInstance(name, name); m_planeDiff = GetDiffusionFactory().CreateInstance(m_diffType, m_diffType);
} }
/** /**
* @brief Initiliase Diffusion3DHomogeneous1D objects and store * @brief Initiliase Diffusion3DHomogeneous1D objects and store
* them before starting the time-stepping. * them before starting the time-stepping.
* *
* @param pSession Pointer to session reader. * @param pSession Pointer to session reader.
...@@ -114,7 +114,26 @@ namespace Nektar ...@@ -114,7 +114,26 @@ namespace Nektar
m_homoLen = pFields[0]->GetHomoLen(); m_homoLen = pFields[0]->GetHomoLen();
m_trans = pFields[0]->GetTransposition(); m_trans = pFields[0]->GetTransposition();
m_planeCounter = 0; m_planeCounter = 0;
m_planeDiff->SetFluxVectorNS(m_fluxVectorNS);
if (m_diffType == "LDG")
{
// Set viscous flux for LDG
m_planeDiff->SetFluxVector(m_fluxVector);
}
else if (m_diffType == "LDGNS")
{
// Set viscous flux for LDGNS
m_planeDiff->SetFluxVectorNS(m_fluxVectorNS);
// Set penalty flux
m_planeDiff->SetFluxPenaltyNS(m_fluxPenaltyNS);
}
else if (m_diffType == "LFRDGNS" ||
m_diffType == "LFRHUNS" ||
m_diffType == "LFRSDNS" )
{
// Set viscous flux for FR cases
m_planeDiff->SetFluxVectorNS(m_fluxVectorNS);
}
m_fieldsPlane = Array<OneD, MultiRegions::ExpListSharedPtr> m_fieldsPlane = Array<OneD, MultiRegions::ExpListSharedPtr>
(nConvectiveFields); (nConvectiveFields);
...@@ -169,7 +188,7 @@ namespace Nektar ...@@ -169,7 +188,7 @@ namespace Nektar
* using an LDG interface flux and the the flux in the third direction. * using an LDG interface flux and the the flux in the third direction.
*/ */
void Diffusion3DHomogeneous1D::v_Diffuse( void Diffusion3DHomogeneous1D::v_Diffuse(
const int nConvectiveFields, const std::size_t nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields, const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray, const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray, Array<OneD, Array<OneD, NekDouble> > &outarray,
...@@ -181,22 +200,21 @@ namespace Nektar ...@@ -181,22 +200,21 @@ namespace Nektar
Array<OneD, NekDouble> tmp(m_numPoints), tmp2; Array<OneD, NekDouble> tmp(m_numPoints), tmp2;
Array<OneD, Array<OneD, NekDouble> > viscHComp; Array<OneD, Array<OneD, NekDouble> > viscHComp;
const int nPointsTot = fields[0]->GetNpoints(); const int nPointsTot = fields[0]->GetNpoints();
int i, j;
NekDouble beta; NekDouble beta;
if (m_fluxVectorNS) if (m_fluxVectorNS)
{ {
viscHComp = Array<OneD, Array<OneD, NekDouble> >(nConvectiveFields); viscHComp = Array<OneD, Array<OneD, NekDouble> >(nConvectiveFields);
for (i = 0; i < nConvectiveFields - 1; ++i) for (int i = 0; i < nConvectiveFields - 1; ++i)
{ {
fields[0]->PhysDeriv(2, inarray[i], m_homoDerivStore[i]); fields[0]->PhysDeriv(2, inarray[i], m_homoDerivStore[i]);
viscHComp[i] = Array<OneD, NekDouble>(m_numPoints); viscHComp[i] = Array<OneD, NekDouble>(m_numPoints);
} }
} }
for (i = 0; i < m_numPlanes; ++i)
for (int i = 0; i < m_numPlanes; ++i)
{ {
// Set up memory references for fields, inarray and outarray for // Set up memory references for fields, inarray and outarray for
// this plane. // this plane.
...@@ -212,7 +230,7 @@ namespace Nektar ...@@ -212,7 +230,7 @@ namespace Nektar
m_outarrayPlane[j] = Array<OneD, NekDouble>( m_outarrayPlane[j] = Array<OneD, NekDouble>(
m_numPointsPlane, tmp2 = outarray[j] + m_planePos[i]); m_numPointsPlane, tmp2 = outarray[j] + m_planePos[i]);
} }
if (m_fluxVectorNS) if (m_fluxVectorNS)
{ {
...@@ -220,15 +238,43 @@ namespace Nektar ...@@ -220,15 +238,43 @@ namespace Nektar
} }
if (m_diffType == "LDGNS")
m_planeDiff->Diffuse(nConvectiveFields, {
m_fieldsPlane, // Store plane Fwd/Bwd traces
m_inarrayPlane, std::size_t nTracePts = m_fieldsPlane[0]->GetTrace()
m_outarrayPlane); ->GetTotPoints();
std::size_t nScalar = m_inarrayPlane.num_elements();
Array<OneD, Array<OneD, NekDouble> > Fwd(nScalar);
Array<OneD, Array<OneD, NekDouble> > Bwd(nScalar);
{
for(std::size_t k = 0; k < nScalar; ++k)
{
Fwd[k] = Array<OneD, NekDouble>(nTracePts, 0.0);
Bwd[k] = Array<OneD, NekDouble>(nTracePts, 0.0);
m_fieldsPlane[k]->GetFwdBwdTracePhys(
m_inarrayPlane[k], Fwd[k], Bwd[k]);
}
}