1 /*
2  * grape-module "memm2.c"
3  *
4  * Description       : memory methods: new-instance, free, xdr, ...
5  *
6  * Author            : Ralf Neubauer
7  *
8  * Copyright (c) 1996  by Universitaet Bonn
9  *                        Institut fuer Angewandte Mathematik
10  *                        Sonderforschungsbereich 256
11  *                        D-53115 Bonn
12  *
13  * $Id: memm2.c,v 1.1.1.1 2005/04/13 15:56:40 dani Exp $
14  * $Log: memm2.c,v $
15  * Revision 1.1.1.1  2005/04/13 15:56:40  dani
16  * Start of the ALBERTA 2.0 repository
17  *
18  * Revision 1.1  2003/06/24 14:06:57  claus
19  * Initial revision.
20  *
21  * Revision 1.19  2000/08/28 14:50:59  wu
22  * restructured mesh class hierarchy
23  *
24  * Revision 1.18  2000/06/07 14:45:37  wu
25  * error corrected
26  *
27  * Revision 1.17  2000/06/07  14:09:03  wu
28  * error corrected
29  *
30  * Revision 1.16  2000/06/07  13:42:45  wu
31  * revised mscalar functions
32  *
33  * Revision 1.15  2000/06/06  13:15:29  wu
34  * corrected copy-function
35  *
36  * Revision 1.14  2000/06/05 19:58:50  wu
37  * added 'synthetic functions', thus revised function list management
38  *
39  * Revision 1.13  2000/01/26  16:25:03  wu
40  * added forgot superclass call in xdr
41  *
42  * Revision 1.12  1999/08/23 12:12:41  haasdonk
43  * bug in get-min-max fixed
44  *
45  * Revision 1.11  1999/05/05  16:29:54  wu
46  * added get-min-max
47  *
48  * Revision 1.10  1999/03/26  16:01:12  wu
49  * softcopy and get-object added
50  *
51  * Revision 1.9  1999/03/25  13:31:43  wu
52  * GenMesh conversion error corrected
53  *
54  * Revision 1.8  1999/03/25  13:23:36  wu
55  * error corrected
56  *
57  * Revision 1.7  1999/03/25  12:34:29  wu
58  * functionality moved to GenMesh
59  *
60  * Revision 1.6  1999/02/05  18:18:45  wu
61  * remove functions on free
62  *
63  * Revision 1.5  1999/01/26  16:07:56  wu
64  * xdr funciton selector
65  *
66  * Revision 1.4  1999/01/19  14:25:17  wu
67  * added new-instance and free
68  *
69  * Revision 1.3  1998/08/18  12:58:19  wu
70  * new methods add/remove-function
71  *
72  * Revision 1.2  1997/08/30  11:05:44  wu
73  * error corrected
74  *
75  */
76 
77 #include <grape.h>
78 
helement_to_element(ELEMENT2D * el)79 static ELEMENT2D *helement_to_element (ELEMENT2D *el)
80 {
81   if (!el)
82     return NULL;
83   el->parent = NULL;
84   el->vinh = NULL;
85   el->level = 0;
86   el->ref_rule = 0;
87   el->has_children = FALSE;
88   return el;
89 }
90 
first_macro(GENMESH2D * self,MESH_ELEMENT_FLAGS flags)91 static ELEMENT2D *first_macro (GENMESH2D *self, MESH_ELEMENT_FLAGS flags)
92 {
93   return helement_to_element
94     ((*((MESH2D *)self)->first_element)((MESH2D *)self, flags));
95 }
96 
next_macro(ELEMENT2D * el,MESH_ELEMENT_FLAGS flags)97 static ELEMENT2D *next_macro (ELEMENT2D *el, MESH_ELEMENT_FLAGS flags)
98 {
99   return helement_to_element
100     ((*((MESH2D *)el->mesh)->next_element)(el, flags));
101 }
102 
get_child(HELEMENT2D * el,MESH_ELEMENT_FLAGS flags)103 static ELEMENT2D *get_child (HELEMENT2D *el, MESH_ELEMENT_FLAGS flags)
104 {
105   return NULL;
106 }
107 
mesh2d_init_mesh(void)108 MESH2D *mesh2d_init_mesh (void)
109 {
110   MESH2D *self;
111 
112   self = (MESH2D *)START_METHOD (G_INSTANCE);
113   ASSURE (self, "", END_METHOD (NULL));
114 
115   self->max_level = 0;
116   self->level_of_interest = 0;
117 
118   self->first_macro = first_macro;
119   self->next_macro = next_macro;
120   self->first_child = get_child;
121   self->next_child = get_child;
122 
123   END_METHOD(self);
124 }
125 
mesh2d_copy_mesh(MESH2D * copy)126 MESH2D *mesh2d_copy_mesh (MESH2D *copy)
127 {
128   MESH2D *self;
129 
130   self = (MESH2D *)START_METHOD (G_INSTANCE);
131   ASSURE (self, "", END_METHOD (NULL));
132 
133   copy->first_element = self->first_element;
134   copy->next_element = self->next_element;
135 
136   END_METHOD (copy);
137 }
138