/[escript]/trunk/dudley/src/Mesh_distributeByRankOfDOF.c
ViewVC logotype

Contents of /trunk/dudley/src/Mesh_distributeByRankOfDOF.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 3770 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14 /**************************************************************/
15
16 /* Dudley: Mesh: this will redistribute the Nodes and Elements including overlap */
17 /* according to the dof_distribiution. It will create an element coloring but will not create any mappings. */
18
19 /**************************************************************/
20
21 #include "Mesh.h"
22
23 /**************************************************************/
24
25 void Dudley_Mesh_distributeByRankOfDOF(Dudley_Mesh * self, index_t * dof_distribution)
26 {
27
28 index_t min_dof_id, max_dof_id, *tmp_node_localDOF_map = NULL, *tmp_node_localDOF_mask = NULL;
29 Esys_MPI_rank *mpiRankOfDOF = NULL;
30 register index_t k;
31 dim_t len, n, numDOFs;
32
33 if (self == NULL)
34 return;
35 mpiRankOfDOF = TMPMEMALLOC(self->Nodes->numNodes, Esys_MPI_rank);
36 if (!Dudley_checkPtr(mpiRankOfDOF))
37 {
38
39 Dudley_NodeFile_assignMPIRankToDOFs(self->Nodes, mpiRankOfDOF, dof_distribution);
40
41 /* first the elements are redistributed according to mpiRankOfDOF */
42 /* at the input the Node tables refering to a the local labeling of the nodes */
43 /* while at the output they refer to the global labeling which is rectified in the next step */
44 if (Dudley_noError())
45 Dudley_ElementFile_distributeByRankOfDOF(self->Elements, mpiRankOfDOF, self->Nodes->Id);
46 if (Dudley_noError())
47 Dudley_ElementFile_distributeByRankOfDOF(self->FaceElements, mpiRankOfDOF, self->Nodes->Id);
48 if (Dudley_noError())
49 Dudley_ElementFile_distributeByRankOfDOF(self->Points, mpiRankOfDOF, self->Nodes->Id);
50
51 /* resolve the node ids */
52 if (Dudley_noError())
53 Dudley_Mesh_resolveNodeIds(self);
54
55 /* create a local labeling of the DOFs */
56 Dudley_NodeFile_setDOFRange(&min_dof_id, &max_dof_id, self->Nodes);
57 len = max_dof_id - min_dof_id + 1;
58 tmp_node_localDOF_mask = TMPMEMALLOC(len, index_t); /* local mask for used nodes */
59 tmp_node_localDOF_map = TMPMEMALLOC(self->Nodes->numNodes, index_t);
60 if (!((Dudley_checkPtr(tmp_node_localDOF_mask) && Dudley_checkPtr(tmp_node_localDOF_map))))
61 {
62
63 #pragma omp parallel for private(n) schedule(static)
64 for (n = 0; n < len; n++)
65 tmp_node_localDOF_mask[n] = -1;
66
67 #pragma omp parallel for private (n) schedule(static)
68 for (n = 0; n < self->Nodes->numNodes; n++)
69 tmp_node_localDOF_map[n] = -1;
70
71 #pragma omp parallel for private(n) schedule(static)
72 for (n = 0; n < self->Nodes->numNodes; n++)
73 {
74 #ifdef BOUNDS_CHECK
75 if ((self->Nodes->globalDegreesOfFreedom[n] - min_dof_id) >= len
76 || (self->Nodes->globalDegreesOfFreedom[n] - min_dof_id) < 0)
77 {
78 printf("BOUNDS_CHECK %s %d\n", __FILE__, __LINE__);
79 exit(1);
80 }
81 #endif
82 tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n] - min_dof_id] = n;
83 }
84
85 numDOFs = 0;
86 for (n = 0; n < len; n++)
87 {
88 k = tmp_node_localDOF_mask[n];
89 if (k >= 0)
90 {
91 tmp_node_localDOF_mask[n] = numDOFs;
92 numDOFs++;
93 }
94 }
95 #pragma omp parallel for private (n,k)
96 for (n = 0; n < self->Nodes->numNodes; n++)
97 {
98 k = tmp_node_localDOF_mask[self->Nodes->globalDegreesOfFreedom[n] - min_dof_id];
99 tmp_node_localDOF_map[n] = k;
100 }
101 /* create element coloring */
102 if (Dudley_noError())
103 Dudley_Mesh_createColoring(self, tmp_node_localDOF_map);
104
105 }
106 TMPMEMFREE(tmp_node_localDOF_mask);
107 TMPMEMFREE(tmp_node_localDOF_map);
108 }
109 TMPMEMFREE(mpiRankOfDOF);
110 return;
111 }

  ViewVC Help
Powered by ViewVC 1.1.26