20 #define fei_file "test_VectorSpace.cpp"
48 std::vector<int> fieldSizes(
numProcs_, fieldSize);
50 for(i=0; i<
numProcs_; ++i) fieldIDs[i] = i;
55 vspace.
defineFields(fieldIDs.size(), &fieldIDs[0], &fieldSizes[0]);
62 int numSharingProcsPerID = 1;
66 &numSharingProcsPerID, &sharingProc) );
74 std::vector<int> globalIndexOffsets;
88 std::vector<int>& fieldIDs = testdata->
fieldIDs;
89 std::vector<int>& idTypes = testdata->
idTypes;
90 std::vector<int>& ids = testdata->
ids;
109 std::vector<int> globalOffsets;
111 vectorSpace.getGlobalIndexOffsets(globalOffsets);
123 std::vector<int> globalBlkOffsets;
124 vectorSpace.getGlobalBlkIndexOffsets(globalBlkOffsets);
135 int len = ids.size();
137 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[0], fieldIDs[0],
138 0, 0, globalIndex) );
141 int correctBlkIndex = globalBlkOffsets[
localProc_];
142 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
145 if (globalIndex != correctIndex) {
149 int globalBlkIndex = 0;
150 CHK_ERR( vectorSpace.getGlobalBlkIndex(idTypes[0], ids[0], globalBlkIndex) );
151 if (globalBlkIndex != correctBlkIndex) {
153 << globalBlkIndex <<
", correctBlkIndex: " << correctBlkIndex <<
FEI_ENDL;
157 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[1], fieldIDs[0],
158 0, 0, globalIndex) );
161 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
163 if (globalIndex != correctIndex) {
167 CHK_ERR( vectorSpace.getGlobalBlkIndex(idTypes[0], ids[1], globalBlkIndex) );
168 correctBlkIndex = globalBlkOffsets[
localProc_]+1;
171 if (globalBlkIndex != correctBlkIndex) {
173 << globalBlkIndex <<
", correctBlkIndex: " << correctBlkIndex <<
FEI_ENDL;
177 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[len-1], fieldIDs[0],
178 0, 0, globalIndex) );
179 correctIndex = globalOffsets[
localProc_] + 12;
180 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
182 if (globalIndex != correctIndex) {
186 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[0], fieldIDs[1],
187 0, 0, globalIndex) );
189 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
191 if (globalIndex != correctIndex) {
195 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[1], fieldIDs[1],
196 0, 0, globalIndex) );
198 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
200 if (globalIndex != correctIndex) {
204 CHK_ERR( vectorSpace.getGlobalIndex(idTypes[0], ids[len-1], fieldIDs[1],
205 0, 0, globalIndex) );
206 correctIndex = globalOffsets[
localProc_] + 13;
207 if (
localProc_ != 0) correctIndex -= 2*numDOFsPerID;
209 if (globalIndex != correctIndex) {
213 std::vector<int> globalIndices(ids.size()*numDOFsPerID);
215 CHK_ERR( vectorSpace.getGlobalIndices(ids.size(),
217 idTypes[0], fieldIDs[0],
218 &globalIndices[0] ));
220 std::vector<int> idFieldIDs(ids.size(), fieldIDs[1]);
221 std::vector<int> idIDTypes(ids.size(), idTypes[0]);
223 CHK_ERR( vectorSpace.getGlobalIndices(ids.size(),
225 idTypes[0], fieldIDs[0],
226 &globalIndices[0] ));
228 CHK_ERR( vectorSpace.getGlobalBlkIndices(ids.size(),
231 &globalIndices[0] ));
233 CHK_ERR( vectorSpace.getGlobalIndices(ids.size(),
237 &globalIndices[0]) );
239 unsigned numFields = vectorSpace.getNumFields();
240 if (numFields != fieldIDs.size()) {
244 std::vector<int> testgetfields;
245 vectorSpace.getFields(testgetfields);
246 if (testgetfields.size() != numFields) {
250 if (fieldIDs != testgetfields) {
262 bool run_this_test =
false;
263 assert( (run_this_test =
true) ==
true);
264 if (!run_this_test)
return(0);
273 std::vector<int>& idTypes = testdata->
idTypes;
274 std::vector<int>& ids = testdata->
ids;
288 int numSharingProcsPerID = 1;
292 &numSharingProcsPerID,
305 if (
numProcs_ > 1)
if (err == 0)
return(-1);
340 std::vector<int> globalOffsets;
341 std::vector<int> globalOffsetsCopy;
347 for(
size_t i=0; i<globalOffsets.size(); ++i) {
348 if (globalOffsets[i] != globalOffsetsCopy[i]) {
376 MPI_Comm_rank(comm, &localProc);
385 false,
false, (
const char*)0, factory);
389 throw std::runtime_error(
"test_Vector::vector_test1: ERROR, failed to create valid fei::VectorSpace.");
400 bool defineBothFields,
401 bool initSolnBothFields,
404 bool turnOnDebugOutput)
417 if (factory.
get() == NULL) {
426 std::vector<int>& fieldIDs = testdata->
fieldIDs;
427 std::vector<int>& fieldSizes = testdata->
fieldSizes;
428 std::vector<int>& idTypes = testdata->
idTypes;
429 std::vector<int>& ids = testdata->
ids;
430 std::vector<int>& sharedIDs = testdata->
sharedIDs;
432 std::vector<int>& sharingProcs = testdata->
sharingProcs;
436 paramset.
add(param1);
437 if (turnOnDebugOutput) {
439 paramset.
add(param2);
444 int numFields = defineBothFields ? 2 : 1;
452 vectorSpace.
addDOFs(fieldIDs[0],
457 if (initSolnBothFields) {
458 vectorSpace.
addDOFs(fieldIDs[1],
466 sharedIDs.size() ? &sharedIDs[0] : 0,
467 numSharingProcsPerID.size() ? &numSharingProcsPerID[0] : 0,
468 sharingProcs.size() ? &sharingProcs[0] : 0
int initSharedIDs(int numShared, int idType, const int *sharedIDs, const int *numSharingProcsPerID, const int *sharingProcs)
std::vector< int > fieldSizes
virtual ~test_VectorSpace()
std::vector< int > fieldIDs
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
std::vector< int > sharedIDs
int addDOFs(int fieldID, int idType, int numIDs, const int *IDs)
std::vector< int > idTypes
void setParameters(const fei::ParameterSet ¶mset)
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
int addVectorSpace(fei::VectorSpace *inputSpace)
test_VectorSpace(MPI_Comm comm)
void add(const Param ¶m, bool maintain_unique_keys=true)
void defineIDTypes(int numIDTypes, const int *idTypes)
std::vector< int > sharingProcs
std::ostream & console_out()
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
int localProc(MPI_Comm comm)
std::vector< int > numSharingProcsPerID
int numProcs(MPI_Comm comm)
static fei::SharedPtr< fei::VectorSpace > create_VectorSpace(MPI_Comm comm)