/[escript]/trunk/finley/src/NodeMapping.cpp
ViewVC logotype

Contents of /trunk/finley/src/NodeMapping.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4441 - (show annotations)
Fri Jun 7 02:23:49 2013 UTC (5 years, 10 months ago) by caltinay
File size: 2634 byte(s)
finley now uses Data objects directly instead of going through the C wrapper.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by 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 since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 #include "NodeMapping.h"
18 #include "Util.h"
19 #include "esysUtils/mem.h"
20
21 using namespace finley;
22
23 Finley_NodeMapping* Finley_NodeMapping_alloc(dim_t numNodes, index_t* target, index_t unused)
24 {
25 dim_t i;
26 index_t min_target, numTargets, max_target;
27 Finley_NodeMapping* out=NULL;
28 /* allocate the return value */
29 min_target=util::getFlaggedMinInt(1,numNodes,target,unused);
30 if (min_target<0) {
31 Finley_setError(VALUE_ERROR,"Finley_NodeMapping_alloc: target has negative entry.");
32 return NULL;
33 }
34 /* now we assume min_target=0! */
35 max_target=util::getFlaggedMaxInt(1,numNodes,target,unused);
36 numTargets= min_target<=max_target ? max_target+1 :0;
37 out=new Finley_NodeMapping;
38 if (!Finley_checkPtr(out)) {
39 out->reference_counter=1;
40 out->unused=unused;
41 out->numNodes=numNodes;
42 out->numTargets=numTargets;
43 out->map=new index_t[numTargets];
44 out->target=new index_t[numNodes];
45 if (! (Finley_checkPtr(out->target) || Finley_checkPtr(out->map) ) ) {
46 #pragma omp parallel
47 {
48 #pragma omp for private(i)
49 for (i=0; i<numTargets; ++i)out-> map[i]=-1;
50 #pragma omp for private(i)
51 for (i=0;i<numNodes;++i) {
52 out->target[i]=target[i];
53 if (target[i] != unused) out->map[out->target[i]]=i;
54 }
55 #pragma omp for private(i)
56 for (i=0; i<numTargets; ++i) {
57 if (out->map[i]==-1) {
58 Finley_setError(VALUE_ERROR,"Finley_NodeMapping_alloc: target does not define a continuous labeling.");
59 }
60 }
61 }
62 }
63 if (!Finley_noError()) {
64 Finley_NodeMapping_free(out) ;
65 }
66
67 }
68 return out;
69 }
70
71 void Finley_NodeMapping_free(Finley_NodeMapping* in) {
72 if (in != NULL) {
73 in->reference_counter--;
74 if (in->reference_counter<=0) {
75 delete[] in->target;
76 delete[] in->map;
77 delete in;
78 }
79 }
80 }
81 Finley_NodeMapping* Finley_NodeMapping_getReference(Finley_NodeMapping *in)
82 {
83 if (in != NULL)
84 in->reference_counter++;
85 return in;
86 }

Properties

Name Value
svn:mergeinfo /branches/lapack2681/finley/src/NodeMapping.cpp:2682-2741 /branches/pasowrap/finley/src/NodeMapping.cpp:3661-3674 /branches/py3_attempt2/finley/src/NodeMapping.cpp:3871-3891 /branches/restext/finley/src/NodeMapping.cpp:2610-2624 /branches/ripleygmg_from_3668/finley/src/NodeMapping.cpp:3669-3791 /branches/stage3.0/finley/src/NodeMapping.cpp:2569-2590 /branches/symbolic_from_3470/finley/src/NodeMapping.cpp:3471-3974 /release/3.0/finley/src/NodeMapping.cpp:2591-2601 /trunk/finley/src/NodeMapping.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26