Dune Core Modules (unstable)

vtkwriter.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5
6#ifndef DUNE_VTKWRITER_HH
7#define DUNE_VTKWRITER_HH
8
9#include <cstring>
10#include <iostream>
11#include <string>
12#include <fstream>
13#include <sstream>
14#include <iomanip>
15#include <memory>
16#include <type_traits>
17#include <vector>
18#include <list>
19#include <map>
20
24#include <dune/common/indent.hh>
26#include <dune/common/path.hh>
27#include <dune/geometry/referenceelements.hh>
29#include <dune/grid/common/gridenums.hh>
34#include <dune/grid/io/file/vtk/pvtuwriter.hh>
35#include <dune/grid/io/file/vtk/streams.hh>
36#include <dune/grid/io/file/vtk/vtuwriter.hh>
37
51namespace Dune
52{
53
54 namespace Impl
55 {
56 // Check whether type F has a method 'bind' (see the dune-functions interface)
57 template< class F, class E, class = void >
58 struct IsBindable
59 : std::false_type
60 {};
61
62 template< class F, class E >
63 struct IsBindable< F, E, std::void_t< decltype( std::declval< F & >().bind( std::declval< const E & >() ) ),
64 decltype( std::declval< F & >().unbind() ) > >
65 : std::true_type
66 {};
67
68 // Check whether localFunction(F) can be called (see the dune-functions interface)
69 template< class F, class = void >
70 struct HasLocalFunction
71 : std::false_type
72 {};
73
74 template< class F >
75 struct HasLocalFunction< F, std::void_t< decltype( localFunction( std::declval< F& >() ) ) > >
76 : std::true_type
77 {};
78
79 } // namespace Impl
80
81 // Forward-declaration here, so the class can be friend of VTKWriter
82 template <class GridView>
83 class VTKSequenceWriterBase;
84 template <class GridView>
85 class VTKSequenceWriter;
86
95 template< class GridView >
96 class VTKWriter {
97
98 // VTKSequenceWriterBase needs getSerialPieceName
99 // and getParallelHeaderName
100 friend class VTKSequenceWriterBase<GridView>;
101 // VTKSequenceWriter needs the grid view, to get the MPI size and rank
102 friend class VTKSequenceWriter<GridView>;
103
104 // extract types
105 typedef typename GridView::Grid Grid;
106 typedef typename GridView::ctype DT;
107 constexpr static int n = GridView::dimension;
108 constexpr static int w = GridView::dimensionworld;
109
110 typedef typename GridView::template Codim< 0 >::Entity Cell;
111 typedef typename GridView::template Codim< n >::Entity Vertex;
112 typedef Cell Entity;
113
114 typedef typename GridView::IndexSet IndexSet;
115
116 static const PartitionIteratorType VTK_Partition = InteriorBorder_Partition;
117 //static const PartitionIteratorType VTK_Partition = All_Partition;
118
119 typedef typename GridView::template Codim< 0 >
120 ::template Partition< VTK_Partition >::Iterator
121 GridCellIterator;
122 typedef typename GridView::template Codim< n >
123 ::template Partition< VTK_Partition >::Iterator
124 GridVertexIterator;
125
126 typedef typename GridCellIterator::Reference EntityReference;
127
128 typedef typename GridView::template Codim< 0 >
129 ::Entity::Geometry::LocalCoordinate Coordinate;
130
132
133 // return true if entity should be skipped in Vertex and Corner iterator
134 static bool skipEntity( const PartitionType entityType )
135 {
136 switch( VTK_Partition )
137 {
138 // for All_Partition no entity has to be skipped
139 case All_Partition: return false;
140 case InteriorBorder_Partition: return ( entityType != InteriorEntity );
141 default: DUNE_THROW(NotImplemented,"Add check for this partition type");
142 }
143 return false ;
144 }
145
146 public:
147
149
150 protected:
151
153
157 {
158
159 public:
160
162
165 {
166
168 virtual void bind(const Entity& e) = 0;
169
171 virtual void unbind() = 0;
172
174
177 virtual void write(const Coordinate& pos, Writer& w, std::size_t count) const = 0;
178
179 virtual ~FunctionWrapperBase()
180 {}
181
182 };
183
185 // DUNE_PRIVATE since _f has less visibility
186 template<typename F>
188 : public FunctionWrapperBase
189 {
190 using Function = typename std::decay<F>::type;
191
192 template<typename F_>
193 FunctionWrapper(F_&& f)
194 : _f(std::forward<F_>(f))
195 {}
196
197 virtual void bind(const Entity& e)
198 {
199 _f.bind(e);
200 }
201
202 virtual void unbind()
203 {
204 _f.unbind();
205 }
206
207 virtual void write(const Coordinate& pos, Writer& writer, std::size_t count) const
208 {
209 auto r = _f(pos);
210 // we need to do different things here depending on whether r supports indexing into it or not.
211 do_write(writer,r,count,IsIndexable<decltype(r)>());
212 }
213
214 private:
215
216 template<typename R>
217 void do_write(Writer& writer, const R& r, std::size_t count, std::true_type) const
218 {
219 for (std::size_t i = 0; i < count; ++i)
220 writer.write(r[i]);
221 }
222
223 template<typename R>
224 void do_write(Writer& writer, const R& r, std::size_t count, std::false_type) const
225 {
226 assert(count == 1);
227 writer.write(r);
228 }
229
230 Function _f;
231 };
232
234 template<typename F>
236 : public FunctionWrapperBase
237 {
238 using Function = typename std::decay<F>::type;
239
240 template<typename F_>
242 : _f(std::forward<F_>(f))
243 , element_(nullptr)
244 {}
245
246 virtual void bind(const Entity& e)
247 {
248 element_ = &e;
249 }
250
251 virtual void unbind()
252 {
253 element_ = nullptr;
254 }
255
256 virtual void write(const Coordinate& pos, Writer& writer, std::size_t count) const
257 {
258 auto globalPos = element_->geometry().global(pos);
259 auto r = _f(globalPos);
260 if constexpr (IsIndexable<decltype(r)>()) {
261 for (std::size_t i = 0; i < count; ++i)
262 writer.write(r[i]);
263 }
264 else {
265 assert(count == 1);
266 writer.write(r);
267 }
268 }
269 private:
270 Function _f;
271 const Entity* element_;
272 };
273
276 : public FunctionWrapperBase
277 {
278 VTKFunctionWrapper(const std::shared_ptr< const VTKFunction >& f)
279 : _f(f)
280 , _entity(nullptr)
281 {}
282
283 virtual void bind(const Entity& e)
284 {
285 _entity = &e;
286 }
287
288 virtual void unbind()
289 {
290 _entity = nullptr;
291 }
292
293 virtual void write(const Coordinate& pos, Writer& writer, std::size_t count) const
294 {
295 for (std::size_t i = 0; i < count; ++i)
296 writer.write(_f->evaluate(i,*_entity,pos));
297 }
298
299 private:
300
301 std::shared_ptr< const VTKFunction > _f;
302 const Entity* _entity;
303
304 };
305
307 template<typename F, std::enable_if_t<Impl::IsBindable<F, Entity>::value, int> = 0>
309 : _f(std::make_unique<FunctionWrapper<F> >(std::forward<F>(f)))
310 , _fieldInfo(fieldInfo)
311 {}
312
314 // That is, a function that you can create a LocalFunction for, and evaluate that in element coordinates
315 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && Impl::HasLocalFunction<F>::value, int> = 0>
317 : _f(std::make_unique< FunctionWrapper<
318 typename std::decay<decltype(localFunction(std::forward<F>(f)))>::type
319 > >(localFunction(std::forward<F>(f))))
320 , _fieldInfo(fieldInfo)
321 {}
322
324 // That is, a function that can be evaluated in global coordinates of the domain
325 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && not Impl::HasLocalFunction<F>::value, int> = 0>
327 : _f(std::make_unique< GlobalFunctionWrapper<F> >(std::forward<F>(f)))
328 , _fieldInfo(fieldInfo)
329 {}
330
332 explicit VTKLocalFunction (const std::shared_ptr< const VTKFunction >& vtkFunctionPtr)
333 : _f(std::make_unique<VTKFunctionWrapper>(vtkFunctionPtr))
334 , _fieldInfo(
335 vtkFunctionPtr->name(),
336 (vtkFunctionPtr->ncomps() == 2 || vtkFunctionPtr->ncomps() == 3) ? VTK::FieldInfo::Type::vector : VTK::FieldInfo::Type::scalar,
337 vtkFunctionPtr->ncomps(),
338 vtkFunctionPtr->precision()
339 )
340 {}
341
343 std::string name() const
344 {
345 return fieldInfo().name();
346 }
347
350 {
351 return _fieldInfo;
352 }
353
355 void bind(const Entity& e) const
356 {
357 _f->bind(e);
358 }
359
361 void unbind() const
362 {
363 _f->unbind();
364 }
365
367 void write(const Coordinate& pos, Writer& writer) const
368 {
369 _f->write(pos,writer,fieldInfo().size());
370 }
371
372 std::shared_ptr<FunctionWrapperBase> _f;
373 VTK::FieldInfo _fieldInfo;
374
375 };
376
377 typedef typename std::list<VTKLocalFunction>::const_iterator FunctionIterator;
378
380
385 class CellIterator : public GridCellIterator
386 {
387 public:
389 CellIterator(const GridCellIterator & x) : GridCellIterator(x) {}
393 {
394 return ReferenceElements<DT,n>::general((*this)->type()).position(0,0);
395 }
396 };
397
398 CellIterator cellBegin() const
399 {
400 return gridView_.template begin< 0, VTK_Partition >();
401 }
402
403 CellIterator cellEnd() const
404 {
405 return gridView_.template end< 0, VTK_Partition >();
406 }
407
409
424 public ForwardIteratorFacade<VertexIterator, const Entity, EntityReference, int>
425 {
426 GridCellIterator git;
427 GridCellIterator gend;
428 VTK::DataMode datamode;
429 // Index of the currently visited corner within the current element.
430 // NOTE: this is in Dune-numbering, in contrast to CornerIterator.
431 int cornerIndexDune;
432 const VertexMapper & vertexmapper;
433 std::vector<bool> visited;
434 // in conforming mode, for each vertex id (as obtained by vertexmapper)
435 // hold its number in the iteration order (VertexIterator)
436 int offset;
437
438 // hide operator ->
439 void operator->();
440 protected:
441 void basicIncrement ()
442 {
443 if( git == gend )
444 return;
445 ++cornerIndexDune;
446 const int numCorners = git->subEntities(n);
447 if( cornerIndexDune == numCorners )
448 {
449 offset += numCorners;
450 cornerIndexDune = 0;
451
452 ++git;
453 while( (git != gend) && skipEntity( git->partitionType() ) )
454 ++git;
455 }
456 }
457 public:
458 VertexIterator(const GridCellIterator & x,
459 const GridCellIterator & end,
460 const VTK::DataMode & dm,
461 const VertexMapper & vm) :
462 git(x), gend(end), datamode(dm), cornerIndexDune(0),
463 vertexmapper(vm), visited(vm.size(), false),
464 offset(0)
465 {
466 if (datamode == VTK::conforming && git != gend)
467 visited[vertexmapper.subIndex(*git,cornerIndexDune,n)] = true;
468 }
469 void increment ()
470 {
471 switch (datamode)
472 {
473 case VTK::conforming :
474 while(visited[vertexmapper.subIndex(*git,cornerIndexDune,n)])
475 {
476 basicIncrement();
477 if (git == gend) return;
478 }
479 visited[vertexmapper.subIndex(*git,cornerIndexDune,n)] = true;
480 break;
481 case VTK::nonconforming :
482 basicIncrement();
483 break;
484 }
485 }
486 bool equals (const VertexIterator & cit) const
487 {
488 return git == cit.git
489 && cornerIndexDune == cit.cornerIndexDune
490 && datamode == cit.datamode;
491 }
492 EntityReference dereference() const
493 {
494 return *git;
495 }
497 int localindex () const
498 {
499 return cornerIndexDune;
500 }
503 {
504 return referenceElement<DT,n>(git->type())
505 .position(cornerIndexDune,n);
506 }
507 };
508
509 VertexIterator vertexBegin () const
510 {
511 return VertexIterator( gridView_.template begin< 0, VTK_Partition >(),
512 gridView_.template end< 0, VTK_Partition >(),
513 datamode, *vertexmapper );
514 }
515
516 VertexIterator vertexEnd () const
517 {
518 return VertexIterator( gridView_.template end< 0, VTK_Partition >(),
519 gridView_.template end< 0, VTK_Partition >(),
520 datamode, *vertexmapper );
521 }
522
524
539 public ForwardIteratorFacade<CornerIterator, const Entity, EntityReference, int>
540 {
541 GridCellIterator git;
542 GridCellIterator gend;
543 VTK::DataMode datamode;
544 // Index of the currently visited corner within the current element.
545 // NOTE: this is in VTK-numbering, in contrast to VertexIterator.
546 int cornerIndexVTK;
547 const VertexMapper & vertexmapper;
548 // in conforming mode, for each vertex id (as obtained by vertexmapper)
549 // hold its number in the iteration order of VertexIterator (*not*
550 // CornerIterator)
551 const std::vector<int> & number;
552 // holds the number of corners of all the elements we have seen so far,
553 // excluding the current element
554 int offset;
555
556 // hide operator ->
557 void operator->();
558 public:
559 CornerIterator(const GridCellIterator & x,
560 const GridCellIterator & end,
561 const VTK::DataMode & dm,
562 const VertexMapper & vm,
563 const std::vector<int> & num) :
564 git(x), gend(end), datamode(dm), cornerIndexVTK(0),
565 vertexmapper(vm),
566 number(num), offset(0) {}
567 void increment ()
568 {
569 if( git == gend )
570 return;
571 ++cornerIndexVTK;
572 const int numCorners = git->subEntities(n);
573 if( cornerIndexVTK == numCorners )
574 {
575 offset += numCorners;
576 cornerIndexVTK = 0;
577
578 ++git;
579 while( (git != gend) && skipEntity( git->partitionType() ) )
580 ++git;
581 }
582 }
583 bool equals (const CornerIterator & cit) const
584 {
585 return git == cit.git
586 && cornerIndexVTK == cit.cornerIndexVTK
587 && datamode == cit.datamode;
588 }
589 EntityReference dereference() const
590 {
591 return *git;
592 }
594
598 int id () const
599 {
600 switch (datamode)
601 {
602 case VTK::conforming :
603 return
604 number[vertexmapper.subIndex(*git,VTK::renumber(*git,cornerIndexVTK),
605 n)];
606 case VTK::nonconforming :
607 return offset + VTK::renumber(*git,cornerIndexVTK);
608 default :
609 DUNE_THROW(IOError,"VTKWriter: unsupported DataMode" << datamode);
610 }
611 }
612 };
613
614 CornerIterator cornerBegin () const
615 {
616 return CornerIterator( gridView_.template begin< 0, VTK_Partition >(),
617 gridView_.template end< 0, VTK_Partition >(),
618 datamode, *vertexmapper, number );
619 }
620
621 CornerIterator cornerEnd () const
622 {
623 return CornerIterator( gridView_.template end< 0, VTK_Partition >(),
624 gridView_.template end< 0, VTK_Partition >(),
625 datamode, *vertexmapper, number );
626 }
627
628 public:
637 explicit VTKWriter ( const GridView &gridView,
638 VTK::DataMode dm = VTK::conforming,
639 VTK::Precision coordPrecision = VTK::Precision::float32)
640 : gridView_( gridView ),
641 datamode( dm ),
642 coordPrec (coordPrecision),
643 polyhedralCellsPresent_( checkForPolyhedralCells() )
644 { }
645
650 void addCellData (const std::shared_ptr< const VTKFunction > & p)
651 {
652 celldata.push_back(VTKLocalFunction(p));
653 }
654
674 template<typename F>
675 void addCellData(F&& f, VTK::FieldInfo vtkFieldInfo)
676 {
677 celldata.push_back(VTKLocalFunction(std::forward<F>(f),vtkFieldInfo));
678 }
679
696 template<class Container>
697 void addCellData (const Container& v, const std::string &name, int ncomps = 1,
698 VTK::Precision prec = VTK::Precision::float32)
699 {
700 typedef P0VTKFunction<GridView, Container> Function;
701 for (int c=0; c<ncomps; ++c) {
702 std::stringstream compName;
703 compName << name;
704 if (ncomps>1)
705 compName << "[" << c << "]";
706 VTKFunction* p = new Function(gridView_, v, compName.str(), ncomps, c, prec);
707 addCellData(std::shared_ptr< const VTKFunction >(p));
708 }
709 }
710
715 void addVertexData (const std::shared_ptr< const VTKFunction > & p)
716 {
717 vertexdata.push_back(VTKLocalFunction(p));
718 }
719
739 template<typename F>
740 void addVertexData(F&& f, VTK::FieldInfo vtkFieldInfo)
741 {
742 vertexdata.push_back(VTKLocalFunction(std::forward<F>(f),vtkFieldInfo));
743 }
744
745
762 template<class Container>
763 void addVertexData (const Container& v, const std::string &name, int ncomps=1,
764 VTK::Precision prec = VTK::Precision::float32)
765 {
766 typedef P1VTKFunction<GridView, Container> Function;
767 for (int c=0; c<ncomps; ++c) {
768 std::stringstream compName;
769 compName << name;
770 if (ncomps>1)
771 compName << "[" << c << "]";
772 VTKFunction* p = new Function(gridView_, v, compName.str(), ncomps, c, prec);
773 addVertexData(std::shared_ptr< const VTKFunction >(p));
774 }
775 }
776
778 void clear ()
779 {
780 celldata.clear();
781 vertexdata.clear();
782 }
783
786 { return coordPrec; }
787
789 virtual ~VTKWriter ()
790 {
791 this->clear();
792 }
793
806 std::string write ( const std::string &name,
807 VTK::OutputType type = VTK::ascii )
808 {
809 return write( name, type, gridView_.comm().rank(), gridView_.comm().size() );
810 }
811
838 std::string pwrite ( const std::string & name, const std::string & path, const std::string & extendpath,
839 VTK::OutputType type = VTK::ascii )
840 {
841 return pwrite( name, path, extendpath, type, gridView_.comm().rank(), gridView_.comm().size() );
842 }
843
844 protected:
846
858 std::string getParallelPieceName(const std::string& name,
859 const std::string& path,
860 int commRank, int commSize) const
861 {
862 std::ostringstream s;
863 // write path first
864 if(path.size() > 0)
865 {
866 s << path;
867 if(path[path.size()-1] != '/')
868 s << '/';
869 }
870
871 std::string fileprefix;
872 // check if a path was already added to name
873 // and if yes find filename without path
874 auto pos = name.rfind('/');
875 if( pos != std::string::npos )
876 {
877 // extract filename without path
878 fileprefix = name.substr( pos+1 );
879 // extract the path and added it before
880 // the magic below is added
881 std::string newpath = name.substr(0, pos);
882 s << newpath;
883 if(newpath[name.size()-1] != '/')
884 s << '/';
885 }
886 else
887 {
888 // if no path was found just copy the name
889 fileprefix = name;
890 }
891
892 s << 's' << std::setw(4) << std::setfill('0') << commSize << '-';
893 const bool writeHeader = commRank < 0;
894 if( ! writeHeader )
895 {
896 s << 'p' << std::setw(4) << std::setfill('0') << commRank << '-';
897 }
898
899 s << fileprefix << ".";
900 // write p for header files
901 if( writeHeader )
902 s << "p";
903 s << "vt";
904
905 if(GridView::dimension > 1)
906 s << "u";
907 else
908 s << "p";
909 return s.str();
910 }
911
913
923 std::string getParallelHeaderName(const std::string& name,
924 const std::string& path,
925 int commSize) const
926 {
927 return getParallelPieceName( name, path, -1, commSize );
928 }
929
931
943 std::string getSerialPieceName(const std::string& name,
944 const std::string& path) const
945 {
946 static const std::string extension =
947 GridView::dimension == 1 ? ".vtp" : ".vtu";
948
949 return concatPaths(path, name+extension);
950 }
951
968 std::string write ( const std::string &name,
969 VTK::OutputType type,
970 const int commRank,
971 const int commSize )
972 {
973 // in the parallel case, just use pwrite, it has all the necessary
974 // stuff, so we don't need to reimplement it here.
975 if(commSize > 1)
976 {
977 std::string filename = name;
978 std::string path = std::string("");
979
980 // check if a path was already added to name
981 // and if yes find filename without path
982 auto pos = name.rfind('/');
983 if( pos != std::string::npos )
984 {
985 // extract filename without path
986 filename = name.substr( pos+1 );
987
988 // extract the path and added it before
989 // the magic below is added
990 path = name.substr(0, pos);
991 }
992
993 return pwrite(filename, path, "", type, commRank, commSize);
994 }
995
996 // make data mode visible to private functions
997 outputtype = type;
998
999 // generate filename for process data
1000 std::string pieceName = getSerialPieceName(name, "");
1001
1002 // write process data
1003 std::ofstream file;
1004 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
1005 std::ios_base::eofbit);
1006 // check if file can be opened
1007 try {
1008 file.open( pieceName.c_str(), std::ios::binary );
1009 }
1010 catch(...) {
1011 std::cerr << "Filename: " << pieceName << " could not be opened" << std::endl;
1012 throw;
1013 }
1014 if (! file.is_open())
1015 DUNE_THROW(IOError, "Could not write to piece file " << pieceName);
1016 writeDataFile( file );
1017 file.close();
1018
1019 return pieceName;
1020 }
1021
1023
1046 std::string pwrite(const std::string& name, const std::string& path,
1047 const std::string& extendpath,
1048 VTK::OutputType ot, const int commRank,
1049 const int commSize )
1050 {
1051 // make data mode visible to private functions
1052 outputtype=ot;
1053
1054 // do some magic because paraview can only cope with relative paths to piece files
1055 std::ofstream file;
1056 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
1057 std::ios_base::eofbit);
1058 std::string piecepath = concatPaths(path, extendpath);
1059 std::string relpiecepath = relativePath(path, piecepath);
1060
1061 // write this processes .vtu/.vtp piece file
1062 std::string fullname = getParallelPieceName(name, piecepath, commRank,
1063 commSize);
1064 // check if file can be opened
1065 try {
1066 file.open(fullname.c_str(),std::ios::binary);
1067 }
1068 catch(...) {
1069 std::cerr << "Filename: " << fullname << " could not be opened" << std::endl;
1070 throw;
1071 }
1072 if (! file.is_open())
1073 DUNE_THROW(IOError, "Could not write to piecefile file " << fullname);
1074 writeDataFile(file);
1075 file.close();
1076 gridView_.comm().barrier();
1077
1078 // if we are rank 0, write .pvtu/.pvtp parallel header
1079 fullname = getParallelHeaderName(name, path, commSize);
1080 if( commRank ==0 )
1081 {
1082 file.open(fullname.c_str());
1083 if (! file.is_open())
1084 DUNE_THROW(IOError, "Could not write to parallel file " << fullname);
1085 writeParallelHeader(file,name,relpiecepath, commSize );
1086 file.close();
1087 }
1088 gridView_.comm().barrier();
1089 return fullname;
1090 }
1091
1092 private:
1094
1111 void writeParallelHeader(std::ostream& s, const std::string& piecename,
1112 const std::string& piecepath, const int commSize)
1113 {
1114 VTK::FileType fileType =
1115 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1116
1117 VTK::PVTUWriter writer(s, fileType);
1118
1119 writer.beginMain();
1120
1121 // PPointData
1122 {
1123 std::string scalars, vectors;
1124 std::tie(scalars,vectors) = getDataNames(vertexdata);
1125 writer.beginPointData(scalars, vectors);
1126 }
1127 for (auto it = vertexdata.begin(),
1128 end = vertexdata.end();
1129 it != end;
1130 ++it)
1131 {
1132 unsigned writecomps = it->fieldInfo().size();
1133 // for 2d vector fields should be written as 3d vector fields
1134 if(it->fieldInfo().type() == VTK::FieldInfo::Type::vector && writecomps == 2)
1135 writecomps = 3;
1136 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1137 }
1138 writer.endPointData();
1139
1140 // PCellData
1141 {
1142 std::string scalars, vectors;
1143 std::tie(scalars,vectors) = getDataNames(celldata);
1144 writer.beginCellData(scalars, vectors);
1145 }
1146 for (auto it = celldata.begin(),
1147 end = celldata.end();
1148 it != end;
1149 ++it)
1150 {
1151 unsigned writecomps = it->fieldInfo().size();
1152 // for 2d vector fields should be written as 3d vector fields
1153 if(it->fieldInfo().type() == VTK::FieldInfo::Type::vector && writecomps == 2)
1154 writecomps = 3;
1155 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1156 }
1157 writer.endCellData();
1158
1159 // PPoints
1160 writer.beginPoints();
1161 writer.addArray("Coordinates", 3, coordPrec);
1162 writer.endPoints();
1163
1164 // Pieces
1165 for( int i = 0; i < commSize; ++i )
1166 {
1167 const std::string& fullname = getParallelPieceName(piecename,
1168 piecepath, i,
1169 commSize);
1170 writer.addPiece(fullname);
1171 }
1172
1173 writer.endMain();
1174 }
1175
1177 void writeDataFile (std::ostream& s)
1178 {
1179 VTK::FileType fileType =
1180 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1181
1182 VTK::VTUWriter writer(s, outputtype, fileType);
1183
1184 // Grid characteristics
1185 vertexmapper = new VertexMapper( gridView_, mcmgVertexLayout() );
1186 if (datamode == VTK::conforming)
1187 {
1188 number.resize(vertexmapper->size());
1189 for (std::vector<int>::size_type i=0; i<number.size(); i++) number[i] = -1;
1190 }
1191 countEntities(nvertices, ncells, ncorners);
1192
1193 writer.beginMain(ncells, nvertices);
1194 writeAllData(writer);
1195 writer.endMain();
1196
1197 // write appended binary data section
1198 if(writer.beginAppended())
1199 writeAllData(writer);
1200 writer.endAppended();
1201
1202 delete vertexmapper; number.clear();
1203 }
1204
1205 void writeAllData(VTK::VTUWriter& writer) {
1206 // PointData
1207 writeVertexData(writer);
1208
1209 // CellData
1210 writeCellData(writer);
1211
1212 // Points
1213 writeGridPoints(writer);
1214
1215 // Cells
1216 writeGridCells(writer);
1217 }
1218
1219 protected:
1220 std::string getFormatString() const
1221 {
1222 if (outputtype==VTK::ascii)
1223 return "ascii";
1224 if (outputtype==VTK::base64)
1225 return "binary";
1226 if (outputtype==VTK::appendedraw)
1227 return "appended";
1228 if (outputtype==VTK::appendedbase64)
1229 return "appended";
1230 DUNE_THROW(IOError, "VTKWriter: unsupported OutputType" << outputtype);
1231 }
1232
1233 std::string getTypeString() const
1234 {
1235 if (n==1)
1236 return "PolyData";
1237 else
1238 return "UnstructuredGrid";
1239 }
1240
1242 virtual void countEntities(int &nvertices_, int &ncells_, int &ncorners_)
1243 {
1244 nvertices_ = 0;
1245 ncells_ = 0;
1246 ncorners_ = 0;
1247 for (CellIterator it=cellBegin(); it!=cellEnd(); ++it)
1248 {
1249 ncells_++;
1250 // because of the use of vertexmapper->map(), this iteration must be
1251 // in the order of Dune's numbering.
1252 const int subEntities = it->subEntities(n);
1253 for (int i=0; i<subEntities; ++i)
1254 {
1255 ncorners_++;
1256 if (datamode == VTK::conforming)
1257 {
1258 int alpha = vertexmapper->subIndex(*it,i,n);
1259 if (number[alpha]<0)
1260 number[alpha] = nvertices_++;
1261 }
1262 else
1263 {
1264 nvertices_++;
1265 }
1266 }
1267 }
1268 }
1269
1270 template<typename T>
1271 std::tuple<std::string,std::string> getDataNames(const T& data) const
1272 {
1273 std::string scalars = "";
1274 for (auto it = data.begin(),
1275 end = data.end();
1276 it != end;
1277 ++it)
1278 if (it->fieldInfo().type() == VTK::FieldInfo::Type::scalar)
1279 {
1280 scalars = it->name();
1281 break;
1282 }
1283
1284 std::string vectors = "";
1285 for (auto it = data.begin(),
1286 end = data.end();
1287 it != end;
1288 ++it)
1289 if (it->fieldInfo().type() == VTK::FieldInfo::Type::vector)
1290 {
1291 vectors = it->name();
1292 break;
1293 }
1294 return std::make_tuple(scalars,vectors);
1295 }
1296
1297 template<typename Data, typename Iterator>
1298 void writeData(VTK::VTUWriter& writer, const Data& data, const Iterator begin, const Iterator end, int nentries)
1299 {
1300 for (auto it = data.begin(),
1301 iend = data.end();
1302 it != iend;
1303 ++it)
1304 {
1305 const auto& f = *it;
1306 VTK::FieldInfo fieldInfo = f.fieldInfo();
1307 std::size_t writecomps = fieldInfo.size();
1308 switch (fieldInfo.type())
1309 {
1311 break;
1313 // vtk file format: a vector data always should have 3 comps (with
1314 // 3rd comp = 0 in 2D case)
1315 if (writecomps > 3)
1316 DUNE_THROW(IOError,"Cannot write VTK vectors with more than 3 components (components was " << writecomps << ")");
1317 writecomps = 3;
1318 break;
1320 DUNE_THROW(NotImplemented,"VTK output for tensors not implemented yet");
1321 }
1322 std::shared_ptr<VTK::DataArrayWriter> p
1323 (writer.makeArrayWriter(f.name(), writecomps, nentries, fieldInfo.precision()));
1324 if(!p->writeIsNoop())
1325 for (Iterator eit = begin; eit!=end; ++eit)
1326 {
1327 const Entity & e = *eit;
1328 f.bind(e);
1329 f.write(eit.position(),*p);
1330 f.unbind();
1331 // vtk file format: a vector data always should have 3 comps
1332 // (with 3rd comp = 0 in 2D case)
1333 for (std::size_t j=fieldInfo.size(); j < writecomps; ++j)
1334 p->write(0.0);
1335 }
1336 }
1337 }
1338
1340 virtual void writeCellData(VTK::VTUWriter& writer)
1341 {
1342 if(celldata.size() == 0)
1343 return;
1344
1345 std::string scalars, vectors;
1346 std::tie(scalars,vectors) = getDataNames(celldata);
1347
1348 writer.beginCellData(scalars, vectors);
1349 writeData(writer,celldata,cellBegin(),cellEnd(),ncells);
1350 writer.endCellData();
1351 }
1352
1354 virtual void writeVertexData(VTK::VTUWriter& writer)
1355 {
1356 if(vertexdata.size() == 0)
1357 return;
1358
1359 std::string scalars, vectors;
1360 std::tie(scalars,vectors) = getDataNames(vertexdata);
1361
1362 writer.beginPointData(scalars, vectors);
1363 writeData(writer,vertexdata,vertexBegin(),vertexEnd(),nvertices);
1364 writer.endPointData();
1365 }
1366
1368 virtual void writeGridPoints(VTK::VTUWriter& writer)
1369 {
1370 writer.beginPoints();
1371
1372 std::shared_ptr<VTK::DataArrayWriter> p
1373 (writer.makeArrayWriter("Coordinates", 3, nvertices, coordPrec));
1374 if(!p->writeIsNoop()) {
1375 VertexIterator vEnd = vertexEnd();
1376 for (VertexIterator vit=vertexBegin(); vit!=vEnd; ++vit)
1377 {
1378 int dimw=w;
1379 for (int j=0; j<std::min(dimw,3); j++)
1380 p->write((*vit).geometry().corner(vit.localindex())[j]);
1381 for (int j=std::min(dimw,3); j<3; j++)
1382 p->write(0.0);
1383 }
1384 }
1385 // free the VTK::DataArrayWriter before touching the stream
1386 p.reset();
1387
1388 writer.endPoints();
1389 }
1390
1392 virtual void writeGridCells(VTK::VTUWriter& writer)
1393 {
1394 writer.beginCells();
1395
1396 // connectivity
1397 {
1398 std::shared_ptr<VTK::DataArrayWriter> p1
1399 (writer.makeArrayWriter("connectivity", 1, ncorners, VTK::Precision::int32));
1400 if(!p1->writeIsNoop())
1401 for (CornerIterator it=cornerBegin(); it!=cornerEnd(); ++it)
1402 p1->write(it.id());
1403 }
1404
1405 // offsets
1406 {
1407 std::shared_ptr<VTK::DataArrayWriter> p2
1408 (writer.makeArrayWriter("offsets", 1, ncells, VTK::Precision::int32));
1409 if(!p2->writeIsNoop()) {
1410 int offset = 0;
1411 for (CellIterator it=cellBegin(); it!=cellEnd(); ++it)
1412 {
1413 offset += it->subEntities(n);
1414 p2->write(offset);
1415 }
1416 }
1417 }
1418
1419 // types
1420 if (n>1)
1421 {
1422 {
1423 std::shared_ptr<VTK::DataArrayWriter> p3
1424 (writer.makeArrayWriter("types", 1, ncells, VTK::Precision::uint8));
1425
1426 if(!p3->writeIsNoop())
1427 {
1428 for (CellIterator it=cellBegin(); it!=cellEnd(); ++it)
1429 {
1430 int vtktype = VTK::geometryType(it->type());
1431 p3->write(vtktype);
1432 }
1433 }
1434 }
1435
1436
1437 // if polyhedron cells found also cell faces need to be written
1438 if( polyhedralCellsPresent_ )
1439 {
1440 writeCellFaces( writer );
1441 }
1442 }
1443
1444 writer.endCells();
1445 }
1446
1447 protected:
1448 bool checkForPolyhedralCells() const
1449 {
1450 // check if polyhedron cells are present
1451 for( const auto& geomType : gridView_.indexSet().types( 0 ) )
1452 {
1453 if( VTK::geometryType( geomType ) == VTK::polyhedron )
1454 {
1456 DUNE_THROW(IOError, "VTKWriter: grid must support codim 1 entities to be able to write VTK polyhedral cells");
1457 return true;
1458 }
1459 }
1460 return false;
1461 }
1462
1464 virtual void writeCellFaces(VTK::VTUWriter& writer)
1465 {
1466 if( ! faceVertices_ )
1467 {
1468 faceVertices_.reset( new std::pair< std::vector<int>, std::vector<int> > () );
1469 // fill face vertex structure
1470 fillFaceVertices( cornerBegin(), cornerEnd(), gridView_.indexSet(),
1471 faceVertices_->first, faceVertices_->second );
1472 }
1473
1474 std::vector< int >& faces = faceVertices_->first;
1475 std::vector< int >& faceOffsets = faceVertices_->second;
1476 assert( int(faceOffsets.size()) == ncells );
1477
1478 {
1479 std::shared_ptr<VTK::DataArrayWriter> p4
1480 (writer.makeArrayWriter("faces", 1, faces.size(), VTK::Precision::int32));
1481 if(!p4->writeIsNoop())
1482 {
1483 for( const auto& face : faces )
1484 p4->write( face );
1485 }
1486 }
1487
1488 {
1489 std::shared_ptr<VTK::DataArrayWriter> p5
1490 (writer.makeArrayWriter("faceoffsets", 1, ncells, VTK::Precision::int32));
1491 if(!p5->writeIsNoop())
1492 {
1493 for( const auto& offset : faceOffsets )
1494 p5->write( offset );
1495
1496 // clear face vertex structure
1497 faceVertices_.reset();
1498 }
1499 }
1500 }
1501
1502 template <class CornerIterator, class IndexSet, class T>
1503 inline void fillFaceVertices( CornerIterator it,
1504 const CornerIterator end,
1505 const IndexSet& indexSet,
1506 std::vector<T>& faces,
1507 std::vector<T>& faceOffsets )
1508 {
1509 if( n == 3 && it != end )
1510 {
1511 // clear output arrays
1512 faces.clear();
1513 faces.reserve( 15 * ncells );
1514 faceOffsets.clear();
1515 faceOffsets.reserve( ncells );
1516
1517 int offset = 0;
1518
1519 Cell element = *it;
1520 int elIndex = indexSet.index( element );
1521 std::vector< T > vertices;
1522 vertices.reserve( 30 );
1523 for( ; it != end; ++it )
1524 {
1525 const Cell& cell = *it ;
1526 const int cellIndex = indexSet.index( cell ) ;
1527 if( elIndex != cellIndex )
1528 {
1529 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1530
1531 vertices.clear();
1532 element = cell ;
1533 elIndex = cellIndex ;
1534 }
1535 vertices.push_back( it.id() );
1536 }
1537
1538 // fill faces for last element
1539 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1540 }
1541 }
1542
1543 template <class Entity, class IndexSet, class T>
1544 static void fillFacesForElement( const Entity& element,
1545 const IndexSet& indexSet,
1546 const std::vector<T>& vertices,
1547 T& offset,
1548 std::vector<T>& faces,
1549 std::vector<T>& faceOffsets )
1550 {
1551 const int dim = n;
1552
1553 std::map< T, T > vxMap;
1554
1555 // get number of local faces
1556 const int nVertices = element.subEntities( dim );
1557 for( int vx = 0; vx < nVertices; ++ vx )
1558 {
1559 const int vxIdx = indexSet.subIndex( element, vx, dim );
1560 vxMap[ vxIdx ] = vertices[ vx ];
1561 }
1562
1563 // get number of local faces
1564 const int nFaces = element.subEntities( 1 );
1565 // store number of faces for current element
1566 faces.push_back( nFaces );
1567 ++offset;
1568 // extract each face as a set of vertex indices
1569 for( int fce = 0; fce < nFaces; ++ fce )
1570 {
1571 if constexpr (Capabilities::hasEntity<typename GridView::Grid, 1>::v) {
1572 // obtain face
1573 const auto face = element.template subEntity< 1 > ( fce );
1574
1575 // get all vertex indices from current face
1576 const int nVxFace = face.subEntities( dim );
1577 faces.push_back( nVxFace );
1578 ++offset ;
1579 for( int i=0; i<nVxFace; ++i )
1580 {
1581 const T vxIndex = indexSet.subIndex( face, i, dim );
1582 assert( vxMap.find( vxIndex ) != vxMap.end() );
1583 faces.push_back( vxMap[ vxIndex ] );
1584 ++offset ;
1585 }
1586 } else {
1587 DUNE_THROW(IOError, "VTKWriter: grid must support codim 1 entities to be able to write VTK polyhedral cells");
1588 }
1589 }
1590
1591 // store face offset for each element
1592 faceOffsets.push_back( offset );
1593 }
1594
1595 protected:
1596 // the list of registered functions
1597 std::list<VTKLocalFunction> celldata;
1598 std::list<VTKLocalFunction> vertexdata;
1599
1600 // the grid
1601 GridView gridView_;
1602
1603 // temporary grid information
1604 int ncells;
1605 int nvertices;
1606 int ncorners;
1607 private:
1608 VertexMapper* vertexmapper;
1609 // in conforming mode, for each vertex id (as obtained by vertexmapper)
1610 // hold its number in the iteration order (VertexIterator)
1611 std::vector<int> number;
1612 VTK::DataMode datamode;
1613 VTK::Precision coordPrec;
1614
1615 // true if polyhedral cells are present in the grid
1616 const bool polyhedralCellsPresent_;
1617
1618 // pointer holding face vertex connectivity if needed
1619 std::shared_ptr< std::pair< std::vector<int>, std::vector<int> > > faceVertices_;
1620
1621 protected:
1622 VTK::OutputType outputtype;
1623 };
1624
1625}
1626
1627#endif
vector space out of a tensor product of fields.
Definition: fvector.hh:97
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:142
Grid view abstract base class.
Definition: gridview.hh:66
Default exception class for I/O errors.
Definition: exceptions.hh:325
Index Set Interface base class.
Definition: indexidset.hh:78
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:113
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:129
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:204
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to starting index in array for dof block.
Definition: mcmgmapper.hh:185
Default exception for dummy implementations.
Definition: exceptions.hh:357
Take a vector and interpret it as cell data for the VTKWriter.
Definition: function.hh:97
Take a vector and interpret it as point data for the VTKWriter.
Definition: function.hh:205
A base class for grid functions with any return type and dimension.
Definition: function.hh:42
Base class to write pvd-files which contains a list of all collected vtk-files.
Definition: vtksequencewriterbase.hh:34
Writer for the output of grid functions in the vtk format.
Definition: vtksequencewriter.hh:29
Iterator over the grids elements.
Definition: vtkwriter.hh:386
CellIterator(const GridCellIterator &x)
construct a CellIterator from the gridview's Iterator.
Definition: vtkwriter.hh:389
const FieldVector< DT, n > position() const
Definition: vtkwriter.hh:392
Iterate over the elements' corners.
Definition: vtkwriter.hh:540
int id() const
Process-local consecutive zero-starting vertex id.
Definition: vtkwriter.hh:598
Type erasure wrapper for VTK data sets.
Definition: vtkwriter.hh:157
void write(const Coordinate &pos, Writer &writer) const
Write the value of the data set at local coordinate pos to the writer.
Definition: vtkwriter.hh:367
void unbind() const
Unbind the data set from the currently bound entity.
Definition: vtkwriter.hh:361
VTKLocalFunction(F &&f, VTK::FieldInfo fieldInfo)
Construct a VTKLocalFunction for a dune-functions style LocalFunction.
Definition: vtkwriter.hh:308
std::string name() const
Returns the name of the data set.
Definition: vtkwriter.hh:343
const VTK::FieldInfo & fieldInfo() const
Returns the VTK::FieldInfo for the data set.
Definition: vtkwriter.hh:349
void bind(const Entity &e) const
Bind the data set to grid entity e.
Definition: vtkwriter.hh:355
VTKLocalFunction(const std::shared_ptr< const VTKFunction > &vtkFunctionPtr)
Construct a VTKLocalFunction for a legacy VTKFunction.
Definition: vtkwriter.hh:332
Iterate over the grid's vertices.
Definition: vtkwriter.hh:425
FieldVector< DT, n > position() const
position of vertex inside the entity
Definition: vtkwriter.hh:502
int localindex() const
index of vertex within the entity, in Dune-numbering
Definition: vtkwriter.hh:497
Writer for the output of grid functions in the vtk format.
Definition: vtkwriter.hh:96
void addCellData(const Container &v, const std::string &name, int ncomps=1, VTK::Precision prec=VTK::Precision::float32)
Add a grid function (represented by container) that lives on the cells of the grid to the visualizati...
Definition: vtkwriter.hh:697
void clear()
clear list of registered functions
Definition: vtkwriter.hh:778
std::string write(const std::string &name, VTK::OutputType type=VTK::ascii)
write output (interface might change later)
Definition: vtkwriter.hh:806
std::string getParallelHeaderName(const std::string &name, const std::string &path, int commSize) const
return name of a parallel header file
Definition: vtkwriter.hh:923
void addVertexData(const std::shared_ptr< const VTKFunction > &p)
Add a grid function that lives on the vertices of the grid to the visualization.
Definition: vtkwriter.hh:715
std::string getSerialPieceName(const std::string &name, const std::string &path) const
return name of a serial piece file
Definition: vtkwriter.hh:943
void addCellData(const std::shared_ptr< const VTKFunction > &p)
Add a grid function that lives on the cells of the grid to the visualization.
Definition: vtkwriter.hh:650
void addVertexData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the grid vertices.
Definition: vtkwriter.hh:740
virtual void writeCellData(VTK::VTUWriter &writer)
write cell data
Definition: vtkwriter.hh:1340
virtual void countEntities(int &nvertices_, int &ncells_, int &ncorners_)
count the vertices, cells and corners
Definition: vtkwriter.hh:1242
std::string getParallelPieceName(const std::string &name, const std::string &path, int commRank, int commSize) const
return name of a parallel piece file (or header name)
Definition: vtkwriter.hh:858
virtual void writeGridCells(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1392
virtual void writeCellFaces(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1464
std::string write(const std::string &name, VTK::OutputType type, const int commRank, const int commSize)
write output (interface might change later)
Definition: vtkwriter.hh:968
VTK::Precision coordPrecision() const
get the precision with which coordinates are written out
Definition: vtkwriter.hh:785
virtual void writeGridPoints(VTK::VTUWriter &writer)
write the positions of vertices
Definition: vtkwriter.hh:1368
virtual void writeVertexData(VTK::VTUWriter &writer)
write vertex data
Definition: vtkwriter.hh:1354
void addCellData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the element centers.
Definition: vtkwriter.hh:675
void addVertexData(const Container &v, const std::string &name, int ncomps=1, VTK::Precision prec=VTK::Precision::float32)
Add a grid function (represented by container) that lives on the vertices of the grid to the visualiz...
Definition: vtkwriter.hh:763
virtual ~VTKWriter()
destructor
Definition: vtkwriter.hh:789
VTKWriter(const GridView &gridView, VTK::DataMode dm=VTK::conforming, VTK::Precision coordPrecision=VTK::Precision::float32)
Construct a VTKWriter working on a specific GridView.
Definition: vtkwriter.hh:637
std::string pwrite(const std::string &name, const std::string &path, const std::string &extendpath, VTK::OutputType ot, const int commRank, const int commSize)
write output; interface might change later
Definition: vtkwriter.hh:1046
std::string pwrite(const std::string &name, const std::string &path, const std::string &extendpath, VTK::OutputType type=VTK::ascii)
write output (interface might change later)
Definition: vtkwriter.hh:838
base class for data array writers
Definition: dataarraywriter.hh:56
void write(T data)
write one element of data
Definition: dataarraywriter.hh:69
Descriptor struct for VTK fields.
Definition: common.hh:328
@ tensor
tensor field (always 3x3)
@ vector
vector-valued field (always 3D, will be padded if necessary)
std::string name() const
The name of the data field.
Definition: common.hh:352
Dump a .vtu/.vtp files contents to a stream.
Definition: pvtuwriter.hh:62
Dump a .vtu/.vtp files contents to a stream.
Definition: vtuwriter.hh:98
DataArrayWriter * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems, Precision prec)
acquire a DataArrayWriter
Definition: vtuwriter.hh:381
void endCellData()
finish CellData section
Definition: vtuwriter.hh:220
void beginCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:274
void endPointData()
finish PointData section
Definition: vtuwriter.hh:182
void beginCellData(const std::string &scalars="", const std::string &vectors="")
start CellData section
Definition: vtuwriter.hh:205
void beginPointData(const std::string &scalars="", const std::string &vectors="")
start PointData section
Definition: vtuwriter.hh:167
void endPoints()
finish section for the point coordinates
Definition: vtuwriter.hh:249
void endCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:285
void beginPoints()
start section for the point coordinates
Definition: vtuwriter.hh:238
A set of traits classes to store static information about grid implementation.
Data array writers for the VTKWriter.
A few common exception classes.
Common stuff for the VTKWriter.
Precision
which precision to use when writing out data to vtk files
Definition: common.hh:271
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:43
FileType
which type of VTK file to write
Definition: common.hh:252
DataMode
Whether to produce conforming or non-conforming output.
Definition: common.hh:67
Functions for VTK output.
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:177
Traits::Grid Grid
type of the grid
Definition: gridview.hh:83
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
const Communication & comm() const
obtain communication object
Definition: gridview.hh:273
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:134
Grid::ctype ctype
type used for coordinates in grid
Definition: gridview.hh:131
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:137
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
@ All_Partition
all entities
Definition: gridenums.hh:141
@ InteriorBorder_Partition
interior and border entities
Definition: gridenums.hh:138
@ InteriorEntity
all interior entities
Definition: gridenums.hh:31
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:507
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:107
std::string relativePath(const std::string &newbase, const std::string &p)
compute a relative path between two paths
Definition: path.cc:149
std::string concatPaths(const std::string &base, const std::string &p)
concatenate two paths
Definition: path.cc:28
Utility class for handling nested indentation in output.
This file implements iterator facade classes for writing stl conformant iterators.
Mapper for multiple codim and multiple geometry types.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
STL namespace.
Utilities for handling filesystem paths.
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Static tag representing a codimension.
Definition: dimension.hh:24
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition: typetraits.hh:250
Base class for polymorphic container of underlying data set.
Definition: vtkwriter.hh:165
virtual void write(const Coordinate &pos, Writer &w, std::size_t count) const =0
Evaluate data set at local position pos inside the current entity and write result to w.
virtual void unbind()=0
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
virtual void bind(const Entity &e)=0
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Type erasure implementation for functions conforming to the dune-functions LocalFunction interface.
Definition: vtkwriter.hh:189
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:202
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:207
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:197
Type erasure implementation for C++ functions, i.e., functions that can be evaluated in global coordi...
Definition: vtkwriter.hh:237
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:251
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:256
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:246
Type erasure implementation for legacy VTKFunctions.
Definition: vtkwriter.hh:277
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:293
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:288
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:283
Traits for type conversions and type information.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_PRIVATE
Mark a symbol as being for internal use within the current DSO only.
Definition: visibility.hh:28
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Nov 15, 23:38, 2025)