Skip to content

Commit

Permalink
AL: Started modifying the ICP-LTE code for dding swirl.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrealani committed Feb 23, 2018
1 parent 014efb1 commit 152ac7f
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 80 deletions.
5 changes: 3 additions & 2 deletions apps/Solver/CMakeLists.txt
Expand Up @@ -10,14 +10,15 @@ LIST ( APPEND coolfluid-solver_libs ${CF_KERNEL_LIBS} ${CF_KERNEL_STATIC_LIBS} )

IF ( NOT CF_HAVE_SINGLE_EXEC )
LIST ( APPEND coolfluid-solver_libs ${CF_Boost_LIBRARIES} )
LOG("CF_Boost_LIBRARIES are [${CF_Boost_LIBRARIES}]" )
ENDIF()

MESSAGE ("###### coolfluid-solver_libs are ${coolfluid-solver_libs}")
MESSAGE ("###### coolfluid-solver_cflibs are ${coolfluid-solver_cflibs}")
IF ( CF_HAVE_ALLSTATIC )
LOG ("coolfluid-solver_libs are ${coolfluid-solver_libs}")
LOG("CF_KERNEL_LIBS is [${CF_KERNEL_LIBS}]" )
LOG("CF_KERNEL_STATIC_LIBS is [${CF_KERNEL_STATIC_LIBS}]" )
LOG("CF_KERNEL_LIBS are [${CF_KERNEL_LIBS}]" )
LOG("CF_KERNEL_STATIC_LIBS are [${CF_KERNEL_STATIC_LIBS}]" )
ENDIF()

CF_ADD_PLUGIN_APP ( coolfluid-solver )
Expand Down
2 changes: 2 additions & 0 deletions plugins/FiniteVolume/FunctionSourceTerm.cxx
Expand Up @@ -108,6 +108,8 @@ void FunctionSourceTerm::computeSource(GeometricEntity *const element,
<< source << "\n");

const CFreal volume = socket_volumes.getDataHandle()[element->getID()];

CFLog(DEBUG_MAX, "source[" << element->getID() << "] = " << source << ", vol = " << volume << "\n");
source *= volume;
}

Expand Down
6 changes: 6 additions & 0 deletions plugins/FiniteVolumeICP/LorentzForceSourceTermAlternative.cxx
Expand Up @@ -85,6 +85,12 @@ void LorentzForceSourceTermAlternative::computeSource
CFLogDebugMax( "LorentzForceSourceTermAlternative::computeSource() => source[" <<
m_velIDs[1] << "] = " <<LorentzForce[1][elemID] << "\n");

if (PhysicalModelStack::getActive()->getImplementor()->is2DHalf()) {
source[m_velIDs[2]] = LorentzForce[2][elemID] ;
CFLogDebugMax( "LorentzForceSourceTermAlternative::computeSource() => source[" <<
m_velIDs[2] << "] = " <<LorentzForce[2][elemID] << "\n");
}

source *= volumes[elemID];
}
}
Expand Down
16 changes: 11 additions & 5 deletions plugins/FiniteVolumeICP/LorentzForceSourceTermComm.ci
Expand Up @@ -141,12 +141,18 @@ void LorentzForceSourceTerm<ST>::setup()
const CFuint nbCells = cells->nbRows();

DataHandle<RealVector> LorentzForce = socket_LorentzForce.getDataHandle();
LorentzForce.resize(2);
LorentzForce[0].resize(nbCells);
LorentzForce[1].resize(nbCells);

const bool is2DHalf = PhysicalModelStack::getActive()->getImplementor()->is2DHalf();
const CFuint dim = (is2DHalf) ? 3 : PhysicalModelStack::getActive()->getDim();

LorentzForce.resize(dim);
for (CFuint i = 0; i < dim; ++i) {
LorentzForce[i].resize(nbCells);
}
for(CFuint iCell = 0; iCell < nbCells; ++iCell) {
LorentzForce[0][iCell] = 0.0;
LorentzForce[1][iCell] = 0.0;
for (CFuint i = 0; i < dim; ++i) {
LorentzForce[i][iCell] = 0.0;
}
}

