33 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__DISC_HELPER__FINITE_VOLUME_OUTPUT__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__DISC_HELPER__FINITE_VOLUME_OUTPUT__
50 template <
typename TElem,
template <
class,
int>
class TFVGeom,
int TWorldDim>
61 std::vector<Vertex*> vVert;
64 for(
size_t i = 0; i < geo.num_scvf(); ++i)
66 const typename TFVGeom<TElem, TWorldDim>::SCVF& scvf = geo.scvf(i);
72 for(
size_t co = 0; co < scvf.num_corners(); ++co)
79 aaPosOut[vrt] = scvf.global_corner(co);
85 if (scvf.num_corners() == 2) {
86 grid.template create<RegularEdge>(
EdgeDescriptor(vVert[0], vVert[1]));
89 UG_THROW(
"SCVF has a number of nodes, that is not drawable.");
95 if (scvf.num_corners() == 4) {
99 else if (scvf.num_corners() == 3) {
104 UG_THROW(
"SCVF has a number of nodes, that is not drawable.");
110 template <
typename TElem,
template <
class,
int>
class TFVGeom,
int TWorldDim>
118 TFVGeom<TElem, TWorldDim> geo;
126 std::vector<MathVector<TWorldDim> > vCornerCoords;
129 for(iter = iterBegin; iter != iterEnd; ++iter)
138 geo.update(elem, &vCornerCoords[0], &(*surfView.
subset_handler()));
141 CreateSCVF<TElem, TFVGeom, TWorldDim>(*elem, geo, shOut, aaPosOut);
146 template <
template <
class,
int>
class TFVGeom,
int TWorldDim>
149 template <
template <
class,
int>
class TFVGeom>
159 case 1: ConstructGridOfSCVF<RegularEdge, TFVGeom, 1>(shOut, surfView, aaPos, aaPosOut, si);
161 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 1 <<
".");
166 template <
template <
class,
int>
class TFVGeom>
176 case 1: ConstructGridOfSCVF<RegularEdge, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
178 case 2: ConstructGridOfSCVF<Triangle, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
179 ConstructGridOfSCVF<Quadrilateral, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
181 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 2);
186 template <
template <
class,
int>
class TFVGeom>
196 case 1: ConstructGridOfSCVF<RegularEdge, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
198 case 2: ConstructGridOfSCVF<Triangle, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
199 ConstructGridOfSCVF<Quadrilateral, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
201 case 3: ConstructGridOfSCVF<Tetrahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
202 ConstructGridOfSCVF<Hexahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
203 ConstructGridOfSCVF<Prism, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
204 ConstructGridOfSCVF<Pyramid, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
205 ConstructGridOfSCVF<Octahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
207 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 3);
212 template <
template <
class,
int>
class TFVGeom,
int TWorldDim>
226 template <
typename TElem,
template <
class,
int>
class TFVGeom,
int TWorldDim>
237 std::vector<Vertex*> vVert;
240 for(
size_t i = 0; i < geo.num_scv(); ++i)
242 const typename TFVGeom<TElem, TWorldDim>::SCV& scv = geo.scv(i);
248 for(
size_t co = 0; co < scv.num_corners(); ++co)
252 vVert.push_back(vrt);
255 aaPosOut[vrt] = scv.global_corner(co);
268 grid.template create<RegularEdge>(
EdgeDescriptor(vVert[0], vVert[1]));
273 if (scv.num_corners() == 4) {
275 vVert[2], vVert[3]));
278 UG_THROW(
"SCV has a number of nodes, that is not drawable.");
284 if (scv.num_corners() == 8) {
286 vVert[4], vVert[5], vVert[6], vVert[7]));
288 else if (scv.num_corners() == 4) {
292 UG_THROW(
"SCV has a number of nodes, that is not drawable.");
298 template <
typename TElem,
template <
class,
int>
class TFVGeom,
int TWorldDim>
305 TFVGeom<TElem, TWorldDim> geo;
313 std::vector<MathVector<TWorldDim> > vCornerCoords;
316 for(iter = iterBegin; iter != iterEnd; ++iter)
325 geo.update(elem, &vCornerCoords[0], &(*surfView.
subset_handler()));
328 CreateSCV<TElem, TFVGeom, TWorldDim>(*elem, geo, shOut, aaPosOut);
333 template <
template <
class,
int>
class TFVGeom,
int TWorldDim>
336 template <
template <
class TElem,
int TWorldDim>
class TFVGeom>
346 case 1: ConstructGridOfSCV<RegularEdge, TFVGeom, 1>(shOut, surfView, aaPos, aaPosOut, si);
348 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 1);
353 template <
template <
class,
int>
class TFVGeom>
363 case 1: ConstructGridOfSCV<RegularEdge, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
365 case 2: ConstructGridOfSCV<Triangle, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
366 ConstructGridOfSCV<Quadrilateral, TFVGeom, 2>(shOut, surfView, aaPos, aaPosOut, si);
368 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 2);
373 template <
template <
class,
int>
class TFVGeom>
383 case 1: ConstructGridOfSCV<RegularEdge, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
385 case 2: ConstructGridOfSCV<Triangle, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
386 ConstructGridOfSCV<Quadrilateral, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
388 case 3: ConstructGridOfSCV<Tetrahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
389 ConstructGridOfSCV<Hexahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
390 ConstructGridOfSCV<Prism, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
391 ConstructGridOfSCV<Pyramid, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
392 ConstructGridOfSCV<Octahedron, TFVGeom, 3>(shOut, surfView, aaPos, aaPosOut, si);
394 default:
UG_THROW(
"CreateDualGrid: Dimension " << siDim <<
" not supported. World dimension is " << 3);
399 template <
template <
class,
int>
class TFVGeom,
int TWorldDim>
413 template <
typename TElem>
421 iterBegin = grid.
begin<TElem>();
422 iterEnd = grid.
end<TElem>();
426 for(iter = iterBegin; iter != iterEnd; ++iter)
432 template <
typename TElem>
440 iterBegin = grid.
begin<TElem>();
441 iterEnd = grid.
end<TElem>();
445 for(iter = iterBegin; iter != iterEnd; ++iter)
452 template <
int TRefDim>
458 std::vector<Volume*> vVols;
459 std::vector<Face*> vFaces;
460 std::vector<Edge*> vEdges;
479 default:
UG_THROW(
"Dimension " << TRefDim <<
" is not supported.");
485 template <
template <
class,
int>
class TFVGeom,
typename TAAPosition>
488 static const int dim = TAAPosition::ValueType::Size;
494 ConstructGridOfSCV<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
502 if(siDim !=
dim)
continue;
504 ConstructGridOfSCV<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
511 case 1: ColorSubControlVolume<Edge>(shOut);
break;
512 case 2: ColorSubControlVolume<Face>(shOut);
break;
513 case 3: ColorSubControlVolume<Volume>(shOut);
break;
514 default:
UG_THROW(
"WriteDualGridToFile: Dimension "<<
dim<<
" not supported.");
518 template <
template <
class,
int>
class TFVGeom,
typename TAAPosition,
typename TAPosition>
521 static const int dim = TAAPosition::ValueType::Size;
527 ConstructGridOfSCV<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
535 if(siDim !=
dim)
continue;
537 ConstructGridOfSCV<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
542 RemoveDoubles<dim>(*shOut.
grid(),
549 case 1: ColorControlVolume<1>(shOut);
break;
550 case 2: ColorControlVolume<2>(shOut);
break;
551 case 3: ColorControlVolume<3>(shOut);
break;
552 default:
UG_THROW(
"WriteDualGridToFile: Dimension "<<
dim<<
" not supported.");
556 template <
template <
class,
int>
class TFVGeom,
typename TAAPosition>
559 static const int dim = TAAPosition::ValueType::Size;
566 ConstructGridOfSCVF<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
574 if(siDim !=
dim)
continue;
576 ConstructGridOfSCVF<TFVGeom, dim>(shOut, surfView, aaPos, aaPosOut, si, siDim);
583 case 1: ColorSubControlVolumeFaces<Vertex>(shOut);
break;
584 case 2: ColorSubControlVolumeFaces<Edge>(shOut);
break;
585 case 3: ColorSubControlVolumeFaces<Face>(shOut);
break;
586 default:
UG_THROW(
"WriteDualGridToFile: Dimension " <<
dim <<
" not supported.");
598 template <
template <
class,
int>
class TFVGeom,
typename TDomain>
601 if(&domOut == &domIn)
602 UG_THROW(
"CreateSubControlVolumeFaceDomain: Domains must be different.");
604 CreateGridOfSubControlVolumeFaces<TFVGeom, typename TDomain::position_accessor_type>
605 ( *domOut.subset_handler(),
606 domOut.position_accessor(),
607 *domIn.subset_handler(),
608 domIn.position_accessor(),
620 template <
template <
class,
int>
class TFVGeom,
typename TDomain>
623 if(&domOut == &domIn)
624 UG_THROW(
"CreateSubControlVolumeDomain: Domains must be different.");
626 CreateGridOfSubControlVolumes<TFVGeom, typename TDomain::position_accessor_type>
627 ( *domOut.subset_handler(),
628 domOut.position_accessor(),
629 *domIn.subset_handler(),
630 domIn.position_accessor(),
642 template <
template <
class,
int>
class TFVGeom,
typename TDomain>
645 if(&domOut == &domIn)
646 UG_THROW(
"CreateControlVolumeDomain: Domains must be different.");
648 CreateGridOfControlVolumes<TFVGeom, typename TDomain::position_accessor_type, typename TDomain::position_attachment_type>
649 ( *domOut.subset_handler(),
650 domOut.position_accessor(),
651 domOut.position_attachment(),
652 *domIn.subset_handler(),
653 domIn.position_accessor(),
A generic specialization of IAttachment.
Definition: attachment_pipe.h:263
Can be used to store information about an edge and to construct an edge.
Definition: grid_base_objects.h:464
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
void clear()
clears the grids geometry and attachments
Definition: grid.cpp:220
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
geometry_traits< TGeomObj >::iterator create(GridObject *pParent=NULL)
create a custom element.
Definition: grid_impl.hpp:69
geometry_traits< TGeomObj >::iterator end()
Definition: grid_impl.hpp:175
Definition: grid_level.h:42
@ TOP
Definition: grid_level.h:45
@ SURFACE
Definition: grid_level.h:48
only used to initialize a hexahedron. for all other tasks you should use VolumeDescriptor.
Definition: grid_objects_3d.h:203
Definition: subset_handler_interface.h:223
void assign_subset(TIterator iterBegin, TIterator iterEnd, int subsetIndex)
Definition: subset_handler_interface_impl.hpp:170
Grid * grid() const
returns a pointer to the grid on which the subset-handler works.
Definition: subset_handler_interface.cpp:304
int get_subset_index(GridObject *elem) const
Definition: subset_handler_interface.cpp:560
int num_subsets() const
returns the number of subset-infos (return value is int, since SubsetIndices are of type int)
Definition: subset_handler_interface.h:317
a mathematical Vector with N entries.
Definition: math_vector.h:97
only used to initialize a quadrilateral. for all other tasks you should use FaceDescriptor.
Definition: grid_objects_2d.h:220
A basic vertex-type.
Definition: grid_objects_0d.h:62
Const iterator to traverse the surface of a multi-grid hierarchy.
Definition: surface_view.h:237
Represents the surface view of a multi-grid hierarchy.
Definition: surface_view.h:61
traits< TElem >::iterator end(int si, const GridLevel &gl, SurfaceState validStates)
Definition: surface_view_impl.hpp:372
@ SURFACE
Definition: surface_view.h:100
SmartPtr< MGSubsetHandler > subset_handler()
returns underlying subset handler
Definition: surface_view_impl.hpp:426
traits< TElem >::iterator begin(int si, const GridLevel &gl, SurfaceState validStates)
Definition: surface_view_impl.hpp:364
only used to initialize a tetrahedron. for all other tasks you should use VolumeDescripor.
Definition: grid_objects_3d.h:68
only used to initialize a triangle. for all other tasks you should use FaceDescriptor.
Definition: grid_objects_2d.h:78
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Definition: grid_base_object_traits.h:68
void CollectCornerCoordinates(std::vector< typename TAAPos::ValueType > &vCornerCoordsOut, const TElem &elem, const TAAPos &aaPos, bool clearContainer=true)
returns the corner coordinates of a geometric object
Definition: domain_util_impl.h:75
void CollectVolumes(std::vector< Volume * > &vVolumesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all volumes that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:592
void CollectEdges(std::vector< Edge * > &vEdgesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all edges which exist in the given grid and which are part of the given vertex.
Definition: grid_util.cpp:295
void CollectFaces(std::vector< Face * > &vFacesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all faces that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:458
#define UG_THROW(msg)
Definition: error.h:57
void ColorSubControlVolume(ISubsetHandler &shOut)
Definition: fv_output.h:433
void CreateSubControlVolumeFaceDomain(TDomain &domOut, const TDomain &domIn, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:599
void CreateGridOfSubControlVolumeFaces(ISubsetHandler &shOut, TAAPosition &aaPosOut, const ISubsetHandler &sh, const TAAPosition &aaPos, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:557
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition: grid_base_object_traits.h:73
void ConstructGridOfSCVF(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPosOut, int si)
Definition: fv_output.h:111
void CreateSubControlVolumeDomain(TDomain &domOut, const TDomain &domIn, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:621
void ColorSubControlVolumeFaces(ISubsetHandler &shOut)
Definition: fv_output.h:414
void ConstructGridOfSCV(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPosOut, int si)
Definition: fv_output.h:299
void CreateGridOfControlVolumes(ISubsetHandler &shOut, TAAPosition &aaPosOut, TAPosition &aPosOut, const ISubsetHandler &sh, const TAAPosition &aaPos, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:519
int DimensionOfSubset(const ISubsetHandler &sh, int si)
returns the current dimension of the subset
Definition: subset_dim_util.cpp:89
void CreateControlVolumeDomain(TDomain &domOut, const TDomain &domIn, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:643
void CreateSCV(const TElem &elem, TFVGeom< TElem, TWorldDim > &geo, ISubsetHandler &shOut, Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPosOut)
Definition: fv_output.h:227
void CreateGridOfSubControlVolumes(ISubsetHandler &shOut, TAAPosition &aaPosOut, const ISubsetHandler &sh, const TAAPosition &aaPos, const SurfaceView &surfView, int si=-1)
Definition: fv_output.h:486
void CreateSCVF(const TElem &elem, TFVGeom< TElem, TWorldDim > &geo, ISubsetHandler &shOut, Grid::VertexAttachmentAccessor< Attachment< MathVector< TWorldDim > > > &aaPosOut)
Definition: fv_output.h:51
void ColorControlVolume(ISubsetHandler &shOut)
Definition: fv_output.h:453
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 1 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 1 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:152
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 2 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 2 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:169
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 3 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 3 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:189
Definition: fv_output.h:147
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 1 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 1 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:339
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 2 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 2 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:356
static void apply(ISubsetHandler &shOut, const SurfaceView &surfView, const Grid::VertexAttachmentAccessor< Attachment< MathVector< 3 > > > &aaPos, Grid::VertexAttachmentAccessor< Attachment< MathVector< 3 > > > &aaPosOut, int si, int siDim)
Definition: fv_output.h:376
Definition: fv_output.h:334