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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2748 - (show annotations)
Tue Nov 17 07:32:59 2009 UTC (9 years, 9 months ago) by gross
File MIME type: text/plain
File size: 2905 byte(s)
Macro elements are implemented now. VTK writer for macro elements still needs testing.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 /* */
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 NN=(*in)->referenceElementSet->numNodes;
36 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 out=Finley_ElementFile_alloc((*in)->referenceElementSet, (*in)->MPIInfo);
41 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