/[escript]/branches/doubleplusgood/dudley/src/Mesh_distributeByRankOfDOF.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/dudley/src/Mesh_distributeByRankOfDOF.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4332 - (hide annotations)
Thu Mar 21 04:21:14 2013 UTC (5 years, 11 months ago) by jfenwick
File size: 3922 byte(s)
like sand though the hourglass
1 ksteube 1315
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 4154 * Copyright (c) 2003-2013 by University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12     * Development since 2012 by School of Earth Sciences
13     *
14     *****************************************************************************/
15 ksteube 1315
16 jfenwick 3981 /************************************************************************************/
17 ksteube 1315
18 jfenwick 3086 /* Dudley: Mesh: this will redistribute the Nodes and Elements including overlap */
19 ksteube 1315 /* according to the dof_distribiution. It will create an element coloring but will not create any mappings. */
20    
21 jfenwick 3981 /************************************************************************************/
22 ksteube 1315
23     #include "Mesh.h"
24    
25 jfenwick 3981 /************************************************************************************/
26 ksteube 1315
27 jfenwick 3224 void Dudley_Mesh_distributeByRankOfDOF(Dudley_Mesh * self, index_t * dof_distribution)
28     {
29 ksteube 1315
30 jfenwick 3224 index_t min_dof_id, max_dof_id, *tmp_node_localDOF_map = NULL, *tmp_node_localDOF_mask = NULL;
31 jfenwick 3227 Esys_MPI_rank *mpiRankOfDOF = NULL;
32 jfenwick 3224 register index_t k;
33     dim_t len, n, numDOFs;
34 ksteube 1315
35 jfenwick 3224 if (self == NULL)
36     return;
37 jfenwick 4332 mpiRankOfDOF = new Esys_MPI_rank[self->Nodes->numNodes];
38 jfenwick 3224 if (!Dudley_checkPtr(mpiRankOfDOF))
39     {
40 ksteube 1315
41 jfenwick 3224 Dudley_NodeFile_assignMPIRankToDOFs(self->Nodes, mpiRankOfDOF, dof_distribution);
42 gross 1739
43 jfenwick 3224 /* first the elements are redistributed according to mpiRankOfDOF */
44     /* at the input the Node tables refering 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 gross 1760
53 jfenwick 3224 /* resolve the node ids */
54     if (Dudley_noError())
55     Dudley_Mesh_resolveNodeIds(self);
56 gross 1760
57 jfenwick 3224 /* 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 jfenwick 4332 tmp_node_localDOF_mask = new index_t[len]; /* local mask for used nodes */
61     tmp_node_localDOF_map = new index_t[self->Nodes->numNodes];
62 jfenwick 3224 if (!((Dudley_checkPtr(tmp_node_localDOF_mask) && Dudley_checkPtr(tmp_node_localDOF_map))))
63     {
64 gross 1760
65 jfenwick 3224 #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 jfenwick 4332 delete[] tmp_node_localDOF_mask;
109     delete[] tmp_node_localDOF_map;
110 jfenwick 3224 }
111 jfenwick 4332 delete[] mpiRankOfDOF;
112 jfenwick 3224 return;
113 ksteube 1315 }

  ViewVC Help
Powered by ViewVC 1.1.26