/[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 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/plain
File size: 3056 byte(s)
And get the *(&(*&(* name right
1
2 /* $Id: ElementFile_optimizeOrdering.c 1306 2007-09-18 05:51:09Z ksteube $ */
3
4 /*******************************************************
5 *
6 * Copyright 2003-2007 by ACceSS MNRF
7 * Copyright 2007 by University of Queensland
8 *
9 * http://esscc.uq.edu.au
10 * Primary Business: Queensland, Australia
11 * Licensed under the Open Software License version 3.0
12 * http://www.opensource.org/licenses/osl-3.0.php
13 *
14 *******************************************************/
15
16 /**************************************************************/
17 /* */
18 /* Finley: 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 Finley_ElementFile_optimizeOrdering(Finley_ElementFile** in) {
30 Finley_Util_ValueAndIndex* item_list=NULL;
31 Finley_ElementFile* out=NULL;
32 dim_t e,i, NN;
33 index_t *index=NULL;
34 if (*in != NULL) {
35 if ((*in)->numElements<1) return;
36 NN=(*in)->ReferenceElement->Type->numNodes;
37 item_list=TMPMEMALLOC((*in)->numElements,Finley_Util_ValueAndIndex);
38 index=TMPMEMALLOC((*in)->numElements,index_t);
39 if (! (Finley_checkPtr(item_list) || Finley_checkPtr(index)) ) {
40
41 out=Finley_ElementFile_alloc((*in)->ReferenceElement->Type->TypeId,(*in)->order, (*in)->reduced_order, (*in)->MPIInfo);
42 if (Finley_noError()) {
43 Finley_ElementFile_allocTable(out,(*in)->numElements);
44 if (Finley_noError()) {
45 #pragma omp parallel for private(e,i) schedule(static)
46 for (e=0;e<(*in)->numElements;e++) {
47 item_list[e].index=e;
48 item_list[e].value=(*in)->Nodes[INDEX2(0,e,NN)];
49 for (i=1;i<NN;i++) item_list[e].value=MIN(item_list[e].value,(*in)->Nodes[INDEX2(i,e,NN)]);
50 }
51 Finley_Util_sortValueAndIndex((*in)->numElements,item_list);
52 #pragma omp parallel for private(e) schedule(static)
53 for (e=0;e<(*in)->numElements;e++) index[e]=item_list[e].index;
54 Finley_ElementFile_gather(index,*in,out);
55 Finley_ElementFile_free(*in);
56 *in=out;
57 } else {
58 Finley_ElementFile_free(out);
59 }
60 }
61 }
62 TMPMEMFREE(item_list);
63 TMPMEMFREE(index);
64 }
65 }

  ViewVC Help
Powered by ViewVC 1.1.26