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

  ViewVC Help
Powered by ViewVC 1.1.26