/[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 1766 - (hide annotations)
Mon Sep 8 02:51:14 2008 UTC (11 years, 2 months ago) by gross
File MIME type: text/plain
File size: 3035 byte(s)
code formatting
1 jgs 150
2 ksteube 1312 /* $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 jgs 82 /**************************************************************/
17    
18     /* Finley: ElementFile */
19    
20     /* allocates and deallocates element table */
21    
22     /**************************************************************/
23    
24 gross 1766
25 jgs 82 #include "ElementFile.h"
26 gross 1766 #include "Util.h"
27 jgs 82
28     /****************************************************************************/
29    
30     /* allocates the element table within an element file to hold numElements: */
31    
32 ksteube 1312 void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
33     {
34 jgs 123 index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
35 ksteube 1312 Paso_MPI_rank *Owner2=NULL;
36 jgs 123 dim_t numNodes,e,i;
37 gross 1028
38 jgs 150 Finley_resetError();
39 ksteube 1312 /* allocate memory: */
40     numNodes=in->numNodes;
41     Owner2=MEMALLOC(numElements,Paso_MPI_rank);
42     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 jgs 82
47     /* if fine, deallocate the old table and replace by new: */
48    
49 ksteube 1312 if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
50     Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
51     MEMFREE(Owner2);
52 bcumming 782 MEMFREE(Nodes2);
53 jgs 82 MEMFREE(Id2);
54     MEMFREE(Tag2);
55     MEMFREE(Color2);
56     } else {
57 ksteube 1312 Finley_ElementFile_freeTable(in);
58     in->Owner=Owner2;
59 jgs 82 in->numElements=numElements;
60     in->Id=Id2;
61     in->Nodes=Nodes2;
62     in->Tag=Tag2;
63     in->Color=Color2;
64    
65     /* this initialization makes sure that data are located on the right processor */
66    
67     #pragma omp parallel for private(e,i) schedule(static)
68     for (e=0;e<numElements;e++) {
69     for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;
70 ksteube 1312 in->Owner[e]=-1;
71 jgs 82 in->Id[e]=-1;
72     in->Tag[e]=-1;
73     in->Color[e]=-1;
74     }
75 jgs 123 in->maxColor=-1;
76     in->minColor=0;
77 jgs 82 }
78     return;
79     }
80    
81 gross 1716 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 jgs 82 /* deallocates the element table within an element file: */
96    
97 ksteube 1312 void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
98     MEMFREE(in->Owner);
99 jgs 82 MEMFREE(in->Id);
100     MEMFREE(in->Nodes);
101     MEMFREE(in->Tag);
102     MEMFREE(in->Color);
103 gross 1716 MEMFREE(in->tagsInUse);
104     in->numTagsInUse=0;
105 jgs 82 in->numElements=0;
106 jgs 123 in->maxColor=-1;
107     in->minColor=0;
108 jgs 82 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26