Commit dbb6cb15 authored by Chris Cantwell's avatar Chris Cantwell

Merge branch 'fix/InitAdaptiveSFD' into 'master'

Fix/init adaptive sfd

See merge request !452
parents de267a40 7e08c509
......@@ -244,7 +244,7 @@ where $\sigma=\left\| \mathbf{u'}(\tau)\right\|$. This is no other that the sing
\subsection{Steady-state solver}
\label{SectionSFD}
To compute linear stability analysis, the choice of the base flow, around which the system will be linearised, is crucial. If one wants to use the steady-state solution of the Navier-Stokes equations as base flow, a steady-state solver is implemented in \nekpp. The method used is the encapsulated formulation of the Selective Frequency Damping method \cite{JoCoSh14}. Unstable steady base flows can be obtained with this method. The SFD method is based on the filtering and the control of the unstable temporal frequencies within the flow. The time continuous formulation of the SFD method is
To compute linear stability analysis, the choice of the base flow, around which the system will be linearised, is crucial. If one wants to use the steady-state solution of the Navier-Stokes equations as base flow, a steady-state solver is implemented in \nekpp. The method used is the encapsulated formulation of the Selective Frequency Damping method \cite{JoCoSh14}. Unstable steady base flows can be obtained with this method. The SFD method is based on the filtering and control of unstable temporal frequencies within the flow. The time continuous formulation of the SFD method is
\begin{equation}
\begin{cases}
\dot{q}=NS(q)-\chi (q-\bar{q}), \\
......@@ -357,7 +357,7 @@ Direct solver & \texttt{CoupledLinearisedNS} & 2D, Quasi-3D, 3D &CG\\
{Driver} & {Description} &{Dimensions}&{Projections} \\
\midrule
\texttt{Standard} & Time integration of the equations & All & CG, DG \\
\texttt{SteadyState} & Steady-state solver (see Sec. \ref{SectionSFD}) & All & CG \\
\texttt{SteadyState} & Steady-state solver (see Sec. \ref{SectionSFD}) & All & CG, DG \\
\bottomrule
\end{tabular}
\end{center}
......@@ -580,6 +580,7 @@ forces for each computational plane are projected along the Cartesian axes and t
\section{Stability analysis Session file configuration}
\label{SecStabFile}
The type of equation which is to be solved is specified through the \inltt
{EqType} option in the session file. This can be set to any of the following:
......@@ -692,7 +693,7 @@ The following parameters can be specified in the \texttt{PARAMETERS} section of
\label{SectionSFD_XML}
In this section, we detail how to use the steady-state solver (that implements the selective frequency damping method, see Sec. \ref{SectionSFD}).
Two cases are detailed here: the execution of the classical SFD method and the adaptive SFD method, where the control coefficient $\chi$ and the filter width $\Delta$ of the SFD method will be updated all along the solver execution. For the second case, the parameters of the SFD method do not need to be defined by the user (they will be automatically calculated all along the solver execution) but several session files must be defined in a very specific way.
Two cases are detailed here: the execution of the classical SFD method and the \textit{adaptive} SFD method, where the control coefficient $\chi$ and the filter width $\Delta$ of the SFD method are updated all along the solver execution. For the second case, the parameters of the SFD method do not need to be defined by the user (they will be automatically calculated all along the solver execution) but several session files must be defined in a very specific way.
\subsection{Execution of the classical steady-state solver}
......@@ -705,34 +706,40 @@ The definition of \inltt{Eqtype}, \inltt{TimeIntegrationMethod} and \inltt{Proj
The following parameters can be specified in the \texttt{PARAMETERS} section of the session file:
\begin{itemize}
\item \inltt{Re}: sets the Reynolds number
\item \inltt{Kinvis}: sets the kinematic viscosity $\nu$
\item \inltt{ControlCoeff}: sets the control coefficient $\chi$ of the SFD method
\item \inltt{FilterWidth}: sets the filter width $\Delta$ of the SFD method
\item \inltt{GrowthRateEV} and \inltt{FrequencyEV}: if the growth rate and the frequency of the dominant eigenvalue are known, they can be given given as input and the code will automatically select the optimum parameters $\chi$ and $\Delta$ (and overwrite the values that may be given in the session file)
\item \inltt{TOL}: sets the tolerance of the SFD method. The code will run until $||q-\bar{q}||_{inf}<TOL$.
%\item \inltt{Re}: sets the Reynolds number
\item \inltt{Kinvis}: sets the kinematic viscosity $\nu$. It is typically $1/Re$ if both the characteristic velocity and characteristic length are chosen to be 1.
\item \inltt{ControlCoeff}: sets the control coefficient $\chi$ of the SFD method. Default value: 1.
\item \inltt{FilterWidth}: sets the filter width $\Delta$ of the SFD method. Default value: 2.
\item \inltt{GrowthRateEV} and \inltt{FrequencyEV}: if the growth rate and the frequency of the dominant eigenvalue are known, they can be given given as input and the code will automatically select the optimum parameters $\chi$ and $\Delta$ (and overwrite the values of \inltt{ControlCoeff} and \inltt{GrowthRateEV} that may be given in the session file)
\item \inltt{TOL}: sets the tolerance of the SFD method. The code will run until $||q-\bar{q}||_{inf}<TOL$. Default value: $10^{-8}$.
\end{itemize}
Note that for the steady-state solver, the parameter \inltt{NumSteps} is not taken into account. The solver will run until a steady-state solution is found and not for a pre-defined number of time steps.
\subsection{Execution of the adaptive steady-state solver}
Running the adaptive selective frequency damping method requires to set up the session files in a very specific manner. First, the \inltt{Geometry} section must be in a separated archive file. If the test case studied is called "Session", the mesh file must be called \inlsh{Session.gz} (the command "gzip" can be used to obtain this file).
Running the adaptive selective frequency damping method requires to set up the session files in a very specific manner. First, the \inltt{Geometry} section must be in a separated archive file. If the test case studied is called "Session", the mesh file must be called \inlsh{Session.xml.gz} (the linux command "gzip" can be used to obtain this file).
The requirements for the file \inlsh{Session.xml} are similar as for the ones for the classical SFD method, without the \inltt{Geometry} section. This file defines the properties of the nonlinear problem solved. Also, the \inltt{SOLVERINFO} section must contain the line:
The requirements for the file \inlsh{Session.xml} are similar as for the ones for the classical SFD method. The \inltt{Geometry} section being removed and placed in \inlsh{Session.xml.gz}. This file defines the properties of the nonlinear problem solved (\textit{i.e.} the flow for which we want a steady-state). Also, the \inltt{SOLVERINFO} section must contain the line:
\begin{lstlisting}[style=XMLStyle]
<I PROPERTY="EvolutionOperator" VALUE="AdaptiveSFD" />
\end{lstlisting}
As the adaptive SFD method used is coupled with a stability analysis method, \inltt{kdim}, \inltt{nvec}, \inltt{evtol} and \inltt{nits} must be defined into the \inltt{PARAMETERS} section of \inlsh{Session.xml}. To define the linear problem executed by the stability analysis method, another file, that must be called \inlsh{Session\_LinNS.xml}, has to be defined. This file can be a copy paste of \inlsh{Session.xml}, only three things have to be modified:
The adaptive SFD method used is coupled with a stability analysis method. Then \inltt{kdim}, \inltt{nvec}, \inltt{evtol} and \inltt{nits} should be defined into the \inltt{PARAMETERS} section of \inlsh{Session.xml}. If not, these parameters will take the default values presented in Sec. \ref{SecStabFile}.
The goal of running the stability analysis is to evaluate the dominant eigenvalue of a ``partially converged'' steady base flow. This approximation is then used by the steady-state solver to select a control coefficient $\chi$ and a filter width $\Delta$ then ensure a fast convergence towards a steady-state solution.
To define the linear stability problem, another file, that must be called \inlsh{Session\_LinNS.xml}, has to be defined. This file \textbf{must be an exact copy/paste of} \inlsh{Session.xml}, only three things have to be modified:
\begin{enumerate}
\item The boundary conditions must be modified to be homogeneous (\textit{i.e.} equal to zero) at the inflow boundary.
\item A random non-zero function \inltt{InitialConditions} has to be defined.
\item A random function \inltt{BaseFlow} has to be defined (it will be overwritten all along the solver execution).
\item The boundary conditions must be modified to be homogeneous (\textit{i.e.} equal to zero) at all inflow boundaries.
\item A non-zero function \inltt{InitialConditions} has to be defined.
\item A random function \inltt{BaseFlow} has to be defined (it will be overwritten all along the solver execution). We recommend it to be a copy of \inltt{InitialConditions}.
\end{enumerate}
Once these three files (the \inltt{Geometry} in \inlsh{Session.gz}, the nonlinear problem definition in \inlsh{Session.xml} and the homogeneous linear problem in \inlsh{Session\_LinNS.xml}) are correctly defined, the adaptive SFD method must be ran using:
Once these three files (the \inltt{Geometry} in \inlsh{Session.xml.gz}, the nonlinear problem definition in \inlsh{Session.xml} and the homogeneous linear problem in \inlsh{Session\_LinNS.xml}) are correctly defined, the adaptive SFD method must be executed using:
\begin{lstlisting}[style=BashInputStyle]
IncNavierStokesSolver Session.gz Session.xml
IncNavierStokesSolver Session.xml.gz Session.xml
\end{lstlisting}
......
......@@ -406,7 +406,7 @@ namespace Nektar
// Load metadata
ImportFieldMetaData(infile,fieldmetadatamap);
if(ElementIDs == NullInt1DArray) //load all fields
{
for(int i = 0; i < filenames.size(); ++i)
......
......@@ -88,7 +88,7 @@ void DriverSteadyState::v_Execute(ostream &out)
m_session->LoadParameter("IO_InfoSteps", m_infosteps, 1000);
m_session->LoadParameter("IO_CheckSteps", m_checksteps, 100000);
m_session->LoadParameter("ControlCoeff",m_X, 1);
m_session->LoadParameter("FilterWidth", m_Delta, 1);
m_session->LoadParameter("FilterWidth", m_Delta, 2);
// To evaluate optimum SFD parameters if growth rate provided in the
// xml file
......@@ -105,7 +105,7 @@ void DriverSteadyState::v_Execute(ostream &out)
m_session->LoadParameter("AdaptiveTOL", AdaptiveTOL, 1.0e-02);
// Used only for the Adaptive SFD method
m_session->LoadParameter("AdaptiveTime", AdaptiveTime, 25.0);
m_session->LoadParameter("AdaptiveTime", AdaptiveTime, 50.0*m_Delta);
if (m_comm->GetRank() == 0)
{
......@@ -166,7 +166,7 @@ void DriverSteadyState::v_Execute(ostream &out)
q0[i] = Array<OneD, NekDouble> (m_equ[m_nequ-1]->GetTotPoints(),
0.0); //q0 is initialised
qBar0[i] = Array<OneD, NekDouble> (m_equ[m_nequ-1]->GetTotPoints(),
0.0); //qBar0 initially set to zero
0.0);
m_equ[m_nequ - 1]->CopyFromPhysField(i, qBar0[i]);
}
......@@ -296,9 +296,22 @@ void DriverSteadyState::v_Execute(ostream &out)
}
m_file.close();
///We save the final solution into a .fld file
m_equ[m_nequ - 1]->Output();
for(int j = 0; j < m_equ[m_nequ - 1]->GetNvariables(); ++j)
{
NekDouble vL2Error = m_equ[m_nequ - 1]->L2Error(j,false);
NekDouble vLinfError = m_equ[m_nequ - 1]->LinfError(j);
if (m_comm->GetRank() == 0)
{
out << "L 2 error (variable " << m_equ[m_nequ - 1]->GetVariable(j)
<< ") : " << vL2Error << endl;
out << "L inf error (variable " << m_equ[m_nequ - 1]->GetVariable(j)
<< ") : " << vLinfError << endl;
}
}
}
......@@ -499,7 +512,7 @@ void DriverSteadyState::ReadEVfile(
{
// This routine reads the .evl file written by the Arnoldi algorithm
// (written in September 2014)
std::string EVfileName = m_session->GetFilenames()[0] + ".evl";
std::string EVfileName = m_session->GetSessionName() + ".evl";
std::ifstream EVfile(EVfileName.c_str());
int NumLinesInFile(0);
......
......@@ -76,6 +76,7 @@ IF( NEKTAR_SOLVER_INCNAVIERSTOKES )
ADD_NEKTAR_TEST(ChannelSpongeNSE)
ADD_NEKTAR_TEST(ChannelSpongeLNSE)
ADD_NEKTAR_TEST(ChanFlow_Standard_BodyForce)
ADD_NEKTAR_TEST(Cyl_AdaptiveSFD)
#IF (NEKTAR_USING_ARPACK)
#ADD_NEKTAR_TEST(ChanStability_adj_Ar) ###
......
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<test>
<description>2D cylinder flow, mixed elements, P=5</description>
<executable>IncNavierStokesSolver</executable>
<parameters>Cyl_AdaptiveSFD.xml.gz Cyl_AdaptiveSFD.xml</parameters>
<files>
<file description="Session File">Cyl_AdaptiveSFD.xml.gz</file>
<file description="Session File">Cyl_AdaptiveSFD.xml</file>
<file description="Session File">Cyl_AdaptiveSFD_LinNS.xml</file>
<file description="Session File">Cyl_AdaptiveSFD.rst</file>
<file description="Session File">Cyl_AdaptiveSFD_Eig.rst</file>
</files>
<metrics>
<metric type="L2" id="1">
<value variable="u" tolerance="1e-8">0.241485</value>
<value variable="v" tolerance="1e-8">0.254726</value>
<value variable="p" tolerance="1e-4">0.0726467</value>
</metric>
<metric type="Linf" id="2">
<value variable="u" tolerance="1e-8">0.0829632</value>
<value variable="v" tolerance="1e-8">0.0752455</value>
<value variable="p" tolerance="1e-8">0.0251153</value>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.nektar.info/schema/nektar.xsd">
<EXPANSIONS>
<E COMPOSITE="C[0-1]" NUMMODES="6" FIELDS="u,v,p" TYPE="MODIFIED"/>
</EXPANSIONS>
<CONDITIONS>
<SOLVERINFO>
<I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
<I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes"/>
<I PROPERTY="Projection" VALUE="Galerkin"/>
<I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2"/>
<I PROPERTY="Driver" VALUE="SteadyState"/>
<I PROPERTY="EvolutionOperator" VALUE="AdaptiveSFD"/>
</SOLVERINFO>
<PARAMETERS>
<P> TimeStep = 0.01 </P>
<P> NumSteps = 1.0/TimeStep </P>
<P> IO_CheckSteps = 25.0/TimeStep </P>
<P> IO_InfoSteps = 0.5/TimeStep </P>
<P> IO_CFLSteps = IO_InfoSteps </P>
<P> Re = 100.0 </P>
<P> Kinvis = 1.0/Re </P>
<P> TOL = 0.000279 </P>
<P> kdim = 16 </P>
<P> nvec = 2 </P>
<P> evtol = 1e-1 </P>
<P> nits = 1000 </P>
</PARAMETERS>
<VARIABLES>
<V ID="0"> u </V>
<V ID="1"> v </V>
<V ID="2"> p </V>
</VARIABLES>
<BOUNDARYREGIONS>
<B ID="0"> C[2] </B>
<!-- Wall -->
<B ID="1"> C[3] </B>
<!-- Far Field -->
<B ID="2"> C[4] </B>
<!-- Outlet -->
</BOUNDARYREGIONS>
<BOUNDARYCONDITIONS>
<REGION REF="0">
<D VAR="u" VALUE="0"/>
<D VAR="v" VALUE="0"/>
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0"/>
</REGION>
<REGION REF="1">
<D VAR="u" VALUE="1"/>
<D VAR="v" VALUE="0"/>
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0"/>
</REGION>
<REGION REF="2">
<N VAR="u" VALUE="0"/>
<N VAR="v" VALUE="0"/>
<D VAR="p" VALUE="0"/>
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="InitialConditions">
<F VAR="u,v,p" FILE="Cyl_AdaptiveSFD.rst"/>
</FUNCTION>
</CONDITIONS>
</NEKTAR>
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.nektar.info/schema/nektar.xsd">
<EXPANSIONS>
<E COMPOSITE="C[0-1]" NUMMODES="6" FIELDS="u,v,p" TYPE="MODIFIED"/>
</EXPANSIONS>
<CONDITIONS>
<SOLVERINFO>
<I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
<I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes"/>
<I PROPERTY="Projection" VALUE="Galerkin"/>
<I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2"/>
<I PROPERTY="Driver" VALUE="SteadyState"/>
<I PROPERTY="EvolutionOperator" VALUE="AdaptiveSFD"/>
</SOLVERINFO>
<PARAMETERS>
<P> TimeStep = 0.01 </P>
<P> NumSteps = 1.0/TimeStep </P>
<P> IO_CheckSteps = 1.0/TimeStep </P>
<P> IO_InfoSteps = 0.25/TimeStep </P>
<P> IO_CFLSteps = 100 </P>
<P> Re = 100.0 </P>
<P> Kinvis = 1.0/Re </P>
</PARAMETERS>
<VARIABLES>
<V ID="0"> u </V>
<V ID="1"> v </V>
<V ID="2"> p </V>
</VARIABLES>
<BOUNDARYREGIONS>
<B ID="0"> C[2] </B>
<!-- Wall -->
<B ID="1"> C[3] </B>
<!-- Far Field -->
<B ID="2"> C[4] </B>
<!-- Outlet -->
</BOUNDARYREGIONS>
<BOUNDARYCONDITIONS>
<REGION REF="0">
<D VAR="u" VALUE="0"/>
<D VAR="v" VALUE="0"/>
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0"/>
</REGION>
<REGION REF="1">
<D VAR="u" VALUE="0"/>
<D VAR="v" VALUE="0"/>
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0"/>
</REGION>
<REGION REF="2">
<N VAR="u" VALUE="0"/>
<N VAR="v" VALUE="0"/>
<D VAR="p" VALUE="0"/>
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="InitialConditions">
<F VAR="u,v,p" FILE="Cyl_AdaptiveSFD_Eig.rst"/>
</FUNCTION>
<FUNCTION NAME="BaseFlow">
<E VAR="u" VALUE="1.0"/>
<E VAR="v" VALUE="0.0"/>
<E VAR="p" VALUE="0.0"/>
</FUNCTION>
</CONDITIONS>
</NEKTAR>
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