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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (show annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 3 months ago) by trankine
Original Path: temp/finley/src/Mesh.c
File MIME type: text/plain
File size: 4178 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1
2 /* $Id$ */
3
4 /*******************************************************
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
16 /**************************************************************/
17
18 /* Finley: Mesh */
19
20 /**************************************************************/
21
22 #include "Mesh.h"
23
24 /**************************************************************/
25
26 /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
27 /* the most appropriate order is selected indepently. */
28
29 extern Finley_RefElementInfo Finley_RefElement_InfoList[];
30
31 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, index_t order, index_t reduced_order, Paso_MPIInfo *mpi_info)
32 {
33 Finley_Mesh *out;
34
35 /* allocate the return value */
36
37 out=MEMALLOC(1,Finley_Mesh);
38 if (Finley_checkPtr(out)) return NULL;
39 out->Name=NULL;
40 out->Nodes=NULL;
41 out->Elements=NULL;
42 out->FaceElements=NULL;
43 out->Points=NULL;
44 out->ContactElements=NULL;
45 out->TagMap=NULL;
46 out->reference_counter=0;
47
48 out->FullFullPattern=NULL;
49 out->FullReducedPattern=NULL;
50 out->ReducedFullPattern=NULL;
51 out->ReducedReducedPattern=NULL;
52 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
53 if (! Finley_noError()) {
54 Finley_Mesh_free(out);
55 return NULL;
56 }
57 /* copy name: */
58
59 out->Name=MEMALLOC(strlen(name)+1,char);
60 if (Finley_checkPtr(out->Name)) {
61 Finley_Mesh_free(out);
62 return NULL;
63 }
64 strcpy(out->Name,name);
65
66 /* allocate node table: */
67 out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );
68 if (! Finley_noError()) {
69 Finley_Mesh_free(out);
70 return NULL;
71 }
72 out->order=order;
73 out->reduced_order=reduced_order;
74 out->Elements=NULL;
75 out->FaceElements=NULL;
76 out->Points=NULL;
77 out->ContactElements=NULL;
78 out->reference_counter++;
79 return out;
80 }
81
82 /* returns a reference to Finley_Mesh in */
83
84 Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {
85 if (in!=NULL) ++(in->reference_counter);
86 return in;
87 }
88
89 /* freeates a mesh: */
90
91 void Finley_Mesh_free(Finley_Mesh* in) {
92 if (in!=NULL) {
93 in->reference_counter--;
94 if (in->reference_counter<1) {
95 #ifdef Finley_TRACE
96 if (in->Name!=NULL) {
97 printf("Finley_Mesh_free: mesh %s is freed.\n",in->Name);
98 } else {
99 printf("Finley_Mesh_free\n");
100 }
101 #endif
102 MEMFREE(in->Name);
103 Finley_NodeFile_free(in->Nodes);
104 Finley_ElementFile_free(in->Elements);
105 Finley_ElementFile_free(in->FaceElements);
106 Finley_ElementFile_free(in->ContactElements);
107 Finley_ElementFile_free(in->Points);
108 Finley_TagMap_free(in->TagMap);
109 Paso_SystemMatrixPattern_free(in->FullFullPattern);
110 Paso_SystemMatrixPattern_free(in->FullReducedPattern);
111 Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
112 Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
113 Paso_MPIInfo_free( in->MPIInfo );
114 MEMFREE(in);
115 }
116 }
117 }
118
119 /**************************************************************/
120
121 /* returns the spatial dimension of the mesh: */
122
123 dim_t Finley_Mesh_getDim(Finley_Mesh *in) {
124 return in->Nodes->numDim;
125 }
126
127 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {
128 Finley_ElementFile_free(self->Elements);
129 self->Elements=elements;
130 }
131 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {
132 Finley_ElementFile_free(self->FaceElements);
133 self->FaceElements=elements;
134 }
135 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {
136 Finley_ElementFile_free(self->ContactElements);
137 self->ContactElements=elements;
138 }
139 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {
140 Finley_ElementFile_free(self->Points);
141 self->Points=elements;
142 }
143

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26