Commit 0c549433 authored by Hui Xu's avatar Hui Xu
Browse files

Updated

parent 2a98ef38
///////////////////////////////////////////////////////////////////////////////
//
// File: Forcing.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Abstract base class for forcing terms.
//
///////////////////////////////////////////////////////////////////////////////
#include <SolverUtils/Forcing/ForcingBody.h>
namespace Nektar
{
namespace SolverUtils
{
std::string ForcingBody::className = GetForcingFactory().RegisterCreatorFunction("BodyForcing", ForcingBody::create, "Body Forcing");
ForcingBody::ForcingBody()
{
}
void ForcingBody::v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
SpatialDomains::MeshGraphSharedPtr pGraph)
{
m_Session = pSession;
v_ReadForceInfo(pSession,pFields,pGraph);
}
void ForcingBody::v_Apply(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray)
{
if (m_Session->DefinesFunction("BodyForce"))
{
for (int i=0; i<m_NumVariable;i++)
{
Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1, m_Forcing[i], 1,outarray[i], 1);
}
}
}
void ForcingBody::v_ReadForceInfo(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
SpatialDomains::MeshGraphSharedPtr pGraph)
{
std::string m_SolverInfo = pSession->GetSolverInfo("SolverType");
int nvariables = pSession->GetVariables().size();
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
}
if(pSession->DefinesFunction("BodyForce"))
{
m_Forcing = Array<OneD, Array<OneD, NekDouble> >(m_NumVariable);
for(int i = 0; i < m_NumVariable; ++i)
{
m_Forcing[i] = Array<OneD, NekDouble> (pFields[0]->GetTotPoints(),0.0);
}
}
std::string s_FieldStr;
for(int i = 0; i < m_NumVariable; ++i)
{
s_FieldStr = pSession->GetVariable(i);
if(pSession->DefinesFunction("BodyForce"))
{
EvaluateFunction(pFields, pSession, s_FieldStr, m_Forcing[i],"BodyForce");
}
}
}/// The end of reading sponge info.
}
}
/// Hui XU 2013 Jul 26
///////////////////////////////////////////////////////////////////////////////
//
// File: Forcing.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Abstract base class for advection.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_SOLVERUTILS_FORCINGBODY
#define NEKTAR_SOLVERUTILS_FORCINGBODY
#include <string>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <MultiRegions/ExpList.h>
#include <SolverUtils/SolverUtilsDeclspec.h>
#include <SolverUtils/Forcing/ForcingSponge.h>
#include <MultiRegions/ContField1D.h>
#include <MultiRegions/ContField2D.h>
#include <MultiRegions/ContField3D.h>
#include <MultiRegions/ContField3DHomogeneous1D.h>
#include <MultiRegions/ContField3DHomogeneous2D.h>
#include <MultiRegions/ExpList2D.h> // for ExpList2D, etc
#include <MultiRegions/ExpList3D.h> // for ExpList3D
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>
namespace Nektar
{
namespace SolverUtils
{
class ForcingBody : public ForcingSponge
{
public:
friend class MemoryManager<ForcingBody>;
/// Creates an instance of this class
SOLVER_UTILS_EXPORT static ForcingSharedPtr create() {
return ForcingSharedPtr(new ForcingBody());
}
SOLVER_UTILS_EXPORT ForcingBody();
///Name of the class
static std::string className;
protected:
virtual void v_InitObject(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
SpatialDomains::MeshGraphSharedPtr pGraph);
virtual void v_Apply(
const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray);
private:
void v_ReadForceInfo(
LibUtilities::SessionReaderSharedPtr pSession,
Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
SpatialDomains::MeshGraphSharedPtr pGraph);
};
}
}
// Hui XU 26 Jul 2013 Created
#endif
<?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]" NUMMODES="8" FIELDS="u,v,p" TYPE="MODIFIED" />
</EXPANSIONS>
<CONDITIONS>
<SOLVERINFO>
<I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme" />
<I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes" />
<I PROPERTY="AdvectionForm" VALUE="Convective" />
<I PROPERTY="Projection" VALUE="Galerkin" />
<I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder1" />
</SOLVERINFO>
<PARAMETERS>
<P> TimeStep = 0.001 </P>
<P> NumSteps = 1000 </P>
<P> IO_CheckSteps = 1000 </P>
<P> IO_InfoSteps = 1000 </P>
<P> Kinvis = 1 </P>
</PARAMETERS>
<VARIABLES>
<V ID="0"> u </V>
<V ID="1"> v </V>
<V ID="2"> p </V>
</VARIABLES>
<BOUNDARYREGIONS>
<B ID="0"> C[1] </B>
<B ID="1"> C[2] </B>
<B ID="2"> C[3] </B>
</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">
<P VAR="u" VALUE="[2]" />
<P VAR="v" VALUE="[2]" />
<P VAR="p" VALUE="[2]" />
</REGION>
<REGION REF="2">
<P VAR="u" VALUE="[1]" />
<P VAR="v" VALUE="[1]" />
<P VAR="p" VALUE="[1]" />
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="InitialConditions">
<E VAR="u" VALUE="0" />
<E VAR="v" VALUE="0" />
<E VAR="p" VALUE="0" />
</FUNCTION>
<FUNCTION NAME="ExactSolution">
<E VAR="u" VALUE="y*(1-y)" />
<E VAR="v" VALUE="0" />
<E VAR="p" VALUE="0" />
</FUNCTION>
<FUNCTION NAME="BodyForce">
<E VAR="u" VALUE="2" />
<E VAR="v" VALUE="0" />
</FUNCTION>
</CONDITIONS>
<GEOMETRY DIM="2" SPACE="2">
<VERTEX>
<V ID="0"> 0.0 0.0 0.0 </V>
<V ID="1"> 0.5 0.0 0.0 </V>
<V ID="2"> 1.0 0.0 0.0 </V>
<V ID="3"> 0.0 0.5 0.0 </V>
<V ID="4"> 0.5 0.5 0.0 </V>
<V ID="5"> 1.0 0.5 0.0 </V>
<V ID="6"> 0.0 1.0 0.0 </V>
<V ID="7"> 0.5 1.0 0.0 </V>
<V ID="8"> 1.0 1.0 0.0 </V>
</VERTEX>
<EDGE>
<E ID="0"> 0 1 </E>
<E ID="1"> 1 2 </E>
<E ID="2"> 0 3 </E>
<E ID="3"> 1 4 </E>
<E ID="4"> 2 5 </E>
<E ID="5"> 3 4 </E>
<E ID="6"> 4 5 </E>
<E ID="7"> 3 6 </E>
<E ID="8"> 4 7 </E>
<E ID="9"> 5 8 </E>
<E ID="10"> 6 7 </E>
<E ID="11"> 7 8 </E>
</EDGE>
<ELEMENT>
<Q ID="0"> 0 3 5 2 </Q>
<Q ID="1"> 1 4 6 3 </Q>
<Q ID="2"> 5 8 10 7 </Q>
<Q ID="3"> 6 9 11 8 </Q>
</ELEMENT>
<COMPOSITE>
<C ID="0"> Q[0-3] </C>
<C ID="1"> E[0,1,10,11] </C> <!-- Walls -->
<C ID="2"> E[2,7] </C> <!-- Inflow -->
<C ID="3"> E[4,9] </C> <!-- Outflow -->
</COMPOSITE>
<DOMAIN> C[0] </DOMAIN>
</GEOMETRY>
</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