/[escript]/trunk/finley/src/NodeFile_allocTable.c
ViewVC logotype

Diff of /trunk/finley/src/NodeFile_allocTable.c

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

revision 730 by bcumming, Mon May 15 04:03:49 2006 UTC revision 782 by bcumming, Tue Jul 18 00:47:47 2006 UTC
# Line 28  Line 28 
28  /*  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, */
29  /*  is deallocated. use Finley_Mesh_setLinearMesh to create a new one. */  /*  is deallocated. use Finley_Mesh_setLinearMesh to create a new one. */
30    
 #ifdef PASO_MPI  
 void Finley_NodeFile_allocTable( Finley_NodeFile* in, dim_t numNodes )  
 #else  
31  void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)  void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
 #endif  
32  {  {
33    index_t *Id2=NULL, *Tag2=NULL, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;    index_t *Id2=NULL, *Tag2=NULL, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;
34    #ifdef PASO_MPI
35        index_t *Dom2=NULL;
36    #endif
37    double *Coordinates2=NULL;    double *Coordinates2=NULL;
38    dim_t n,i;    dim_t n,i;
39        
40    /*  allocate memory: */    /*  allocate memory: */
41    #ifdef PASO_MPI
42      Dom2=MEMALLOC(numNodes,index_t);
43    #endif
44    Id2=MEMALLOC(numNodes,index_t);    Id2=MEMALLOC(numNodes,index_t);
45    Coordinates2=MEMALLOC(numNodes*in->numDim,double);    Coordinates2=MEMALLOC(numNodes*in->numDim,double);
46    Tag2=MEMALLOC(numNodes,index_t);    Tag2=MEMALLOC(numNodes,index_t);
# Line 47  void Finley_NodeFile_allocTable(Finley_N Line 49  void Finley_NodeFile_allocTable(Finley_N
49    toReduced2=MEMALLOC(numNodes,index_t);    toReduced2=MEMALLOC(numNodes,index_t);
50        
51    /*  if fine, deallocate the old table and replace by new: */    /*  if fine, deallocate the old table and replace by new: */
52      #ifdef PASO_MPI
53      if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Dom2) ||
54          Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
55            MEMFREE( Dom2 );
56    #else
57    if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||    if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||
58        Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {        Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
59    #endif
60      MEMFREE(Id2);      MEMFREE(Id2);
61      MEMFREE(Coordinates2);      MEMFREE(Coordinates2);
62      MEMFREE(Tag2);      MEMFREE(Tag2);
# Line 58  void Finley_NodeFile_allocTable(Finley_N Line 65  void Finley_NodeFile_allocTable(Finley_N
65      MEMFREE(toReduced2);      MEMFREE(toReduced2);
66    } else {    } else {
67      Finley_NodeFile_deallocTable(in);      Finley_NodeFile_deallocTable(in);
68    #ifdef PASO_MPI
69            in->Dom=Dom2;
70    #endif
71      in->Id=Id2;      in->Id=Id2;
72      in->Coordinates=Coordinates2;      in->Coordinates=Coordinates2;
73      in->Tag=Tag2;      in->Tag=Tag2;
# Line 72  void Finley_NodeFile_allocTable(Finley_N Line 82  void Finley_NodeFile_allocTable(Finley_N
82      #pragma omp parallel for private(n,i) schedule(static)      #pragma omp parallel for private(n,i) schedule(static)
83      for (n=0;n<numNodes;n++) {      for (n=0;n<numNodes;n++) {
84         for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;         for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
85    #ifdef PASO_MPI
86           in->Dom[n]=-1;
87    #endif
88         in->Id[n]=-1;         in->Id[n]=-1;
89         in->Tag[n]=-1;         in->Tag[n]=-1;
90         in->degreeOfFreedom[n]=n;         in->degreeOfFreedom[n]=n;
# Line 86  void Finley_NodeFile_allocTable(Finley_N Line 99  void Finley_NodeFile_allocTable(Finley_N
99    
100  void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {  void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {
101    if (in!=NULL) {    if (in!=NULL) {
102    #ifdef PASO_MPI
103        MEMFREE(in->Dom);
104    #endif
105      MEMFREE(in->Id);      MEMFREE(in->Id);
106      MEMFREE(in->Coordinates);      MEMFREE(in->Coordinates);
107      MEMFREE(in->Tag);      MEMFREE(in->Tag);

Legend:
Removed from v.730  
changed lines
  Added in v.782

  ViewVC Help
Powered by ViewVC 1.1.26