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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6009 - (show annotations)
Wed Mar 2 04:13:26 2016 UTC (2 years, 11 months ago) by caltinay
File size: 2520 byte(s)
Much needed sync with trunk...

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 #include "NodeMapping.h"
18 #include "Util.h"
19
20 namespace dudley {
21
22 Dudley_NodeMapping *Dudley_NodeMapping_alloc(dim_t numNodes, index_t * target, index_t unused)
23 {
24 dim_t i;
25 index_t min_target, numTargets, max_target;
26 Dudley_NodeMapping *out = NULL;
27 /* allocate the return value */
28 min_target = Dudley_Util_getFlaggedMinInt(1, numNodes, target, unused);
29 if (min_target < 0)
30 throw DudleyException("Dudley_NodeMapping_alloc: target has negative entry.");
31
32 /* now we assume min_target=0! */
33 max_target = Dudley_Util_getFlaggedMaxInt(1, numNodes, target, unused);
34 numTargets = min_target <= max_target ? max_target + 1 : 0;
35 out = new Dudley_NodeMapping;
36 out->reference_counter = 1;
37 out->unused = unused;
38 out->numNodes = numNodes;
39 out->numTargets = numTargets;
40 out->map = new index_t[numTargets];
41 out->target = new index_t[numNodes];
42 #pragma omp parallel
43 {
44 #pragma omp for private(i)
45 for (i = 0; i < numTargets; ++i)
46 out->map[i] = -1;
47 #pragma omp for private(i)
48 for (i = 0; i < numNodes; ++i) {
49 out->target[i] = target[i];
50 if (target[i] != unused)
51 out->map[out->target[i]] = i;
52 }
53 #pragma omp for private(i)
54 for (i = 0; i < numTargets; ++i) {
55 if (out->map[i] == -1) {
56 throw DudleyException("Dudley_NodeMapping_alloc: target does not define a continuous labeling.");
57 }
58 }
59 }
60 return out;
61 }
62
63 void Dudley_NodeMapping_free(Dudley_NodeMapping* in)
64 {
65 if (in != NULL) {
66 in->reference_counter--;
67 if (in->reference_counter <= 0) {
68 delete[] in->target;
69 delete[] in->map;
70 delete in;
71 }
72 }
73 }
74
75 Dudley_NodeMapping *Dudley_NodeMapping_getReference(Dudley_NodeMapping* in)
76 {
77 if (in != NULL)
78 in->reference_counter++;
79 return in;
80 }
81
82 } // namespace dudley
83

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26