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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1384 - (hide annotations)
Fri Jan 11 02:29:38 2008 UTC (11 years, 9 months ago) by phornby
Original Path: temp_trunk_copy/finley/src/Mesh_prepare.c
File MIME type: text/plain
File size: 5158 byte(s)
Make a temp copy of the trunk before checking in the windows changes


1 jgs 150
2 ksteube 1312 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
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 jgs 82
16     /**************************************************************/
17    
18 ksteube 1312 /* Finley: Mesh: prepares the mesh for further calculations */
19 jgs 82
20     /**************************************************************/
21    
22     #include "Mesh.h"
23    
24     /**************************************************************/
25    
26 ksteube 1312 void Finley_Mesh_prepare(Finley_Mesh* in, bool_t optimize) {
27     dim_t newGlobalNumDOFs=0, numReducedNodes=0,i;
28     index_t* distribution=NULL, *maskReducedNodes=NULL, *indexReducedNodes=NULL;
29     if (in==NULL) return;
30     if (in->Nodes == NULL) return;
31 jgs 82
32 ksteube 1312 /* first step is to distribute the elements according to a global distribution of DOF */
33 jgs 82
34 ksteube 1312 distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);
35     if (! Finley_checkPtr(distribution)) {
36     /* first we create dense labeling for the DOFs */
37     newGlobalNumDOFs=Finley_NodeFile_createDenseDOFLabeling(in->Nodes);
38 jgs 82
39 ksteube 1312 /* create a distribution of the global DOFs and determine
40     the MPI_rank controling the DOFs on this processor */
41     Paso_MPIInfo_setDistribution(in->MPIInfo,0,newGlobalNumDOFs-1,distribution);
42 gross 964
43 ksteube 1312 /* now the mesh is re-distributed according to the mpiRankOfDOF vector */
44     /* this will redistribute the Nodes and Elements including overlap and will create an element coloring
45     but will not create any mappings (see later in this function) */
46     if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);
47     }
48 gross 964
49 ksteube 1312 /* at this stage we are able to start an optimization of the DOF distribution using ParaMetis */
50     /* on return distribution is altered and new DOF ids have been assigned */
51     if (Finley_noError() && optimize && in->MPIInfo->size>1) {
52    
53     Finley_Mesh_optimizeDOFDistribution(in,distribution);
54    
55     if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,distribution);
56    
57     }
58     /* now a local labeling of the DOF is introduced */
59     if (Finley_noError() && optimize) {
60     Finley_Mesh_optimizeDOFLabeling(in,distribution);
61     }
62     /* rearrange elements with the attempt to bring elements closer to memory locations of the nodes (distributed shared memory!): */
63     if (Finley_noError()) Finley_Mesh_optimizeElementOrdering(in);
64    
65    
66     /* create the global indices */
67     if (Finley_noError()) {
68     maskReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);
69     indexReducedNodes=TMPMEMALLOC(in->Nodes->numNodes,index_t);
70     if (! ( Finley_checkPtr(maskReducedNodes) || Finley_checkPtr(indexReducedNodes) ) ) {
71    
72     #pragma omp parallel for private(i) schedule(static)
73     for (i=0;i<in->Nodes->numNodes;++i) maskReducedNodes[i]=-1;
74    
75     Finley_Mesh_markNodes(maskReducedNodes,0,in,1);
76    
77     numReducedNodes=Finley_Util_packMask(in->Nodes->numNodes,maskReducedNodes,indexReducedNodes);
78    
79     Finley_NodeFile_createDenseNodeLabeling(in->Nodes);
80     Finley_NodeFile_createDenseReducedNodeLabeling(in->Nodes,maskReducedNodes);
81     Finley_NodeFile_createDenseReducedDOFLabeling(in->Nodes,maskReducedNodes);
82     /* create the missing mappings */
83     if (Finley_noError()) Finley_Mesh_createNodeFileMappings(in,numReducedNodes,indexReducedNodes,distribution);
84     }
85    
86     TMPMEMFREE(maskReducedNodes);
87     TMPMEMFREE(indexReducedNodes);
88     }
89    
90     TMPMEMFREE(distribution);
91    
92     return;
93 gross 964 }
94 ksteube 1312
95 jgs 82 /* */
96     /* tries to reduce the coloring for all element files: */
97     /* */
98 ksteube 1312 void Finley_Mesh_createColoring(Finley_Mesh* in, index_t *node_localDOF_map) {
99     if (Finley_noError()) Finley_ElementFile_createColoring(in->Elements,in->Nodes->numNodes,node_localDOF_map);
100     if (Finley_noError()) Finley_ElementFile_createColoring(in->FaceElements,in->Nodes->numNodes,node_localDOF_map);
101     if (Finley_noError()) Finley_ElementFile_createColoring(in->Points,in->Nodes->numNodes,node_localDOF_map);
102     if (Finley_noError()) Finley_ElementFile_createColoring(in->ContactElements,in->Nodes->numNodes,node_localDOF_map);
103 jgs 82 }
104     /* */
105     /* redistribute elements to minimize communication during assemblage */
106     /* */
107 ksteube 1312 void Finley_Mesh_optimizeElementOrdering(Finley_Mesh* in) {
108     if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->Elements));
109     if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->FaceElements));
110     if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->Points));
111     if (Finley_noError()) Finley_ElementFile_optimizeOrdering(&(in->ContactElements));
112 jgs 82 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26