/[escript]/branches/trilinos_from_5897/dudley/src/Mesh_getPattern.cpp
ViewVC logotype

Diff of /branches/trilinos_from_5897/dudley/src/Mesh_getPattern.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6078 by caltinay, Wed Mar 2 04:13:26 2016 UTC revision 6079 by caltinay, Mon Mar 21 12:22:38 2016 UTC
# Line 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
 /****************************************************************************/  
   
 /* Dudley: Mesh */  
   
 /****************************************************************************/  
   
17  #include "Mesh.h"  #include "Mesh.h"
18  #include "IndexList.h"  #include "IndexList.h"
19    
# Line 27  Line 21 
21    
22  namespace dudley {  namespace dudley {
23    
24  /* returns a reference to the matrix pattern                  */  paso::SystemMatrixPattern_ptr Mesh::getPasoPattern()
 paso::SystemMatrixPattern_ptr Dudley_getPattern(Dudley_Mesh* mesh, bool reduce_row_order, bool reduce_col_order)  
25  {  {
26      paso::SystemMatrixPattern_ptr out;      // make sure that the pattern is available
27      /* make sure that the requested pattern is available */      if (!pasoPattern)
28      if (reduce_row_order) {          pasoPattern = makePasoPattern();
         if (reduce_col_order) {  
             if (mesh->ReducedReducedPattern == NULL)  
                 mesh->ReducedReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);  
         } else {  
             if (mesh->ReducedFullPattern == NULL)  
                 mesh->ReducedFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);  
         }  
     } else {  
         if (reduce_col_order) {  
             if (mesh->FullReducedPattern == NULL)  
                 mesh->FullReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);  
         } else {  
             if (mesh->FullFullPattern == NULL)  
                 mesh->FullFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);  
         }  
     }  
29    
30      if (reduce_row_order) {      return pasoPattern;
         if (reduce_col_order) {  
             out = mesh->ReducedReducedPattern;  
         } else {  
             out = mesh->ReducedFullPattern;  
         }  
     } else {  
         if (reduce_col_order) {  
             out = mesh->FullReducedPattern;  
         } else {  
             out = mesh->FullFullPattern;  
         }  
     }  
     return out;  
31  }  }
32    
33  paso::SystemMatrixPattern_ptr Dudley_makePattern(Dudley_Mesh* mesh, bool reduce_row_order, bool reduce_col_order)  paso::SystemMatrixPattern_ptr Mesh::makePasoPattern() const
34  {  {
35      paso::SystemMatrixPattern_ptr out;      const dim_t myNumTargets = Nodes->getNumDegreesOfFreedom();
36      paso::Pattern_ptr main_pattern, col_couple_pattern, row_couple_pattern;      const dim_t numTargets = Nodes->getNumDegreesOfFreedomTargets();
37      paso::Connector_ptr col_connector, row_connector;      const index_t* target = Nodes->borrowTargetDegreesOfFreedom();
38      Dudley_NodeMapping *colMap = NULL, *rowMap = NULL;      boost::scoped_array<IndexList> index_list(new IndexList[numTargets]);
     paso::Distribution_ptr colDistribution, rowDistribution;  
   
     if (reduce_col_order)  
     {  
         colMap = mesh->Nodes->reducedDegreesOfFreedomMapping;  
         colDistribution = mesh->Nodes->reducedDegreesOfFreedomDistribution;  
         col_connector = mesh->Nodes->reducedDegreesOfFreedomConnector;  
   
     }  
     else  
     {  
         colMap = mesh->Nodes->degreesOfFreedomMapping;  
         colDistribution = mesh->Nodes->degreesOfFreedomDistribution;  
         col_connector = mesh->Nodes->degreesOfFreedomConnector;  
     }  
   
     if (reduce_row_order)  
     {  
         rowMap = mesh->Nodes->reducedDegreesOfFreedomMapping;  
         rowDistribution = mesh->Nodes->reducedDegreesOfFreedomDistribution;  
         row_connector = mesh->Nodes->reducedDegreesOfFreedomConnector;  
     }  
     else  
     {  
         rowMap = mesh->Nodes->degreesOfFreedomMapping;  
         rowDistribution = mesh->Nodes->degreesOfFreedomDistribution;  
         row_connector = mesh->Nodes->degreesOfFreedomConnector;  
     }  
   
     boost::scoped_array<IndexList> index_list(new IndexList[rowMap->numTargets]);  
39    
40  #pragma omp parallel  #pragma omp parallel
41      {      {
42          /*  insert contributions from element matrices into columns index index_list: */          // insert contributions from element matrices into columns in indexlist
43          Dudley_IndexList_insertElements(index_list.get(), mesh->Elements,          IndexList_insertElements(index_list.get(), Elements, target);
44                                          reduce_row_order, rowMap->target, reduce_col_order, colMap->target);          IndexList_insertElements(index_list.get(), FaceElements, target);
45          Dudley_IndexList_insertElements(index_list.get(), mesh->FaceElements,          IndexList_insertElements(index_list.get(), Points, target);
46                                          reduce_row_order, rowMap->target, reduce_col_order, colMap->target);      }
47          Dudley_IndexList_insertElements(index_list.get(), mesh->Points,  
48                                          reduce_row_order, rowMap->target, reduce_col_order, colMap->target);      // create pattern
49        paso::Pattern_ptr mainPattern(paso::Pattern::fromIndexListArray(0,
50      }                myNumTargets, index_list.get(), 0, myNumTargets, 0));
51        paso::Pattern_ptr colCouplePattern(paso::Pattern::fromIndexListArray(0,
52      /* create pattern */                myNumTargets, index_list.get(), myNumTargets, numTargets,
53      main_pattern = paso::Pattern::fromIndexListArray(0,                -myNumTargets));
54          rowDistribution->getMyNumComponents(), index_list.get(),      paso::Pattern_ptr rowCouplePattern(paso::Pattern::fromIndexListArray(
55          0, colDistribution->getMyNumComponents(), 0);                myNumTargets, numTargets, index_list.get(), 0, myNumTargets, 0));
56      col_couple_pattern = paso::Pattern::fromIndexListArray(0,  
57          rowDistribution->getMyNumComponents(), index_list.get(),      paso::Connector_ptr connector(Nodes->degreesOfFreedomConnector);
58          colDistribution->getMyNumComponents(), colMap->numTargets,      paso::SystemMatrixPattern_ptr out(new paso::SystemMatrixPattern(
59          -colDistribution->getMyNumComponents());                  MATRIX_FORMAT_DEFAULT, Nodes->dofDistribution,
60      row_couple_pattern = paso::Pattern::fromIndexListArray(                  Nodes->dofDistribution, mainPattern, colCouplePattern,
61          rowDistribution->getMyNumComponents(), rowMap->numTargets,                  rowCouplePattern, connector, connector));
         index_list.get(), 0, colDistribution->getMyNumComponents(), 0);  
   
     /* if everything is in order we can create the return value */  
     out.reset(new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,  
             rowDistribution, colDistribution, main_pattern,  
             col_couple_pattern, row_couple_pattern, col_connector,  
             row_connector));  
62      return out;      return out;
63  }  }
64    

Legend:
Removed from v.6078  
changed lines
  Added in v.6079

  ViewVC Help
Powered by ViewVC 1.1.26