Commit 1cdcfdf5 authored by Chris Cantwell's avatar Chris Cantwell

Tidy up code.

parent 2ccec3d4
......@@ -58,4 +58,4 @@ GET_FILENAME_COMPONENT(LAPACK_DIR ${WIN32_LAPACK} PATH CACHE)
LINK_DIRECTORIES(${LAPACK_DIR})
MESSAGE(STATUS "Found Win32 BLAS: ${WIN32_BLAS}")
MESSAGE(STATUS "Found Win32 Lapack: ${WIN32_LAPACK}")
\ No newline at end of file
MESSAGE(STATUS "Found Win32 Lapack: ${WIN32_LAPACK}")
......@@ -37,61 +37,93 @@
namespace Nektar
{
namespace SolverUtils
{
AdvectionFactory& GetAdvectionFactory()
{
typedef Loki::SingletonHolder<AdvectionFactory,
Loki::CreateUsingNew,
Loki::NoDestroy > Type;
return Type::Instance();
}
namespace SolverUtils
{
/**
* @returns The advection factory.
*/
AdvectionFactory& GetAdvectionFactory()
{
typedef Loki::SingletonHolder<AdvectionFactory,
Loki::CreateUsingNew,
Loki::NoDestroy > Type;
return Type::Instance();
}
/**
* @param pSession Session configuration data.
* @param pFields Array of ExpList objects.
*/
void Advection::InitObject(
const LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
v_InitObject(pSession, pFields);
}
/**
* @param nConvectiveFields Number of velocity components.
* @param pFields Expansion lists for scalar fields.
* @param pAdvVel Advection velocity.
* @param pInarray Scalar data to advect.
* @param pOutarray Advected scalar data.
* @param pTime Simulation time.
*/
void Advection::Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &pFields,
const Array<OneD, Array<OneD, NekDouble> > &pAdvVel,
const Array<OneD, Array<OneD, NekDouble> > &pInarray,
Array<OneD, Array<OneD, NekDouble> > &pOutarray,
const NekDouble &pTime)
{
v_Advect(nConvectiveFields, pFields, pAdvVel, pInarray, pOutarray, pTime);
}
void Advection::InitObject(
const LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
/**
* This function should be overridden in derived classes to initialise the
* specific advection data members. However, this base class function should
* be called as the first statement of the overridden function to ensure the
* base class is correctly initialised in order.
*
* @param pSession Session information.
* @param pFields Expansion lists for scalar fields.
*/
void Advection::v_InitObject(
const LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
m_spaceDim = pFields[0]->GetCoordim(0);
if (pSession->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = pSession->GetSolverInfo("HOMOGENEOUS");
if (HomoStr == "HOMOGENEOUS1D" || HomoStr == "Homogeneous1D" ||
HomoStr == "1D" || HomoStr == "Homo1D")
{
v_InitObject(pSession, pFields);
m_spaceDim++;
}
void Advection::Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time)
else
{
v_Advect(nConvectiveFields, fields, advVel, inarray, outarray, time);
ASSERTL0(false, "Only 1D homogeneous dimension supported.");
}
}
}
void Advection::v_InitObject(
const LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
m_spaceDim = pFields[0]->GetCoordim(0);
if (pSession->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = pSession->GetSolverInfo("HOMOGENEOUS");
if (HomoStr == "HOMOGENEOUS1D" || HomoStr == "Homogeneous1D" ||
HomoStr == "1D" || HomoStr == "Homo1D")
{
m_spaceDim++;
}
else
{
ASSERTL0(false, "Only 1D homogeneous dimension supported.");
}
}
}
void Advection::v_SetBaseFlow(
const Array<OneD, Array<OneD, NekDouble> > &inarray)
{
ASSERTL0(false,
"A baseflow is not appropriate for this advection type.");
}
/**
*
*/
void Advection::v_SetBaseFlow(
const Array<OneD, Array<OneD, NekDouble> > &inarray)
{
ASSERTL0(false,
"A baseflow is not appropriate for this advection type.");
}
}
}
}
......@@ -47,116 +47,125 @@
namespace Nektar
{
namespace SolverUtils
namespace SolverUtils
{
/// Defines a callback function which evaluates the flux vector \f$ F(u)
/// \f$ in a conservative advection of the form \f$ \nabla\cdot F(u)
/// \f$.
typedef boost::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
AdvectionFluxVecCB;
/**
* @brief An abstract base class encapsulating the concept of advection
* of a vector field.
*
* Subclasses override the Advection::v_InitObject function to
* initialise the object and the Advection::v_Advect function to
* evaluate the advection of the vector field.
*/
class Advection
{
public:
/// Interface function to initialise the advection object.
SOLVER_UTILS_EXPORT void InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
/// Interface function to advect the vector field.
SOLVER_UTILS_EXPORT void Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time);
/**
* @brief Set the flux vector callback function.
*
* This routine is a utility function to avoid the explicit use of
* boost::bind. A function and object can be passed to this function
* instead.
*/
template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
{
m_fluxVector = boost::bind(func, obj, _1, _2);
}
/**
* @brief Set a Riemann solver object for this advection object.
*
* @param riemann The RiemannSolver object.
*/
inline void SetRiemannSolver(RiemannSolverSharedPtr riemann)
{
m_riemann = riemann;
}
/**
* @brief Set the flux vector callback function.
*
* @param fluxVector The callback function to override.
*/
inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
{
/// Defines a callback function which evaluates the flux vector \f$ F(u)
/// \f$ in a conservative advection of the form \f$ \nabla\cdot F(u)
/// \f$.
typedef boost::function<void (
const Array<OneD, Array<OneD, NekDouble> >&,
Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
AdvectionFluxVecCB;
/**
* @brief An abstract base class encapsulating the concept of advection
* of a vector field.
*
* Subclasses override the Advection::v_InitObject function to
* initialise the object and the Advection::v_Advect function to
* evaluate the advection of the vector field.
*/
class Advection
{
public:
SOLVER_UTILS_EXPORT void InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
SOLVER_UTILS_EXPORT void Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time);
/**
* @brief Set the flux vector callback function.
*
* This routine is a utility function to avoid the explicit use of
* boost::bind. A function and object can be passed to this function
* instead.
*/
template<typename FuncPointerT, typename ObjectPointerT>
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
{
m_fluxVector = boost::bind(func, obj, _1, _2);
}
/**
* @brief Set a Riemann solver object for this advection object.
*
* @param riemann The RiemannSolver object.
*/
inline void SetRiemannSolver(RiemannSolverSharedPtr riemann)
{
m_riemann = riemann;
}
/**
* @brief Set the flux vector callback function.
*
* @param fluxVector The callback function to override.
*/
inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
{
m_fluxVector = fluxVector;
}
/**
* @brief Set the base flow used for linearised advection objects.
*
* @param inarray Vector to use as baseflow
*/
inline void SetBaseFlow(const Array<OneD, Array<OneD, NekDouble> >& inarray)
{
v_SetBaseFlow(inarray);
}
protected:
/// Callback function to the flux vector (set when advection is in
/// conservative form).
AdvectionFluxVecCB m_fluxVector;
/// Riemann solver for DG-type schemes.
RiemannSolverSharedPtr m_riemann;
/// Storage for space dimension. Used for homogeneous extension.
int m_spaceDim;
SOLVER_UTILS_EXPORT virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
SOLVER_UTILS_EXPORT virtual void v_Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time)=0;
SOLVER_UTILS_EXPORT virtual void v_SetBaseFlow(
const Array<OneD, Array<OneD, NekDouble> > &inarray);
};
/// A shared pointer to an Advection object.
typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived
/// from the Advection class.
typedef LibUtilities::NekFactory<std::string, Advection,
std::string> AdvectionFactory;
SOLVER_UTILS_EXPORT AdvectionFactory& GetAdvectionFactory();
m_fluxVector = fluxVector;
}
/**
* @brief Set the base flow used for linearised advection objects.
*
* @param inarray Vector to use as baseflow
*/
inline void SetBaseFlow(const Array<OneD, Array<OneD, NekDouble> >& inarray)
{
v_SetBaseFlow(inarray);
}
protected:
/// Callback function to the flux vector (set when advection is in
/// conservative form).
AdvectionFluxVecCB m_fluxVector;
/// Riemann solver for DG-type schemes.
RiemannSolverSharedPtr m_riemann;
/// Storage for space dimension. Used for homogeneous extension.
int m_spaceDim;
/// Initialises the advection object.
SOLVER_UTILS_EXPORT virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
/// Advects a vector field.
SOLVER_UTILS_EXPORT virtual void v_Advect(
const int nConvectiveFields,
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time)=0;
/// Overrides the base flow used during linearised advection
SOLVER_UTILS_EXPORT virtual void v_SetBaseFlow(
const Array<OneD, Array<OneD, NekDouble> > &inarray);
};
/// A shared pointer to an Advection object.
typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
/// Datatype of the NekFactory used to instantiate classes derived
/// from the Advection class.
typedef LibUtilities::NekFactory<std::string, Advection,
std::string> AdvectionFactory;
/// Gets the factory for initialising advection objects.
SOLVER_UTILS_EXPORT AdvectionFactory& GetAdvectionFactory();
}
}
#endif
......@@ -36,8 +36,7 @@
#ifndef NEKTAR_SOLVERUTILS_ADVECTION3DHOMOGENEOUS1D
#define NEKTAR_SOLVERUTILS_ADVECTION3DHOMOGENEOUS1D
#include <SolverUtils/AdvectionSystem.h>
/// #include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Advection/HomogeneousRSScalar.hpp>
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -74,7 +73,7 @@ namespace Nektar
Array<OneD, Array<OneD, NekDouble> > m_advVelPlane;
Array<OneD, Array<OneD, Array<OneD, Array<OneD, NekDouble> > > >
m_fluxVecPlane;
virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
......
......@@ -36,8 +36,7 @@
#ifndef NEKTAR_SOLVERUTILS_ADVECTIONFR
#define NEKTAR_SOLVERUTILS_ADVECTIONFR
#include <SolverUtils/AdvectionSystem.h>
/// #include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Advection/Advection.h>
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
......@@ -88,7 +87,7 @@ namespace Nektar
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time);
virtual void v_SetupMetrics(
......
......@@ -36,8 +36,7 @@
#ifndef NEKTAR_SOLVERUTILS_ADVECTIONNONCONSERVATIVE
#define NEKTAR_SOLVERUTILS_ADVECTIONNONCONSERVATIVE
#include <SolverUtils/AdvectionSystem.h>
/// #include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Advection/Advection.h>
namespace Nektar
{
......@@ -65,7 +64,7 @@ namespace Nektar
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time);
};
}
......
......@@ -36,8 +36,7 @@
#ifndef NEKTAR_SOLVERUTILS_ADVECTIONWEAKDG
#define NEKTAR_SOLVERUTILS_ADVECTIONWEAKDG
#include <SolverUtils/AdvectionSystem.h>
/// #include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Advection/Advection.h>
namespace Nektar
{
......@@ -65,7 +64,7 @@ namespace Nektar
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &advVel,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
Array<OneD, Array<OneD, NekDouble> > &outarray,
const NekDouble &time);
};
}
......
......@@ -8,22 +8,34 @@
#include <SolverUtils/AdvectionSystem.h>
namespace Nektar {
namespace SolverUtils {
AdvectionSystem::AdvectionSystem(const LibUtilities::SessionReaderSharedPtr& pSession)
: UnsteadySystem(pSession)
{
}
AdvectionSystem::~AdvectionSystem()
{
}
void AdvectionSystem::v_InitObject()
{
UnsteadySystem::v_InitObject();
}
}
namespace SolverUtils {
/**
*
*/
AdvectionSystem::AdvectionSystem(
const LibUtilities::SessionReaderSharedPtr& pSession)
: UnsteadySystem(pSession)
{
}
/**
*
*/
AdvectionSystem::~AdvectionSystem()
{
}
/**
*
*/
void AdvectionSystem::v_InitObject()
{
UnsteadySystem::v_InitObject();
}
}
}
......@@ -39,31 +39,35 @@
#include <SolverUtils/UnsteadySystem.h>
#include <SolverUtils/Advection/Advection.h>
namespace Nektar {
namespace SolverUtils {
class AdvectionSystem: public UnsteadySystem
{
public:
SOLVER_UTILS_EXPORT AdvectionSystem(
const LibUtilities::SessionReaderSharedPtr &pSession);
SOLVER_UTILS_EXPORT virtual ~AdvectionSystem();
SOLVER_UTILS_EXPORT virtual void v_InitObject();
namespace SolverUtils {
/// A base class for PDEs which include an advection component
class AdvectionSystem: virtual public UnsteadySystem
{
public:
SOLVER_UTILS_EXPORT AdvectionSystem(
const LibUtilities::SessionReaderSharedPtr &pSession);
AdvectionSharedPtr GetAdvObject()
{
return m_advObject;
}
SOLVER_UTILS_EXPORT virtual ~AdvectionSystem();
protected:
/// Advection term
SolverUtils::AdvectionSharedPtr m_advObject;
};
typedef boost::shared_ptr<AdvectionSystem> AdvectionSystemSharedPtr;
SOLVER_UTILS_EXPORT virtual void v_InitObject();
/// Returns the advection object held by this instance.
AdvectionSharedPtr GetAdvObject()
{
return m_advObject;
}
protected:
/// Advection term
SolverUtils::AdvectionSharedPtr m_advObject;
};
/// Shared pointer to an AdvectionSystem class
typedef boost::shared_ptr<AdvectionSystem> AdvectionSystemSharedPtr;
}
}
#endif
......@@ -78,14 +78,9 @@ namespace Nektar
m_equ[0]->PrintSummary(out);
m_equ[0]->DoInitialise();
////////////////////////////////////////////////////////////////////////////////////////////////////////////
AdvectionSystemSharedPtr A = boost::dynamic_pointer_cast<AdvectionSystem>(m_equ[0]);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// - SFD Routine -
// Compressible case
NumVar_SFD = m_equ[0]->UpdateFields()[0]->GetCoordim(0);
......@@ -141,13 +136,9 @@ namespace Nektar
MaxNormDiff_q_qBar = 1.0;
MaxNormDiff_q1_q0 = 1.0;
Min_MaxNormDiff_q_qBar = MaxNormDiff_q_qBar;