Commit 141c322c authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Removed solver-specific code in Forcing terms.

parent 4b28e5f3
......@@ -2095,11 +2095,6 @@ namespace Nektar
return Array<OneD, bool>(m_session->GetVariables().size(), false);
}
int EquationSystem::v_GetForceDimension()
{
return 0;
}
void EquationSystem::v_GetFluxVector(
const int i, Array<OneD,
Array<OneD, NekDouble> > &physfield,
......
......@@ -551,7 +551,6 @@ namespace Nektar
private:
SOLVER_UTILS_EXPORT virtual Array<OneD, bool> v_GetSystemSingularChecks();
SOLVER_UTILS_EXPORT virtual int v_GetForceDimension();
SOLVER_UTILS_EXPORT virtual void v_GetFluxVector(
const int i, Array<OneD,
Array<OneD, NekDouble> >&physfield,
......
......@@ -55,9 +55,10 @@ namespace Nektar
void Forcing::InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
v_InitObject(pFields, pForce);
v_InitObject(pFields, pNumForcingFields, pForce);
}
......@@ -80,7 +81,8 @@ namespace Nektar
*/
vector<ForcingSharedPtr> Forcing::Load(
const LibUtilities::SessionReaderSharedPtr& pSession,
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields)
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields)
{
vector<ForcingSharedPtr> vForceList;
......@@ -92,6 +94,11 @@ namespace Nektar
TiXmlElement* vForcing = pSession->GetElement("Nektar/Forcing");
if (vForcing)
{
unsigned int vNumForcingFields = pNumForcingFields;
if (!pNumForcingFields)
{
vNumForcingFields = pFields.num_elements();
}
TiXmlElement* vForce = vForcing->FirstChildElement("FORCE");
while (vForce)
......@@ -99,7 +106,8 @@ namespace Nektar
string vType = vForce->Attribute("TYPE");
vForceList.push_back(GetForcingFactory().CreateInstance(
vType, pSession, pFields, vForce));
vType, pSession, pFields,
vNumForcingFields, vForce));
vForce = vForce->NextSiblingElement("FORCE");
}
}
......
......@@ -57,6 +57,7 @@ namespace SolverUtils
typedef LibUtilities::NekFactory<std::string, Forcing,
const LibUtilities::SessionReaderSharedPtr&,
const Array<OneD, MultiRegions::ExpListSharedPtr>&,
const unsigned int&,
const TiXmlElement*> ForcingFactory;
/// Declaration of the forcing factory singleton
......@@ -72,6 +73,7 @@ namespace SolverUtils
/// Initialise the forcing object
SOLVER_UTILS_EXPORT void InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce);
/// Apply the forcing
......@@ -82,7 +84,8 @@ namespace SolverUtils
static std::vector<ForcingSharedPtr> Load(
const LibUtilities::SessionReaderSharedPtr& pSession,
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields);
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields = 0);
protected:
/// Session reader
......@@ -97,6 +100,7 @@ namespace SolverUtils
virtual void v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce) = 0;
virtual void v_Apply(
......
......@@ -54,21 +54,12 @@ namespace SolverUtils
void ForcingBody::v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
std::string m_SolverInfo = m_session->GetSolverInfo("SolverType");
int nvariables = m_session->GetVariables().size();
m_NumVariable = pNumForcingFields;
int nq = pFields[0]->GetTotPoints();
if (m_SolverInfo == "VelocityCorrectionScheme")
{
m_NumVariable = nvariables - 1; // e.g. (u v w p) for 3D case
}
if (m_SolverInfo == "CoupledLinearisedNS")
{
m_NumVariable = nvariables; // e.g. (u v w) for 3D case
}
const TiXmlElement* funcNameElmt = pForce->FirstChildElement("BODYFORCE");
ASSERTL0(funcNameElmt, "Requires BODYFORCE tag specifying function "
"name which prescribes body force.");
......
......@@ -58,11 +58,12 @@ namespace SolverUtils
SOLVER_UTILS_EXPORT static ForcingSharedPtr create(
const LibUtilities::SessionReaderSharedPtr& pSession,
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
ForcingSharedPtr p = MemoryManager<ForcingBody>::
AllocateSharedPtr(pSession);
p->InitObject(pFields, pForce);
p->InitObject(pFields, pNumForcingFields, pForce);
return p;
}
......@@ -72,6 +73,7 @@ namespace SolverUtils
protected:
virtual void v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce);
virtual void v_Apply(
......
......@@ -58,21 +58,12 @@ namespace SolverUtils
void ForcingProgrammatic::v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
std::string m_SolverInfo = m_session->GetSolverInfo("SolverType");
int nvariables = m_session->GetVariables().size();
m_NumVariable = pNumForcingFields;
int nq = pFields[0]->GetTotPoints();
if (m_SolverInfo == "VelocityCorrectionScheme")
{
m_NumVariable = nvariables - 1; // e.g. (u v w p) for 3D case
}
if (m_SolverInfo == "CoupledLinearisedNS")
{
m_NumVariable = nvariables; // e.g. (u v w) for 3D case
}
m_Forcing = Array<OneD, Array<OneD, NekDouble> > (m_NumVariable);
for (int i = 0; i < m_NumVariable; ++i)
{
......
......@@ -64,11 +64,12 @@ namespace SolverUtils
SOLVER_UTILS_EXPORT static ForcingSharedPtr create(
const LibUtilities::SessionReaderSharedPtr& pSession,
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
ForcingSharedPtr p = MemoryManager<ForcingProgrammatic>::
AllocateSharedPtr(pSession);
p->InitObject(pFields, pForce);
p->InitObject(pFields, pNumForcingFields, pForce);
return p;
}
......@@ -80,6 +81,7 @@ namespace SolverUtils
protected:
virtual void v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce);
virtual void v_Apply(
......
......@@ -53,16 +53,12 @@ namespace SolverUtils
void ForcingSponge::v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
std::string m_SolverInfo = m_session->GetSolverInfo("SolverType");
int nvariables = m_session->GetVariables().size();
m_NumVariable = pNumForcingFields;
int npts = pFields[0]->GetTotPoints();
m_NumVariable = (m_SolverInfo == "CoupledLinearisedNS"
? nvariables
: nvariables - 1);
const TiXmlElement* funcNameElmt;
funcNameElmt = pForce->FirstChildElement("SPONGECOEFF");
ASSERTL0(funcNameElmt, "Requires SPONGECOEFF tag, specifying function "
......
......@@ -57,11 +57,12 @@ namespace SolverUtils
SOLVER_UTILS_EXPORT static ForcingSharedPtr create(
const LibUtilities::SessionReaderSharedPtr& pSession,
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce)
{
ForcingSharedPtr p = MemoryManager<ForcingSponge>::
AllocateSharedPtr(pSession);
p->InitObject(pFields, pForce);
p->InitObject(pFields, pNumForcingFields, pForce);
return p;
}
......@@ -75,6 +76,7 @@ namespace SolverUtils
virtual void v_InitObject(
const Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
const unsigned int& pNumForcingFields,
const TiXmlElement* pForce);
virtual void v_Apply(
......
......@@ -177,7 +177,8 @@ namespace Nektar
}
// Forcing terms
m_forcing = SolverUtils::Forcing::Load(m_session, m_fields);
m_forcing = SolverUtils::Forcing::Load(m_session, m_fields,
v_GetForceDimension());
// check to see if any Robin boundary conditions and if so set
// up m_field to boundary condition maps;
......@@ -1160,6 +1161,10 @@ namespace Nektar
return maxV;
}
int IncNavierStokes::v_GetForceDimension()
{
return m_session->GetVariables().size();
}
......
......@@ -274,6 +274,8 @@ namespace Nektar
ASSERTL0(false,"This method is not defined in this class");
}
virtual int v_GetForceDimension();
private:
};
......
......@@ -386,7 +386,7 @@ namespace Nektar
if(init)
{
m_solverRoll->DoInitialise();
m_vwiForcingObj = boost::dynamic_pointer_cast<SolverUtils::ForcingProgrammatic>(GetForcingFactory().CreateInstance("Programmatic", m_sessionRoll, m_solverRoll->UpdateFields(), 0));
m_vwiForcingObj = boost::dynamic_pointer_cast<SolverUtils::ForcingProgrammatic>(GetForcingFactory().CreateInstance("Programmatic", m_sessionRoll, m_solverRoll->UpdateFields(), m_solverRoll->UpdateFields().num_elements() - 1, 0));
std::vector<std::string> vFieldNames = m_sessionRoll->GetVariables();
vFieldNames.erase(vFieldNames.end()-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