diff --git a/test/freeflow/navierstokes/channel/2d/main.cc b/test/freeflow/navierstokes/channel/2d/main.cc index cb3fba4112329e003af8a86ce0cfdb1c680da8ca..3b7149483729e9ebec59fb5707ba8bcee5fe0972 100644 --- a/test/freeflow/navierstokes/channel/2d/main.cc +++ b/test/freeflow/navierstokes/channel/2d/main.cc @@ -188,7 +188,12 @@ int main(int argc, char** argv) try // In this case, we add half a cell-width to the x-position in order to make sure that // the cell faces lie on the surface. This assumes a regular cartesian grid. const Scalar planePosMiddleX = xMin + 0.5*(xMax - xMin); - const int numCellsX = getParam<std::vector<int>>("Grid.Cells")[0]; + int numCellsX = getParam<std::vector<int>>("Grid.Cells")[0]; + + const unsigned int refinement = getParam<unsigned int>("Grid.Refinement", 0); + + numCellsX *= (1<<refinement); + const Scalar offsetX = (numCellsX % 2 == 0) ? 0.0 : 0.5*((xMax - xMin) / numCellsX); const auto p0middle = GlobalPosition{planePosMiddleX + offsetX, yMin}; diff --git a/test/freeflow/navierstokes/channel/3d/main.cc b/test/freeflow/navierstokes/channel/3d/main.cc index fadc9cdd2c6a3cb54c6638c3966fd17fce8c545e..99b5058ebf66790bd53b68cdc9248faf1ab92165 100644 --- a/test/freeflow/navierstokes/channel/3d/main.cc +++ b/test/freeflow/navierstokes/channel/3d/main.cc @@ -182,7 +182,12 @@ int main(int argc, char** argv) try #endif const Scalar planePosMiddleX = xMin + 0.5*(xMax - xMin); - const int numCellsX = getParam<std::vector<int>>("Grid.Cells")[0]; + int numCellsX = getParam<std::vector<int>>("Grid.Cells")[0]; + + const unsigned int refinement = getParam<unsigned int>("Grid.Refinement", 0); + + numCellsX *= (1<<refinement); + const Scalar offsetX = (numCellsX % 2 == 0) ? 0.0 : 0.5*((xMax - xMin) / numCellsX); #if DIM_3D diff --git a/test/freeflow/navierstokes/closedsystem/problem.hh b/test/freeflow/navierstokes/closedsystem/problem.hh index ddd3b90891fab557152bc7f494df3cab9e4f2feb..e32f7c8a5603e09b3fd02e59cf04800b6650542e 100644 --- a/test/freeflow/navierstokes/closedsystem/problem.hh +++ b/test/freeflow/navierstokes/closedsystem/problem.hh @@ -83,24 +83,22 @@ class ClosedSystemTestProblem : public NavierStokesProblem<TypeTag> using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>; using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>; + using FVElementGeometry = typename FVGridGeometry::LocalView; + using SubControlVolume = typename FVGridGeometry::SubControlVolume; using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>; using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; using Scalar = GetPropType<TypeTag, Properties::Scalar>; static constexpr auto dimWorld = GetPropType<TypeTag, Properties::GridView>::dimensionworld; - using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>; + using Element = typename FVGridGeometry::GridView::template Codim<0>::Entity; + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; public: ClosedSystemTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry) : ParentType(fvGridGeometry), eps_(1e-6) { lidVelocity_ = getParam<Scalar>("Problem.LidVelocity"); - - using CellArray = std::array<unsigned int, dimWorld>; - const CellArray numCells = getParam<CellArray>("Grid.Cells"); - cellSizeX_ = this->fvGridGeometry().bBoxMax()[0] / numCells[0]; - cellSizeY_ = this->fvGridGeometry().bBoxMax()[1] / numCells[1]; } /*! @@ -163,14 +161,16 @@ public: * \param fvGeometry The finite-volume geometry * \param scv The sub control volume */ - template<class Element, class FVElementGeometry, class SubControlVolume> bool isDirichletCell(const Element& element, const FVElementGeometry& fvGeometry, const SubControlVolume& scv, int pvIdx) const { + auto isLowerLeftCell = [&](const SubControlVolume& scv) + { return scv.dofIndex() == 0; }; + // set a fixed pressure in one cell - return (isLowerLeftCell_(scv.center()) && pvIdx == Indices::pressureIdx); + return (isLowerLeftCell(scv) && pvIdx == Indices::pressureIdx); } /*! @@ -210,15 +210,8 @@ public: private: - bool isLowerLeftCell_(const GlobalPosition& globalPos) const - { - return globalPos[0] < (0.5*cellSizeX_ + eps_) && globalPos[1] < (0.5*cellSizeY_ + eps_); - } - Scalar eps_; Scalar lidVelocity_; - Scalar cellSizeX_; - Scalar cellSizeY_; }; } //end namespace diff --git a/test/freeflow/navierstokes/kovasznay/problem.hh b/test/freeflow/navierstokes/kovasznay/problem.hh index 162747a9d64beb1395dcbdd11631174dccdc93a5..aecf6676206f4b0f4f950ccc29bc996910ac9590 100644 --- a/test/freeflow/navierstokes/kovasznay/problem.hh +++ b/test/freeflow/navierstokes/kovasznay/problem.hh @@ -83,6 +83,8 @@ class KovasznayTestProblem : public NavierStokesProblem<TypeTag> using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>; using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>; + using FVElementGeometry = typename FVGridGeometry::LocalView; + using SubControlVolume = typename FVGridGeometry::SubControlVolume; using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>; @@ -106,11 +108,6 @@ public: lambda_ = 0.5 * reynoldsNumber - std::sqrt(reynoldsNumber * reynoldsNumber * 0.25 + 4.0 * M_PI * M_PI); - using CellArray = std::array<unsigned int, dimWorld>; - const auto numCells = getParam<CellArray>("Grid.Cells"); - - cellSizeX_ = (this->fvGridGeometry().bBoxMax()[0] - this->fvGridGeometry().bBoxMin()[0]) / numCells[0]; - createAnalyticalSolution_(); } @@ -191,15 +188,23 @@ public: * \param fvGeometry The finite-volume geometry * \param scv The sub control volume */ - template<class Element, class FVElementGeometry, class SubControlVolume> bool isDirichletCell(const Element& element, const FVElementGeometry& fvGeometry, const SubControlVolume& scv, int pvIdx) const { // set fixed pressure in all cells at the left boundary - auto isAtLeftBoundary = [&](const auto& globalPos) { return globalPos[0] < (this->fvGridGeometry().bBoxMin()[0] + 0.6*cellSizeX_ + eps_); }; - return (isAtLeftBoundary(scv.center()) && pvIdx == Indices::pressureIdx); + auto isAtLeftBoundary = [&](const FVElementGeometry& fvGeometry) + { + if (fvGeometry.hasBoundaryScvf()) + { + for (const auto& scvf : scvfs(fvGeometry)) + if (scvf.boundary() && scvf.center()[0] < this->fvGridGeometry().bBoxMin()[0] + eps_) + return true; + } + return false; + }; + return (isAtLeftBoundary(fvGeometry) && pvIdx == Indices::pressureIdx); } /*! @@ -317,7 +322,6 @@ private: } Scalar eps_; - Scalar cellSizeX_; Scalar kinematicViscosity_; Scalar lambda_;