/[escript]/branches/doubleplusgood/finley/src/Mesh.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/finley/src/Mesh.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 2 months ago) by ksteube
Original Path: trunk/finley/src/Mesh.c
File MIME type: text/plain
File size: 4143 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* Finley: Mesh */
18
19 /**************************************************************/
20
21 #include "Mesh.h"
22
23 /**************************************************************/
24
25 /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
26 /* the most appropriate order is selected indepently. */
27
28 extern Finley_RefElementInfo Finley_RefElement_InfoList[];
29
30 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
31 {
32 Finley_Mesh *out;
33
34 /* allocate the return value */
35
36 out=MEMALLOC(1,Finley_Mesh);
37 if (Finley_checkPtr(out)) return NULL;
38 out->Name=NULL;
39 out->Nodes=NULL;
40 out->Elements=NULL;
41 out->FaceElements=NULL;
42 out->Points=NULL;
43 out->ContactElements=NULL;
44 out->TagMap=NULL;
45 out->reference_counter=0;
46
47 out->FullFullPattern=NULL;
48 out->FullReducedPattern=NULL;
49 out->ReducedFullPattern=NULL;
50 out->ReducedReducedPattern=NULL;
51 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
52 if (! Finley_noError()) {
53 Finley_Mesh_free(out);
54 return NULL;
55 }
56 /* copy name: */
57
58 out->Name=MEMALLOC(strlen(name)+1,char);
59 if (Finley_checkPtr(out->Name)) {
60 Finley_Mesh_free(out);
61 return NULL;
62 }
63 strcpy(out->Name,name);
64
65 /* allocate node table: */
66 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
67 if (! Finley_noError()) {
68 Finley_Mesh_free(out);
69 return NULL;
70 }
71 out->order=order;
72 out->reduced_order=reduced_order;
73 out->Elements=NULL;
74 out->FaceElements=NULL;
75 out->Points=NULL;
76 out->ContactElements=NULL;
77 out->reference_counter++;
78 return out;
79 }
80
81 /* returns a reference to Finley_Mesh in */
82
83 Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
84 if (in!=NULL) ++(in->reference_counter);
85 return in;
86 }
87
88 /* freeates a mesh: */
89
90 void Finley_Mesh_free(Finley_Mesh* in) {
91 if (in!=NULL) {
92 in->reference_counter--;
93 if (in->reference_counter<1) {
94 #ifdef Finley_TRACE
95 if (in->Name!=NULL) {
96 printf("Finley_Mesh_free: mesh %s is freed.\n",in->Name);
97 } else {
98 printf("Finley_Mesh_free\n");
99 }
100 #endif
101 MEMFREE(in->Name);
102 Finley_NodeFile_free(in->Nodes);
103 Finley_ElementFile_free(in->FaceElements);
104 Finley_ElementFile_free(in->Elements);
105 Finley_ElementFile_free(in->ContactElements);
106 Finley_ElementFile_free(in->Points);
107 Finley_TagMap_free(in->TagMap);
108 Paso_SystemMatrixPattern_free(in->FullFullPattern);
109 Paso_SystemMatrixPattern_free(in->FullReducedPattern);
110 Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
111 Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
112 Paso_MPIInfo_free( in->MPIInfo );
113 MEMFREE(in);
114 }
115 }
116 }
117
118 /**************************************************************/
119
120 /* returns the spatial dimension of the mesh: */
121
122 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
123 return in->Nodes->numDim;
124 }
125
126 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
127 Finley_ElementFile_free(self->Elements);
128 self->Elements=elements;
129 }
130 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
131 Finley_ElementFile_free(self->FaceElements);
132 self->FaceElements=elements;
133 }
134 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
135 Finley_ElementFile_free(self->ContactElements);
136 self->ContactElements=elements;
137 }
138 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
139 Finley_ElementFile_free(self->Points);
140 self->Points=elements;
141 }
142

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26