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

Contents of /branches/trilinos_from_5897/dudley/src/Mesh_distributeByRankOfDOF.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5963 - (show annotations)
Mon Feb 22 06:59:27 2016 UTC (3 years, 3 months ago) by caltinay
File size: 4035 byte(s)
sync and fix.

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

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/dudley/src/Mesh_distributeByRankOfDOF.cpp:5567-5588 /branches/complex/dudley/src/Mesh_distributeByRankOfDOF.cpp:5866-5937 /branches/lapack2681/finley/src/Mesh_distributeByRankOfDOF.cpp:2682-2741 /branches/pasowrap/dudley/src/Mesh_distributeByRankOfDOF.cpp:3661-3674 /branches/py3_attempt2/dudley/src/Mesh_distributeByRankOfDOF.cpp:3871-3891 /branches/restext/finley/src/Mesh_distributeByRankOfDOF.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/Mesh_distributeByRankOfDOF.cpp:3669-3791 /branches/stage3.0/finley/src/Mesh_distributeByRankOfDOF.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/Mesh_distributeByRankOfDOF.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/Mesh_distributeByRankOfDOF.cpp:3517-3974 /release/3.0/finley/src/Mesh_distributeByRankOfDOF.cpp:2591-2601 /release/4.0/dudley/src/Mesh_distributeByRankOfDOF.cpp:5380-5406 /trunk/dudley/src/Mesh_distributeByRankOfDOF.cpp:4257-4344,5898-5962 /trunk/ripley/test/python/dudley/src/Mesh_distributeByRankOfDOF.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26