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

Contents of /trunk-mpi-branch/finley/src/ElementFile_allocTable.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1267 - (show annotations)
Tue Aug 21 22:01:21 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 2819 byte(s)
check for preperation status removed. is not really needed.
1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* Finley: ElementFile */
16
17 /* allocates and deallocates element table */
18
19 /**************************************************************/
20
21 /* Author: gross@access.edu.au */
22 /* Version: $Id$ */
23
24 /**************************************************************/
25
26 #include "ElementFile.h"
27
28 /****************************************************************************/
29
30 /* allocates the element table within an element file to hold numElements: */
31
32 void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
33 {
34 index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
35 Paso_MPI_rank *Owner2=NULL;
36 dim_t numNodes,e,i;
37
38 Finley_resetError();
39 /* 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
47 /* if fine, deallocate the old table and replace by new: */
48
49 if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
50 Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
51 MEMFREE(Owner2);
52 MEMFREE(Nodes2);
53 MEMFREE(Id2);
54 MEMFREE(Tag2);
55 MEMFREE(Color2);
56 } else {
57 Finley_ElementFile_freeTable(in);
58 in->Owner=Owner2;
59 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 in->Owner[e]=-1;
71 in->Id[e]=-1;
72 in->Tag[e]=-1;
73 in->Color[e]=-1;
74 }
75 in->maxColor=-1;
76 in->minColor=0;
77 }
78 return;
79 }
80
81 /* deallocates the element table within an element file: */
82
83 void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
84 MEMFREE(in->Owner);
85 MEMFREE(in->Id);
86 MEMFREE(in->Nodes);
87 MEMFREE(in->Tag);
88 MEMFREE(in->Color);
89 in->numElements=0;
90 in->maxColor=-1;
91 in->minColor=0;
92 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26