/[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 102 - (hide annotations)
Wed Dec 15 07:08:39 2004 UTC (15 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/NodeFile_allocTable.c
File MIME type: text/plain
File size: 2935 byte(s)
*** empty log message ***

1 jgs 82 /* $Id$ */
2     /**************************************************************/
3    
4     /* Finley: Mesh: NodeFile */
5    
6     /**************************************************************/
7    
8     /* Copyrights by ACcESS Australia 2003 */
9     /* Author: gross@access.edu.au */
10     /* Version: $Id$ */
11    
12     /**************************************************************/
13    
14     #include "Finley.h"
15     #include "NodeFile.h"
16    
17     /**************************************************************/
18    
19     /* allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
20     /* is deallocated. use Finley_Mesh_setLinearMesh to create a new one. */
21    
22     void Finley_NodeFile_allocTable(Finley_NodeFile* in ,int numNodes) {
23     maybelong *Id2=NULL, *Tag2=NULL, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;
24     double *Coordinates2=NULL;
25     maybelong n,i;
26    
27     /* allocate memory: */
28    
29 jgs 102 Id2=MEMALLOC(numNodes,maybelong);
30     Coordinates2=MEMALLOC(numNodes*in->numDim,double);
31     Tag2=MEMALLOC(numNodes,maybelong);
32     degreeOfFreedom2=MEMALLOC(numNodes,maybelong);
33     reducedDegreeOfFreedom2=MEMALLOC(numNodes,maybelong);
34     toReduced2=MEMALLOC(numNodes,maybelong);
35 jgs 82
36     /* if fine, deallocate the old table and replace by new: */
37    
38     if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||
39     Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {
40     MEMFREE(Id2);
41     MEMFREE(Coordinates2);
42     MEMFREE(Tag2);
43     MEMFREE(degreeOfFreedom2);
44     MEMFREE(reducedDegreeOfFreedom2);
45     MEMFREE(toReduced2);
46     } else {
47     Finley_NodeFile_deallocTable(in);
48     in->Id=Id2;
49     in->Coordinates=Coordinates2;
50     in->Tag=Tag2;
51     in->degreeOfFreedom=degreeOfFreedom2;
52     in->reducedDegreeOfFreedom=reducedDegreeOfFreedom2;
53     in->toReduced=toReduced2;
54     in->numNodes=numNodes;
55     in->numDegreesOfFreedom=numNodes;
56     in->reducedNumDegreesOfFreedom=numNodes;
57     in->reducedNumNodes=numNodes;
58     /* this initialization makes sure that data are located on the right processor */
59     #pragma omp parallel for private(n,i) schedule(static)
60     for (n=0;n<numNodes;n++) {
61     for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
62     in->Id[n]=-1;
63     in->Tag[n]=-1;
64     in->degreeOfFreedom[n]=n;
65     in->reducedDegreeOfFreedom[n]=n;
66     in->toReduced[n]=n;
67     }
68     }
69     return;
70     }
71    
72     /* deallocates the node table within an node file: */
73    
74     void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {
75     if (in!=NULL) {
76     MEMFREE(in->Id);
77     MEMFREE(in->Coordinates);
78     MEMFREE(in->Tag);
79     MEMFREE(in->degreeOfFreedom);
80     MEMFREE(in->reducedDegreeOfFreedom);
81     MEMFREE(in->toReduced);
82     in->numNodes=0;
83     in->numDegreesOfFreedom=0;
84     in->reducedNumDegreesOfFreedom=0;
85     in->reducedNumNodes=0;
86     }
87     }
88     /*
89     * $Log$
90 jgs 102 * Revision 1.4 2004/12/15 07:08:33 jgs
91 jgs 97 * *** empty log message ***
92 jgs 82 *
93 jgs 97 *
94 jgs 82 *
95     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26