24#ifndef DUMUX_IO_VTK_INTERSECTIONWRITER_HH
25#define DUMUX_IO_VTK_INTERSECTIONWRITER_HH
30#include <dune/common/typetraits.hh>
31#include <dune/grid/io/file/vtk.hh>
32#include <dune/grid/io/file/vtk/basicwriter.hh>
33#include <dune/grid/io/file/vtk/function.hh>
34#include <dune/grid/io/file/vtk/skeletonfunction.hh>
47:
public Dune::ForwardIteratorFacade<GridIntersectionIterator<GV>,
48 const typename GV::Intersection,
49 const typename GV::Intersection&,
50 typename std::iterator_traits<typename GV::template Codim<0>::Iterator>::difference_type>
58 using DifferenceType =
typename std::iterator_traits<ElementIterator>::difference_type;
66 : gridView_(gv), eIt_(end ? gridView_.template end<0>() : gridView_.template begin<0>())
68 if (eIt_ != gridView_.template end<0>())
74 if constexpr (std::is_lvalue_reference_v<decltype(*std::declval<IntersectionIterator>())>)
81 intersection_ = *iIt_;
88 if (eIt_ != other.eIt_)
93 bool mePassedTheEnd = eIt_ == gridView_.template end<0>();
94 bool otherPassedTheEnd = other.eIt_ == other.gridView_.template end<0>();
97 if(mePassedTheEnd && otherPassedTheEnd)
101 if(mePassedTheEnd || otherPassedTheEnd)
105 return iIt_ == other.iIt_;
111 if (iIt_ == gridView_.iend(*eIt_))
115 if (eIt_ != gridView_.template end<0>())
131template<
class Gr
idView>
135 static constexpr auto dimCell = GridView::dimension-1;
136 using Cell =
typename GridView::Intersection;
170 {
return gridView_.comm(); }
180template<
class Gr
idView,
class Mapper,
class F>
183 using Intersection =
typename GridView::Intersection;
185 using Traits = Dune::VTK::SkeletonFunctionTraits<GridView, typename GridView::ctype>;
193 if constexpr (std::is_invocable_v<F, Intersection, int>)
195 if constexpr (Dune::IsIndexable<std::decay_t<decltype(field(std::declval<Intersection>(), 0))>>{})
197 if constexpr (Dune::IsIndexable<std::decay_t<decltype(field(std::declval<Intersection>(), 0)[0])>>{})
198 DUNE_THROW(Dune::InvalidStateException,
"Invalid field type");
201 const auto& is = *(intersections(gv, *(elements(gv).begin())).begin());
202 components_ = field(is, mapper_(is, gv_)).size();
206 else if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field[0])>>{})
208 assert(field.size() == gv.size(1));
209 if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field[0][0])>>{})
210 DUNE_THROW(Dune::InvalidStateException,
"Invalid field type");
212 components_ = field[0].size();
219 void evaluate(
const typename Traits::Cell& intersection,
220 const typename Traits::Domain& xl,
221 typename Traits::Range& result)
const
223 assert(intersection.conforming());
224 result.resize(components_);
225 const auto idx = mapper_(intersection, gv_);
229 if constexpr (std::is_invocable_v<F, Intersection, int>)
231 if constexpr (Dune::IsIndexable<std::decay_t<
decltype(field_(intersection, idx))>>{})
232 return field_(intersection, idx)[i];
234 return field_(intersection, idx);
238 if constexpr (Dune::IsIndexable<std::decay_t<decltype(std::declval<F>()[0])>>{})
239 return field_[idx][i];
245 for (
int i = 0; i < components_; ++i)
251 const Mapper& mapper_;
255 std::conditional_t<std::is_invocable_v<F,Intersection, int>,
const F,
const F&> field_;
257 std::size_t components_;
267template<
class Gr
idView>
270,
public Dune::VTK::BasicWriter<Detail::NonConformingIntersectionIteratorFactory<GridView>>
273 using Base = Dune::VTK::BasicWriter<Factory>;
277 :
Factory(gridView), Base(static_cast<const
Factory&>(*this)), gridView_(gridView)
279 static bool addProcessRank = getParamFromGroup<bool>(paramGroup,
"Vtk.AddProcessRank");
282 auto getRank = [rank = gridView_.comm().rank()](
const auto& is,
const auto idx)
287 auto fun = std::make_shared<SF>(gridView_, mapper, getRank);
292 using Base::addCellData;
296 return [](
const auto& is,
const GridView& gridView){
return gridView.indexSet().subIndex(is.inside(), is.indexInInside(), 1); };
299 template<
class F,
class Mapper = decltype(getStandardMapper())>
306 void addCellData(
const std::shared_ptr<Func>& p,
const std::string& name)
308 addCellData(std::shared_ptr<typename Base::FunctionWriter>
309 (
new Dune::VTK::SkeletonFunctionWriter<Func>(p, name)));
319 void addField(
const F& field,
const std::string& name)
325 using Base::addPointData;
328 void addPointData(
const std::shared_ptr<Func>& p,
const std::string& name)
330 addPointData(std::shared_ptr<typename Base::FunctionWriter>
331 (
new Dune::VTK::SkeletonFunctionWriter<Func>(p, name)));
340 std::string
write(
const std::string& name, Dune::VTK::OutputType outputType = Dune::VTK::OutputType::ascii)
342 return Base::write(name, outputType);
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Distance implementation details.
Definition: fclocalassembler.hh:42
double accessEntry(const Field &f, int mycomp, int i)
Definition: function.hh:43
Iterate over the GridViews boundary intersections This will visit all intersections for which boundar...
Definition: intersectionwriter.hh:51
typename GV::Intersection Intersection
Definition: intersectionwriter.hh:54
typename std::iterator_traits< ElementIterator >::difference_type DifferenceType
Definition: intersectionwriter.hh:58
const Intersection & dereference() const
Definition: intersectionwriter.hh:72
typename GV::IntersectionIterator IntersectionIterator
Definition: intersectionwriter.hh:57
GridIntersectionIterator(const GV &gv, bool end=false)
Construct a GridIntersectionIterator If end == true, construct an end iterator for the given gridview...
Definition: intersectionwriter.hh:65
void increment()
Definition: intersectionwriter.hh:108
typename GV::template Codim< 0 >::Iterator ElementIterator
Definition: intersectionwriter.hh:56
const Intersection Value
Definition: intersectionwriter.hh:55
bool equals(const DerivedType &other) const
Definition: intersectionwriter.hh:86
Non conforming intersection iterator factory.
Definition: intersectionwriter.hh:133
PointIterator beginPoints() const
Definition: intersectionwriter.hh:160
CornerIterator PointIterator
Definition: intersectionwriter.hh:141
Corner Point
Definition: intersectionwriter.hh:140
PointIterator endPoints() const
Definition: intersectionwriter.hh:163
static constexpr auto dimCell
Definition: intersectionwriter.hh:135
GridIntersectionIterator< GridView > CellIterator
Definition: intersectionwriter.hh:137
Dune::VTK::Corner< Cell > Corner
Definition: intersectionwriter.hh:138
Dune::VTK::NonConformingConnectivityWriter< Cell > ConnectivityWriter
Definition: intersectionwriter.hh:142
typename GridView::CollectiveCommunication Communication
Definition: intersectionwriter.hh:143
NonConformingIntersectionIteratorFactory(const GridView &gv)
Definition: intersectionwriter.hh:145
CornerIterator endCorners() const
Definition: intersectionwriter.hh:157
CornerIterator beginCorners() const
Definition: intersectionwriter.hh:154
typename GridView::Intersection Cell
Definition: intersectionwriter.hh:136
CellIterator beginCells() const
Definition: intersectionwriter.hh:148
ConnectivityWriter makeConnectivity() const
Definition: intersectionwriter.hh:166
CellIterator endCells() const
Definition: intersectionwriter.hh:151
Dune::VTK::CornerIterator< CellIterator > CornerIterator
Definition: intersectionwriter.hh:139
const Communication & comm() const
Definition: intersectionwriter.hh:169
Skeleton function for intersection writer.
Definition: intersectionwriter.hh:182
Dune::VTK::SkeletonFunctionTraits< GridView, typename GridView::ctype > Traits
Definition: intersectionwriter.hh:185
SkeletonFunction(const GridView &gv, const Mapper &mapper, const F &field)
Definition: intersectionwriter.hh:187
unsigned dimRange() const
return number of components
Definition: intersectionwriter.hh:217
void evaluate(const typename Traits::Cell &intersection, const typename Traits::Domain &xl, typename Traits::Range &result) const
Definition: intersectionwriter.hh:219
Conforming intersection writer.
Definition: intersectionwriter.hh:271
void addCellData(const std::shared_ptr< Func > &p, const std::string &name)
Definition: intersectionwriter.hh:306
void addPointData(const std::shared_ptr< Func > &p, const std::string &name)
Definition: intersectionwriter.hh:328
ConformingIntersectionWriter(const GridView &gridView, const std::string ¶mGroup="")
Definition: intersectionwriter.hh:276
static auto getStandardMapper()
Definition: intersectionwriter.hh:294
void addCellData(Func *p, const std::string &name)
Definition: intersectionwriter.hh:313
auto makeSkeletonFunction(const F &f, const Mapper &mapper=getStandardMapper()) const
Definition: intersectionwriter.hh:300
void addField(const F &field, const std::string &name)
Definition: intersectionwriter.hh:319
void addPointData(Func *p, const std::string &name)
Definition: intersectionwriter.hh:335
std::string write(const std::string &name, Dune::VTK::OutputType outputType=Dune::VTK::OutputType::ascii)
Definition: intersectionwriter.hh:340