1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 | //- Class: CABodies
//- Description: Cubit Attribute for a list of bodies the entity is part of.
//- Author: Hong-Jun Kim
//- Version:
#include "CABodies.hpp"
#include "BasicTopologyEntity.hpp"
#include "Body.hpp"
#include "RefEntityName.hpp"
#include "CastTo.hpp"
#include "TDParallel.hpp"
#include "CubitMessage.hpp"
#include <typeinfo>
CubitAttrib* CABodies_creator(RefEntity* entity, const CubitSimpleAttrib& p_csa)
{
CABodies *new_attrib = NULL;
CubitSimpleAttrib csa = p_csa;
new_attrib = new CABodies(entity, &csa);
return new_attrib;
}
CABodies::CABodies(RefEntity* new_attrib_owner,
CubitSimpleAttrib *csa_ptr)
: CubitAttrib(new_attrib_owner)
{
assert ( csa_ptr != NULL );
if (DEBUG_FLAG(138))
{
PRINT_DEBUG_138( "Creating BODIES attribute from CSA for %s %d\n",
(attribOwnerEntity ? attribOwnerEntity->class_name() : "(none)"),
(attribOwnerEntity ? attribOwnerEntity->id() : 0));
}
std::vector<int> i_list = csa_ptr->int_data_list();
// first, the ints
if (i_list.size() > 0)
{
m_interface = i_list[0]; // is interface
if (i_list.size() > 1)
{
m_uniqueID = i_list[1]; // unique ID
if(i_list.size() > 2)
{
// shared bodies
int num_list = i_list[2];
for (int i = 0; i < num_list; i++)
m_sharedBodies.append(i_list[3+i]);
// shared procs
int new_start = 3 + num_list;
if((int)i_list.size() > new_start + 1)
{
num_list = i_list[new_start];
for (int i = 1; i <= num_list; i++)
m_sharedProcs.append(i_list[new_start + i]);
// ghost procs
new_start += num_list+1;
if((int)i_list.size() > new_start + 1)
{
num_list = i_list[new_start];
for (int i = 1; i <= num_list; i++)
m_ghostProcs.append(i_list[new_start + i]);
}
}
}
}
}
}
CABodies::CABodies(RefEntity* new_attrib_owner)
: CubitAttrib(new_attrib_owner)
, m_interface(0)
, m_uniqueID(0)
{
if (DEBUG_FLAG(138))
{
PRINT_DEBUG_138( "Creating BODIES attribute for %s %d\n",
(attribOwnerEntity ? attribOwnerEntity->class_name() : "(none)"),
(attribOwnerEntity ? attribOwnerEntity->id() : 0));
}
}
CABodies::~CABodies()
{
}
CubitStatus CABodies::actuate()
{
CubitStatus status = CUBIT_SUCCESS;
if (hasActuated == CUBIT_TRUE) return CUBIT_SUCCESS;
if (DEBUG_FLAG(138))
{
PRINT_DEBUG_138( "Actuating BODIES attribute for %s %d\n",
attribOwnerEntity->class_name(), attribOwnerEntity->id());
}
// create a TDParallel for the entity, if it doesn't already exist
TDParallel *par = (TDParallel *) attrib_owner()->get_TD(&TDParallel::is_parallel);
if (par != NULL) {
if (par->is_interface() != m_interface) {
PRINT_ERROR("TDParallel interface check is failed for %s %d.\n",
attrib_owner()->class_name(), attrib_owner()->id());
return CUBIT_FAILURE;
}
// check to make sure it's the same body list
par->get_shared_body_list()->reset();
m_sharedBodies.reset();
int size = par->get_shared_body_list()->size();
for (int i = 0; i < size; i++) {
if (par->get_shared_body_list()->get_and_step() != m_sharedBodies.get_and_step()) {
PRINT_ERROR("Different body found for %s %d.\n",
attrib_owner()->class_name(), attrib_owner()->id());
return CUBIT_FAILURE;
}
}
par->get_shared_proc_list()->reset();
m_sharedProcs.reset();
size = par->get_shared_proc_list()->size();
for (int i = 0; i < size; i++) {
if (par->get_shared_proc_list()->get_and_step() != m_sharedProcs.get_and_step()) {
PRINT_ERROR("Different processor found for %s %d.\n",
attrib_owner()->class_name(), attrib_owner()->id());
return CUBIT_FAILURE;
}
}
par->get_ghost_proc_list()->reset();
m_ghostProcs.reset();
size = par->get_ghost_proc_list()->size();
for (int i = 0; i < size; i++) {
if (par->get_ghost_proc_list()->get_and_step() != m_ghostProcs.get_and_step()) {
PRINT_ERROR("Different ghost processor found for %s %d.\n",
attrib_owner()->class_name(), attrib_owner()->id());
return CUBIT_FAILURE;
}
}
if ((int)par->get_unique_id() != m_uniqueID) {
PRINT_ERROR("Different unique ID found for %s %d.\n",
attrib_owner()->class_name(), attrib_owner()->id());
return CUBIT_FAILURE;
}
}
else {
// else make a new one
par = new TDParallel(attrib_owner(), &m_sharedBodies, &m_sharedProcs,<--- Variable 'par' is assigned a value that is never used.
&m_ghostProcs, m_uniqueID, m_interface);
}
delete_attrib(CUBIT_TRUE);
hasActuated = CUBIT_TRUE;
return status;
}
CubitStatus CABodies::update()
{
if (hasUpdated) return CUBIT_SUCCESS;
if (DEBUG_FLAG(138))
{
PRINT_DEBUG_138( "Updating BODIES attribute for %s %d\n",
attribOwnerEntity->class_name(), attribOwnerEntity->id());
}
// set the updated flag
hasUpdated = CUBIT_TRUE;
// if the owner has a body list, save it, otherwise delete this one
TDParallel *td_par = (TDParallel *) attrib_owner()->get_TD(&TDParallel::is_parallel);
if (td_par == NULL) {
delete_attrib(CUBIT_TRUE);
}
else {
m_interface = td_par->is_interface();
m_uniqueID = td_par->get_unique_id();
int size = td_par->get_shared_body_list()->size();
td_par->get_shared_body_list()->reset();
m_sharedBodies.clean_out();
for (int i = 0; i < size; i++) {
m_sharedBodies.append(td_par->get_shared_body_list()->get_and_step());
}
size = td_par->get_shared_proc_list()->size();
td_par->get_shared_proc_list()->reset();
m_sharedProcs.clean_out();
for (int i = 0; i < size; i++) {
m_sharedProcs.append(td_par->get_shared_proc_list()->get_and_step());
}
size = td_par->get_ghost_proc_list()->size();
td_par->get_ghost_proc_list()->reset();
m_ghostProcs.clean_out();
for (int i = 0; i < size; i++) {
m_ghostProcs.append(td_par->get_ghost_proc_list()->get_and_step());
}
if (delete_attrib() == CUBIT_TRUE) delete_attrib(CUBIT_FALSE);
}
return CUBIT_SUCCESS;
}
CubitSimpleAttrib CABodies::cubit_simple_attrib()
{
std::vector<CubitString> cs_list;
std::vector<int> i_list;
// attribute internal name
cs_list.push_back(att_internal_name());
// is interface
i_list.push_back(m_interface);
// unique ID
i_list.push_back(m_uniqueID);
// shared bodies
i_list.push_back(m_sharedBodies.size());
int i;
for (i = m_sharedBodies.size(); i > 0; i--) {
i_list.push_back(m_sharedBodies.get_and_step());
}
// shared procs
i_list.push_back(m_sharedProcs.size());
for (i = m_sharedProcs.size(); i > 0; i--) {
i_list.push_back(m_sharedProcs.get_and_step());
}
// ghost procs
i_list.push_back(m_ghostProcs.size());
for (i = m_ghostProcs.size(); i > 0; i--) {
i_list.push_back(m_ghostProcs.get_and_step());
}
CubitSimpleAttrib csattrib = CubitSimpleAttrib(&cs_list, NULL, &i_list);
return csattrib;
}
CubitStatus CABodies::reset()
{
m_sharedBodies.clean_out();
return CUBIT_SUCCESS;
}
const std::type_info& CABodies::entity_type_info() const
{
return typeid(CABodies);
}
int CABodies::int_attrib_type()
{
return CA_BODIES;
}
|