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

Contents of /trunk-mpi-branch/finley/src/Mesh_prepare.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (11 years, 8 months ago) by gross
File MIME type: text/plain
File size: 4783 byte(s)
first attemt towards an improved MPI version.  

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: Mesh: prepares the mesh for further calculations */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "Mesh.h"
25
26 /**************************************************************/
27
28 void Finley_Mesh_prepare(Finley_Mesh* in) {
29
30 dim_t newGlobalNumDOFs=0;
31 Paso_MPI_rank* mpiRankOfDOF=NULL;
32 index_t* distribution=NULL;
33 if (in==NULL) return;
34 if (in->Nodes == NULL) return;
35
36 /* first step is to distribute the elements according to a global distribution of DOF */
37
38 mpiRankOfDOF=TMPMEMALLOC(in->Nodes->numNodes,Paso_MPI_rank);
39 distribution=TMPMEMALLOC(in->MPIInfo->size+1,index_t);
40 if (!(Finley_checkPtr(mpiRankOfDOF) || Finley_checkPtr(distribution))) {
41 /* first we create dense labeling for the DOFs */
42 newGlobalNumDOFs=Finley_NodeFile_createDenseDOFLabeling(in->Nodes);
43 /* create a distribution of the global DOFs and determine
44 the MPI_rank controling the DOFs on this processor */
45 Paso_MPIInfo_setDistribution(in->MPIInfo,0,newGlobalNumDOFs-1,distribution);
46 Finley_NodeFile_assignMPIRankToDOFs(in->Nodes,mpiRankOfDOF,distribution);
47
48 /* now the mesh is re-distributed according to the mpiRankOfDOF vector */
49 /* this will redistribute the Nodes and Elements including overlap and will create an element coloring
50 but will not create any mappings (see later in this function) */
51 if (Finley_noError()) Finley_Mesh_distributeByRankOfDOF(in,mpiRankOfDOF);
52 }
53 TMPMEMFREE(mpiRankOfDOF);
54 TMPMEMFREE(distribution);
55 if (!Finley_noError()) return;
56
57 /* at this stage we are able to start an optimization of the DOF distribution using ParaMetis */
58
59 /* now a local labeling of the DOF is introduced */
60 return;
61
62 /* set the labeling vectors in node files: */
63 Finley_Mesh_prepareNodes(in);
64
65 /* rearrange elements: */
66 Finley_Mesh_optimizeElementDistribution(in);
67
68 /* improve coloring */
69 /* precoloring! */
70 Finley_Mesh_improveColoring(in);
71 }
72
73 bool_t Finley_Mesh_isPrepared(Finley_Mesh* in) {
74 /* returns true if nodes and elements have been prepared for calculation */
75 index_t out = TRUE;
76 if ( in->Nodes != NULL) out = MIN(out , in->Nodes->isPrepared);
77 if ( in->Elements != NULL) out = MIN(out , in->Elements->isPrepared);
78 if ( in->FaceElements != NULL) out = MIN(out , in->FaceElements->isPrepared);
79 if ( in->ContactElements != NULL) out = MIN(out , in->ContactElements->isPrepared);
80 if ( in->Points != NULL) out = MIN(out , in->Points->isPrepared);
81
82 return out == FINLEY_PREPARED;
83 }
84 /* */
85 /* tries to reduce the coloring for all element files: */
86 /* */
87 void Finley_Mesh_improveColoring(Finley_Mesh* in) {
88 Finley_ElementFile_improveColoring(in->Elements,in->Nodes->degreesOfFreedomMapping->numNodes,in->Nodes->degreesOfFreedomMapping->target);
89 Finley_ElementFile_improveColoring(in->FaceElements,in->Nodes->degreesOfFreedomMapping->numNodes,in->Nodes->degreesOfFreedomMapping->target);
90 Finley_ElementFile_improveColoring(in->Points,in->Nodes->degreesOfFreedomMapping->numNodes,in->Nodes->degreesOfFreedomMapping->target);
91 Finley_ElementFile_improveColoring(in->ContactElements,in->Nodes->degreesOfFreedomMapping->numNodes,in->Nodes->degreesOfFreedomMapping->target);
92 }
93 /* */
94 /* redistribute elements to minimize communication during assemblage */
95 /* */
96 void Finley_Mesh_optimizeElementDistribution(Finley_Mesh* in) {
97 Finley_ElementFile_optimizeDistribution(&(in->Elements));
98 Finley_ElementFile_optimizeDistribution(&(in->FaceElements));
99 Finley_ElementFile_optimizeDistribution(&(in->Points));
100 Finley_ElementFile_optimizeDistribution(&(in->ContactElements));
101 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26