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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 3000 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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 /* Dudley: ElementFile */
17
18 /* allocates and deallocates element table */
19
20 /**************************************************************/
21
22 #include "ElementFile.h"
23 #include "Util.h"
24
25 /****************************************************************************/
26
27 /* allocates the element table within an element file to hold numElements: */
28
29 void Dudley_ElementFile_allocTable(Dudley_ElementFile * in, dim_t numElements)
30 {
31 index_t *Id2 = NULL, *Nodes2 = NULL, *Tag2 = NULL, *Color2 = NULL;
32 Esys_MPI_rank *Owner2 = NULL;
33 dim_t numNodes, e, i;
34
35 Dudley_resetError();
36 /* allocate memory: */
37 numNodes = in->numNodes;
38 Owner2 = MEMALLOC(numElements, Esys_MPI_rank);
39 Id2 = MEMALLOC(numElements, index_t);
40 Nodes2 = MEMALLOC(numElements * in->numNodes, index_t);
41 Tag2 = MEMALLOC(numElements, index_t);
42 Color2 = MEMALLOC(numElements, index_t);
43
44 /* if fine, deallocate the old table and replace by new: */
45
46 if (Dudley_checkPtr(Owner2) || Dudley_checkPtr(Id2) || Dudley_checkPtr(Nodes2) ||
47 Dudley_checkPtr(Tag2) || Dudley_checkPtr(Color2))
48 {
49 MEMFREE(Owner2);
50 MEMFREE(Nodes2);
51 MEMFREE(Id2);
52 MEMFREE(Tag2);
53 MEMFREE(Color2);
54 }
55 else
56 {
57 Dudley_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 {
70 for (i = 0; i < numNodes; i++)
71 in->Nodes[INDEX2(i, e, numNodes)] = -1;
72 in->Owner[e] = -1;
73 in->Id[e] = -1;
74 in->Tag[e] = -1;
75 in->Color[e] = -1;
76 }
77 in->maxColor = -1;
78 in->minColor = 0;
79 }
80 return;
81 }
82
83 void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in)
84 {
85 index_t *tagsInUse = NULL;
86 dim_t numTagsInUse;
87 if (in != NULL)
88 {
89 Dudley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
90 if (Dudley_noError())
91 {
92 MEMFREE(in->tagsInUse);
93 in->tagsInUse = tagsInUse;
94 in->numTagsInUse = numTagsInUse;
95 }
96 }
97 }
98
99 /* deallocates the element table within an element file: */
100
101 void Dudley_ElementFile_freeTable(Dudley_ElementFile * in)
102 {
103 MEMFREE(in->Owner);
104 MEMFREE(in->Id);
105 MEMFREE(in->Nodes);
106 MEMFREE(in->Tag);
107 MEMFREE(in->Color);
108 MEMFREE(in->tagsInUse);
109 in->numTagsInUse = 0;
110 in->numElements = 0;
111 in->maxColor = -1;
112 in->minColor = 0;
113 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26