/[escript]/branches/trilinos_from_5897/dudley/src/NodeMapping.h
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/NodeMapping.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 10 months ago) by caltinay
File MIME type: text/plain
File size: 3036 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

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 #ifndef __DUDLEY_NODEMAPPING_H__
18 #define __DUDLEY_NODEMAPPING_H__
19
20 #include "Util.h"
21
22 namespace dudley {
23
24 /// NodeMapping provides a mapping from the local nodes typically to the
25 /// degrees of freedom, the reduced degrees of freedom or the reduced node set
26 struct NodeMapping
27 {
28 NodeMapping() : numNodes(0), target(NULL), numTargets(0), map(NULL) {}
29
30 /// resets both map and target
31 void clear()
32 {
33 delete[] map;
34 delete[] target;
35 target = NULL;
36 map = NULL;
37 numNodes = 0;
38 numTargets = 0;
39 }
40
41 /// initializes a node mapping. The target array is copied and a reverse
42 /// map created.
43 /// theTarget[i]=unused means that no target is defined for FEM node i.
44 void assign(const index_t* theTarget, dim_t nNodes, index_t unused)
45 {
46 clear();
47
48 if (nNodes == 0)
49 return;
50
51 numNodes = nNodes;
52
53 std::pair<index_t,index_t> range(
54 util::getFlaggedMinMaxInt(numNodes, theTarget, unused));
55 if (range.first < 0) {
56 throw escript::ValueError("NodeMapping: target has negative entry.");
57 }
58 numTargets = range.first<=range.second ? range.second+1 : 0;
59
60 target = new index_t[numNodes];
61 map = new index_t[numTargets];
62
63 bool err = false;
64 #pragma omp parallel
65 {
66 #pragma omp for
67 for (index_t i=0; i<numNodes; ++i) {
68 target[i] = theTarget[i];
69 if (target[i] != unused)
70 map[target[i]] = i;
71 }
72 // sanity check
73 #pragma omp for
74 for (index_t i=0; i<numTargets; ++i) {
75 if (map[i] == -1) {
76 #pragma omp critical
77 err = true;
78 }
79 }
80 }
81 if (err)
82 throw escript::ValueError("NodeMapping: target does not define a continuous labeling.");
83 }
84
85 /// returns the number of target nodes (number of items in the map array)
86 inline dim_t getNumTargets() const { return numTargets; }
87
88 /// size of `target` (number of FEM nodes)
89 dim_t numNodes;
90
91 /// target[i] defines the target of FEM node i=0,...,numNodes
92 index_t* target;
93
94 /// size of `map` (number of target nodes, e.g. DOF, reduced DOF, etc.)
95 dim_t numTargets;
96
97 /// maps the target nodes back to the FEM nodes: target[map[i]]=i
98 index_t* map;
99 };
100
101 } // namespace dudley
102
103 #endif // __DUDLEY_NODEMAPPING_H__
104

  ViewVC Help
Powered by ViewVC 1.1.26