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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/plain
File size: 3000 byte(s)
Copyright updated in all files

1
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 */
18
19 /* allocates and deallocates element table */
20
21 /**************************************************************/
22
23
24 #include "ElementFile.h"
25 #include "Util.h"
26
27 /****************************************************************************/
28
29 /* allocates the element table within an element file to hold numElements: */
30
31 void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
32 {
33 index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
34 Paso_MPI_rank *Owner2=NULL;
35 dim_t numNodes,e,i;
36
37 Finley_resetError();
38 /* allocate memory: */
39 numNodes=in->numNodes;
40 Owner2=MEMALLOC(numElements,Paso_MPI_rank);
41 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: */
47
48 if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
49 Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
50 MEMFREE(Owner2);
51 MEMFREE(Nodes2);
52 MEMFREE(Id2);
53 MEMFREE(Tag2);
54 MEMFREE(Color2);
55 } else {
56 Finley_ElementFile_freeTable(in);
57 in->Owner=Owner2;
58 in->numElements=numElements;
59 in->Id=Id2;
60 in->Nodes=Nodes2;
61 in->Tag=Tag2;
62 in->Color=Color2;
63
64 /* this initialization makes sure that data are located on the right processor */
65
66 #pragma omp parallel for private(e,i) schedule(static)
67 for (e=0;e<numElements;e++) {
68 for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;
69 in->Owner[e]=-1;
70 in->Id[e]=-1;
71 in->Tag[e]=-1;
72 in->Color[e]=-1;
73 }
74 in->maxColor=-1;
75 in->minColor=0;
76 }
77 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: */
95
96 void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
97 MEMFREE(in->Owner);
98 MEMFREE(in->Id);
99 MEMFREE(in->Nodes);
100 MEMFREE(in->Tag);
101 MEMFREE(in->Color);
102 MEMFREE(in->tagsInUse);
103 in->numTagsInUse=0;
104 in->numElements=0;
105 in->maxColor=-1;
106 in->minColor=0;
107 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26