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

Diff of /branches/trilinos_from_5897/dudley/src/NodeFile_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    
 /************************************************************************************/  
   
 /*   Dudley: Mesh: NodeFile */  
   
 /************************************************************************************/  
   
 #define ESNEEDPYTHON  
 #include "esysUtils/first.h"  
   
17  #include "NodeFile.h"  #include "NodeFile.h"
18  #include "Util.h"  #include "Util.h"
19    
20  /************************************************************************************/  namespace dudley {
21    
22  /*  allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */  /*  allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
23  /*  is frees. use Dudley_Mesh_setLinearMesh to create a new one. */  /*  is frees. use Dudley_Mesh_setLinearMesh to create a new one. */
24    void Dudley_NodeFile_allocTable(Dudley_NodeFile* in, dim_t numNodes)
 void Dudley_NodeFile_allocTable(Dudley_NodeFile * in, dim_t numNodes)  
25  {  {
26      index_t *Id2 = NULL, *Tag2 = NULL, *globalDegreesOfFreedom2 = NULL, *globalReducedDOFIndex2 = NULL,      index_t *Id2 = NULL, *Tag2 = NULL, *globalDegreesOfFreedom2 = NULL, *globalReducedDOFIndex2 = NULL,
27      *globalReducedNodesIndex2 = NULL, *globalNodesIndex2 = NULL, *reducedNodesId2 = NULL, *degreesOfFreedomId2 =          *globalReducedNodesIndex2 = NULL, *globalNodesIndex2 = NULL, *reducedNodesId2 = NULL, *degreesOfFreedomId2 =
28      NULL, *reducedDegreesOfFreedomId2 = NULL;          NULL, *reducedDegreesOfFreedomId2 = NULL;
29      double *Coordinates2 = NULL;      double *Coordinates2 = NULL;
30      dim_t n, i;      dim_t n, i;
31    
32      /*  allocate memory: */      /*  allocate memory: */
33      Id2 = new  index_t[numNodes];      Id2 = new index_t[numNodes];
34      Coordinates2 = new  double[numNodes * in->numDim];      Coordinates2 = new double[numNodes * in->numDim];
35      Tag2 = new  index_t[numNodes];      Tag2 = new index_t[numNodes];
36      globalDegreesOfFreedom2 = new  index_t[numNodes];      globalDegreesOfFreedom2 = new index_t[numNodes];
37      globalReducedDOFIndex2 = new  index_t[numNodes];      globalReducedDOFIndex2 = new index_t[numNodes];
38      globalReducedNodesIndex2 = new  index_t[numNodes];      globalReducedNodesIndex2 = new index_t[numNodes];
39      globalNodesIndex2 = new  index_t[numNodes];      globalNodesIndex2 = new index_t[numNodes];
40      reducedNodesId2 = new  index_t[numNodes];      reducedNodesId2 = new index_t[numNodes];
41      degreesOfFreedomId2 = new  index_t[numNodes];      degreesOfFreedomId2 = new index_t[numNodes];
42      reducedDegreesOfFreedomId2 = new  index_t[numNodes];      reducedDegreesOfFreedomId2 = new index_t[numNodes];
43    
44      /*  if fine, free the old table and replace by new: */      /*  if fine, free the old table and replace by new: */
45      if (Dudley_checkPtr(Id2) || Dudley_checkPtr(Coordinates2) || Dudley_checkPtr(Tag2)      Dudley_NodeFile_freeTable(in);
46      || Dudley_checkPtr(globalDegreesOfFreedom2)      in->Id = Id2;
47      || Dudley_checkPtr(globalReducedDOFIndex2)      in->Coordinates = Coordinates2;
48      || Dudley_checkPtr(globalReducedNodesIndex2)      in->globalDegreesOfFreedom = globalDegreesOfFreedom2;
49      || Dudley_checkPtr(globalNodesIndex2)      in->Tag = Tag2;
50      || Dudley_checkPtr(reducedNodesId2) || Dudley_checkPtr(degreesOfFreedomId2))      in->globalReducedDOFIndex = globalReducedDOFIndex2;
51      {      in->globalReducedNodesIndex = globalReducedNodesIndex2;
52      delete[] Id2;      in->globalNodesIndex = globalNodesIndex2;
53      delete[] Coordinates2;      in->reducedNodesId = reducedNodesId2;
54      delete[] Tag2;      in->degreesOfFreedomId = degreesOfFreedomId2;
55      delete[] globalDegreesOfFreedom2;      in->reducedDegreesOfFreedomId = reducedDegreesOfFreedomId2;
56      delete[] globalReducedDOFIndex2;      in->numNodes = numNodes;
57      delete[] globalReducedNodesIndex2;      /* this initialization makes sure that data are located on the right processor */
     delete[] globalNodesIndex2;  
     delete[] reducedNodesId2;  
     delete[] degreesOfFreedomId2;  
     delete[] reducedDegreesOfFreedomId2;  
     }  
     else  
     {  
     Dudley_NodeFile_freeTable(in);  
     in->Id = Id2;  
     in->Coordinates = Coordinates2;  
     in->globalDegreesOfFreedom = globalDegreesOfFreedom2;  
     in->Tag = Tag2;  
     in->globalReducedDOFIndex = globalReducedDOFIndex2;  
     in->globalReducedNodesIndex = globalReducedNodesIndex2;  
     in->globalNodesIndex = globalNodesIndex2;  
     in->reducedNodesId = reducedNodesId2;  
     in->degreesOfFreedomId = degreesOfFreedomId2;  
     in->reducedDegreesOfFreedomId = reducedDegreesOfFreedomId2;  
     in->numNodes = numNodes;  
     /* this initialization makes sure that data are located on the right processor */  
58  #pragma omp parallel for private(n,i) schedule(static)  #pragma omp parallel for private(n,i) schedule(static)
59      for (n = 0; n < numNodes; n++)      for (n = 0; n < numNodes; n++)
60      {      {
61          in->Id[n] = -1;          in->Id[n] = -1;
62          for (i = 0; i < in->numDim; i++)          for (i = 0; i < in->numDim; i++)
63          in->Coordinates[INDEX2(i, n, in->numDim)] = 0.;              in->Coordinates[INDEX2(i, n, in->numDim)] = 0.;
64          in->Tag[n] = -1;          in->Tag[n] = -1;
65          in->globalDegreesOfFreedom[n] = -1;          in->globalDegreesOfFreedom[n] = -1;
66          in->globalReducedDOFIndex[n] = -1;          in->globalReducedDOFIndex[n] = -1;
67          in->globalReducedNodesIndex[n] = -1;          in->globalReducedNodesIndex[n] = -1;
68          in->globalNodesIndex[n] = -1;          in->globalNodesIndex[n] = -1;
69          in->reducedNodesId[n] = -1;          in->reducedNodesId[n] = -1;
70          in->degreesOfFreedomId[n] = -1;          in->degreesOfFreedomId[n] = -1;
71          in->reducedDegreesOfFreedomId[n] = -1;          in->reducedDegreesOfFreedomId[n] = -1;
     }  
72      }      }
     return;  
73  }  }
74    
75  /*  frees the node table within an node file: */  /*  frees the node table within an node file: */
# Line 110  void Dudley_NodeFile_freeTable(Dudley_No Line 78  void Dudley_NodeFile_freeTable(Dudley_No
78  {  {
79      if (in != NULL)      if (in != NULL)
80      {      {
81      delete[] in->Id;          delete[] in->Id;
82      delete[] in->Coordinates;          delete[] in->Coordinates;
83      delete[] in->globalDegreesOfFreedom;          delete[] in->globalDegreesOfFreedom;
84      delete[] in->globalReducedDOFIndex;          delete[] in->globalReducedDOFIndex;
85      delete[] in->globalReducedNodesIndex;          delete[] in->globalReducedNodesIndex;
86      delete[] in->globalNodesIndex;          delete[] in->globalNodesIndex;
87      delete[] in->Tag;          delete[] in->Tag;
88      delete[] in->reducedNodesId;          delete[] in->reducedNodesId;
89      delete[] in->degreesOfFreedomId;          delete[] in->degreesOfFreedomId;
90      delete[] in->reducedDegreesOfFreedomId;          delete[] in->reducedDegreesOfFreedomId;
91      delete[] in->tagsInUse;          delete[] in->tagsInUse;
92      in->numTagsInUse = 0;          in->numTagsInUse = 0;
93      Dudley_NodeMapping_free(in->nodesMapping);          Dudley_NodeMapping_free(in->nodesMapping);
94      in->nodesMapping = NULL;          in->nodesMapping = NULL;
95      Dudley_NodeMapping_free(in->reducedNodesMapping);          Dudley_NodeMapping_free(in->reducedNodesMapping);
96      in->reducedNodesMapping = NULL;          in->reducedNodesMapping = NULL;
97      Dudley_NodeMapping_free(in->degreesOfFreedomMapping);          Dudley_NodeMapping_free(in->degreesOfFreedomMapping);
98      in->degreesOfFreedomMapping = NULL;          in->degreesOfFreedomMapping = NULL;
99      Dudley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);          Dudley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
100      in->reducedDegreesOfFreedomMapping = NULL;          in->reducedDegreesOfFreedomMapping = NULL;
101      in->nodesDistribution.reset();          in->nodesDistribution.reset();
102      in->reducedNodesDistribution.reset();          in->reducedNodesDistribution.reset();
103      in->degreesOfFreedomDistribution.reset();          in->degreesOfFreedomDistribution.reset();
104      in->reducedDegreesOfFreedomDistribution.reset();          in->reducedDegreesOfFreedomDistribution.reset();
105      in->degreesOfFreedomConnector.reset();          in->degreesOfFreedomConnector.reset();
106      in->reducedDegreesOfFreedomConnector.reset();          in->reducedDegreesOfFreedomConnector.reset();
107      in->numTagsInUse = 0;          in->numTagsInUse = 0;
108      in->numNodes = 0;          in->numNodes = 0;
109      }      }
110  }  }
111    
# Line 147  void Dudley_NodeFile_setTagsInUse(Dudley Line 115  void Dudley_NodeFile_setTagsInUse(Dudley
115      dim_t numTagsInUse;      dim_t numTagsInUse;
116      if (in != NULL)      if (in != NULL)
117      {      {
118      Dudley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);          Dudley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);
119      if (Dudley_noError())          delete[] in->tagsInUse;
120      {          in->tagsInUse = tagsInUse;
121          delete[] in->tagsInUse;          in->numTagsInUse = numTagsInUse;
         in->tagsInUse = tagsInUse;  
         in->numTagsInUse = numTagsInUse;  
     }  
122      }      }
123  }  }
124    
125    } // namespace dudley
126    

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

  ViewVC Help
Powered by ViewVC 1.1.26