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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (show annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 2571 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1
2 /* $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 /**************************************************************/
17
18 /* Finley: ElementFile */
19
20 /* allocates and deallocates element table */
21
22 /**************************************************************/
23
24 #include "ElementFile.h"
25
26 /****************************************************************************/
27
28 /* allocates the element table within an element file to hold numElements: */
29
30 void Finley_ElementFile_allocTable(Finley_ElementFile* in,dim_t numElements)
31 {
32 index_t *Id2=NULL,*Nodes2=NULL,*Tag2=NULL,*Color2=NULL;
33 Paso_MPI_rank *Owner2=NULL;
34 dim_t numNodes,e,i;
35
36 Finley_resetError();
37 /* allocate memory: */
38 numNodes=in->numNodes;
39 Owner2=MEMALLOC(numElements,Paso_MPI_rank);
40 Id2=MEMALLOC(numElements,index_t);
41 Nodes2=MEMALLOC(numElements*in->numNodes,index_t);
42 Tag2=MEMALLOC(numElements,index_t);
43 Color2=MEMALLOC(numElements,index_t);
44
45 /* if fine, deallocate the old table and replace by new: */
46
47 if ( Finley_checkPtr(Owner2) || Finley_checkPtr(Id2) || Finley_checkPtr(Nodes2) ||
48 Finley_checkPtr(Tag2) || Finley_checkPtr(Color2) ) {
49 MEMFREE(Owner2);
50 MEMFREE(Nodes2);
51 MEMFREE(Id2);
52 MEMFREE(Tag2);
53 MEMFREE(Color2);
54 } else {
55 Finley_ElementFile_freeTable(in);
56 in->Owner=Owner2;
57 in->numElements=numElements;
58 in->Id=Id2;
59 in->Nodes=Nodes2;
60 in->Tag=Tag2;
61 in->Color=Color2;
62
63 /* this initialization makes sure that data are located on the right processor */
64
65 #pragma omp parallel for private(e,i) schedule(static)
66 for (e=0;e<numElements;e++) {
67 for (i=0;i<numNodes;i++) in->Nodes[INDEX2(i,e,numNodes)]=-1;
68 in->Owner[e]=-1;
69 in->Id[e]=-1;
70 in->Tag[e]=-1;
71 in->Color[e]=-1;
72 }
73 in->maxColor=-1;
74 in->minColor=0;
75 }
76 return;
77 }
78
79 /* deallocates the element table within an element file: */
80
81 void Finley_ElementFile_freeTable(Finley_ElementFile* in) {
82 MEMFREE(in->Owner);
83 MEMFREE(in->Id);
84 MEMFREE(in->Nodes);
85 MEMFREE(in->Tag);
86 MEMFREE(in->Color);
87 in->numElements=0;
88 in->maxColor=-1;
89 in->minColor=0;
90 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26