From 03d2d7b0b68f1e368404709ec919a93b1762601e Mon Sep 17 00:00:00 2001 From: Andreas Lauser <and@poware.org> Date: Fri, 2 Sep 2011 11:54:47 +0000 Subject: [PATCH] box2p: make it compile with Scalar != double git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6567 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/boxmodels/2p/2pfluxvariables.hh | 4 ++-- dumux/boxmodels/2p/2plocalresidual.hh | 5 ++++- dumux/boxmodels/2p/2pmodel.hh | 20 +++++++++++--------- dumux/boxmodels/2p/2pproblem.hh | 12 +++++++----- test/boxmodels/2p/lensspatialparameters.hh | 4 ++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/dumux/boxmodels/2p/2pfluxvariables.hh b/dumux/boxmodels/2p/2pfluxvariables.hh index b304cd2e23..4ea7096c07 100644 --- a/dumux/boxmodels/2p/2pfluxvariables.hh +++ b/dumux/boxmodels/2p/2pfluxvariables.hh @@ -71,8 +71,8 @@ class TwoPFluxVariables typedef typename FVElementGeometry::SubControlVolume SCV; typedef typename FVElementGeometry::SubControlVolumeFace SCVFace; - typedef Dune::FieldMatrix<CoordScalar, dimWorld, dimWorld> Tensor; - typedef Dune::FieldVector<CoordScalar, dimWorld> Vector; + typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> Tensor; + typedef Dune::FieldVector<Scalar, dimWorld> Vector; public: /* diff --git a/dumux/boxmodels/2p/2plocalresidual.hh b/dumux/boxmodels/2p/2plocalresidual.hh index 3f7541bdfa..0b554f26fd 100644 --- a/dumux/boxmodels/2p/2plocalresidual.hh +++ b/dumux/boxmodels/2p/2plocalresidual.hh @@ -171,7 +171,10 @@ public: // (the minus comes from the Darcy law which states that // the flux is from high to low pressure potentials.) fluxVars.intrinsicPermeability().mv(fluxVars.potentialGrad(phaseIdx), tmpVec); - Scalar normalFlux = - (tmpVec*fluxVars.face().normal); + Scalar normalFlux = 0; + for (int i = 0; i < Vector::size; ++i) + normalFlux += tmpVec[i]*fluxVars.face().normal[i]; + normalFlux *= -1; // data attached to upstream and the downstream vertices // of the current phase diff --git a/dumux/boxmodels/2p/2pmodel.hh b/dumux/boxmodels/2p/2pmodel.hh index f06902110e..604d538d0d 100644 --- a/dumux/boxmodels/2p/2pmodel.hh +++ b/dumux/boxmodels/2p/2pmodel.hh @@ -110,6 +110,7 @@ class TwoPModel : public BoxModel<TypeTag> typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition; typedef typename GridView::template Codim<0>::Iterator ElementIterator; + typedef typename GridView::ctype CoordScalar; public: /*! @@ -139,8 +140,8 @@ public: MultiWriter &writer) { bool velocityOutput = GET_PROP_VALUE(TypeTag, PTAG(EnableVelocityOutput)); - typedef Dune::BlockVector<Dune::FieldVector<Scalar, 1> > ScalarField; - typedef Dune::BlockVector<Dune::FieldVector<Scalar, dim> > VectorField; + typedef Dune::BlockVector<Dune::FieldVector<double, 1> > ScalarField; + typedef Dune::BlockVector<Dune::FieldVector<double, dim> > VectorField; // create the required scalar fields unsigned numVertices = this->problem_().gridView().size(dim); @@ -156,8 +157,8 @@ public: ScalarField *poro = writer.allocateManagedBuffer(numVertices); ScalarField *Te = writer.allocateManagedBuffer(numVertices); ScalarField *cellNum =writer.allocateManagedBuffer (numVertices); - VectorField *velocityN = writer.template allocateManagedBuffer <Scalar, dim> (numVertices); - VectorField *velocityW = writer.template allocateManagedBuffer <Scalar, dim> (numVertices); + VectorField *velocityN = writer.template allocateManagedBuffer<double, dim>(numVertices); + VectorField *velocityW = writer.template allocateManagedBuffer<double, dim>(numVertices); if(velocityOutput) // check if velocity output is demanded { @@ -271,7 +272,7 @@ public: const Dune::FieldVector<Scalar, dim>& localPosIP = fvElemGeom.subContVolFace[faceIdx].ipLocal; // Transformation of the global normal vector to normal vector in the reference element - const Dune::FieldMatrix<Scalar, dim, dim> jacobianT1 = elemIt->geometry().jacobianTransposed(localPosIP); + const Dune::FieldMatrix<CoordScalar, dim, dim> jacobianT1 = elemIt->geometry().jacobianTransposed(localPosIP); GlobalPosition localNormal(0); jacobianT1.mv(globalNormal, localNormal); @@ -305,18 +306,19 @@ public: } } typedef Dune::GenericReferenceElements<Scalar, dim> ReferenceElements; - const Dune::FieldVector<Scalar, dim>& localPos = ReferenceElements::general(elemIt->geometry().type()).position(0, - 0); + const Dune::FieldVector<Scalar, dim> &localPos + = ReferenceElements::general(elemIt->geometry().type()).position(0, 0); // get the transposed Jacobian of the element mapping - const Dune::FieldMatrix<Scalar, dim, dim> jacobianT2 = elemIt->geometry().jacobianTransposed(localPos); + const Dune::FieldMatrix<CoordScalar, dim, dim> &jacobianT2 + = elemIt->geometry().jacobianTransposed(localPos); // transform vertex velocities from local to global coordinates for (int i = 0; i < numVerts; ++i) { int globalIdx = this->vertexMapper().map(*elemIt, i, dim); // calculate the subcontrolvolume velocity by the Piola transformation - Dune::FieldVector<Scalar, dim> scvVelocity(0); + Dune::FieldVector<CoordScalar, dim> scvVelocity(0); jacobianT2.mtv(scvVelocityW[i], scvVelocity); scvVelocity /= elemIt->geometry().integrationElement(localPos); diff --git a/dumux/boxmodels/2p/2pproblem.hh b/dumux/boxmodels/2p/2pproblem.hh index b9b4b6e4c1..6981be5acc 100644 --- a/dumux/boxmodels/2p/2pproblem.hh +++ b/dumux/boxmodels/2p/2pproblem.hh @@ -53,8 +53,10 @@ class TwoPProblem : public BoxProblem<TypeTag> dimWorld = GridView::dimensionworld }; - typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition; + typedef typename GridView::ctype CoordScalar; + typedef Dune::FieldVector<CoordScalar, dimWorld> GlobalPosition; typedef typename GridView::template Codim<0>::Entity Element; + typedef Dune::FieldVector<Scalar, dim> Vector; public: /*! @@ -152,7 +154,7 @@ public: * This is the box discretization specific interface. By default * it just calls gravityAtPos(). */ - const GlobalPosition &boxGravity(const Element &element, + const Vector &boxGravity(const Element &element, const FVElementGeometry &fvGeom, int scvIdx) const { return asImp_().gravityAtPos(fvGeom.subContVol[scvIdx].global); } @@ -163,7 +165,7 @@ public: * This is discretization independent interface. By default it * just calls gravity(). */ - const GlobalPosition &gravityAtPos(const GlobalPosition &pos) const + const Vector &gravityAtPos(const GlobalPosition &pos) const { return asImp_().gravity(); } /*! @@ -175,7 +177,7 @@ public: * property is true, \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$ holds, * else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$. */ - const GlobalPosition &gravity() const + const Vector &gravity() const { return gravity_; } /*! @@ -200,7 +202,7 @@ private: const Implementation &asImp_() const { return *static_cast<const Implementation *>(this); } - GlobalPosition gravity_; + Vector gravity_; // fluids and material properties SpatialParameters* spatialParameters_; diff --git a/test/boxmodels/2p/lensspatialparameters.hh b/test/boxmodels/2p/lensspatialparameters.hh index 3188c22e20..d0a34f0f15 100644 --- a/test/boxmodels/2p/lensspatialparameters.hh +++ b/test/boxmodels/2p/lensspatialparameters.hh @@ -26,8 +26,8 @@ * \brief The spatial parameters for the LensProblem which uses the * twophase box model */ -#ifndef DUMUX_LENSSPATIALPARAMETERS_HH -#define DUMUX_LENSSPATIALPARAMETERS_HH +#ifndef DUMUX_LENS_SPATIAL_PARAMETERS_HH +#define DUMUX_LENS_SPATIAL_PARAMETERS_HH #include <dumux/material/spatialparameters/boxspatialparameters.hh> #include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchten.hh> -- GitLab