/[escript]/trunk/finley/src/NodeFile_allocTable.c
ViewVC logotype

Annotation of /trunk/finley/src/NodeFile_allocTable.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1716 - (hide annotations)
Thu Aug 21 05:03:49 2008 UTC (11 years, 5 months ago) by gross
File MIME type: text/plain
File size: 5580 byte(s)
getListOfTags method added to FunctionSpace class
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    
24     /**************************************************************/
25    
26     /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
27 ksteube 1312 /* is frees. use Finley_Mesh_setLinearMesh to create a new one. */
28 jgs 82
29 bcumming 730 void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
30     {
31 ksteube 1312 index_t *Id2=NULL, *Tag2=NULL, *globalDegreesOfFreedom2=NULL, *globalReducedDOFIndex2=NULL,
32     *globalReducedNodesIndex2=NULL, *globalNodesIndex2=NULL, *reducedNodesId2=NULL, *degreesOfFreedomId2=NULL,
33     *reducedDegreesOfFreedomId2=NULL;
34 jgs 82 double *Coordinates2=NULL;
35 jgs 123 dim_t n,i;
36 jgs 82
37     /* allocate memory: */
38 jgs 123 Id2=MEMALLOC(numNodes,index_t);
39 jgs 102 Coordinates2=MEMALLOC(numNodes*in->numDim,double);
40 jgs 123 Tag2=MEMALLOC(numNodes,index_t);
41 ksteube 1312 globalDegreesOfFreedom2=MEMALLOC(numNodes,index_t);
42     globalReducedDOFIndex2=MEMALLOC(numNodes,index_t);
43     globalReducedNodesIndex2=MEMALLOC(numNodes,index_t);
44     globalNodesIndex2=MEMALLOC(numNodes,index_t);
45     reducedNodesId2=MEMALLOC(numNodes,index_t);
46     degreesOfFreedomId2=MEMALLOC(numNodes,index_t);
47     reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
48 jgs 82
49 ksteube 1312 /* if fine, freeate the old table and replace by new: */
50     if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2)
51     || Finley_checkPtr(globalDegreesOfFreedom2)
52     || Finley_checkPtr(globalReducedDOFIndex2)
53     || Finley_checkPtr(globalReducedNodesIndex2)
54     || Finley_checkPtr(globalNodesIndex2)
55     || Finley_checkPtr(reducedNodesId2)
56     || Finley_checkPtr(degreesOfFreedomId2) ) {
57 jgs 82 MEMFREE(Id2);
58     MEMFREE(Coordinates2);
59     MEMFREE(Tag2);
60 ksteube 1312 MEMFREE(globalDegreesOfFreedom2);
61     MEMFREE(globalReducedDOFIndex2);
62     MEMFREE(globalReducedNodesIndex2);
63     MEMFREE(globalNodesIndex2);
64     MEMFREE(reducedNodesId2);
65     MEMFREE(degreesOfFreedomId2);
66     MEMFREE(reducedDegreesOfFreedomId2);
67 jgs 82 } else {
68 ksteube 1312 Finley_NodeFile_freeTable(in);
69 jgs 82 in->Id=Id2;
70     in->Coordinates=Coordinates2;
71 ksteube 1312 in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
72 jgs 82 in->Tag=Tag2;
73 ksteube 1312 in->globalReducedDOFIndex=globalReducedDOFIndex2;
74     in->globalReducedNodesIndex=globalReducedNodesIndex2;
75     in->globalNodesIndex=globalNodesIndex2;
76     in->reducedNodesId=reducedNodesId2;
77     in->degreesOfFreedomId=degreesOfFreedomId2;
78     in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
79 jgs 82 in->numNodes=numNodes;
80     /* this initialization makes sure that data are located on the right processor */
81     #pragma omp parallel for private(n,i) schedule(static)
82     for (n=0;n<numNodes;n++) {
83     for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
84     in->Id[n]=-1;
85     in->Tag[n]=-1;
86 ksteube 1312 in->globalDegreesOfFreedom[n]=-1;
87     in->globalReducedDOFIndex[n]=-1;
88     in->globalReducedNodesIndex[n]=-1;
89     in->globalNodesIndex[n]=-1;
90     in->reducedNodesId[n]=-1;
91     in->degreesOfFreedomId[n]=-1;
92     in->reducedDegreesOfFreedomId[n]=-1;
93 jgs 82 }
94     }
95     return;
96     }
97    
98 ksteube 1312 /* frees the node table within an node file: */
99 jgs 82
100 ksteube 1312 void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
101 jgs 82 if (in!=NULL) {
102     MEMFREE(in->Id);
103     MEMFREE(in->Coordinates);
104 ksteube 1312 MEMFREE(in->globalDegreesOfFreedom);
105     MEMFREE(in->globalReducedDOFIndex);
106     MEMFREE(in->globalReducedNodesIndex);
107     MEMFREE(in->globalNodesIndex);
108 jgs 82 MEMFREE(in->Tag);
109 ksteube 1312 MEMFREE(in->reducedNodesId);
110     MEMFREE(in->degreesOfFreedomId);
111     MEMFREE(in->reducedDegreesOfFreedomId);
112 gross 1716 MEMFREE(in->tagsInUse);
113     in->numTagsInUse=0;
114 ksteube 1312 Finley_NodeMapping_free(in->nodesMapping);
115     in->nodesMapping=NULL;
116     Finley_NodeMapping_free(in->reducedNodesMapping);
117     in->reducedNodesMapping=NULL;
118     Finley_NodeMapping_free(in->degreesOfFreedomMapping);
119     in->degreesOfFreedomMapping=NULL;
120     Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
121     in->reducedDegreesOfFreedomMapping=NULL;
122     Paso_Distribution_free(in->nodesDistribution);
123     in->nodesDistribution=NULL;
124     Paso_Distribution_free(in->reducedNodesDistribution);
125     in->nodesDistribution=NULL;
126     Paso_Distribution_free(in->degreesOfFreedomDistribution);
127     in->degreesOfFreedomDistribution=NULL;
128     Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
129     in->reducedDegreesOfFreedomDistribution=NULL;
130 gross 1552 Paso_Connector_free(in->degreesOfFreedomConnector);
131     in->degreesOfFreedomConnector=NULL;
132     Paso_Connector_free(in->reducedDegreesOfFreedomConnector);
133     in->reducedDegreesOfFreedomConnector=NULL;
134 ksteube 1312
135 gross 1716 in->numTagsInUse=0;
136 jgs 82 in->numNodes=0;
137     }
138     }
139 gross 1716
140     void Finley_NodeFile_setTagsInUse(Finley_NodeFile* in)
141     {
142     index_t *tagsInUse=NULL;
143     dim_t numTagsInUse;
144     if (in != NULL) {
145     Finley_Util_setValuesInUse(in->Tag, in->numNodes, &numTagsInUse, &tagsInUse, in->MPIInfo);
146     if (Finley_noError()) {
147     MEMFREE(in->tagsInUse);
148     in->tagsInUse=tagsInUse;
149     in->numTagsInUse=numTagsInUse;
150     }
151     }
152     }
153    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26