-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBOVVectorImage.cxx
99 lines (88 loc) · 2.42 KB
/
BOVVectorImage.cxx
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
/*
____ _ __ ____ __ ____
/ __/___(_) / ___ ____/ __ \__ _____ ___ / /_ / _/__ ____
_\ \/ __/ / _ \/ -_) __/ /_/ / // / -_|_-</ __/ _/ // _ \/ __/
/___/\__/_/_.__/\__/_/ \___\_\_,_/\__/___/\__/ /___/_//_/\__(_)
Copyright 2012 SciberQuest Inc.
*/
#include "BOVVectorImage.h"
//-----------------------------------------------------------------------------
BOVVectorImage::~BOVVectorImage()
{
this->Clear();
}
//-----------------------------------------------------------------------------
void BOVVectorImage::Clear()
{
int nComps=this->ComponentFiles.size();
for (int i=0; i<nComps; ++i)
{
BOVScalarImage *comp=this->ComponentFiles[i];
if (comp)
{
delete comp;
}
}
this->ComponentFiles.clear();
}
//-----------------------------------------------------------------------------
void BOVVectorImage::SetComponentFile(
int i,
MPI_Comm comm,
MPI_Info hints,
const char *fileName,
int mode)
{
BOVScalarImage *oldComp = this->ComponentFiles[i];
if (oldComp)
{
delete oldComp;
}
this->ComponentFiles[i] = new BOVScalarImage(comm,hints,fileName,mode);
}
//-----------------------------------------------------------------------------
void BOVVectorImage::SetNumberOfComponents(int nComps)
{
this->Clear();
this->ComponentFiles.resize(nComps,0);
}
//-----------------------------------------------------------------------------
ostream &operator<<(ostream &os, const BOVVectorImage &vi)
{
os << vi.GetName() << endl;
int nComps = vi.GetNumberOfComponents();
for (int i=0; i<nComps; ++i)
{
os
<< " " << vi.ComponentFiles[i]->GetFileName()
<< " " << vi.ComponentFiles[i]->GetFile()
<< endl;
}
#ifndef SQTK_WITHOUT_MPI
// only one of the file's hints
MPI_File file=vi.ComponentFiles[0]->GetFile();
if (file)
{
os << " Hints:" << endl;
int WorldRank;
MPI_Comm_rank(MPI_COMM_WORLD,&WorldRank);
if (WorldRank==0)
{
MPI_Info info;
char key[MPI_MAX_INFO_KEY];
char val[MPI_MAX_INFO_KEY];
MPI_File_get_info(file,&info);
int nKeys;
MPI_Info_get_nkeys(info,&nKeys);
for (int i=0; i<nKeys; ++i)
{
int flag;
MPI_Info_get_nthkey(info,i,key);
MPI_Info_get(info,key,MPI_MAX_INFO_KEY,val,&flag);
os << " " << key << "=" << val << endl;
}
}
}
#endif
return os;
}