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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/ElementFile_allocTable.c
File MIME type: text/plain
File size: 2373 byte(s)
Initial revision

1 jgs 82 /* $Id$ */
2     /**************************************************************/
3    
4     /* Finley: ElementFile */
5    
6     /* allocates and deallocates element table */
7    
8     /**************************************************************/
9    
10     /* Copyrights by ACcESS Australia 2003 */
11     /* Author: gross@access.edu.au */
12     /* Version: $Id$ */
13    
14     /**************************************************************/
15    
16     #include "Finley.h"
17     #include "ElementFile.h"
18    
19     /****************************************************************************/
20    
21     /* allocates the element table within an element file to hold numElements: */
22    
23     void Finley_ElementFile_allocTable(Finley_ElementFile* in,int numElements) {
24     maybelong *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
25     maybelong numNodes,e,i;
26    
27     /* allocate memory: */
28    
29     numNodes=(maybelong) in->ReferenceElement->Type->numNodes;
30     Id2=(maybelong*) MEMALLOC(numElements*sizeof(maybelong));
31     Nodes2=(maybelong*) MEMALLOC(numElements*numNodes*sizeof(maybelong));
32     Tag2=(maybelong*) MEMALLOC(numElements*sizeof(maybelong));
33     Color2=(maybelong*) MEMALLOC(numElements*sizeof(maybelong));
34    
35     /* if fine, deallocate the old table and replace by new: */
36    
37     if (Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Color2)) {
38     MEMFREE(Id2);
39     MEMFREE(Nodes2);
40     MEMFREE(Tag2);
41     MEMFREE(Color2);
42     } else {
43     Finley_ElementFile_deallocTable(in);
44     in->numElements=numElements;
45     in->Id=Id2;
46     in->Nodes=Nodes2;
47     in->Tag=Tag2;
48     in->Color=Color2;
49    
50     /* this initialization makes sure that data are located on the right processor */
51    
52     #pragma omp parallel for private(e,i) schedule(static)
53     for (e=0;e<numElements;e++) {
54     for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;
55     in->Id[e]=-1;
56     in->Tag[e]=-1;
57     in->Color[e]=-1;
58     }
59     in->numColors=0;
60     }
61     return;
62     }
63    
64     /* deallocates the element table within an element file: */
65    
66     void Finley_ElementFile_deallocTable(Finley_ElementFile* in) {
67     MEMFREE(in->Id);
68     MEMFREE(in->Nodes);
69     MEMFREE(in->Tag);
70     MEMFREE(in->Color);
71     in->numElements=0;
72     in->numColors=0;
73     }
74    
75     /*
76     * $Log$
77     * Revision 1.1 2004/10/26 06:53:57 jgs
78     * Initial revision
79     *
80     * Revision 1.1.1.1 2004/06/24 04:00:40 johng
81     * Initial version of eys using boost-python.
82     *
83     *
84     */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26