Commit ad49e01c authored by Andreas Nüßing's avatar Andreas Nüßing

[UnfittedStatistics] add class providing statistics for cutcell methods

currently, this class provides a way to obtain interface values at
a certain location, and the volumne of the different domains.
parent 72887569
#ifndef DUNEURO_UNFITTED_STATISTICS_HH
#define DUNEURO_UNFITTED_STATISTICS_HH
#include <dune/udg/pdelab/subtriangulation.hh>
#include <duneuro/meeg/unfitted_meeg_driver.hh>
#include <duneuro/meeg/unfitted_meeg_driver_data.hh>
namespace duneuro
{
template <int dim>
class UnfittedStatistics
{
public:
using STTraits = SubTriangulationTraits<dim>;
using ElementSearch = KDTreeElementSearch<typename STTraits::GridView>;
UnfittedStatistics(UnfittedMEEGDriverData<dim> data, const Dune::ParameterTree& config)
: data_(data)
, grid_(make_structured_grid<dim>(config.sub("volume_conductor.grid")))
, fundamentalGridView_(grid_->levelGridView(0))
, levelSetGridView_(grid_->levelGridView(grid_->maxLevel()))
, domain_(levelSetGridView_, data_.levelSetData, config.sub("domain"))
, subTriangulation_(std::make_shared<typename STTraits::SubTriangulation>(
fundamentalGridView_, levelSetGridView_, domain_.getDomainConfiguration(),
config.get<bool>("udg.force_refinement", false)))
, levelSetElementSearch_(std::make_shared<ElementSearch>(levelSetGridView_))
{
}
std::vector<double> interfaceValues(const Dune::FieldVector<double, dim>& x) const
{
std::vector<double> result;
auto element = levelSetElementSearch_->findEntity(x);
auto local = element.geometry().local(x);
for (const auto& interface : domain_.getDomainConfiguration().interfaces()) {
auto localInterfaceFunction = localFunction(interface.function());
localInterfaceFunction.bind(element);
result.push_back(localInterfaceFunction(local));
}
return result;
}
std::map<std::size_t, double> domainVolumes() const
{
Dune::PDELab::UnfittedSubTriangulation<typename STTraits::GridView> ust(fundamentalGridView_,
*subTriangulation_);
std::map<std::size_t, double> volume;
for (const auto& element : Dune::elements(fundamentalGridView_)) {
ust.create(element);
for (const auto& part : ust) {
const auto& geometry = part.geometry();
const auto& quadRule =
Dune::QuadratureRules<typename STTraits::GridView::ctype, dim>::rule(
geometry.type(), geometry.type().isCube() ? 2 : 0);
for (const auto& quadPoint : quadRule) {
volume[part.domainIndex()] +=
quadPoint.weight() * geometry.integrationElement(quadPoint.position());
}
}
}
return volume;
}
private:
UnfittedMEEGDriverData<dim> data_;
std::unique_ptr<typename STTraits::Grid> grid_;
typename STTraits::GridView fundamentalGridView_;
typename STTraits::GridView levelSetGridView_;
SimpleTPMCDomain<typename STTraits::GridView, typename STTraits::GridView> domain_;
std::shared_ptr<typename STTraits::SubTriangulation> subTriangulation_;
std::shared_ptr<ElementSearch> levelSetElementSearch_;
};
}
#endif // DUNEURO_UNFITTED_STATISTICS_HH
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment