Ejemplo n.º 1
0
  void MeshModeler::SetElementNeighbours(ModelPart& rModelPart,
					 MeshingParametersType & rMeshingVariables)
  {
    KRATOS_TRY

    unsigned int& MeshId = rMeshingVariables.MeshId;

    if( this->GetEchoLevel() > 0 ){
      std::cout<<" [ SET ELEMENT NEIGHBOURS : "<<std::endl;
      std::cout<<"   Initial Faces : "<<rModelPart.Conditions(MeshId).size()<<std::endl;
    }

    ModelPart::ElementsContainerType::const_iterator el_begin = rModelPart.ElementsBegin(MeshId);
	
    int facecounter=0;
    for(ModelPart::ElementsContainerType::const_iterator iii = rModelPart.ElementsBegin(MeshId);
	iii != rModelPart.ElementsEnd(MeshId); iii++)
      {

	int Id= iii->Id() - 1;
	//std::cout<<" Id ELNEIG "<<Id<<std::endl;


	int number_of_faces = iii->GetGeometry().FacesNumber(); //defined for triangles and tetrahedra
	(iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(number_of_faces);
	WeakPointerVector< Element >& neighb = iii->GetValue(NEIGHBOUR_ELEMENTS);

	for(int i = 0; i<number_of_faces; i++)
	  {
	    int index = rMeshingVariables.NeighbourList[Id][i];
				
	    if(index > 0)
	      {
		//std::cout<<" Element "<<Id<<" size "<<rMeshingVariables.PreservedElements.size()<<std::endl;			    
		//std::cout<<" Index pre "<<index<<" size "<<rMeshingVariables.PreservedElements.size()<<std::endl;
		index = rMeshingVariables.PreservedElements[index-1];
		//std::cout<<" Index post "<<index<<std::endl;
	      }

	    if(index > 0)
	      {
		neighb(i) = *((el_begin + index -1 ).base());
	      }
	    else
	      {
		//neighb(i) = Element::WeakPointer();
		neighb(i) = *(iii.base());
		facecounter++;
	      }
	  }
      }
	
    if( this->GetEchoLevel() > 0 ){
      std::cout<<"   Final Faces : "<<facecounter<<std::endl;
      std::cout<<"   SET ELEMENT NEIGHBOURS ]; "<<std::endl;
    }

    KRATOS_CATCH( "" )

  }
Ejemplo n.º 2
0
void copy_cells_archetypes(Complex2D      & G_dst, 
			   GSRC      const& G_src,
			   VtxCorr&         vtx_corr,
			   CellCorr&        cell_corr)
{
  typedef grid_types<GSRC>                      src_gt;
  typedef typename src_gt::CellIterator         src_cell_it;
  typedef typename src_gt::VertexOnCellIterator src_vertex_on_cell_it;
  
  typedef grid_types<Complex2D>     gt;
  typedef           gt::Cell        Cell;
  typedef           gt::cell_handle cell_handle;

  typedef              gt::archetype_type   dst_archetype;
  typedef typename src_gt::archetype_type   src_archetype;
  typedef              gt::archetype_handle src_arch_handle;
  typedef typename src_gt::archetype_handle dst_arch_handle;


  //typedef typename gt::BoundaryFacetIterator BdFacetIterator;    

  friend_for_input cc(G_dst);

  // (2) copy archetypes
  typedef vertex_morphism<src_archetype, dst_archetype> arch_morphism;
  ::std::vector<arch_morphism> morphism;
  bijective_mapping<src_arch_handle, dst_arch_handle> arch_corr;
  typename src_gt::archetype_iterator arch_src = G_src.BeginArchetype();
  for(; arch_src != G_src.EndArchetype() ; ++arch_src) {
    //  dst_arch_handle a_dst = cc.add_archetype(); //G_dst.add_archetype();
    src_arch_handle a_src = G_src.handle(arch_src);

    dst_archetype  arch_dst;
    dst_arch_handle a_dst = cc.add_archetype(arch_dst, (*arch_src).NumOfVertices());
    morphism.push_back(arch_morphism(*arch_src,G_dst.Archetype(a_dst)));

    ConstructGrid0(G_dst.Archetype(a_dst),
                   G_src.Archetype(a_src),
                   morphism.back());
    arch_corr[a_src] = a_dst;
  }


  for(typename src_gt::CellIterator c_src = G_src.FirstCell(); ! c_src.IsDone(); ++c_src){
    src_arch_handle a_src = G_src.archetype_of(*c_src);
    //  dst_arch_handle a_dst = arch_corr(a_src);

    cell_handle pc = cc._new_cell(GrAL::size<typename src_gt::Vertex>(*c_src)); // correct arch gets selected automatically a_dst);
    cell_corr[c_src.handle()] = pc;
    gt::Cell c_dst(G_dst, pc);

    typedef cell2d_connectivity c2d;
    c2d::vertex_list&   verts (cc._cell_vertices(pc));
 
    src_vertex_on_cell_it vc_src((*c_src)); // .FirstVertex());
    typename grid_types<src_archetype>::VertexIterator
       lv_src(G_src.Archetype(a_src).FirstVertex());
    for(; ! vc_src.IsDone(); ++vc_src, ++lv_src) {
      int lv = morphism[a_src][lv_src.handle()];
      verts [lv] = vtx_corr[vc_src.handle()];
    }


    // initialize cell neighbors
    cell_handle boundary(cc.outer_cell_handle()); // invalid reference to a cell
                                                // (used to mark unknown neighbours)
    c2d::cell_list&  neighb(cc._cell_neighbours(pc));
    for(int ln = 0; ln < c_dst.NumOfFacets(); ++ln)
      neighb[ln] = boundary; // correct neighbour is calculated later
  }

}