void manifold_checking_report(std::ostream& out, std::string const& grid_name, bool is_mf, GRID const& G, GF_F const& singular_facets, GF_V const& isolated_vertices, GF_V const& singular_interior_vertices, GF_V const& singular_boundary_vertices) { using namespace GrAL; typedef grid_types<GF_V> vgt; typedef grid_types<GF_F> fgt; out << "Grid \"" << grid_name << "\" is" << (is_mf ? " " : " NOT " ) << "a manifold grid.\n"; out << "|V|=" << G.NumOfVertices() << " |E|=" << G.NumOfEdges() << " |C|=" << G.NumOfCells() << std::endl; if(! is_mf) { if(singular_facets.size() > 0) { out << singular_facets.size() << " singular edges: "; for(typename fgt::EdgeIterator e = GrAL::begin_x(singular_facets); !e.IsDone(); ++e) out << "[" << (*e).v1() << "," << (*e).v2() << "] "; out << "\n"; } if(isolated_vertices.size() > 0) { out << isolated_vertices.size() << " isolated vertices: "; for(typename vgt::VertexIterator v = GrAL::begin_x(isolated_vertices); !v.IsDone(); ++v) out << v.handle() << ","; out << "\n"; } if(singular_interior_vertices.size() > 0) { out << singular_interior_vertices.size() << " singular interior vertices: "; for(typename vgt::VertexIterator v = GrAL::begin_x(singular_interior_vertices); !v.IsDone(); ++v) out << v.handle() << ","; out << "\n"; } if(singular_boundary_vertices.size() > 0) { out << singular_boundary_vertices.size() << " singular boundary vertices: "; for(typename vgt::VertexIterator v = GrAL::begin_x(singular_boundary_vertices); !v.IsDone(); ++v) out << v.handle() << ","; out << "\n"; } } }
void write_complex2d(GRID const& G, ::std::ostream& out, int offset, VCORR & G2Out_v, CCORR & G2Out_c) { typedef grid_types<GRID> gt; typedef typename gt::Vertex Vertex; typedef typename gt::Cell Cell; typedef typename gt::VertexIterator VertexIterator; typedef typename gt::CellIterator CellIterator; typedef typename gt::VertexOnCellIterator VertexOnCellIterator; out << G.NumOfVertices() << " " << G.NumOfCells() << "\n\n"; // if GRID is a subrange type, we cannot initialized grid-functions // directly with G, but must get hold of the underlying grid. // This solution is not optimal. There could be a c-t branch // with an additional grid-type parameter for grid-functions. typedef element_traits<Vertex> et; typedef typename et::grid_type base_grid_type; // possibly != GRID Vertex dummy(*(G.FirstVertex())); base_grid_type const& baseG(dummy.TheGrid()); grid_function<Vertex,int> VNum(baseG); int vnum = offset; for(VertexIterator v= G.FirstVertex(); ! v.IsDone(); ++v){ // out << Geo.coord(*v) << "\n"; VNum[*v] = vnum; G2Out_v[v.handle()] = vnum; vnum++; } out << "\n"; int cnum = offset; for(CellIterator c = GrAL::begin_x(G); !c.IsDone(); ++c){ out << (*c).NumOfVertices() << " "; G2Out_c[c.handle()] = cnum; ++cnum; for(VertexOnCellIterator vc = GrAL::begin_x(*c); ! vc.IsDone(); ++vc) out << VNum[*vc] << " "; out << "\n"; } }
void write_complex2d(GRID const& G, GEOM const& Geo, ::std::ostream& out, int offset) { typedef grid_types<GRID> gt; typedef typename gt::Vertex Vertex; typedef typename gt::Cell Cell; typedef typename gt::VertexIterator VertexIterator; typedef typename gt::CellIterator CellIterator; typedef typename gt::VertexOnCellIterator VertexOnCellIterator; out << G.NumOfVertices() << " " << G.NumOfCells() << "\n\n"; // if GRID is a subrange type, we cannot initialized grid-functions // directly with G, but must get hold of the underlying grid. // This solution is not optimal. There could be a c-t branch // with an additional grid-type parameter for grid-functions. typedef element_traits<Vertex> et; typedef typename et::grid_type base_grid_type; // possibly != GRID Vertex dummy(*(G.FirstVertex())); ref_ptr<base_grid_type const> baseG(dummy.TheGrid()); grid_function<Vertex,int> VNum(* baseG); int vnum = offset; for(VertexIterator v= G.FirstVertex(); ! v.IsDone(); ++v){ out << std::setprecision(std::numeric_limits<double>::digits10) << Geo.coord(*v) << "\n"; VNum[*v] = vnum; vnum++; } out << "\n"; for(CellIterator c = G.FirstCell(); !c.IsDone(); ++c){ out << GrAL::size<Vertex>(*c) << " "; for(VertexOnCellIterator vc = GrAL::begin<Vertex>(*c); ! vc.IsDone(); ++vc) out << VNum[*vc] << " "; out << "\n"; } }
void ConstructGrid(OstreamGMV3DFmt& Out, GRID const& G, GEOM const& GEO, heterogeneous_list::List<GF,MOREGFS> GFS) { typedef OstreamGMV3DFmt GMV3D; std::ostream& out = Out.Out(); typedef grid_types<GRID> gt; typedef grid_types<GMV3D::archetype_type> gmv_agt; out << "gmvinput ascii\n"; out << "nodev " << G.NumOfVertices() << '\n'; for(typename gt::VertexIterator v(G); ! v.IsDone(); ++v) out << GEO.coord(*v) << '\n'; // map G's vertices to GMV numbers, starting from 1. element_numbering<typename gt::Vertex> G2GMV(G,1); // map archetypes of G to those of GMV typedef partial_grid_morphism<typename gt::archetype_type, GMV3D::archetype_type> morphism_type; bijective_mapping<typename gt::archetype_type const*, std::pair<morphism_type, int> > phi; for(typename gt::archetype_iterator a = G.BeginArchetype(); a != G.EndArchetype(); ++a) { bool found = false; int cnt_a = 0; // could be GMV::archetype_handle for(GMV3D::archetype_iterator a_gmv = Out.BeginArchetype(); a_gmv != Out.EndArchetype(); ++a_gmv, ++cnt_a) { morphism_type phi_a(*a,*a_gmv); found = construct_isomorphism(*a,*a_gmv, phi_a); if(found) { phi[&(*a)] = std::make_pair(phi_a,cnt_a); break; } } ENSURE(found, "sorry, no mapping to GMV cell type found!\n",1); // should use the general cell feature of GMV. } // map cells out << "cells " << G.NumOfCells() << "\n"; for(typename gt::CellIterator c(G); ! c.IsDone(); ++c) { // phi_a.inv c.V() G2GMV // gmv-archetype -> G::archetype -> G::global -> GMV::global morphism_type const& phi_a = phi(&G.ArchetypeOf(*c)).first; int cnt_a = phi(&G.ArchetypeOf(*c)).second; GMV3D::archetype_type const& archetype_gmv(phi_a.ImgGrid()); out << Out.name(cnt_a) << " " << archetype_gmv.NumOfVertices() << " "; for(gmv_agt::VertexIterator vc(archetype_gmv); !vc.IsDone(); ++vc) out << G2GMV( (*c).V(phi_a.inverse()(*vc))) << " "; out << '\n'; } Out.copy_grid_functions(GFS); out << "endgmv\n"; }