• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PracticeSource.cc

Go to the documentation of this file.
00001 
00002 //*****************************************************************//
00003 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00004 //    This Software is released under the BSD license detailed     //
00005 //    in the file "license.txt" in the top-level Albany directory  //
00006 //*****************************************************************//
00007 
00008 // Define only if LCM is enabled
00009 #if defined (ALBANY_LCM)
00010 
00011 #include <stk_mesh/base/FieldData.hpp>
00012 #include "Topology.h"
00013 
00014 // FIXME: need to extract Topology member functions specific to
00015 // Barycentric subdivision and move into their own header!
00016 
00017 
00018 
00019 
00020 
00021 namespace LCM
00022 {
00023 
00024 void
00025 Topology::divideSegmentsHalf()
00026 {
00027 //get the segment from the original mesh
00028 std::vector<Entity*>
00029 initial_entities_1D = getEntitiesByRank(*(getBulkData()),1);
00030 std::vector<Entity*> vector_nodes;
00031 
00032 
00033 //Adding nodes to the divide segments by half
00034 std::vector<size_t> request1(getSpaceDimension()+1, 0);
00035 request1[0]=initial_entities_1D.size();
00036 addEntities(request1);
00037 
00038 std::vector<Entity*>
00039 initial_entities_0D = getEntitiesByRank(*(getBulkData()),0);
00040 
00041 //add a relation from the former segment to a new node
00042 for(unsigned int i=0; i< initial_entities_1D.size();i++){
00043       addRelation(*(initial_entities_1D[i]),*(initial_entities_0D[i]),2);
00044 }
00045 
00046 //adding segments
00047 std::vector<size_t> requests_step1_2(getSpaceDimension() + 1, 0);
00048 requests_step1_2[1] = initial_entities_1D.size();
00049 addEntities(requests_step1_2);
00050 std::vector<Entity*>
00051 modified_entities_1D = getEntitiesByRank(*(getBulkData()),1);
00052 
00053 for(unsigned int i=0; i<initial_entities_1D.size();i++){
00054 //Look for all the relations for each segment
00055   stk::mesh::PairIterRelation _relations=initial_entities_1D[i]->relations();
00056   //add new relation between the new node and the corresponding node in the original mesh
00057   for(unsigned j=0;j<_relations.size();j++){
00058     if(_relations[j].entity()->entity_rank()==0 && getLocalRelationId(*(initial_entities_1D[i]),*(_relations[j].entity()))== 1){
00059                  addRelation(*(modified_entities_1D[i]),*(_relations[j].entity()),0);
00060                  removeRelation(*(initial_entities_1D[i]),*(_relations[j].entity()),1);
00061       }
00062     addRelation(*(modified_entities_1D[i]),*(initial_entities_0D[i]),1);
00063   }
00064   // change the blue relation into a green one
00065   for(unsigned j=0;j<_relations.size();j++){
00066          if(_relations[j].entity()->entity_rank()==0 && getLocalRelationId(*(initial_entities_1D[i]),*(_relations[j].entity()))== 2){
00067         addRelation(*(initial_entities_1D[i]),*(_relations[j].entity()),1);
00068         removeRelation(*(initial_entities_1D[i]),*(_relations[j].entity()),2);
00069             }
00070   }
00071 }
00072 
00073 //adding the relation between the new segment and the faces
00074 for(unsigned int i=0; i < initial_entities_1D.size();i++){
00075   stk::mesh::PairIterRelation _relations=initial_entities_1D[i]->relations();
00076   for(unsigned int j=0;j<_relations.size();j++){
00077       if(_relations[j].entity()->entity_rank()==2){
00078         addRelation(*(_relations[j].entity()),*(modified_entities_1D[i]),getNumberLowerRankEntities(*(_relations[j].entity())));
00079       }
00080           }
00081     }
00082 
00083 
00084 }
00085 
00086 void
00087 Topology::addcentroid()
00088 {
00089   //get the faces form the original mesh
00090   std::vector<Entity*>
00091   initial_entities_2D = getEntitiesByRank(*(getBulkData()),2);
00092 
00093   //Adding nodes to the faces
00094   std::vector<size_t> request2(getSpaceDimension()+1, 0);
00095   request2[0]=initial_entities_2D.size();
00096   addEntities(request2);
00097 }
00098 
00099 void
00100 Topology::connectcentroid(){
00101   //get the faces form the original mesh
00102   std::vector<Entity*>
00103   initial_entities_2D = getEntitiesByRank(*(getBulkData()),2);
00104 
00105   //get the centroid
00106   std::vector<Entity*>
00107   modified_entities_0D = getEntitiesByRank(*(getBulkData()),0);
00108 
00109   //adding new segment
00110   std::vector<size_t> request2(getSpaceDimension()+1, 0);
00111   request2[1]=6*initial_entities_2D.size();
00112     addEntities(request2);
00113     std::vector<Entity*>
00114     modified_entities_1D = getEntitiesByRank(*(getBulkData()),1);
00115 
00116 
00117 for(unsigned int i=0; i < initial_entities_2D.size(); i++){
00118 
00119 
00120     //get boundary nodes
00121     std::vector<Entity*>
00122     boundary_entities_0D= getBoundaryEntities(*(initial_entities_2D[i]),0);
00123 
00124     //adding new relation
00125     for(int j=0;j< getNumberLowerRankEntities(*(initial_entities_2D[i])); j++){
00126         addRelation(*(modified_entities_1D[6*i+j]),*(modified_entities_0D[i]),0);
00127         addRelation(*(modified_entities_1D[6*i+j]),*(boundary_entities_0D[j]),1);
00128    }
00129 }
00130 }
00131 
00132 void
00133 Topology::addnewfaces()
00134 {
00135   //get the faces form the original mesh
00136   std::vector<Entity*>
00137   initial_entities_2D = getEntitiesByRank(*(getBulkData()),2);
00138 
00139   //Adding nodes to the faces
00140   std::vector<size_t> request2(getSpaceDimension()+1, 0);
00141   request2[2]=6*initial_entities_2D.size();
00142   addEntities(request2);
00143 
00144     //get boundary nodes
00145     std::vector<Entity*>
00146     boundary_entities_1D= getBoundaryEntities(*(initial_entities_2D[0]),1);
00147 
00148     for(unsigned i=0;i< boundary_entities_1D.size();i++){
00149       std::cout<<boundary_entities_1D[i]->identifier()<<std::endl;
00150       }
00151 }
00152 void
00153 Topology::connectnewfaces(){
00154   //get the faces form the original mesh
00155   std::vector<Entity*>
00156   initial_entities_2D = getEntitiesByRank(*(getBulkData()),2);
00157 
00158 }
00159 
00163 void
00164 Topology::barycentricSubdivision_()
00165 {
00166   // Use to assign unique ids
00167   setHighestIds();
00168   // Begin mesh update
00169   getBulkData()->modification_begin();
00170     divideSegmentsHalf();
00171     addcentroid();
00172     connectcentroid();
00173     addnewfaces();
00174     connectnewfaces();
00175   // End mesh update
00176   getBulkData()->modification_end();
00177 }
00178 
00179 } //End of namespace LCM
00180 
00181 #endif // #if defined (ALBANY_LCM)
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 

Generated on Wed Mar 26 2014 18:36:43 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1