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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 2655 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 /* reorders the elements in the element file such that the elements are stored close to the nodes */
19 /* */
20 /**************************************************************/
21
22 #include "Util.h"
23 #include "ElementFile.h"
24
25 /**************************************************************/
26
27 void Dudley_ElementFile_optimizeOrdering(Dudley_ElementFile ** in)
28 {
29 Dudley_Util_ValueAndIndex *item_list = NULL;
30 Dudley_ElementFile *out = NULL;
31 dim_t e, i, NN;
32 index_t *index = NULL;
33 if (*in != NULL)
34 {
35 if ((*in)->numElements < 1)
36 return;
37 NN = (*in)-> /*referenceElementSet-> */ numNodes;
38 item_list = TMPMEMALLOC((*in)->numElements, Dudley_Util_ValueAndIndex);
39 index = TMPMEMALLOC((*in)->numElements, index_t);
40 if (!(Dudley_checkPtr(item_list) || Dudley_checkPtr(index)))
41 {
42
43 out = Dudley_ElementFile_alloc((*in)->etype /*referenceElementSet */ , (*in)->MPIInfo);
44 if (Dudley_noError())
45 {
46 Dudley_ElementFile_allocTable(out, (*in)->numElements);
47 if (Dudley_noError())
48 {
49 #pragma omp parallel for private(e,i) schedule(static)
50 for (e = 0; e < (*in)->numElements; e++)
51 {
52 item_list[e].index = e;
53 item_list[e].value = (*in)->Nodes[INDEX2(0, e, NN)];
54 for (i = 1; i < NN; i++)
55 item_list[e].value = MIN(item_list[e].value, (*in)->Nodes[INDEX2(i, e, NN)]);
56 }
57 Dudley_Util_sortValueAndIndex((*in)->numElements, item_list);
58 #pragma omp parallel for private(e) schedule(static)
59 for (e = 0; e < (*in)->numElements; e++)
60 index[e] = item_list[e].index;
61 Dudley_ElementFile_gather(index, *in, out);
62 Dudley_ElementFile_free(*in);
63 *in = out;
64 }
65 else
66 {
67 Dudley_ElementFile_free(out);
68 }
69 }
70 }
71 TMPMEMFREE(item_list);
72 TMPMEMFREE(index);
73 }
74 }

  ViewVC Help
Powered by ViewVC 1.1.26