2
/*******************************************************
4
* Copyright (c) 2003-2010 by University of Queensland
5
* Earth Systems Science Computational Center (ESSCC)
6
* http://www.uq.edu.au/esscc
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
12
*******************************************************/
14
/**************************************************************/
16
/* Dudley: ElementFile */
18
/* allocates and deallocates element table */
20
/**************************************************************/
22
#include "ElementFile.h"
25
/****************************************************************************/
27
/* allocates the element table within an element file to hold numElements: */
29
void Dudley_ElementFile_allocTable(Dudley_ElementFile * in, dim_t numElements)
31
index_t *Id2 = NULL, *Nodes2 = NULL, *Tag2 = NULL, *Color2 = NULL;
32
Esys_MPI_rank *Owner2 = NULL;
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);
44
/* if fine, deallocate the old table and replace by new: */
46
if (Dudley_checkPtr(Owner2) || Dudley_checkPtr(Id2) || Dudley_checkPtr(Nodes2) ||
47
Dudley_checkPtr(Tag2) || Dudley_checkPtr(Color2))
57
Dudley_ElementFile_freeTable(in);
59
in->numElements = numElements;
65
/* this initialization makes sure that data are located on the right processor */
67
#pragma omp parallel for private(e,i) schedule(static)
68
for (e = 0; e < numElements; e++)
70
for (i = 0; i < numNodes; i++)
71
in->Nodes[INDEX2(i, e, numNodes)] = -1;
83
void Dudley_ElementFile_setTagsInUse(Dudley_ElementFile * in)
85
index_t *tagsInUse = NULL;
89
Dudley_Util_setValuesInUse(in->Tag, in->numElements, &numTagsInUse, &tagsInUse, in->MPIInfo);
92
MEMFREE(in->tagsInUse);
93
in->tagsInUse = tagsInUse;
94
in->numTagsInUse = numTagsInUse;
99
/* deallocates the element table within an element file: */
101
void Dudley_ElementFile_freeTable(Dudley_ElementFile * in)
108
MEMFREE(in->tagsInUse);
109
in->numTagsInUse = 0;