Commit 09758738 authored by Klaus Mosthaf's avatar Klaus Mosthaf
Browse files

Changed component indices:

phaseIdx is called from the property system (default to nPhase)

wComp or comp1Idx -> transportCompIdx (transported component)
nComp or comp0Idx -> phaseCompIdx (main component of phase)

transportCompIdx is |1-phaseIdx|, because usually the transported
component of interest is the minor component of the phase. This allows
the to choose an arbitrary phase of a two-phase fluidsystem, if
wComp is the main component of wPhase and both have the same index with either 0 or 1.

Corrected index names for primary variables, they get the correct
primary variable index instead of the equation index;
massOrMoleFracIdx has been employed for the mass or mole fraction (seems
to be self-explanatory...)

Adapted also test problems for stokes2c, stokes2cni.

Reviewed bei Markus.



git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@8275 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 36ee1cc0
......@@ -66,9 +66,8 @@ class Stokes2cFluxVariables : public StokesFluxVariables<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Stokes2cIndices) Indices;
enum { dim = GridView::dimension };
enum { comp1Idx = Indices::comp1Idx };
enum { lCompIdx = comp1Idx } DUMUX_DEPRECATED_MSG("use comp1Idx instead");
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx) };
enum { phaseIdx = Indices::phaseIdx };
enum { transportCompIdx = Indices::transportCompIdx };
typedef typename GridView::template Codim<0>::Entity Element;
typedef Dune::FieldVector<Scalar, dim> DimVector;
......@@ -86,7 +85,7 @@ public:
}
/*!
* \brief Return the mass fraction at the integration point.
* \brief Return the mass fraction of the transported component at the integration point.
*/
Scalar massFraction() const
{ return massFraction_; }
......@@ -139,7 +138,7 @@ protected:
idx < this->fvGeometry_.numVertices;
idx++) // loop over vertices of the element
{
massFraction_ += elemVolVars[idx].fluidState().massFraction(phaseIdx, comp1Idx) *
massFraction_ += elemVolVars[idx].fluidState().massFraction(phaseIdx, transportCompIdx) *
this->face().shapeValue[idx];
diffusionCoeff_ += elemVolVars[idx].diffusionCoeff() *
this->face().shapeValue[idx];
......@@ -149,7 +148,7 @@ protected:
{
moleFractionGrad_ +=
this->face().grad[idx][dimIdx] *
elemVolVars[idx].fluidState().moleFraction(phaseIdx, comp1Idx);
elemVolVars[idx].fluidState().moleFraction(phaseIdx, transportCompIdx);
}
}
......
......@@ -48,26 +48,31 @@ struct Stokes2cCommonIndices : public StokesCommonIndices<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
public:
// Phase indices
static const int wPhaseIdx = FluidSystem::lPhaseIdx; //!< Index of the wetting phase
static const int nPhaseIdx = FluidSystem::gPhaseIdx; //!< Index of the non-wetting phase
static const int lPhaseIdx = wPhaseIdx; //!< \deprecated use wPhaseIdx instead
static const int gPhaseIdx = nPhaseIdx; //!< \deprecated use nPhaseIdx instead
// Phase index
static const int phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx); //!< Index of the employed phase in case of a two-phase fluidsystem (set by default to nPhase)
static const int wPhaseIdx = FluidSystem::wPhaseIdx; //!< \deprecated use phaseIdx instead, only one phase employed
static const int nPhaseIdx = FluidSystem::nPhaseIdx; //!< \deprecated use phaseIdx instead, only one phase employed
static const int lPhaseIdx = wPhaseIdx; //!< \deprecated use phaseIdx instead, only one phase employed
static const int gPhaseIdx = nPhaseIdx; //!< \deprecated use phaseIdx instead, only one phase employed
// Component indices
static const int comp1Idx = 0; //!< Index of the wetting's primary component
static const int comp0Idx = 1; //!< Index of the non-wetting's primary component
static const int lCompIdx = comp1Idx; //!< \deprecated use comp1Idx instead
static const int gCompIdx = comp0Idx; //!< \deprecated use comp0Idx instead
static const int phaseCompIdx = phaseIdx; //!< The index of the main component of the considered phase
static const int transportCompIdx = (unsigned int)(1-phaseIdx); //!< The index of the transported (minor) component; ASSUMES phase indices of 0 and 1
static const int comp1Idx = 0; //!< \deprecated Index of the wetting's primary component
static const int comp0Idx = 1; //!< \deprecated Index of the non-wetting's primary component
static const int lCompIdx = transportCompIdx; //!< \deprecated use transportComp instead
static const int gCompIdx = phaseCompIdx; //!< \deprecated use phaseCompIdx instead
// equation and primary variable indices
static const int dim = StokesCommonIndices<TypeTag>::dim;
static const int transportEqIdx = PVOffset + dim+1; //!< The index for the transport equation.
static const int transportEqIdx = PVOffset + dim+1; //!< The index for the transport equation
static const int transportIdx = transportEqIdx; //!< \deprecated use transportEqIdx instead
static const int transportCompIdx = transportEqIdx; //!< The index for the mass or mole fraction in primary variable vectors.
static const int massOrMoleFracIndex = transportCompIdx; //!< \deprecated use transportCompIdx instead
static const int phaseIdx = nPhaseIdx; //!< Index of the non-wetting phase (required to use the same fluid system in coupled models)
static const int massOrMoleFracIdx = transportEqIdx; //!< The index of the mass or mole fraction of the transported component in primary variable vectors
static const int massOrMoleFracIndex = massOrMoleFracIdx; //!< \deprecated use massOrMoleFracIdx instead
};
} // end namespace
......
......@@ -54,10 +54,11 @@ class Stokes2cLocalResidual : public StokesLocalResidual<TypeTag>
enum { dim = GridView::dimension };
enum { transportEqIdx = Indices::transportEqIdx }; //!< Index of the transport equation
enum { transportIdx = transportEqIdx }; DUMUX_DEPRECATED_MSG("use transportEqIdx instead");
enum { comp1Idx = Indices::comp1Idx }; //!< Index of the transported component
enum { lCompIdx = comp1Idx } DUMUX_DEPRECATED_MSG("use comp1Idx instead");
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx)}; //!< Index of the considered phase (only of interest when using two-phase fluidsystems)
enum { phaseIdx = Indices::phaseIdx }; //!< Index of the considered phase (only of interest when using two-phase fluidsystems)
// component indices
enum { phaseCompIdx = Indices::phaseCompIdx }; //!< Index of the main component of the fluid phase
enum { transportCompIdx = Indices::transportCompIdx }; //!< Index of the minor component of the fluid phase
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
typedef typename GET_PROP_TYPE(TypeTag, VolumeVariables) VolumeVariables;
......@@ -93,10 +94,10 @@ public:
// compute the storage of the component
storage[transportEqIdx] =
volVars.density() *
volVars.fluidState().massFraction(phaseIdx, comp1Idx);
volVars.fluidState().massFraction(phaseIdx, transportCompIdx);
Valgrind::CheckDefined(volVars.density());
Valgrind::CheckDefined(volVars.fluidState().massFraction(phaseIdx, comp1Idx));
Valgrind::CheckDefined(volVars.fluidState().massFraction(phaseIdx, transportCompIdx));
}
/*!
......@@ -124,10 +125,10 @@ public:
if (this->massUpwindWeight_ > 0.0)
tmp *= this->massUpwindWeight_ * // upwind data
up.density() * up.fluidState().massFraction(phaseIdx, comp1Idx);
up.density() * up.fluidState().massFraction(phaseIdx, transportCompIdx);
if (this->massUpwindWeight_ < 1.0)
tmp += (1.0 - this->massUpwindWeight_) * // rest
dn.density() * dn.fluidState().massFraction(phaseIdx, comp1Idx);
dn.density() * dn.fluidState().massFraction(phaseIdx, transportCompIdx);
flux[transportEqIdx] += tmp;
Valgrind::CheckDefined(flux[transportEqIdx]);
......@@ -153,7 +154,7 @@ public:
fluxVars.face().normal[dimIdx] *
fluxVars.diffusionCoeff() *
fluxVars.molarDensity() *
FluidSystem::molarMass(comp1Idx);
FluidSystem::molarMass(transportCompIdx);
Valgrind::CheckDefined(flux[transportEqIdx]);
}
......
......@@ -75,8 +75,7 @@ class Stokes2cModel : public StokesModel<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Stokes2cIndices) Indices;
enum { dim = GridView::dimension };
enum { comp1Idx = Indices::comp1Idx };
enum { lCompIdx = comp1Idx } DUMUX_DEPRECATED_MSG("use comp1Idx instead");
enum { transportCompIdx = Indices::transportCompIdx };
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx) };
typedef typename GridView::template Codim<0>::Iterator ElementIterator;
......@@ -138,7 +137,7 @@ public:
pN[globalIdx] = volVars.pressure()*scale_;
delP[globalIdx] = volVars.pressure()*scale_ - 1e5;
Xw[globalIdx] = volVars.fluidState().massFraction(phaseIdx, comp1Idx);
Xw[globalIdx] = volVars.fluidState().massFraction(phaseIdx, transportCompIdx);
rho[globalIdx] = volVars.density()*scale_*scale_*scale_;
mu[globalIdx] = volVars.viscosity()*scale_;
velocity[globalIdx] = volVars.velocity();
......@@ -148,7 +147,7 @@ public:
writer.attachVertexData(pN, "P");
writer.attachVertexData(delP, "delP");
std::ostringstream outputNameX;
outputNameX << "X^" << FluidSystem::componentName(comp1Idx);
outputNameX << "X^" << FluidSystem::componentName(transportCompIdx);
writer.attachVertexData(Xw, outputNameX.str());
writer.attachVertexData(rho, "rho");
writer.attachVertexData(mu, "mu");
......
......@@ -57,17 +57,13 @@ class Stokes2cVolumeVariables : public StokesVolumeVariables<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
enum {
comp1Idx = Indices::comp1Idx,
comp0Idx = Indices::comp0Idx
transportCompIdx = Indices::transportCompIdx,
phaseCompIdx = Indices::phaseCompIdx
};
enum {
lCompIdx = comp1Idx,
gCompIdx = comp0Idx
} DUMUX_DEPRECATED_MSG("use comp1Idx instead");
enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx) };
enum { transportEqIdx = Indices::transportEqIdx };
enum { transportIdx = transportEqIdx }; //!< \deprecated use transportEqIdx instead
enum { massOrMoleFracIdx = Indices::massOrMoleFracIdx };
public:
/*!
......@@ -100,8 +96,8 @@ public:
diffCoeff_ = FluidSystem::binaryDiffusionCoefficient(this->fluidState(),
paramCache,
phaseIdx,
comp1Idx,
comp0Idx);
transportCompIdx,
phaseCompIdx);
Valgrind::CheckDefined(diffCoeff_);
};
......@@ -119,18 +115,18 @@ public:
const bool isOldSol = false)
{
Scalar massFraction[numComponents];
massFraction[comp1Idx] = priVars[transportEqIdx];
massFraction[comp0Idx] = 1 - massFraction[comp1Idx];
massFraction[transportCompIdx] = priVars[massOrMoleFracIdx];
massFraction[phaseCompIdx] = 1 - massFraction[transportCompIdx];
// calculate average molar mass of the gas phase
Scalar M1 = FluidSystem::molarMass(comp1Idx);
Scalar M2 = FluidSystem::molarMass(comp0Idx);
Scalar X2 = massFraction[comp0Idx];
Scalar M1 = FluidSystem::molarMass(transportCompIdx);
Scalar M2 = FluidSystem::molarMass(phaseCompIdx);
Scalar X2 = massFraction[phaseCompIdx];
Scalar avgMolarMass = M1*M2/(M2 + X2*(M1 - M2));
// convert mass to mole fractions and set the fluid state
fluidState.setMoleFraction(phaseIdx, comp1Idx, massFraction[comp1Idx]*avgMolarMass/M1);
fluidState.setMoleFraction(phaseIdx, comp0Idx, massFraction[comp0Idx]*avgMolarMass/M2);
fluidState.setMoleFraction(phaseIdx, transportCompIdx, massFraction[transportCompIdx]*avgMolarMass/M1);
fluidState.setMoleFraction(phaseIdx, phaseCompIdx, massFraction[phaseCompIdx]*avgMolarMass/M2);
}
/*!
......
......@@ -46,8 +46,9 @@ struct Stokes2cniCommonIndices : public Stokes2cCommonIndices<TypeTag, PVOffset>
public:
// number of dimensions
static const int dim = StokesCommonIndices<TypeTag>::dim;
static const int energyIdx = PVOffset + dim+2; //! The index for the energy balance equation.
static const int temperatureIdx = energyIdx; //! The index for temperature in primary variable vectors.
static const int energyEqIdx = PVOffset + dim+2; //! The index for the energy balance equation
static const int energyIdx = energyEqIdx; // \deprecated Use energyEqIdx instaed
static const int temperatureIdx = energyEqIdx; //! The index for temperature in primary variable vectors
};
} // end namespace
......
......@@ -55,7 +55,7 @@ class Stokes2cniLocalResidual : public Stokes2cLocalResidual<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Stokes2cniIndices) Indices;
enum { dim = GridView::dimension };
enum { energyIdx = Indices::energyIdx }; //!< Index of the transport equation
enum { energyEqIdx = Indices::energyEqIdx }; //!< Index of the transport equation
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
typedef typename GET_PROP_TYPE(TypeTag, VolumeVariables) VolumeVariables;
......@@ -84,7 +84,7 @@ public:
const VolumeVariables &volVars = elemVolVars[scvIdx];
// compute the storage of energy
storage[energyIdx] =
storage[energyEqIdx] =
volVars.density() *
volVars.internalEnergy();
}
......@@ -115,8 +115,8 @@ public:
(1.0 - this->massUpwindWeight_) * // rest
dn.density() * dn.enthalpy();
flux[energyIdx] += tmp;
Valgrind::CheckDefined(flux[energyIdx]);
flux[energyEqIdx] += tmp;
Valgrind::CheckDefined(flux[energyEqIdx]);
}
/*!
......@@ -134,7 +134,7 @@ public:
// diffusive heat flux
for (int dimIdx = 0; dimIdx < dim; ++dimIdx)
flux[energyIdx] -=
flux[energyEqIdx] -=
fluxVars.temperatureGrad()[dimIdx] *
fluxVars.face().normal[dimIdx] *
fluxVars.heatConductivity();
......
......@@ -85,8 +85,8 @@ class Stokes2cniModel : public Stokes2cModel<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Stokes2cniIndices) Indices;
enum { dim = GridView::dimension };
enum { comp1Idx = Indices::comp1Idx };
enum { lCompIdx = comp1Idx } DUMUX_DEPRECATED_MSG("use comp1Idx instead");
enum { transportCompIdx = Indices::transportCompIdx };
enum { lCompIdx = transportCompIdx } DUMUX_DEPRECATED_MSG("use transportCompIdx instead");
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIndex) };
typedef typename GridView::template Codim<0>::Iterator ElementIterator;
......@@ -149,7 +149,7 @@ public:
pN [globalIdx] = volVars.pressure();
delP[globalIdx] = volVars.pressure() - 1e5;
Xw [globalIdx] = volVars.fluidState().massFraction(phaseIdx, comp1Idx);
Xw [globalIdx] = volVars.fluidState().massFraction(phaseIdx, transportCompIdx);
T [globalIdx] = volVars.temperature();
rho [globalIdx] = volVars.density();
mu [globalIdx] = volVars.viscosity();
......@@ -162,7 +162,7 @@ public:
writer.attachVertexData(delP, "delP");
// writer.attachVertexData(D, "Dwg");
std::ostringstream outputNameX;
outputNameX << "X^" << FluidSystem::componentName(comp1Idx);
outputNameX << "X^" << FluidSystem::componentName(transportCompIdx);
writer.attachVertexData(Xw, outputNameX.str());
writer.attachVertexData(T, "temperature");
writer.attachVertexData(rho, "rhoG");
......
......@@ -55,7 +55,7 @@ class Stokes2cniVolumeVariables : public Stokes2cVolumeVariables<TypeTag>
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
enum { phaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx) };
enum { energyIdx = Indices::energyIdx };
enum { temperatureIdx = Indices::temperatureIdx };
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
......@@ -118,7 +118,7 @@ protected:
const FVElementGeometry &fvGeometry,
const int scvIdx)
{
return priVars[energyIdx];
return priVars[temperatureIdx];
}
template<class ParameterCache>
......
......@@ -110,12 +110,17 @@ class Stokes2cTestProblem : public StokesProblem<TypeTag>
// Number of equations and grid dimension
enum { dim = GridView::dimension };
enum {
// copy some indices for convenience
enum { // equation indices
massBalanceIdx = Indices::massBalanceIdx,
momentumXIdx = Indices::momentumXIdx, //!< Index of the x-component of the momentum balance
momentumYIdx = Indices::momentumYIdx, //!< Index of the y-component of the momentum balance
transportIdx = Indices::transportIdx //!< Index of the transport equation (massfraction)
transportEqIdx = Indices::transportEqIdx, //!< Index of the transport equation
};
enum { // indices for primary variables
velocityXIdx = Indices::velocityXIdx,
velocityYIdx = Indices::velocityYIdx,
pressureIdx = Indices::pressureIdx,
massOrMoleFracIdx = Indices::massOrMoleFracIdx
};
......@@ -216,7 +221,7 @@ public:
if (onUpperBoundary_(globalPos))
{
values[transportIdx] = 0.005;
values[massOrMoleFracIdx] = 0.005;
}
}
......@@ -286,18 +291,18 @@ private:
{
values = 0.0;
values[massBalanceIdx] = 1e5;
values[momentumXIdx] = 0.0;
values[pressureIdx] = 1e5;
values[velocityXIdx] = 0.0;
//parabolic profile
const Scalar v1 = 1.0;
values[momentumYIdx] = -v1*(globalPos[0] - this->bboxMin()[0])*(this->bboxMax()[0] - globalPos[0])
values[velocityYIdx] = -v1*(globalPos[0] - this->bboxMin()[0])*(this->bboxMax()[0] - globalPos[0])
/ (0.25*(this->bboxMax()[0] - this->bboxMin()[0])*(this->bboxMax()[0] - this->bboxMin()[0]));
if (onUpperBoundary_(globalPos))
values[transportIdx] = 0.005;
values[massOrMoleFracIdx] = 0.005;
else
values[transportIdx] = 0.007;
values[massOrMoleFracIdx] = 0.007;
}
bool onLeftBoundary_(const GlobalPosition &globalPos) const
{ return globalPos[0] < this->bboxMin()[0] + eps_; }
......
......@@ -116,8 +116,15 @@ class Stokes2cniTestProblem : public StokesProblem<TypeTag>
momentumXIdx = Indices::momentumXIdx, //!< Index of the x-component of the momentum balance
momentumYIdx = Indices::momentumYIdx, //!< Index of the y-component of the momentum balance
momentumZIdx = Indices::momentumZIdx, //!< Index of the z-component of the momentum balance
transportIdx = Indices::transportIdx, //!< Index of the transport equation (massfraction)
energyIdx = Indices::energyIdx //!< Index of the energy equation (temperature)
transportEqIdx = Indices::transportEqIdx, //!< Index of the transport equation
energyEqIdx = Indices::energyEqIdx //!< Index of the energy equation
};
enum { // indices for primary variables
velocityXIdx = Indices::velocityXIdx,
velocityYIdx = Indices::velocityYIdx,
pressureIdx = Indices::pressureIdx,
massOrMoleFracIdx = Indices::massOrMoleFracIdx,
temperatureIdx = Indices::temperatureIdx
};
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
......@@ -271,19 +278,19 @@ private:
const GlobalPosition &globalPos) const
{
const Scalar v1 = 0.5;
values[momentumXIdx] = 0.0;
values[momentumYIdx] = v1*(globalPos[0] - this->bboxMin()[0])*(this->bboxMax()[0] - globalPos[0])
values[velocityXIdx] = 0.0;
values[velocityYIdx] = v1*(globalPos[0] - this->bboxMin()[0])*(this->bboxMax()[0] - globalPos[0])
/ (0.25*(this->bboxMax()[0] - this->bboxMin()[0])*(this->bboxMax()[0] - this->bboxMin()[0]));
values[massBalanceIdx] = 1e5 - 1.189*this->gravity()[1]*globalPos[1];
values[transportIdx] = 1e-4;
values[energyIdx] = 283.15;
values[pressureIdx] = 1e5 - 1.189*this->gravity()[1]*globalPos[1];
values[massOrMoleFracIdx] = 1e-4;
values[temperatureIdx] = 283.15;
if(globalPos[0]<0.75 && globalPos[0]>0.25 &&
globalPos[1]<0.75 && globalPos[1]>0.25)
// if(onLowerBoundary_(globalPos) &&
// !onLeftBoundary_(globalPos) && !onRightBoundary_(globalPos))
{
values[transportIdx] = 0.9e-4;
values[energyIdx] = 284.15;
values[massOrMoleFracIdx] = 0.9e-4;
values[temperatureIdx] = 284.15;
}
}
// \}
......
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