12#ifndef DUMUX_IO_VTK_INTERSECTIONWRITER_HH
13#define DUMUX_IO_VTK_INTERSECTIONWRITER_HH
18#include <dune/common/typetraits.hh>
19#include <dune/grid/io/file/vtk.hh>
20#include <dune/grid/io/file/vtk/basicwriter.hh>
21#include <dune/grid/io/file/vtk/function.hh>
22#include <dune/grid/io/file/vtk/skeletonfunction.hh>
35:
public Dune::ForwardIteratorFacade<GridIntersectionIterator<GV>,
36 const typename GV::Intersection,
37 const typename GV::Intersection&,
38 typename std::iterator_traits<typename GV::template Codim<0>::Iterator>::difference_type>
46 using DifferenceType =
typename std::iterator_traits<ElementIterator>::difference_type;
54 : gridView_(gv), eIt_(end ? gridView_.template end<0>() : gridView_.template begin<0>())
56 if (eIt_ != gridView_.template end<0>())
62 if constexpr (std::is_lvalue_reference_v<decltype(*std::declval<IntersectionIterator>())>)
69 intersection_ = *iIt_;
76 if (eIt_ != other.eIt_)
81 bool mePassedTheEnd = eIt_ == gridView_.template end<0>();
82 bool otherPassedTheEnd = other.eIt_ == other.gridView_.template end<0>();
85 if(mePassedTheEnd && otherPassedTheEnd)
89 if(mePassedTheEnd || otherPassedTheEnd)
93 return iIt_ == other.iIt_;
99 if (iIt_ == gridView_.iend(*eIt_))
103 if (eIt_ != gridView_.template end<0>())
119template<
class Gr
idView>
123 static constexpr auto dimCell = GridView::dimension-1;
124 using Cell =
typename GridView::Intersection;
158 {
return gridView_.comm(); }
168template<
class Gr
idView,
class Mapper,
class F>
171 using Intersection =
typename GridView::Intersection;
173 using Traits = Dune::VTK::SkeletonFunctionTraits<GridView, typename GridView::ctype>;
181 if constexpr (std::is_invocable_v<F, Intersection, int>)
183 if constexpr (Dune::IsIndexable<std::decay_t<decltype(field(std::declval<Intersection>(), 0))>>{})
185 if constexpr (Dune::IsIndexable<std::decay_t<decltype(field(std::declval<Intersection>(), 0)[0])>>{})
186 DUNE_THROW(Dune::InvalidStateException,
"Invalid field type");
189 const auto& is = *(intersections(gv, *(elements(gv).begin())).begin());
190 components_ = field(is, mapper_(is, gv_)).size();
194 else if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field[0])>>{})
196 assert(field.size() == gv.size(1));
197 if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field[0][0])>>{})
198 DUNE_THROW(Dune::InvalidStateException,
"Invalid field type");
200 components_ = field[0].size();
207 void evaluate(
const typename Traits::Cell& intersection,
208 const typename Traits::Domain& xl,
209 typename Traits::Range& result)
const
211 assert(intersection.conforming());
212 result.resize(components_);
213 const auto idx = mapper_(intersection, gv_);
217 if constexpr (std::is_invocable_v<F, Intersection, int>)
219 if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field_(intersection, idx))>>{})
220 return field_(intersection, idx)[i];
222 return field_(intersection, idx);
226 if constexpr (Dune::IsIndexable<std::decay_t<decltype(std::declval<F>()[0])>>{})
227 return field_[idx][i];
233 for (
int i = 0; i < components_; ++i)
239 const Mapper& mapper_;
243 std::conditional_t<std::is_invocable_v<F,Intersection, int>,
const F,
const F&> field_;
245 std::size_t components_;
255template<
class Gr
idView>
258,
public Dune::VTK::BasicWriter<Detail::NonConformingIntersectionIteratorFactory<GridView>>
261 using Base = Dune::VTK::BasicWriter<Factory>;
265 :
Factory(gridView), Base(static_cast<const
Factory&>(*this)), gridView_(gridView)
267 static bool addProcessRank = getParamFromGroup<bool>(paramGroup,
"Vtk.AddProcessRank");
270 auto getRank = [rank = gridView_.comm().rank()](
const auto& is,
const auto idx)
275 auto fun = std::make_shared<SF>(gridView_, mapper, getRank);
280 using Base::addCellData;
284 return [](
const auto& is,
const GridView& gridView){
return gridView.indexSet().subIndex(is.inside(), is.indexInInside(), 1); };
287 template<
class F,
class Mapper = decltype(getStandardMapper())>
294 void addCellData(
const std::shared_ptr<Func>& p,
const std::string& name)
296 addCellData(std::shared_ptr<typename Base::FunctionWriter>
297 (
new Dune::VTK::SkeletonFunctionWriter<Func>(p, name)));
307 void addField(
const F& field,
const std::string& name)
313 using Base::addPointData;
316 void addPointData(
const std::shared_ptr<Func>& p,
const std::string& name)
318 addPointData(std::shared_ptr<typename Base::FunctionWriter>
319 (
new Dune::VTK::SkeletonFunctionWriter<Func>(p, name)));
328 std::string
write(
const std::string& name, Dune::VTK::OutputType outputType = Dune::VTK::OutputType::ascii)
330 return Base::write(name, outputType);
Iterate over the GridViews boundary intersections This will visit all intersections for which boundar...
Definition: intersectionwriter.hh:39
typename GV::Intersection Intersection
Definition: intersectionwriter.hh:42
typename std::iterator_traits< ElementIterator >::difference_type DifferenceType
Definition: intersectionwriter.hh:46
const Intersection & dereference() const
Definition: intersectionwriter.hh:60
typename GV::IntersectionIterator IntersectionIterator
Definition: intersectionwriter.hh:45
GridIntersectionIterator(const GV &gv, bool end=false)
Construct a GridIntersectionIterator If end == true, construct an end iterator for the given gridview...
Definition: intersectionwriter.hh:53
void increment()
Definition: intersectionwriter.hh:96
typename GV::template Codim< 0 >::Iterator ElementIterator
Definition: intersectionwriter.hh:44
const Intersection Value
Definition: intersectionwriter.hh:43
bool equals(const DerivedType &other) const
Definition: intersectionwriter.hh:74
Skeleton function for intersection writer.
Definition: intersectionwriter.hh:170
Dune::VTK::SkeletonFunctionTraits< GridView, typename GridView::ctype > Traits
Definition: intersectionwriter.hh:173
SkeletonFunction(const GridView &gv, const Mapper &mapper, const F &field)
Definition: intersectionwriter.hh:175
unsigned dimRange() const
return number of components
Definition: intersectionwriter.hh:205
void evaluate(const typename Traits::Cell &intersection, const typename Traits::Domain &xl, typename Traits::Range &result) const
Definition: intersectionwriter.hh:207
Distance implementation details.
Definition: cvfelocalresidual.hh:25
double accessEntry(const Field &f, int mycomp, int i)
Definition: function.hh:34
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.