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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (hide annotations)
Wed Dec 15 07:08:39 2004 UTC (15 years, 6 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/ElementFile_allocTable.c
File MIME type: text/plain
File size: 2206 byte(s)
*** empty log message ***

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 jgs 102 Id2=MEMALLOC(numElements,maybelong);
31     Nodes2=MEMALLOC(numElements*numNodes,maybelong);
32     Tag2=MEMALLOC(numElements,maybelong);
33     Color2=MEMALLOC(numElements,maybelong);
34 jgs 82
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 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
78 jgs 97 * *** empty log message ***
79 jgs 82 *
80 jgs 97 *
81 jgs 82 *
82     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26