From 10b89364b88fd5c3fd8f17a88a09eb2f436bf298 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Mon, 27 Feb 2017 13:59:28 +0100 Subject: [PATCH] [embedded] Compute lowdim vol fraction in postInit --- .../cellcentered/bboxtreecouplingmanager.hh | 42 ++++++++++++++- .../bboxtreecouplingmanagersimple.hh | 52 ++++++++++++++----- 2 files changed, 80 insertions(+), 14 deletions(-) diff --git a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh index 2bd7df5c31..1a64a13cb6 100644 --- a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh +++ b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh @@ -131,7 +131,19 @@ public: * initializing the subproblems / models */ void postInit() - {} + { + glue_ = std::make_shared<CCMultiDimensionGlue<TypeTag>>(bulkProblem(), lowDimProblem()); + asImp_().computeLowDimVolumeFractions(); + } + + /*! + * \brief Update after the grid has changed + */ + void update() + { + asImp_().computePointSourceData(); + asImp_().computeLowDimVolumeFractions(); + } /*! * \brief The bulk coupling stencil, i.e. which low-dimensional dofs @@ -344,6 +356,31 @@ public: std::cout << "took " << watch.elapsed() << " seconds." << std::endl; } + //! Compute the low dim volume fraction in the bulk domain cells + void computeLowDimVolumeFractions() + { + // intersect the bounding box trees + glue_->build(); + + // compute the low dim volume fractions + for (const auto& is : intersections(*glue_)) + { + // all inside elements are identical... + const auto& inside = is.inside(0); + const auto intersectionGeometry = is.geometry(); + const unsigned int lowDimElementIdx = lowDimProblem().elementMapper().index(inside); + + // compute the volume the low-dim domain occupies in the bulk domain if it were full-dimensional + const auto radius = lowDimProblem().spatialParams().radius(lowDimElementIdx); + for (unsigned int outsideIdx = 0; outsideIdx < is.neighbor(0); ++outsideIdx) + { + const auto& outside = is.outside(outsideIdx); + const unsigned int bulkElementIdx = bulkProblem().elementMapper().index(outside); + lowDimVolumeInBulkElement_[bulkElementIdx] += intersectionGeometry.volume()*M_PI*radius*radius; + } + } + } + /*! * \brief Methods to be accessed by the subproblems */ @@ -597,6 +634,9 @@ private: //! id generator for point sources unsigned int idCounter_; + + //! The glue object + std::shared_ptr<CCMultiDimensionGlue<TypeTag>> glue_; }; } // end namespace Dumux diff --git a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh index f48d229325..611578d116 100644 --- a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh +++ b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh @@ -123,6 +123,7 @@ public: */ void preInit() { + glue_ = std::make_shared<CCMultiDimensionGlue<TypeTag>>(bulkProblem(), lowDimProblem()); asImp_().computePointSourceData(); } @@ -131,7 +132,18 @@ public: * initializing the subproblems / models */ void postInit() - {} + { + asImp_().computeLowDimVolumeFractions(); + } + + /*! + * \brief Update after the grid has changed + */ + void update() + { + asImp_().computePointSourceData(); + asImp_().computeLowDimVolumeFractions(); + } /*! * \brief The bulk coupling stencil, i.e. which low-dimensional dofs @@ -217,10 +229,9 @@ public: lowDimVolumeInBulkElement_.resize(this->bulkGridView().size(0)); // intersect the bounding box trees - Dumux::CCMultiDimensionGlue<TypeTag> glue(bulkProblem(), lowDimProblem()); - glue.build(); + glue_->build(); - for (const auto& is : intersections(glue)) + for (const auto& is : intersections(*glue_)) { // all inside elements are identical... const auto& inside = is.inside(0); @@ -231,15 +242,6 @@ public: const auto& quad = Dune::QuadratureRules<Scalar, lowDimDim>::rule(intersectionGeometry.type(), order); const unsigned int lowDimElementIdx = lowDimProblem().elementMapper().index(inside); - // compute the volume the low-dim domain occupies in the bulk domain if it were full-dimensional - const auto radius = lowDimProblem().spatialParams().radius(lowDimElementIdx); - for (unsigned int outsideIdx = 0; outsideIdx < is.neighbor(0); ++outsideIdx) - { - const auto& outside = is.outside(outsideIdx); - const unsigned int bulkElementIdx = bulkProblem().elementMapper().index(outside); - lowDimVolumeInBulkElement_[bulkElementIdx] += intersectionGeometry.volume()*M_PI*radius*radius; - } - // iterate over all quadrature points for (auto&& qp : quad) { @@ -292,6 +294,27 @@ public: std::cout << "took " << watch.elapsed() << " seconds." << std::endl; } + //! Compute the low dim volume fraction in the bulk domain cells + void computeLowDimVolumeFractions() + { + for (const auto& is : intersections(*glue_)) + { + // all inside elements are identical... + const auto& inside = is.inside(0); + const auto intersectionGeometry = is.geometry(); + const unsigned int lowDimElementIdx = lowDimProblem().elementMapper().index(inside); + + // compute the volume the low-dim domain occupies in the bulk domain if it were full-dimensional + const auto radius = lowDimProblem().spatialParams().radius(lowDimElementIdx); + for (unsigned int outsideIdx = 0; outsideIdx < is.neighbor(0); ++outsideIdx) + { + const auto& outside = is.outside(outsideIdx); + const unsigned int bulkElementIdx = bulkProblem().elementMapper().index(outside); + lowDimVolumeInBulkElement_[bulkElementIdx] += intersectionGeometry.volume()*M_PI*radius*radius; + } + } + } + /*! * \brief Methods to be accessed by the subproblems */ @@ -493,6 +516,9 @@ private: //! id generator for point sources unsigned int idCounter_; + + //! The glue object + std::shared_ptr<CCMultiDimensionGlue<TypeTag>> glue_; }; } // end namespace Dumux -- GitLab