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

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

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

revision 6008 by caltinay, Fri Feb 5 03:37:49 2016 UTC revision 6009 by caltinay, Wed Mar 2 04:13:26 2016 UTC
# Line 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
17  /************************************************************************************/  /****************************************************************************/
18    
19  /*   Dudley: ElementFile */  /*   Dudley: ElementFile */
20    
21  /*   allocates and deallocates element table                  */  /*   allocates and deallocates element table                  */
22    
23  /************************************************************************************/  /****************************************************************************/
   
 #define ESNEEDPYTHON  
 #include "esysUtils/first.h"  
24    
25  #include "ElementFile.h"  #include "ElementFile.h"
26  #include "Util.h"  #include "Util.h"
27    
28  /**************************************************************************************************/  namespace dudley {
29    
30  /*  allocates the element table within an element file to hold numElements: */  /*  allocates the element table within an element file to hold numElements: */
31    
32  void Dudley_ElementFile_allocTable(Dudley_ElementFile * in, dim_t numElements)  void Dudley_ElementFile_allocTable(Dudley_ElementFile* in, dim_t numElements)
33  {  {
34      index_t *Id2 = NULL, *Nodes2 = NULL, *Tag2 = NULL, *Color2 = NULL;      index_t *Id2 = NULL, *Nodes2 = NULL, *Tag2 = NULL, *Color2 = NULL;
35      Esys_MPI_rank *Owner2 = NULL;      int *Owner2 = NULL;
36      dim_t numNodes, e, i;      dim_t numNodes, e, i;
37    
     Dudley_resetError();  
38      /*  allocate memory: */      /*  allocate memory: */
39      numNodes = in->numNodes;      numNodes = in->numNodes;
40      Owner2 = new  Esys_MPI_rank[numElements];      Owner2 = new int[numElements];
41      Id2 = new  index_t[numElements];      Id2 = new index_t[numElements];
42      Nodes2 = new  index_t[numElements * in->numNodes];      Nodes2 = new index_t[numElements * in->numNodes];
43      Tag2 = new  index_t[numElements];      Tag2 = new index_t[numElements];
44      Color2 = new  index_t[numElements];      Color2 = new index_t[numElements];
45    
46      /*  if fine, deallocate the old table and replace by new: */      /*  if fine, deallocate the old table and replace by new: */
47        Dudley_ElementFile_freeTable(in);
48        in->Owner = Owner2;
49        in->numElements = numElements;
50        in->Id = Id2;
51        in->Nodes = Nodes2;
52        in->Tag = Tag2;
53        in->Color = Color2;
54    
55      if (Dudley_checkPtr(Owner2) || Dudley_checkPtr(Id2) || Dudley_checkPtr(Nodes2) ||      /* this initialization makes sure that data are located on the right processor */
     Dudley_checkPtr(Tag2) || Dudley_checkPtr(Color2))  
     {  
     delete[] Owner2;  
     delete[] Nodes2;  
     delete[] Id2;  
     delete[] Tag2;  
     delete[] Color2;  
     }  
     else  
     {  
     Dudley_ElementFile_freeTable(in);  
     in->Owner = Owner2;  
     in->numElements = numElements;  
     in->Id = Id2;  
     in->Nodes = Nodes2;  
     in->Tag = Tag2;  
     in->Color = Color2;  
   
     /* this initialization makes sure that data are located on the right processor */  
56    
57  #pragma omp parallel for private(e,i) schedule(static)  #pragma omp parallel for private(e,i) schedule(static)
58      for (e = 0; e < numElements; e++)      for (e = 0; e < numElements; e++)
59      {      {
60          for (i = 0; i < numNodes; i++)          for (i = 0; i < numNodes; i++)
61          in->Nodes[INDEX2(i, e, numNodes)] = -1;              in->Nodes[INDEX2(i, e, numNodes)] = -1;
62          in->Owner[e] = -1;          in->Owner[e] = -1;
63          in->Id[e] = -1;          in->Id[e] = -1;
64          in->Tag[e] = -1;          in->Tag[e] = -1;
65          in->Color[e] = -1;          in->Color[e] = -1;
     }  
     in->maxColor = -1;  
     in->minColor = 0;  
66      }      }
67      return;      in->maxColor = -1;
68        in->minColor = 0;
69  }  }
70    
71  void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in)  void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in)
# Line 92  void Dudley_ElementFile_setTagsInUse(Dud Line 74  void Dudley_ElementFile_setTagsInUse(Dud
74      dim_t numTagsInUse;      dim_t numTagsInUse;
75      if (in != NULL)      if (in != NULL)
76      {      {
77      Dudley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);          Dudley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
78      if (Dudley_noError())          delete[] in->tagsInUse;
79      {          in->tagsInUse = tagsInUse;
80          delete[] in->tagsInUse;          in->numTagsInUse = numTagsInUse;
         in->tagsInUse = tagsInUse;  
         in->numTagsInUse = numTagsInUse;  
     }  
81      }      }
82  }  }
83    
# Line 117  void Dudley_ElementFile_freeTable(Dudley Line 96  void Dudley_ElementFile_freeTable(Dudley
96      in->maxColor = -1;      in->maxColor = -1;
97      in->minColor = 0;      in->minColor = 0;
98  }  }
99    
100    } // namespace dudley
101    

Legend:
Removed from v.6008  
changed lines
  Added in v.6009

  ViewVC Help
Powered by ViewVC 1.1.26