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

Annotation of /trunk/finley/src/ElementFile_optimizeOrdering.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 2905 byte(s)
Don't panic.
Updating copyright stamps

1 ksteube 1315
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 ksteube 1315
14 ksteube 1811
15 ksteube 1315 /**************************************************************/
16     /* */
17     /* Finley: ElementFile */
18     /* */
19     /* reorders the elements in the element file such that the elements are stored close to the nodes */
20     /* */
21     /**************************************************************/
22    
23     #include "Util.h"
24     #include "ElementFile.h"
25    
26     /**************************************************************/
27    
28     void Finley_ElementFile_optimizeOrdering(Finley_ElementFile** in) {
29     Finley_Util_ValueAndIndex* item_list=NULL;
30     Finley_ElementFile* out=NULL;
31     dim_t e,i, NN;
32     index_t *index=NULL;
33     if (*in != NULL) {
34     if ((*in)->numElements<1) return;
35 gross 2748 NN=(*in)->referenceElementSet->numNodes;
36 ksteube 1315 item_list=TMPMEMALLOC((*in)->numElements,Finley_Util_ValueAndIndex);
37     index=TMPMEMALLOC((*in)->numElements,index_t);
38     if (! (Finley_checkPtr(item_list) || Finley_checkPtr(index)) ) {
39    
40 gross 2748 out=Finley_ElementFile_alloc((*in)->referenceElementSet, (*in)->MPIInfo);
41 ksteube 1315 if (Finley_noError()) {
42     Finley_ElementFile_allocTable(out,(*in)->numElements);
43     if (Finley_noError()) {
44     #pragma omp parallel for private(e,i) schedule(static)
45     for (e=0;e<(*in)->numElements;e++) {
46     item_list[e].index=e;
47     item_list[e].value=(*in)->Nodes[INDEX2(0,e,NN)];
48     for (i=1;i<NN;i++) item_list[e].value=MIN(item_list[e].value,(*in)->Nodes[INDEX2(i,e,NN)]);
49     }
50     Finley_Util_sortValueAndIndex((*in)->numElements,item_list);
51     #pragma omp parallel for private(e) schedule(static)
52     for (e=0;e<(*in)->numElements;e++) index[e]=item_list[e].index;
53     Finley_ElementFile_gather(index,*in,out);
54     Finley_ElementFile_free(*in);
55     *in=out;
56     } else {
57     Finley_ElementFile_free(out);
58     }
59     }
60     }
61     TMPMEMFREE(item_list);
62     TMPMEMFREE(index);
63     }
64     }

  ViewVC Help
Powered by ViewVC 1.1.26