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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1231 - (show annotations)
Fri Aug 10 06:34:21 2007 UTC (12 years, 9 months ago) by ksteube
File MIME type: text/plain
File size: 3692 byte(s)
New parallelization now compiles on Altix
Some boost_ variables in options files were mis-spelled
Added -DMPI_NO_CPPBIND so mpi.h doesn't include mpi++.h and cause extern "C" confusion
Removed blockpapi until I fix it

1 /*
2 ************************************************************
3 * Copyright 2007 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: this will redistribute the Nodes and Elements including overlap */
16 /* according to the dof_distribiution. It will create an element coloring but will not create any mappings. */
17
18 /**************************************************************/
19
20 /* Author: gross@access.edu.au */
21 /* Version: $Id:$ */
22
23 /**************************************************************/
24
25 #include "Mesh.h"
26
27 /**************************************************************/
28
29 void Finley_Mesh_distributeByRankOfDOF(Finley_Mesh* self, index_t *dof_distribution) {
30
31 index_t min_id, max_id, *tmp_node_localDOF_map=NULL, *tmp_node_localDOF_mask=NULL;
32 Paso_MPI_rank* mpiRankOfDOF=NULL;
33 register index_t k;
34 dim_t len,n,numDOFs;
35
36 if (self==NULL) return;
37 mpiRankOfDOF=TMPMEMALLOC(self->Nodes->numNodes,Paso_MPI_rank);
38 if (!Finley_checkPtr(mpiRankOfDOF)) {
39
40 Finley_NodeFile_assignMPIRankToDOFs(self->Nodes,mpiRankOfDOF,dof_distribution);
41
42 /* first the elements are redistributed according to mpiRankOfDOF */
43 /* at the input the Node tables refering to a the local labeling of the nodes */
44 /* while at the output they refer to the global labeling which is rectified in the next step */
45 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Elements,mpiRankOfDOF, self->Nodes->Id);
46 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->FaceElements,mpiRankOfDOF, self->Nodes->Id);
47 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->ContactElements,mpiRankOfDOF, self->Nodes->Id);
48 if (Finley_noError()) Finley_ElementFile_distributeByRankOfDOF(self->Points,mpiRankOfDOF, self->Nodes->Id);
49
50 /* resolve the node ids */
51 if (Finley_noError()) Finley_Mesh_resolveNodeIds(self);
52
53 /* create a local labeling of the DOFs */
54 Finley_NodeFile_setDOFRange(&min_id,&max_id,self->Nodes);
55 len=max_id-min_id+1;
56 tmp_node_localDOF_mask=TMPMEMALLOC(len,index_t); /* local mask for used nodes */
57 tmp_node_localDOF_map=TMPMEMALLOC(len,index_t);
58 if (! ( (Finley_checkPtr(tmp_node_localDOF_mask) && Finley_checkPtr(tmp_node_localDOF_map) ) ) ) {
59
60 #pragma omp parallel for private(n) schedule(static)
61 for (n=0;n<len;n++) tmp_node_localDOF_mask[n]=-1;
62 #pragma omp parallel for private(n) schedule(static)
63 for (n=0;n<self->Nodes->numNodes;n++) tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n]-min_id]=n;
64
65 numDOFs=0;
66 for (n=0;n<len;n++) {
67 k=tmp_node_localDOF_mask[n];
68 if (k>=0) {
69 tmp_node_localDOF_map[k]=numDOFs;
70 numDOFs++;
71 }
72 }
73 /* create element coloring */
74 if (Finley_noError()) Finley_Mesh_createColoring(self,tmp_node_localDOF_map);
75
76 }
77 TMPMEMFREE(tmp_node_localDOF_mask);
78 TMPMEMFREE(tmp_node_localDOF_map);
79 }
80 TMPMEMFREE(mpiRankOfDOF);
81 return;
82 }

  ViewVC Help
Powered by ViewVC 1.1.26