Commit 4d057f07 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

boxmodels/common: implement naming conventions

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@8208 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 8f37a2b4
......@@ -227,7 +227,7 @@ public:
*
* \param yesno If true, only rescale; else do full Jacobian assembly.
*/
void setMatrixReuseable(bool yesno = true)
void setMatrixReuseable(const bool yesno = true)
{
if (enableJacobianRecycling_())
reuseMatrix_ = yesno;
......@@ -288,15 +288,15 @@ public:
// evaluation point used for linearization from the original
// evaluation point
for (unsigned int i = 0; i < vertexDelta_.size(); ++i) {
PrimaryVariables uCurrent(u[i]);
PrimaryVariables uNext(uCurrent);
uNext -= uDelta[i];
PrimaryVariables currentPriVars(u[i]);
PrimaryVariables nextPriVars(currentPriVars);
nextPriVars -= uDelta[i];
// we need to add the distance the solution was moved for
// this vertex
Scalar dist = model_().relativeErrorVertex(i,
uCurrent,
uNext);
currentPriVars,
nextPriVars);
vertexDelta_[i] += std::abs(dist);
}
......@@ -309,7 +309,7 @@ public:
* \param globalVertIdx The global index of the vertex which ought
* to be red.
*/
void markVertexRed(int globalVertIdx)
void markVertexRed(const int globalVertIdx)
{
if (!enablePartialReassemble_())
return;
......@@ -338,7 +338,7 @@ public:
* linearization point and the current solution and
* _not_ the delta vector of the Newton iteration!
*/
void computeColors(Scalar relTol)
void computeColors(const Scalar relTol)
{
if (!enablePartialReassemble_())
return;
......@@ -482,7 +482,7 @@ public:
* \param element An element which contains the vertex
* \param vertIdx The local index of the vertex in the element.
*/
int vertexColor(const Element &element, int vertIdx) const
int vertexColor(const Element &element, const int vertIdx) const
{
if (!enablePartialReassemble_())
return Red; // reassemble unconditionally!
......@@ -496,7 +496,7 @@ public:
*
* \param globalVertIdx The global index of the vertex.
*/
int vertexColor(int globalVertIdx) const
int vertexColor(const int globalVertIdx) const
{
if (!enablePartialReassemble_())
return Red; // reassemble unconditionally!
......@@ -522,7 +522,7 @@ public:
*
* \param globalElementIdx The global index of the element.
*/
int elementColor(int globalElementIdx) const
int elementColor(const int globalElementIdx) const
{
if (!enablePartialReassemble_())
return Red; // reassemble unconditionally!
......
......@@ -72,7 +72,7 @@ public:
void update(const Problem &problem,
const Element &element,
const FVElementGeometry &fvGeometry,
bool oldSol)
const bool oldSol)
{
const SolutionVector &globalSol =
oldSol?
......@@ -84,9 +84,9 @@ public:
int numVertices = element.template count<dim>();
this->resize(numVertices);
for (int scvIdx = 0; scvIdx < numVertices; scvIdx++) {
const PrimaryVariables &solI
const PrimaryVariables &priVars
= globalSol[vertexMapper.map(element, scvIdx, dim)];
(*this)[scvIdx].update(solI,
(*this)[scvIdx].update(priVars,
problem,
element,
fvGeometry,
......@@ -118,10 +118,10 @@ public:
this->resize(numVertices);
for (int scvIdx = 0; scvIdx < numVertices; scvIdx++)
{
PrimaryVariables solI(0);
PrimaryVariables priVars(0);
for (int eqnIdx = 0; eqnIdx < numEq; eqnIdx++)
solI[eqnIdx] = elementSolVector[scvIdx + eqnIdx*numVertices];
(*this)[scvIdx].update(solI,
priVars[eqnIdx] = elementSolVector[scvIdx + eqnIdx*numVertices];
(*this)[scvIdx].update(priVars,
problem,
element,
fvGeometry,
......
......@@ -546,7 +546,7 @@ class BoxFVElementGeometry
}
public:
int boundaryFaceIndex(int face, int vertInFace) const
int boundaryFaceIndex(const int face, const int vertInFace) const
{
return (face*maxCOS + vertInFace);
}
......@@ -598,14 +598,14 @@ public:
computeGradientAtScvCenters = false;
}
BoxFVElementGeometry(bool computeGradientAtCenters)
BoxFVElementGeometry(const bool computeGradientAtCenters)
{
computeGradientAtScvCenters = computeGradientAtCenters;
};
void update(const GridView& gridView, const Element& e)
void update(const GridView& gridView, const Element& element)
{
const Geometry& geometry = e.geometry();
const Geometry& geometry = element.geometry();
Dune::GeometryType gt = geometry.type();
const typename Dune::GenericReferenceElementContainer<CoordScalar,dim>::value_type&
......@@ -722,8 +722,8 @@ public:
} // end loop over edges / sub control volume faces
// fill boundary face data:
IntersectionIterator endit = gridView.iend(e);
for (IntersectionIterator it = gridView.ibegin(e); it != endit; ++it)
IntersectionIterator endit = gridView.iend(element);
for (IntersectionIterator it = gridView.ibegin(element); it != endit; ++it)
if (it->boundary())
{
int face = it->indexInInside();
......
......@@ -223,7 +223,7 @@ public:
* \param j The local vertex (or sub-control volume) index which holds
* primary variables
*/
const MatrixBlock &mat(int i, int j) const
const MatrixBlock &mat(const int i, const int j) const
{ return A_[i][j]; }
/*!
......@@ -231,7 +231,7 @@ public:
*
* \param i The local vertex (or sub-control volume) index
*/
const MatrixBlock &storageJacobian(int i) const
const MatrixBlock &storageJacobian(const int i) const
{ return storageJacobian_[i]; }
/*!
......@@ -240,7 +240,7 @@ public:
* \param i The local vertex (or sub-control volume) index on which
* the equations are defined
*/
const PrimaryVariables &residual(int i) const
const PrimaryVariables &residual(const int i) const
{ return residual_[i]; }
/*!
......@@ -249,7 +249,7 @@ public:
* \param i The local vertex (or sub-control volume) index on which
* the equations are defined
*/
const PrimaryVariables &storageTerm(int i) const
const PrimaryVariables &storageTerm(const int i) const
{ return storageTerm_[i]; }
/*!
......@@ -260,8 +260,8 @@ public:
* which the local derivative ought to be calculated.
* \param pvIdx The index of the primary variable which gets varied
*/
Scalar numericEpsilon(int scvIdx,
int pvIdx) const
Scalar numericEpsilon(const int scvIdx,
const int pvIdx) const
{
// define the base epsilon as the geometric mean of 1 and the
// resolution of the scalar type. E.g. for standard 64 bit
......@@ -275,8 +275,8 @@ public:
assert(std::numeric_limits<Scalar>::epsilon()*1e4 < baseEps);
// the epsilon value used for the numeric differentiation is
// now scaled by the absolute value of the primary variable...
Scalar pv = this->curVolVars_[scvIdx].primaryVar(pvIdx);
return baseEps*(std::abs(pv) + 1.0);
Scalar priVar = this->curVolVars_[scvIdx].priVar(pvIdx);
return baseEps*(std::abs(priVar) + 1.0);
}
protected:
......@@ -398,8 +398,8 @@ protected:
*/
void evalPartialDerivative_(ElementSolutionVector &partialDeriv,
PrimaryVariables &storageDeriv,
int scvIdx,
int pvIdx)
const int scvIdx,
const int pvIdx)
{
int globalIdx = vertexMapper_().map(element_(), scvIdx, dim);
......@@ -494,8 +494,8 @@ protected:
* partial derivatives of all equations in regard to the
* primary variable 'pvIdx' at vertex 'scvIdx' .
*/
void updateLocalJacobian_(int scvIdx,
int pvIdx,
void updateLocalJacobian_(const int scvIdx,
const int pvIdx,
const ElementSolutionVector &partialDeriv,
const PrimaryVariables &storageDeriv)
{
......
......@@ -300,7 +300,7 @@ public:
* \param scvIdx The local index of the sub-control volume
* (i.e. the element's local vertex index)
*/
const PrimaryVariables &residual(int scvIdx) const
const PrimaryVariables &residual(const int scvIdx) const
{ return residual_[scvIdx]; }
/*!
......@@ -314,7 +314,7 @@ public:
* \brief Returns the storage term for a given sub-control volumes
* of the element.
*/
const PrimaryVariables &storageTerm(int scvIdx) const
const PrimaryVariables &storageTerm(const int scvIdx) const
{ return storageTerm_[scvIdx]; }
protected:
......@@ -373,7 +373,7 @@ protected:
Valgrind::CheckDefined(dirichletValues[pvIdx]);
residual_[scvIdx][eqIdx] =
curPrimaryVar_(scvIdx, pvIdx) - dirichletValues[pvIdx];
curPriVar_(scvIdx, pvIdx) - dirichletValues[pvIdx];
storageTerm_[scvIdx][eqIdx] = 0.0;
};
......@@ -387,7 +387,7 @@ protected:
void evalBoundaryFluxes_()
{
Dune::GeometryType geoType = element_().geometry().type();
const ReferenceElement &refElem = ReferenceElements::general(geoType);
const ReferenceElement &refElement = ReferenceElements::general(geoType);
IntersectionIterator isIt = gridView_().ibegin(element_());
const IntersectionIterator &endIt = gridView_().iend(element_());
......@@ -400,12 +400,12 @@ protected:
// Assemble the boundary for all vertices of the current
// face
int faceIdx = isIt->indexInInside();
int numFaceVerts = refElem.size(faceIdx, 1, dim);
int numFaceVerts = refElement.size(faceIdx, 1, dim);
for (int faceVertIdx = 0;
faceVertIdx < numFaceVerts;
++faceVertIdx)
{
int scvIdx = refElem.subEntity(faceIdx,
int scvIdx = refElement.subEntity(faceIdx,
1,
faceVertIdx,
dim);
......@@ -433,8 +433,8 @@ protected:
* volume face to the local residual.
*/
void evalNeumannSegment_(const IntersectionIterator &isIt,
int scvIdx,
int boundaryFaceIdx)
const int scvIdx,
const int boundaryFaceIdx)
{
// temporary vector to store the neumann boundary fluxes
PrimaryVariables neumannFlux(0.0);
......@@ -640,27 +640,58 @@ protected:
* the last time step of the i'th
* sub-control volume of the current element.
*/
const PrimaryVariables &prevPrimaryVars_(int i) const
const PrimaryVariables &prevPriVars_(const int i) const
{
return prevVolVars_(i).primaryVars();
return prevVolVars_(i).priVars();
}
/*!
* \brief Returns a reference to the primary variables of
* the last time step of the i'th
* sub-control volume of the current element.
*/
DUMUX_DEPRECATED_MSG("use prevPriVars_ instead")
const PrimaryVariables &prevPrimaryVars_(const int i) const
{
return prevPriVars_(i);
}
/*!
* \brief Returns a reference to the primary variables of the i'th
* sub-control volume of the current element.
*/
const PrimaryVariables &curPriVars_(const int i) const
{
return curVolVars_(i).priVars();
}
/*!
* \brief Returns a reference to the primary variables of the i'th
* sub-control volume of the current element.
*/
const PrimaryVariables &curPrimaryVars_(int i) const
DUMUX_DEPRECATED_MSG("use curPriVars_ instead")
const PrimaryVariables &curPrimaryVars_(const int i) const
{
return curPriVars_(i);
}
/*!
* \brief Returns the j'th primary of the i'th sub-control volume
* of the current element.
*/
Scalar curPriVar_(const int i, const int j) const
{
return curVolVars_(i).primaryVars();
return curVolVars_(i).priVar(j);
}
/*!
* \brief Returns the j'th primary of the i'th sub-control volume
* of the current element.
*/
Scalar curPrimaryVar_(int i, int j) const
DUMUX_DEPRECATED_MSG("use curPriVar_ instead")
Scalar curPrimaryVar_(const int i, const int j) const
{
return curVolVars_(i).primaryVar(j);
return curPriVar_(i, j);
}
/*!
......@@ -677,7 +708,7 @@ protected:
* \brief Returns a reference to the volume variables of the i-th
* sub-control volume of the current element.
*/
const VolumeVariables &curVolVars_(int i) const
const VolumeVariables &curVolVars_(const int i) const
{
return curVolVars_()[i];
}
......@@ -698,7 +729,7 @@ protected:
* variables of the i-th sub-control volume of the current
* element.
*/
const VolumeVariables &prevVolVars_(int i) const
const VolumeVariables &prevVolVars_(const int i) const
{
return prevVolVars_()[i];
}
......@@ -717,7 +748,7 @@ protected:
* \brief Returns a reference to the boundary types of the i-th
* sub-control volume of the current element.
*/
const BoundaryTypes &bcTypes_(int i) const
const BoundaryTypes &bcTypes_(const int i) const
{
return bcTypes_()[i];
}
......
......@@ -289,7 +289,7 @@ public:
* \param globalIdx The global index of the control volume's
* associated vertex
*/
Scalar boxVolume(int globalIdx) const
Scalar boxVolume(const int globalIdx) const
{ return boxVolume_[globalIdx][0]; }
/*!
......@@ -363,7 +363,7 @@ public:
* \param vertIdx The global index of the control volume
* \param pvIdx The index of the primary variable
*/
Scalar primaryVarWeight(int vertIdx, int pvIdx) const
Scalar primaryVarWeight(const int vertIdx, const int pvIdx) const
{
return 1.0/std::max(std::abs(this->prevSol()[vertIdx][pvIdx]), 1.0);
}
......@@ -374,8 +374,8 @@ public:
*
* \param vertexIdx The global index of the control volume's
* associated vertex
* \param pv1 The first vector of primary variables
* \param pv2 The second vector of primary variables
* \param priVars1 The first vector of primary variables
* \param priVars2 The second vector of primary variables
*
* \todo The vertexIdx argument is pretty hacky. it is required by
* models with pseudo primary variables (i.e. the primary
......@@ -383,16 +383,16 @@ public:
* to access the pseudo primary variables from the primary
* variables.
*/
Scalar relativeErrorVertex(int vertexIdx,
const PrimaryVariables &pv1,
const PrimaryVariables &pv2)
Scalar relativeErrorVertex(const int vertexIdx,
const PrimaryVariables &priVars1,
const PrimaryVariables &priVars2)
{
Scalar result = 0.0;
for (int j = 0; j < numEq; ++j) {
//Scalar weight = asImp_().primaryVarWeight(vertexIdx, j);
//Scalar eqErr = std::abs(pv1[j] - pv2[j])*weight;
Scalar eqErr = std::abs(pv1[j] - pv2[j]);
eqErr /= std::max<Scalar>(1.0, std::abs(pv1[j] + pv2[j])/2);
//Scalar eqErr = std::abs(priVars1[j] - priVars2[j])*weight;
Scalar eqErr = std::abs(priVars1[j] - priVars2[j]);
eqErr /= std::max<Scalar>(1.0, std::abs(priVars1[j] + priVars2[j])/2);
result = std::max(result, eqErr);
}
......@@ -719,7 +719,7 @@ public:
* \param globalVertIdx The global index of the control volume's
* associated vertex
*/
bool onBoundary(int globalVertIdx) const
bool onBoundary(const int globalVertIdx) const
{ return boundaryIndices_[globalVertIdx]; }
/*!
......@@ -730,7 +730,7 @@ public:
* volume's associated vertex.
* \param vIdx The local vertex index inside element
*/
bool onBoundary(const Element &element, int vIdx) const
bool onBoundary(const Element &element, const int vIdx) const
{ return onBoundary(vertexMapper().map(element, vIdx, dim)); }
/*!
......@@ -740,23 +740,23 @@ public:
* the fluid state is filled with every information that is
* necessary to evaluate the model's local residual.
*
* \param primaryVariables The primary variables of the model.
* \param priVars The primary variables of the model.
* \param problem The problem at hand.
* \param element The current element.
* \param elementGeometry The finite volume element geometry.
* \param fvGeometry The finite volume element geometry.
* \param scvIdx The index of the subcontrol volume.
* \param fluidState The fluid state to fill.
*/
template <class FluidState>
static void completeFluidState(const PrimaryVariables& primaryVariables,
static void completeFluidState(const PrimaryVariables& priVars,
const Problem& problem,
const Element& element,
const FVElementGeometry& elementGeometry,
int scvIdx,
const FVElementGeometry& fvGeometry,
const int scvIdx,
FluidState& fluidState)
{
VolumeVariables::completeFluidState(primaryVariables, problem, element,
elementGeometry, scvIdx, fluidState);
VolumeVariables::completeFluidState(priVars, problem, element,
fvGeometry, scvIdx, fluidState);
}
protected:
/*!
......@@ -814,21 +814,21 @@ protected:
// let the problem do the dirty work of nailing down
// the initial solution.
PrimaryVariables initVal;
Valgrind::SetUndefined(initVal);
problem_().initial(initVal,
PrimaryVariables initPriVars;
Valgrind::SetUndefined(initPriVars);
problem_().initial(initPriVars,
*eIt,
fvGeometry,
scvIdx);
Valgrind::CheckDefined(initVal);
Valgrind::CheckDefined(initPriVars);
// add up the initial values of all sub-control
// volumes. If the initial values disagree for
// different sub control volumes, the initial value
// will be the arithmetic mean.
initVal *= fvGeometry.subContVol[scvIdx].volume;
initPriVars *= fvGeometry.subContVol[scvIdx].volume;
boxVolume_[globalIdx] += fvGeometry.subContVol[scvIdx].volume;
uCur_[globalIdx] += initVal;
uCur_[globalIdx] += initPriVars;
Valgrind::CheckDefined(uCur_[globalIdx]);
}
}
......@@ -874,7 +874,7 @@ protected:
ElementIterator eEndIt = gridView_().template end<0>();
for (; eIt != eEndIt; ++eIt) {
Dune::GeometryType geoType = eIt->geometry().type();
const ReferenceElement &refElem = ReferenceElements::general(geoType);
const ReferenceElement &refElement = ReferenceElements::general(geoType);
IntersectionIterator isIt = gridView_().ibegin(*eIt);
IntersectionIterator isEndIt = gridView_().iend(*eIt);
......@@ -884,12 +884,12 @@ protected:
// add all vertices on the intersection to the set of
// boundary vertices
int faceIdx = isIt->indexInInside();
int numFaceVerts = refElem.size(faceIdx, 1, dim);
int numFaceVerts = refElement.size(faceIdx, 1, dim);
for (int faceVertIdx = 0;
faceVertIdx < numFaceVerts;
++faceVertIdx)
{
int elemVertIdx = refElem.subEntity(faceIdx,
int elemVertIdx = refElement.subEntity(faceIdx,
1,
faceVertIdx,
dim);
......
......@@ -235,8 +235,8 @@ public:
const Element &element,
const FVElementGeometry &fvGeometry,
const Intersection &is,
int scvIdx,
int boundaryFaceIdx,
const int scvIdx,
const int boundaryFaceIdx,
const ElementVolumeVariables &elemVolVars) const
{
// forward it to the interface without the volume variables
......@@ -266,8 +266,8 @@ public:
const Element &element,
const FVElementGeometry &fvGeometry,
const Intersection &is,
int scvIdx,
int boundaryFaceIdx) const
const int scvIdx,
const int boundaryFaceIdx) const
{
// forward it to the interface with only the global position
asImp_().neumannAtPos(values, fvGeometry.boundaryFace[boundaryFaceIdx].ipGlobal);
......@@ -315,7 +315,7 @@ public:
void boxSDSource(PrimaryVariables &values,
const Element &element,
const FVElementGeometry &fvGeometry,
int scvIdx,
const int scvIdx,
const ElementVolumeVariables &elemVolVars) const
{
// forward to solution independent, box specific interface
......@@ -338,7 +338,7 @@ public:
void source(PrimaryVariables &values,
const Element &element,
const FVElementGeometry &fvGeometry,
int scvIdx) const
const int scvIdx) const
{
// forward to generic interface
asImp_().sourceAtPos(values, fvGeometry.subContVol[scvIdx].global);
......@@ -379,7 +379,7 @@ public:
void initial(PrimaryVariables &values,
const Element &element,
const FVElementGeometry &fvGeometry,
int scvIdx) const
const int scvIdx) const
{
// forward to generic interface
asImp_().initialAtPos(values, fvGeometry.subContVol[scvIdx].global);
......@@ -416,7 +416,7 @@ public:
*/
Scalar boxExtrusionFactor(const Element &element,
const FVElementGeometry &fvGeometry,
int scvIdx) const
const int scvIdx) const
{
// forward to generic interface
return asImp_().extrusionFactorAtPos(fvGeometry.subContVol[scvIdx].global);
......@@ -516,7 +516,7 @@ public:
*
* \param dt The current time-step size
*/
Scalar nextTimeStepSize(Scalar dt)
Scalar nextTimeStepSize(const Scalar dt)
{
return std::min(GET_PARAM(TypeTag, Scalar, MaxTimeStepSize),
newtonCtl_.suggestTimeStepSize(dt));
......@@ -725,7 +725,7 @@ public:
* \param tRestart The simulation time on which the program was
* written to disk.
*/
void restart(Scalar tRestart)
void restart(const Scalar tRestart)
{
typedef Dumux::Restart Restarter;
......@@ -769,7 +769,7 @@ public:
* \brief Write the relevant secondary variables of the current
* solution into an VTK output file.
*/
void writeOutput(bool verbose = true)
void writeOutput(const bool verbose = true)
{
// write the current result to disk
if (asImp_().shouldWriteOutput()) {
......
......@@ -63,7 +63,7 @@ public:
BoxVolumeVariables(const BoxVolumeVariables &v)
{
evalPoint_ = 0;
primaryVars_ = v.primaryVars_;