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

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

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

trunk/esys2/finley/src/finleyC/ElementFile_allocTable.c revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC trunk/finley/src/ElementFile_allocTable.c revision 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC
# Line 1  Line 1 
1  /* $Id$ */  
2    /*******************************************************
3    *
4    * Copyright (c) 2003-2008 by University of Queensland
5    * Earth Systems Science Computational Center (ESSCC)
6    * http://www.uq.edu.au/esscc
7    *
8    * Primary Business: Queensland, Australia
9    * Licensed under the Open Software License version 3.0
10    * http://www.opensource.org/licenses/osl-3.0.php
11    *
12    *******************************************************/
13    
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*   Finley: ElementFile */  /*   Finley: ElementFile */
# Line 7  Line 20 
20    
21  /**************************************************************/  /**************************************************************/
22    
 /*   Copyrights by ACcESS Australia 2003 */  
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$                                            */  
23    
 /**************************************************************/  
   
 #include "Finley.h"  
24  #include "ElementFile.h"  #include "ElementFile.h"
25    #include "Util.h"
26    
27  /****************************************************************************/  /****************************************************************************/
28    
29  /*  allocates the element table within an element file to hold numElements: */  /*  allocates the element table within an element file to hold numElements: */
30    
31  void Finley_ElementFile_allocTable(Finley_ElementFile* in,int numElements) {  void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
32    maybelong *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;  {
33    maybelong numNodes,e,i;    index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
34        Paso_MPI_rank *Owner2=NULL;
35    /*  allocate memory: */    dim_t numNodes,e,i;
36      
37    numNodes=(maybelong) in->ReferenceElement->Type->numNodes;    Finley_resetError();
38    Id2=MEMALLOC(numElements,maybelong);    /*  allocate memory: */
39    Nodes2=MEMALLOC(numElements*numNodes,maybelong);    numNodes=in->numNodes;
40    Tag2=MEMALLOC(numElements,maybelong);    Owner2=MEMALLOC(numElements,Paso_MPI_rank);
41    Color2=MEMALLOC(numElements,maybelong);    Id2=MEMALLOC(numElements,index_t);
42      Nodes2=MEMALLOC(numElements*in->numNodes,index_t);
43      Tag2=MEMALLOC(numElements,index_t);
44      Color2=MEMALLOC(numElements,index_t);
45        
46    /*  if fine, deallocate the old table and replace by new: */    /*  if fine, deallocate the old table and replace by new: */
47        
48    if (Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Color2)) {    if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
49      MEMFREE(Id2);                                                         Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
50        MEMFREE(Owner2);    
51      MEMFREE(Nodes2);      MEMFREE(Nodes2);
52        MEMFREE(Id2);
53      MEMFREE(Tag2);      MEMFREE(Tag2);
54      MEMFREE(Color2);      MEMFREE(Color2);
55    } else {    } else {
56      Finley_ElementFile_deallocTable(in);      Finley_ElementFile_freeTable(in);
57        in->Owner=Owner2;
58      in->numElements=numElements;      in->numElements=numElements;
59      in->Id=Id2;      in->Id=Id2;
60      in->Nodes=Nodes2;      in->Nodes=Nodes2;
# Line 52  void Finley_ElementFile_allocTable(Finle Line 66  void Finley_ElementFile_allocTable(Finle
66      #pragma omp parallel for private(e,i) schedule(static)      #pragma omp parallel for private(e,i) schedule(static)
67      for (e=0;e<numElements;e++) {      for (e=0;e<numElements;e++) {
68         for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;         for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;
69           in->Owner[e]=-1;
70         in->Id[e]=-1;         in->Id[e]=-1;
71         in->Tag[e]=-1;         in->Tag[e]=-1;
72         in->Color[e]=-1;         in->Color[e]=-1;
73      }      }
74      in->numColors=0;      in->maxColor=-1;
75        in->minColor=0;
76    }    }
77    return;    return;
78  }  }
79    
80    void Finley_ElementFile_setTagsInUse(Finley_ElementFile* in)
81    {
82        index_t *tagsInUse=NULL;
83        dim_t numTagsInUse;
84        if (in !=NULL) {
85           Finley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
86           if (Finley_noError()) {
87              MEMFREE(in->tagsInUse);
88              in->tagsInUse=tagsInUse;
89              in->numTagsInUse=numTagsInUse;
90           }
91        }
92    }
93    
94  /*  deallocates the element table within an element file: */  /*  deallocates the element table within an element file: */
95    
96  void Finley_ElementFile_deallocTable(Finley_ElementFile* in) {  void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
97      MEMFREE(in->Owner);
98    MEMFREE(in->Id);    MEMFREE(in->Id);
99    MEMFREE(in->Nodes);    MEMFREE(in->Nodes);
100    MEMFREE(in->Tag);    MEMFREE(in->Tag);
101    MEMFREE(in->Color);    MEMFREE(in->Color);
102      MEMFREE(in->tagsInUse);
103      in->numTagsInUse=0;
104    in->numElements=0;    in->numElements=0;
105    in->numColors=0;    in->maxColor=-1;
106      in->minColor=0;
107  }  }
   
 /*  
 * $Log$  
 * Revision 1.2  2004/12/14 05:39:30  jgs  
 * *** empty log message ***  
 *  
 * Revision 1.1.1.1.2.1  2004/11/24 01:37:13  gross  
 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
 *  
 * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  
 * initial import of project esys2  
 *  
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
 *  
 *  
 */  

Legend:
Removed from v.97  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.26