/[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 1766 by gross, Mon Sep 8 02:51:14 2008 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /* $Id$ */
3    
4    /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   Finley: ElementFile */  /*   Finley: ElementFile */
# Line 7  Line 21 
21    
22  /**************************************************************/  /**************************************************************/
23    
 /*   Copyrights by ACcESS Australia 2003 */  
 /*   Author: gross@access.edu.au */  
 /*   Version: $Id$                                            */  
24    
 /**************************************************************/  
   
 #include "Finley.h"  
25  #include "ElementFile.h"  #include "ElementFile.h"
26    #include "Util.h"
27    
28  /****************************************************************************/  /****************************************************************************/
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 Finley_ElementFile_allocTable(Finley_ElementFile* in,int numElements) {  void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
33    maybelong *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;  {
34    maybelong numNodes,e,i;    index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
35        Paso_MPI_rank *Owner2=NULL;
36    /*  allocate memory: */    dim_t numNodes,e,i;
37      
38    numNodes=(maybelong) in->ReferenceElement->Type->numNodes;    Finley_resetError();
39    Id2=MEMALLOC(numElements,maybelong);    /*  allocate memory: */
40    Nodes2=MEMALLOC(numElements*numNodes,maybelong);    numNodes=in->numNodes;
41    Tag2=MEMALLOC(numElements,maybelong);    Owner2=MEMALLOC(numElements,Paso_MPI_rank);
42    Color2=MEMALLOC(numElements,maybelong);    Id2=MEMALLOC(numElements,index_t);
43      Nodes2=MEMALLOC(numElements*in->numNodes,index_t);
44      Tag2=MEMALLOC(numElements,index_t);
45      Color2=MEMALLOC(numElements,index_t);
46        
47    /*  if fine, deallocate the old table and replace by new: */    /*  if fine, deallocate the old table and replace by new: */
48        
49    if (Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Color2)) {    if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
50      MEMFREE(Id2);                                                         Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
51        MEMFREE(Owner2);    
52      MEMFREE(Nodes2);      MEMFREE(Nodes2);
53        MEMFREE(Id2);
54      MEMFREE(Tag2);      MEMFREE(Tag2);
55      MEMFREE(Color2);      MEMFREE(Color2);
56    } else {    } else {
57      Finley_ElementFile_deallocTable(in);      Finley_ElementFile_freeTable(in);
58        in->Owner=Owner2;
59      in->numElements=numElements;      in->numElements=numElements;
60      in->Id=Id2;      in->Id=Id2;
61      in->Nodes=Nodes2;      in->Nodes=Nodes2;
# Line 52  void Finley_ElementFile_allocTable(Finle Line 67  void Finley_ElementFile_allocTable(Finle
67      #pragma omp parallel for private(e,i) schedule(static)      #pragma omp parallel for private(e,i) schedule(static)
68      for (e=0;e<numElements;e++) {      for (e=0;e<numElements;e++) {
69         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;
70           in->Owner[e]=-1;
71         in->Id[e]=-1;         in->Id[e]=-1;
72         in->Tag[e]=-1;         in->Tag[e]=-1;
73         in->Color[e]=-1;         in->Color[e]=-1;
74      }      }
75      in->numColors=0;      in->maxColor=-1;
76        in->minColor=0;
77    }    }
78    return;    return;
79  }  }
80    
81    void Finley_ElementFile_setTagsInUse(Finley_ElementFile* in)
82    {
83        index_t *tagsInUse=NULL;
84        dim_t numTagsInUse;
85        if (in !=NULL) {
86           Finley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
87           if (Finley_noError()) {
88              MEMFREE(in->tagsInUse);
89              in->tagsInUse=tagsInUse;
90              in->numTagsInUse=numTagsInUse;
91           }
92        }
93    }
94    
95  /*  deallocates the element table within an element file: */  /*  deallocates the element table within an element file: */
96    
97  void Finley_ElementFile_deallocTable(Finley_ElementFile* in) {  void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
98      MEMFREE(in->Owner);
99    MEMFREE(in->Id);    MEMFREE(in->Id);
100    MEMFREE(in->Nodes);    MEMFREE(in->Nodes);
101    MEMFREE(in->Tag);    MEMFREE(in->Tag);
102    MEMFREE(in->Color);    MEMFREE(in->Color);
103      MEMFREE(in->tagsInUse);
104      in->numTagsInUse=0;
105    in->numElements=0;    in->numElements=0;
106    in->numColors=0;    in->maxColor=-1;
107      in->minColor=0;
108  }  }
   
 /*  
 * $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.1766

  ViewVC Help
Powered by ViewVC 1.1.26