diff --git a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh index 2bd7df5c31b1a6e44f5d0502d44716444846f3cc..1a64a13cb626f878c79dcd152e68c548eae94cb2 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 f48d229325282b38388430f7a7b569a1bf269d4f..611578d116a56914082be9e51d6ce15d4852d7a8 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