// suppose that just one space method is available
Expand Down
20 changes: 11 additions & 9 deletions plugins/FiniteVolumeNavierStokes/RhieChowFlux.ci
Expand Up @@ -61,7 +61,10 @@ void RhieChowFlux<UPDATEVAR>::compute(RealVector& result)
const CFuint nbEqs =
PhysicalModelStack::getActive()->getEquationSubSysDescriptor().getNbEqsSS();

const CFuint dim = PhysicalModelStack::getActive()->getDim();
Common::SafePtr<PhysicalModelImpl> pm =
PhysicalModelStack::getActive()->getImplementor();
const bool is2DHalf = pm->is2DHalf();
const CFuint dim = (is2DHalf) ? 3 : PhysicalModelStack::getActive()->getDim();
const EquationSetData& eulerEqSet = UPDATEVAR::EULERSET::getEqSetData()[0];
const vector<CFuint>& eulerVarIDs = eulerEqSet.getEqSetVarIDs();
const CFuint nbEulerEqs = eulerVarIDs.size() ;
Expand Down Expand Up @@ -116,21 +119,19 @@ void RhieChowFlux<UPDATEVAR>::compute(RealVector& result)

// calculation of the normal component of velocity for
// the left and right states

CFreal unL = 0.0;
CFreal unR = 0.0;
if (dim == DIM_3D)
{
const CFreal nz = unitNormal[ZZ];
if (dim == DIM_3D) {
const CFreal nz = (!is2DHalf) ? unitNormal[ZZ] : 0.;
unL = uL*nx + vL*ny + wL*nz;
unR = uR*nx + vR*ny + wR*nz;
}
else
{
else {
unL = uL*nx + vL*ny;
unR = uR*nx + vR*ny;
}

m_rhoUn12 = .5*(rhoL*unL + rhoR*unR);

// this can modify m_rhoUn12
Expand Down Expand Up @@ -200,8 +201,8 @@ void RhieChowFlux<UPDATEVAR>::compute(RealVector& result)
if (dim == DIM_3D)
{
m_w12 = .5*(wL + wR);
const CFreal nz = unitNormal[ZZ];
if (nbEulerEqs == dim + 2) {
const CFreal nz = (!is2DHalf) ? unitNormal[ZZ] : 0.;
result[1] = mflux*m_u12 - .5*(std::abs(mflux) + addLambdaU)*(uR - uL) + dp12*nx;
result[2] = mflux*m_v12 - .5*(std::abs(mflux) + addLambdaU)*(vR - vL) + dp12*ny;
result[3] = mflux*m_w12 - .5*(std::abs(mflux) + addLambdaU)*(wR - wL) + dp12*nz;
Expand All @@ -227,6 +228,7 @@ void RhieChowFlux<UPDATEVAR>::compute(RealVector& result)
}
else {
// NEQ cases should enter here
const CFreal nz = (!is2DHalf) ? unitNormal[ZZ] : 0.;
result[eulerVarIDs[0]] = mflux*m_u12 - .5*(std::abs(mflux) + addLambdaU)*(uR - uL) + dp12*nx;
result[eulerVarIDs[1]] = mflux*m_v12 - .5*(std::abs(mflux) + addLambdaU)*(vR - vL) + dp12*ny;
result[eulerVarIDs[2]] = mflux*m_w12 - .5*(std::abs(mflux) + addLambdaU)*(wR - wL) + dp12*nz;
Expand Down
7 changes: 7 additions & 0 deletions plugins/FiniteVolumeNavierStokes/RhieChowFlux.cxx
Expand Up @@ -33,6 +33,13 @@ MethodStrategyProvider<RhieChowFlux<Euler3DVarSet>,
FluxSplitter<CellCenterFVMData>,
FiniteVolumeNavierStokesModule>
rhieChowFlux3DProvider("RhieChow3D");

// 2D and 1/2
MethodStrategyProvider<RhieChowFlux<Euler3DVarSet>,
CellCenterFVMData,
FluxSplitter<CellCenterFVMData>,
FiniteVolumeNavierStokesModule>
rhieChowFlux2DHalfProvider("RhieChow2DHalf");

MethodStrategyProvider<RhieChowFlux<MultiScalarVarSet<Euler2DVarSet> >,
CellCenterFVMData,
Expand Down
4 changes: 2 additions & 2 deletions plugins/ICP/CMakeLists.txt
Expand Up @@ -6,8 +6,8 @@ ICPInductionConvVarSet.cxx
ICPInductionDiffVarSet.hh
ICPInductionDiffVarSet.ci
ICPInductionDiffVarSet.cxx
ICPLTE2DPuvtToCons.hh
ICPLTE2DPuvtToCons.cxx
ICPLTEPvtToCons.hh
ICPLTEPvtToCons.cxx
ICPLTE2DdPuvtToPuvt.hh
ICPLTE2DdPuvtToPuvt.cxx
ICPLTE2DPuvtToConsInPuvt.cxx
Expand Down
@@ -1,5 +1,5 @@
#include "ICP/ICP.hh"
#include "ICPLTE2DPuvtToCons.hh"
#include "ICP/ICPLTEPvtToCons.hh"
#include "Framework/PhysicalModel.hh"
#include "Environment/ObjectProvider.hh"
#include "Framework/PhysicalChemicalLibrary.hh"
Expand All @@ -21,12 +21,15 @@ namespace COOLFluiD {

//////////////////////////////////////////////////////////////////////

Environment::ObjectProvider<ICPLTE2DPuvtToCons, VarSetTransformer, ICPModule,1>
Environment::ObjectProvider<ICPLTEPvtToCons, VarSetTransformer, ICPModule,1>
icpLTE2DPuvtToConsProvider("ICPLTE2DPuvtToCons");

Environment::ObjectProvider<ICPLTEPvtToCons, VarSetTransformer, ICPModule,1>
icpLTE2DPvtToConsProvider("ICPLTE2DPvtToCons");

//////////////////////////////////////////////////////////////////////

ICPLTE2DPuvtToCons::ICPLTE2DPuvtToCons
ICPLTEPvtToCons::ICPLTEPvtToCons
(Common::SafePtr<Framework::PhysicalModelImpl> model) :
VarSetTransformer(model),
_icpModel(model->getConvectiveTerm().d_castTo<PTERM>()),
Expand All @@ -37,57 +40,70 @@ ICPLTE2DPuvtToCons::ICPLTE2DPuvtToCons

//////////////////////////////////////////////////////////////////////

ICPLTE2DPuvtToCons::~ICPLTE2DPuvtToCons()
ICPLTEPvtToCons::~ICPLTEPvtToCons()
{
}

//////////////////////////////////////////////////////////////////////

void ICPLTE2DPuvtToCons::transform(const State& state, State& result)
void ICPLTEPvtToCons::transform(const State& state, State& result)
{
Common::SafePtr<PhysicalModelImpl> pm =
PhysicalModelStack::getActive()->getImplementor();
const CFuint dim = (pm->is2DHalf()) ?
3 : PhysicalModelStack::getActive()->getDim();
// find a way of storing this pointer (sdd setup() function)
static Common::SafePtr<PhysicalChemicalLibrary> library =
PhysicalModelStack::getActive()->getImplementor()->
getPhysicalPropertyLibrary<PhysicalChemicalLibrary>();
pm->getPhysicalPropertyLibrary<PhysicalChemicalLibrary>();

const RealVector& refData = _icpModel->getReferencePhysicalData();

const CFreal u = state[1];
const CFreal v = state[2];
const CFreal T = state[3];
const CFreal EpR = state[4];
const CFreal EpI = state[5];
const CFuint TID = dim+1;
const CFuint erID = TID+1;
const CFuint eiID = TID+2;
const CFreal T = state[TID];
const CFreal EpR = state[erID];
const CFreal EpI = state[eiID];
CFreal pdim = _icpModel->getPressureFromState(state[0])*refData[EulerTerm::P];
CFreal Tdim = T*refData[EulerTerm::T];

// set the composition
library->setComposition(Tdim,pdim);
library->setDensityEnthalpyEnergy(Tdim, pdim, _dhe);
const CFreal rho = _dhe[0]/refData[EulerTerm::RHO];
const CFreal V2 = u*u + v*v;

result[0] = rho;
result[1] = rho*u;
result[2] = rho*v;
result[3] = rho*(_dhe[2]/refData[EulerTerm::E] + 0.5*V2);
result[4] = EpR;
result[5] = EpI;

CFreal V2 = 0.;
for (CFuint i = 1; i <= dim; ++i) {
const CFreal ui = state[i];
result[i] = rho*ui;
V2 += ui*ui;
}

result[TID] = rho*(_dhe[2]/refData[EulerTerm::E] + 0.5*V2);
result[erID] = EpR;
result[eiID] = EpI;
}

//////////////////////////////////////////////////////////////////////

void ICPLTE2DPuvtToCons::transformFromRef(const RealVector& data, State& result)
void ICPLTEPvtToCons::transformFromRef(const RealVector& data, State& result)
{
Common::SafePtr<PhysicalModelImpl> pm =
PhysicalModelStack::getActive()->getImplementor();
const CFuint dim = (pm->is2DHalf()) ?
3 : PhysicalModelStack::getActive()->getDim();

// here we assume that E's are the last two components
const CFuint firstScalarVar = _icpModel->getDataSize() - 2;
const CFreal rho = data[EulerTerm::RHO];

result[0] = rho;
result[1] = rho*data[EulerTerm::VX];
result[2] = rho*data[EulerTerm::VY];
result[3] = rho*data[EulerTerm::E];
result[4] = data[firstScalarVar];
result[5] = data[firstScalarVar+1];
for (CFuint i = 0; i < dim; ++i) {
result[i+1] = rho*data[EulerTerm::VX+i];
}
result[dim+1] = rho*data[EulerTerm::E];
result[dim+2] = data[firstScalarVar];
result[dim+3] = data[firstScalarVar+1];
}

//////////////////////////////////////////////////////////////////////
Expand Down
@@ -1,5 +1,5 @@
#ifndef COOLFluiD_Physics_ICP_ICPLTE2DPuvtToCons_hh
#define COOLFluiD_Physics_ICP_ICPLTE2DPuvtToCons_hh
#ifndef COOLFluiD_Physics_ICP_ICPLTEPvtToCons_hh
#define COOLFluiD_Physics_ICP_ICPLTEPvtToCons_hh

//////////////////////////////////////////////////////////////////////

Expand All @@ -24,20 +24,20 @@ namespace COOLFluiD {
* @author Radek Honzattko
*
*/
class ICPLTE2DPuvtToCons : public Framework::VarSetTransformer {
class ICPLTEPvtToCons : public Framework::VarSetTransformer {
public:

typedef Framework::MultiScalarTerm<Physics::NavierStokes::EulerTerm> PTERM;

/**
* Default constructor without arguments
*/
ICPLTE2DPuvtToCons(Common::SafePtr<Framework::PhysicalModelImpl> model);
ICPLTEPvtToCons(Common::SafePtr<Framework::PhysicalModelImpl> model);

/**
* Default destructor
*/
virtual ~ICPLTE2DPuvtToCons();
virtual ~ICPLTEPvtToCons();

/**
* Transform a set of state vectors into another one
Expand All @@ -58,7 +58,7 @@ private:
/// array storing density enthalpy energy
RealVector _dhe;

}; // end of class ICPLTE2DPuvtToCons
}; // end of class ICPLTEPvtToCons

//////////////////////////////////////////////////////////////////////

Expand All @@ -70,4 +70,4 @@ private:

//////////////////////////////////////////////////////////////////////

#endif // COOLFluiD_Physics_ICP_ICPLTE2DPuvtToCons_hh
#endif // COOLFluiD_Physics_ICP_ICPLTEPvtToCons_hh
Expand Up @@ -163,13 +163,10 @@ Simulator.SubSystem.CellCenterFVM.Data.DistanceBasedGMoveMultiTRS.Inlet.Values =
Simulator.SubSystem.CellCenterFVM.Data.DistanceBasedGMoveMultiTRS.Wall_probe.ValuesIdx = 1 2 3
Simulator.SubSystem.CellCenterFVM.Data.DistanceBasedGMoveMultiTRS.Wall_probe.Values = 0. 0. 350.


Simulator.SubSystem.CellCenterFVM.Data.isAxisymm = true
Simulator.SubSystem.CellCenterFVM.Data.SourceTerm = \
NavierStokes2DAxiST ICPInductionEquationST RMSJouleHeatST LorentzForceAlternativeST

#Simulator.SubSystem.CellCenterFVM.Data.PolyRec = Constant

Simulator.SubSystem.CellCenterFVM.SetupCom = LeastSquareP1Setup
Simulator.SubSystem.CellCenterFVM.SetupNames = Setup1
Simulator.SubSystem.CellCenterFVM.Setup1.stencil = FaceVertexPlusGhost
Expand Down
3 changes: 3 additions & 0 deletions plugins/LTE/Euler3DPvtLTE.cxx
Expand Up @@ -23,6 +23,9 @@ namespace COOLFluiD {

Environment::ObjectProvider<Euler3DPvtLTE, ConvectiveVarSet, LTEModule, 1> euler3DPvtLTEProvider("Euler3DPvtLTE");

// 2D and 1/2
Environment::ObjectProvider<Euler3DPvtLTE, ConvectiveVarSet, LTEModule, 1> euler2DPvtLTEProvider("Euler2DPvtLTE");

//////////////////////////////////////////////////////////////////////////////

Euler3DPvtLTE::Euler3DPvtLTE(Common::SafePtr<BaseTerm> term) :
Expand Down
2 changes: 1 addition & 1 deletion plugins/LTE/Euler3DPvtLTE.hh
Expand Up @@ -123,7 +123,7 @@ public: // classes

/// Set the IDs corresponding to the velocity components in a State
virtual void setStateVelocityIDs (std::vector<CFuint>& velIDs)
{
{
velIDs.resize(3); velIDs[XX] = 1; velIDs[YY] = 2; velIDs[ZZ] = 3;
}

Expand Down
19 changes: 14 additions & 5 deletions plugins/LTE/EulerPvtLTEToCons.cxx
Expand Up @@ -30,6 +30,10 @@ euler2DPuvtLTEToConsProvider("Euler2DPuvtLTEToCons");
Environment::ObjectProvider<EulerPvtLTEToCons, VarSetTransformer, LTEModule, 1>
euler3DPvtLTEToConsProvider("Euler3DPvtLTEToCons");

// 2D and 1/2
Environment::ObjectProvider<EulerPvtLTEToCons, VarSetTransformer, LTEModule, 1>
euler2DPvtLTEToConsProvider("Euler2DPvtLTEToCons");

//////////////////////////////////////////////////////////////////////////////

EulerPvtLTEToCons::EulerPvtLTEToCons(Common::SafePtr<Framework::PhysicalModelImpl> model) :
Expand All @@ -52,7 +56,10 @@ void EulerPvtLTEToCons::transform(const State& state, State& result)
{
const RealVector& refData = _model->getReferencePhysicalData();

const CFuint dim = PhysicalModelStack::getActive()->getDim();
Common::SafePtr<PhysicalModelImpl> pm =
PhysicalModelStack::getActive()->getImplementor();
const CFuint dim = (pm->is2DHalf()) ?
3 : PhysicalModelStack::getActive()->getDim();
const CFuint TID = dim+1;

CFreal p = _model->getPressureFromState(state[0]);
Expand All @@ -61,8 +68,7 @@ void EulerPvtLTEToCons::transform(const State& state, State& result)
CFreal Tdim = T*_model->getTempRef();

static Common::SafePtr<PhysicalChemicalLibrary> library =
PhysicalModelStack::getActive()->getImplementor()->
getPhysicalPropertyLibrary<PhysicalChemicalLibrary>();
pm->getPhysicalPropertyLibrary<PhysicalChemicalLibrary>();

// set the composition
library->setComposition(Tdim,pdim);
Expand All @@ -87,9 +93,12 @@ void EulerPvtLTEToCons::transform(const State& state, State& result)
void EulerPvtLTEToCons::transformFromRef(const RealVector& data, State& result)
{
m_rho = data[EulerTerm::RHO];
result[0] = m_rho;
result[0] = m_rho;

const CFuint dim = PhysicalModelStack::getActive()->getDim();
Common::SafePtr<PhysicalModelImpl> pm =
PhysicalModelStack::getActive()->getImplementor();
const CFuint dim = (pm->is2DHalf()) ?
3 : PhysicalModelStack::getActive()->getDim();
for (CFuint i=0; i < dim; ++i) {
result[i+1] = m_rho*data[EulerTerm::VX+i];
}
Expand Down

0 comments on commit 152ac7f

Please sign in to comment.