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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (show annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 5 months ago) by elspeth
File MIME type: text/plain
File size: 3889 byte(s)
Copyright added to more source files.

1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14 /* */
15 /* Finley: ElementFile */
16 /* */
17 /* reorders the elements in the element file such that the elements are stored close to the nodes */
18 /* */
19 /**************************************************************/
20
21 /* Author: gross@access.edu.au */
22 /* Version: $Id$ */
23
24 /**************************************************************/
25
26 #include "Util.h"
27 #include "ElementFile.h"
28
29 /**************************************************************/
30
31 void Finley_ElementFile_optimizeDistribution(Finley_ElementFile** in) {
32 Finley_Util_ValueAndIndex* item_list=NULL;
33 Finley_ElementFile* out=NULL;
34 dim_t e,i;
35 index_t *index=NULL;
36
37 if (*in != NULL) {
38 if ((*in)->numElements<1) return;
39 dim_t NN=(*in)->ReferenceElement->Type->numNodes;
40 item_list=TMPMEMALLOC((*in)->numElements,Finley_Util_ValueAndIndex);
41 index=TMPMEMALLOC((*in)->numElements,index_t);
42 if (! (Finley_checkPtr(item_list) || Finley_checkPtr(index)) ) {
43 out=Finley_ElementFile_alloc((*in)->ReferenceElement->Type->TypeId,(*in)->order);
44 if (Finley_noError()) {
45 Finley_ElementFile_allocTable(out,(*in)->numElements);
46 if (Finley_noError()) {
47 #pragma omp parallel for private(e,i) schedule(static)
48 for (e=0;e<(*in)->numElements;e++) {
49 item_list[e].index=e;
50 item_list[e].value=(*in)->Nodes[INDEX2(0,e,NN)];
51 for (i=1;i<NN;i++) item_list[e].value=MIN(item_list[e].value,(*in)->Nodes[INDEX2(i,e,NN)]);
52 }
53 Finley_Util_sortValueAndIndex((*in)->numElements,item_list);
54 #pragma omp parallel for private(e) schedule(static)
55 for (e=0;e<(*in)->numElements;e++) index[e]=item_list[e].index;
56 Finley_ElementFile_gather(index,*in,out);
57 Finley_ElementFile_dealloc(*in);
58 *in=out;
59 } else {
60 Finley_ElementFile_dealloc(out);
61 }
62 }
63 }
64 TMPMEMFREE(item_list);
65 TMPMEMFREE(index);
66 }
67 }
68 /*
69 * $Log$
70 * Revision 1.6 2005/09/15 03:44:22 jgs
71 * Merge of development branch dev-02 back to main trunk on 2005-09-15
72 *
73 * Revision 1.5.2.1 2005/09/07 06:26:18 gross
74 * the solver from finley are put into the standalone package paso now
75 *
76 * Revision 1.5 2005/07/08 04:07:50 jgs
77 * Merge of development branch back to main trunk on 2005-07-08
78 *
79 * Revision 1.4 2004/12/15 07:08:32 jgs
80 * *** empty log message ***
81 * Revision 1.1.1.1.2.2 2005/06/29 02:34:50 gross
82 * some changes towards 64 integers in finley
83 *
84 * Revision 1.1.1.1.2.1 2004/11/24 01:37:13 gross
85 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
86 *
87 *
88 *
89 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26