/[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 4154 - (show annotations)
Tue Jan 22 09:30:23 2013 UTC (6 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 3185 byte(s)
Round 1 of copyright fixes
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16 /************************************************************************************/
17
18 /* Dudley: ElementFile */
19
20 /* allocates and deallocates element table */
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 Dudley_ElementFile_allocTable(Dudley_ElementFile * in, dim_t numElements)
32 {
33 index_t *Id2 = NULL, *Nodes2 = NULL, *Tag2 = NULL, *Color2 = NULL;
34 Esys_MPI_rank *Owner2 = NULL;
35 dim_t numNodes, e, i;
36
37 Dudley_resetError();
38 /* allocate memory: */
39 numNodes = in->numNodes;
40 Owner2 = MEMALLOC(numElements, Esys_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 (Dudley_checkPtr(Owner2) || Dudley_checkPtr(Id2) || Dudley_checkPtr(Nodes2) ||
49 Dudley_checkPtr(Tag2) || Dudley_checkPtr(Color2))
50 {
51 MEMFREE(Owner2);
52 MEMFREE(Nodes2);
53 MEMFREE(Id2);
54 MEMFREE(Tag2);
55 MEMFREE(Color2);
56 }
57 else
58 {
59 Dudley_ElementFile_freeTable(in);
60 in->Owner = Owner2;
61 in->numElements = numElements;
62 in->Id = Id2;
63 in->Nodes = Nodes2;
64 in->Tag = Tag2;
65 in->Color = Color2;
66
67 /* this initialization makes sure that data are located on the right processor */
68
69 #pragma omp parallel for private(e,i) schedule(static)
70 for (e = 0; e < numElements; e++)
71 {
72 for (i = 0; i < numNodes; i++)
73 in->Nodes[INDEX2(i, e, numNodes)] = -1;
74 in->Owner[e] = -1;
75 in->Id[e] = -1;
76 in->Tag[e] = -1;
77 in->Color[e] = -1;
78 }
79 in->maxColor = -1;
80 in->minColor = 0;
81 }
82 return;
83 }
84
85 void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in)
86 {
87 index_t *tagsInUse = NULL;
88 dim_t numTagsInUse;
89 if (in != NULL)
90 {
91 Dudley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
92 if (Dudley_noError())
93 {
94 MEMFREE(in->tagsInUse);
95 in->tagsInUse = tagsInUse;
96 in->numTagsInUse = numTagsInUse;
97 }
98 }
99 }
100
101 /* deallocates the element table within an element file: */
102
103 void Dudley_ElementFile_freeTable(Dudley_ElementFile * in)
104 {
105 MEMFREE(in->Owner);
106 MEMFREE(in->Id);
107 MEMFREE(in->Nodes);
108 MEMFREE(in->Tag);
109 MEMFREE(in->Color);
110 MEMFREE(in->tagsInUse);
111 in->numTagsInUse = 0;
112 in->numElements = 0;
113 in->maxColor = -1;
114 in->minColor = 0;
115 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26