/[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 5963 - (show annotations)
Mon Feb 22 06:59:27 2016 UTC (3 years, 3 months ago) by caltinay
File size: 2562 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 #include "NodeMapping.h"
18 #include "Util.h"
19
20 Dudley_NodeMapping *Dudley_NodeMapping_alloc(dim_t numNodes, index_t * target, index_t unused)
21 {
22 dim_t i;
23 index_t min_target, numTargets, max_target;
24 Dudley_NodeMapping *out = NULL;
25 /* allocate the return value */
26 min_target = Dudley_Util_getFlaggedMinInt(1, numNodes, target, unused);
27 if (min_target < 0)
28 {
29 Dudley_setError(VALUE_ERROR, "Dudley_NodeMapping_alloc: target has negative entry.");
30 return NULL;
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 if (!Dudley_checkPtr(out))
37 {
38 out->reference_counter = 1;
39 out->unused = unused;
40 out->numNodes = numNodes;
41 out->numTargets = numTargets;
42 out->map = new index_t[numTargets];
43 out->target = new index_t[numNodes];
44 if (!(Dudley_checkPtr(out->target) || Dudley_checkPtr(out->map)))
45 {
46 #pragma omp parallel
47 {
48 #pragma omp for private(i)
49 for (i = 0; i < numTargets; ++i)
50 out->map[i] = -1;
51 #pragma omp for private(i)
52 for (i = 0; i < numNodes; ++i)
53 {
54 out->target[i] = target[i];
55 if (target[i] != unused)
56 out->map[out->target[i]] = i;
57 }
58 #pragma omp for private(i)
59 for (i = 0; i < numTargets; ++i)
60 {
61 if (out->map[i] == -1)
62 {
63 Dudley_setError(VALUE_ERROR,
64 "Dudley_NodeMapping_alloc: target does not define a continuous labeling.");
65 }
66 }
67 }
68 }
69 if (!Dudley_noError())
70 {
71 Dudley_NodeMapping_free(out);
72 }
73
74 }
75 return out;
76 }
77
78 void Dudley_NodeMapping_free(Dudley_NodeMapping * in)
79 {
80 if (in != NULL)
81 {
82 in->reference_counter--;
83 if (in->reference_counter <= 0)
84 {
85 delete[] in->target;
86 delete[] in->map;
87 delete in;
88 }
89 }
90 }
91
92 Dudley_NodeMapping *Dudley_NodeMapping_getReference(Dudley_NodeMapping * in)
93 {
94 if (in != NULL)
95 in->reference_counter++;
96 return in;
97 }
98

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-5962 /trunk/ripley/test/python/dudley/src/NodeMapping.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26