10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
12 #include "../shared/io/Comm/IssmComm.h"
20 this->common_recv = NULL;
21 this->common_recv_ids = NULL;
22 this->common_send = NULL;
23 this->common_send_ids = NULL;
24 this->numberofnodes = -1;
25 this->numberofnodes_local = -1;
26 this->numberofmasters_local = -1;
33 if(this->common_recv) xDelete<int>(common_recv);
34 if(this->common_send) xDelete<int>(common_send);
35 if(this->common_recv_ids){
36 for(
int i=0;i<num_proc;i++) if(common_recv_ids[i]) xDelete<int>(common_recv_ids[i]);
37 xDelete<int*>(common_recv_ids);
39 if(this->common_send_ids){
40 for(
int i=0;i<num_proc;i++) if(common_send_ids[i]) xDelete<int>(common_send_ids[i]);
41 xDelete<int*>(common_send_ids);
54 output->
sorted=this->sorted;
57 for(vector<Object*>::iterator obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){
62 int objsize = this->numsorted;
65 if(this->sorted && objsize>0 && this->id_offsets){
67 xMemCpy<int>(output->
id_offsets,this->id_offsets,objsize);
69 if(this->sorted && objsize>0 && this->sorted_ids){
71 xMemCpy<int>(output->
sorted_ids,this->sorted_ids,objsize);
79 if(this->common_recv){
81 for(
int i=0;i<num_proc;i++) output->
common_recv[i]=this->common_recv[i];
83 if(this->common_send){
85 for(
int i=0;i<num_proc;i++) output->
common_send[i]=this->common_send[i];
87 if(this->common_recv_ids){
89 for(
int i=0;i<num_proc;i++){
91 for(
int j=0;j<this->common_recv[i];j++) output->
common_recv_ids[i][j]=this->common_recv_ids[i][j];
94 if(this->common_send_ids){
96 for(
int i=0;i<num_proc;i++){
98 for(
int j=0;j<this->common_send[i];j++) output->
common_send_ids[i][j]=this->common_send_ids[i][j];
105 void Nodes::Marshall(
char** pmarshalled_data,
int* pmarshalled_data_size,
int marshall_direction){
108 int test = num_procs;
115 if(test!=num_procs)
_error_(
"number of cores is not the same as before");
120 this->common_recv_ids = xNew<int*>(num_procs);
121 this->common_send_ids = xNew<int*>(num_procs);
122 for(
int i=0;i<num_procs;i++){
123 this->common_recv_ids[i] = NULL;
124 this->common_send_ids[i] = NULL;
129 if(this->
Size()==0)
return;
133 for(
int i=0;i<num_procs;i++){
134 if(this->common_recv[i])
MARSHALLING_DYNAMIC(this->common_recv_ids[i],
int,this->common_recv[i]);
135 if(this->common_send[i])
MARSHALLING_DYNAMIC(this->common_send_ids[i],
int,this->common_send[i]);
147 for(
int i=0;i<this->
Size();i++){
148 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
154 for(
int i=0;i<this->
Size();i++){
155 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
159 int dofcount_local = dofcount;
160 for(
int i=0;i<this->
Size();i++){
161 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
169 int* alldofcount=xNew<int>(num_procs);
175 for(
int i=0;i<my_rank;i++) offset+=alldofcount[i];
176 xDelete<int>(alldofcount);
178 for(
int i=0;i<this->
Size();i++){
179 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
186 int maxdofspernode = this->MaxNumDofs(setenum);
187 int* truedofs = xNewZeroInit<int>(this->
Size()*maxdofspernode);
188 for(
int rank=0;rank<num_procs;rank++){
189 if(this->common_send[rank]){
190 int numids = this->common_send[rank];
191 for(
int i=0;i<numids;i++){
192 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->common_send_ids[rank][i]));
198 for(
int rank=0;rank<num_procs;rank++){
199 if(this->common_recv[rank]){
200 int numids = this->common_recv[rank];
202 for(
int i=0;i<numids;i++){
203 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->common_recv_ids[rank][i]));
208 xDelete<int>(truedofs);
211 for(
int i=0;i<this->
Size();i++){
212 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
233 this->numberofnodes_local=this->
Size();
234 this->numberofmasters_local=0;
235 for(
int i=0;i<this->
Size();i++){
236 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
237 if(!node->
clone) this->numberofmasters_local++;
243 for(
int i=0;i<this->
Size();i++){
244 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
247 for(
int i=0;i<this->
Size();i++){
248 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
253 int* all_num_masters=xNew<int>(num_procs);
257 for(
int i=0;i<my_rank;i++) offset+=all_num_masters[i];
258 xDelete<int>(all_num_masters);
260 for(
int i=0;i<this->
Size();i++){
261 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
262 node->
pid = node->
lid+offset;
266 int* truepids = xNew<int>(this->
Size());
267 for(
int rank=0;rank<num_procs;rank++){
268 if(this->common_send[rank]){
269 int numids = this->common_send[rank];
270 for(
int i=0;i<numids;i++){
271 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->common_send_ids[rank][i]));
272 truepids[i] = node->
pid;
277 for(
int rank=0;rank<num_procs;rank++){
278 if(this->common_recv[rank]){
279 int numids = this->common_recv[rank];
281 for(
int i=0;i<numids;i++){
282 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->common_recv_ids[rank][i]));
283 node->
pid = truepids[i];
287 xDelete<int>(truepids);
300 for(
int i=0;i<this->
Size();i++){
301 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
304 if(numdofs>
max)
max=numdofs;
319 int numdofs=this->NumberOfDofsLocal(setenum);
331 for(
int i=0;i<this->
Size();i++){
332 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
347 for(
int i=0;i<this->
Size();i++){
348 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
356 return this->numberofnodes;
361 return this->numberofmasters_local;
366 return this->numberofnodes_local;
375 for(
int i=0;i<this->
Size();i++){
376 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
386 if(allflag)
return true;
402 int gsize = this->NumberOfDofs(
GsetEnum);
403 int glocalsize = this->NumberOfDofsLocal(
GsetEnum);
407 for(
int i=0;i<this->
Size();i++){
408 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
415 for(
int j=0;j<node->
gsize;j++){
417 if(node->
s_set[j])
_error_(
"a degree of freedom is both in f and s set!");
422 if(node->
s_set[j]==0)
_error_(
"a degree of freedom is neither in f nor in s set!");
435 for(
int i=0;i<this->
Size();i++){
436 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
442 for(
int j=0;j<node->
gsize;j++){
445 if(reCast<int>(local_dofs_check[index]) != node->
fdoflist[countf]){
446 _error_(
"Dof #"<<j<<
" of node sid "<<node->
Sid()<<
" not consistent: "<<local_dofs_check[index]<<
"!="<<node->
fdoflist[countf]);
451 if(local_dofs_check[index] != -1.){
452 _error_(
"Dof #"<<j<<
" of node sid "<<node->
Sid()<<
" not consistently in s set");
461 xDelete<IssmDouble>(local_dofs_check);
471 int glocalsize = this->NumberOfDofsLocalAll(
GsetEnum);
472 int glocalsize_masters = this->NumberOfDofsLocal(
GsetEnum);
473 int maxdofspernode = this->MaxNumDofs(
GsetEnum);
476 int *indices_ug_masters = NULL;
479 _assert_(glocalsize_masters==indices_ug_masters[glocalsize_masters-1] - indices_ug_masters[0]+1);
480 xDelete<int>(indices_ug_masters);
483 IssmDouble *local_ug = xNew<IssmDouble>(glocalsize);
484 xMemCpy<IssmDouble>(local_ug,local_ug_masters,glocalsize_masters);
485 xDelete<IssmDouble>(local_ug_masters);
489 IssmDouble* buffer = xNew<IssmDouble>(this->
Size()*maxdofspernode,
"t");
491 IssmDouble* buffer = xNew<IssmDouble>(this->
Size()*maxdofspernode);
493 for(
int rank=0;rank<num_procs;rank++){
494 if(this->common_send[rank]){
495 int numids = this->common_send[rank];
496 for(
int i=0;i<numids;i++){
497 int master_lid = this->common_send_ids[rank][i];
498 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(master_lid));
500 for(
int j=0;j<node->
gsize;j++) buffer[i*maxdofspernode+j]=local_ug[node->
gdoflist_local[j]];
505 for(
int rank=0;rank<num_procs;rank++){
506 if(this->common_recv[rank]){
507 int numids = this->common_recv[rank];
509 for(
int i=0;i<numids;i++){
510 int master_lid = this->common_recv_ids[rank][i];
511 Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(master_lid));
512 for(
int j=0;j<node->
gsize;j++) local_ug[node->
gdoflist_local[j]] = buffer[i*maxdofspernode+j];
516 xDelete<IssmDouble>(buffer);
519 *plocal_ug = local_ug;