/[escript]/branches/arrayview_from_1695_trunk/finley/src/NodeFile_allocTable.c
ViewVC logotype

Annotation of /branches/arrayview_from_1695_trunk/finley/src/NodeFile_allocTable.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1781 - (hide annotations)
Thu Sep 11 05:03:14 2008 UTC (11 years ago) by jfenwick
File MIME type: text/plain
File size: 5598 byte(s)
Branch commit

Merged changes from trunk version 1695 up to and including version 1779.


1 jgs 150
2 ksteube 1312 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15 jgs 82
16     /**************************************************************/
17    
18 ksteube 1312 /* Finley: Mesh: NodeFile */
19 jgs 82
20     /**************************************************************/
21    
22     #include "NodeFile.h"
23 jfenwick 1781 #include "Util.h"
24 jgs 82
25     /**************************************************************/
26    
27     /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
28 ksteube 1312 /* is frees. use Finley_Mesh_setLinearMesh to create a new one. */
29 jgs 82
30 bcumming 730 void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
31     {
32 ksteube 1312 index_t *Id2=NULL, *Tag2=NULL, *globalDegreesOfFreedom2=NULL, *globalReducedDOFIndex2=NULL,
33     *globalReducedNodesIndex2=NULL, *globalNodesIndex2=NULL, *reducedNodesId2=NULL, *degreesOfFreedomId2=NULL,
34     *reducedDegreesOfFreedomId2=NULL;
35 jgs 82 double *Coordinates2=NULL;
36 jgs 123 dim_t n,i;
37 jgs 82
38     /* allocate memory: */
39 jgs 123 Id2=MEMALLOC(numNodes,index_t);
40 jgs 102 Coordinates2=MEMALLOC(numNodes*in->numDim,double);
41 jgs 123 Tag2=MEMALLOC(numNodes,index_t);
42 ksteube 1312 globalDegreesOfFreedom2=MEMALLOC(numNodes,index_t);
43     globalReducedDOFIndex2=MEMALLOC(numNodes,index_t);
44     globalReducedNodesIndex2=MEMALLOC(numNodes,index_t);
45     globalNodesIndex2=MEMALLOC(numNodes,index_t);
46     reducedNodesId2=MEMALLOC(numNodes,index_t);
47     degreesOfFreedomId2=MEMALLOC(numNodes,index_t);
48     reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
49 jgs 82
50 ksteube 1312 /* if fine, freeate the old table and replace by new: */
51     if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2)
52     || Finley_checkPtr(globalDegreesOfFreedom2)
53     || Finley_checkPtr(globalReducedDOFIndex2)
54     || Finley_checkPtr(globalReducedNodesIndex2)
55     || Finley_checkPtr(globalNodesIndex2)
56     || Finley_checkPtr(reducedNodesId2)
57     || Finley_checkPtr(degreesOfFreedomId2) ) {
58 jgs 82 MEMFREE(Id2);
59     MEMFREE(Coordinates2);
60     MEMFREE(Tag2);
61 ksteube 1312 MEMFREE(globalDegreesOfFreedom2);
62     MEMFREE(globalReducedDOFIndex2);
63     MEMFREE(globalReducedNodesIndex2);
64     MEMFREE(globalNodesIndex2);
65     MEMFREE(reducedNodesId2);
66     MEMFREE(degreesOfFreedomId2);
67     MEMFREE(reducedDegreesOfFreedomId2);
68 jgs 82 } else {
69 ksteube 1312 Finley_NodeFile_freeTable(in);
70 jgs 82 in->Id=Id2;
71     in->Coordinates=Coordinates2;
72 ksteube 1312 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
73 jgs 82 in->Tag=Tag2;
74 ksteube 1312 in->globalReducedDOFIndex=globalReducedDOFIndex2;
75     in->globalReducedNodesIndex=globalReducedNodesIndex2;
76     in->globalNodesIndex=globalNodesIndex2;
77     in->reducedNodesId=reducedNodesId2;
78     in->degreesOfFreedomId=degreesOfFreedomId2;
79     in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
80 jgs 82 in->numNodes=numNodes;
81     /* this initialization makes sure that data are located on the right processor */
82     #pragma omp parallel for private(n,i) schedule(static)
83     for (n=0;n<numNodes;n++) {
84 jfenwick 1781 in->Id[n]=-1;
85 jgs 82 for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
86     in->Tag[n]=-1;
87 ksteube 1312 in->globalDegreesOfFreedom[n]=-1;
88     in->globalReducedDOFIndex[n]=-1;
89     in->globalReducedNodesIndex[n]=-1;
90     in->globalNodesIndex[n]=-1;
91     in->reducedNodesId[n]=-1;
92     in->degreesOfFreedomId[n]=-1;
93     in->reducedDegreesOfFreedomId[n]=-1;
94 jgs 82 }
95     }
96     return;
97     }
98    
99 ksteube 1312 /* frees the node table within an node file: */
100 jgs 82
101 ksteube 1312 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
102 jgs 82 if (in!=NULL) {
103     MEMFREE(in->Id);
104     MEMFREE(in->Coordinates);
105 ksteube 1312 MEMFREE(in->globalDegreesOfFreedom);
106     MEMFREE(in->globalReducedDOFIndex);
107     MEMFREE(in->globalReducedNodesIndex);
108     MEMFREE(in->globalNodesIndex);
109 jgs 82 MEMFREE(in->Tag);
110 ksteube 1312 MEMFREE(in->reducedNodesId);
111     MEMFREE(in->degreesOfFreedomId);
112     MEMFREE(in->reducedDegreesOfFreedomId);
113 jfenwick 1781 MEMFREE(in->tagsInUse);
114     in->numTagsInUse=0;
115 ksteube 1312 Finley_NodeMapping_free(in->nodesMapping);
116     in->nodesMapping=NULL;
117     Finley_NodeMapping_free(in->reducedNodesMapping);
118     in->reducedNodesMapping=NULL;
119     Finley_NodeMapping_free(in->degreesOfFreedomMapping);
120     in->degreesOfFreedomMapping=NULL;
121     Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
122     in->reducedDegreesOfFreedomMapping=NULL;
123     Paso_Distribution_free(in->nodesDistribution);
124     in->nodesDistribution=NULL;
125     Paso_Distribution_free(in->reducedNodesDistribution);
126     in->nodesDistribution=NULL;
127     Paso_Distribution_free(in->degreesOfFreedomDistribution);
128     in->degreesOfFreedomDistribution=NULL;
129     Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
130     in->reducedDegreesOfFreedomDistribution=NULL;
131 gross 1552 Paso_Connector_free(in->degreesOfFreedomConnector);
132     in->degreesOfFreedomConnector=NULL;
133     Paso_Connector_free(in->reducedDegreesOfFreedomConnector);
134     in->reducedDegreesOfFreedomConnector=NULL;
135 ksteube 1312
136 jfenwick 1781 in->numTagsInUse=0;
137 jgs 82 in->numNodes=0;
138     }
139     }
140 jfenwick 1781
141     void Finley_NodeFile_setTagsInUse(Finley_NodeFile* in)
142     {
143     index_t *tagsInUse=NULL;
144     dim_t numTagsInUse;
145     if (in != NULL) {
146     Finley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);
147     if (Finley_noError()) {
148     MEMFREE(in->tagsInUse);
149     in->tagsInUse=tagsInUse;
150     in->numTagsInUse=numTagsInUse;
151     }
152     }
153     }
154    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26