/[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 4286 - (show annotations)
Thu Mar 7 04:28:11 2013 UTC (6 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 3951 byte(s)
Assorted spelling fixes.

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

  ViewVC Help
Powered by ViewVC 1.1.26