FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
base
snl_fei_SubdMsgHandler.cpp
Go to the documentation of this file.
1
/*--------------------------------------------------------------------*/
2
/* Copyright 2005 Sandia Corporation. */
3
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4
/* non-exclusive license for use of this work by or on behalf */
5
/* of the U.S. Government. Export of this program may require */
6
/* a license from the United States Government. */
7
/*--------------------------------------------------------------------*/
8
9
#include <
fei_macros.hpp
>
10
11
#include <
snl_fei_SubdMsgHandler.hpp
>
12
#include <
snl_fei_RecordCollection.hpp
>
13
#include <
fei_SharedIDs.hpp
>
14
#include <
fei_TemplateUtils.hpp
>
15
16
#undef fei_file
17
#define fei_file "snl_fei::SubdMsgHandler"
18
#include <
fei_ErrMacros.hpp
>
19
20
snl_fei::SubdMsgHandler::SubdMsgHandler
(
RecordCollection
* recordCollection,
21
fei::SharedIDs<int>
* sharedIDTable,
22
fei::SharedIDs<int>
* subdomainIDTable)
23
:
sendPattern_
(NULL),
24
recvPattern_
(NULL),
25
recordCollection_
(recordCollection),
26
sharedIDTable_
(sharedIDTable),
27
subdomainIDTable_
(subdomainIDTable),
28
sendProcs_
(0, 32),
29
recvProcs_
(0, 32)
30
{
31
}
32
33
snl_fei::SubdMsgHandler::~SubdMsgHandler
()
34
{
35
}
36
37
std::vector<int>&
snl_fei::SubdMsgHandler::getSendProcs
()
38
{
39
fei::copyKeysToVector
(
sendPattern_
->getMap(),
sendProcs_
);
40
return
(
sendProcs_
);
41
}
42
43
std::vector<int>&
snl_fei::SubdMsgHandler::getRecvProcs
()
44
{
45
fei::copyKeysToVector
(
recvPattern_
->getMap(),
recvProcs_
);
46
return
(
recvProcs_
);
47
}
48
49
int
snl_fei::SubdMsgHandler::getSendMessageLength
(
int
destProc,
50
int
& messageLength)
51
{
52
fei::comm_map::row_type
* list =
sendPattern_
->getRow(destProc);
53
if
(list == NULL) {
54
FEI_COUT
<<
"SubdMsdHandler: destProc: "
<< destProc <<
", list is NULL."
<<
FEI_ENDL
;
55
return
(-1);
56
}
57
58
messageLength = list->size();
59
60
return
( 0 );
61
}
62
63
int
snl_fei::SubdMsgHandler::getSendMessage
(
int
destProc,
64
std::vector<int>& message)
65
{
66
int
len =
sendPattern_
->getRow(destProc)->size();
67
message.resize(len);
68
int
* msgPtr = &message[0];
69
70
fei::comm_map::row_type
* ids =
sendPattern_
->getRow(destProc);
71
fei::comm_map::row_type::const_iterator
72
id_iter = ids->begin(),
73
id_end = ids->end();
74
75
int
offset = 0;
76
for
(; id_iter != id_end; ++id_iter) {
77
int
ID = *id_iter;
78
fei::Record<int>
* rec =
recordCollection_
->getRecordWithID(ID);
79
if
(rec == NULL) {
80
ERReturn
(-1);
81
}
82
83
if
(rec->
isInLocalSubdomain_
) {
84
msgPtr[offset++] = 1;
85
}
86
else
{
87
msgPtr[offset++] = 0;
88
}
89
}
90
91
return
(0);
92
}
93
94
int
snl_fei::SubdMsgHandler::processRecvMessage
(
int
srcProc,
95
std::vector<int>& message)
96
{
97
fei::comm_map::row_type
* ids =
recvPattern_
->getRow(srcProc);
98
fei::comm_map::row_type::const_iterator
99
id_iter = ids->begin(),
100
id_end = ids->end();
101
102
int
* msgPtr = &message[0];
103
104
if
(message.size() != ids->size()) {
105
ERReturn
(-1);
106
}
107
108
int
offset = 0;
109
for
(; id_iter != id_end; ++id_iter) {
110
int
ID = *id_iter;
111
112
bool
isInRemoteSubdomain = msgPtr[offset++] > 1 ? true :
false
;
113
114
if
(isInRemoteSubdomain) {
115
subdomainIDTable_
->addSharedID(ID, 1, &srcProc);
116
}
117
}
118
119
return
(0);
120
}
121
fei::Record
Definition
fei_Record.hpp:20
fei::Record::isInLocalSubdomain_
bool isInLocalSubdomain_
Definition
fei_Record.hpp:162
fei::SharedIDs
Definition
fei_SharedIDs.hpp:22
snl_fei::RaggedTable< std::map< int, std::set< int > * >, std::set< int > >::row_type
std::set< int > row_type
Definition
snl_fei_RaggedTable.hpp:44
snl_fei::RecordCollection
Definition
snl_fei_RecordCollection.hpp:32
snl_fei::SubdMsgHandler::getRecvProcs
std::vector< int > & getRecvProcs()
Definition
snl_fei_SubdMsgHandler.cpp:43
snl_fei::SubdMsgHandler::getSendMessage
int getSendMessage(int destProc, std::vector< int > &message)
Definition
snl_fei_SubdMsgHandler.cpp:63
snl_fei::SubdMsgHandler::subdomainIDTable_
fei::SharedIDs< int > * subdomainIDTable_
Definition
snl_fei_SubdMsgHandler.hpp:61
snl_fei::SubdMsgHandler::~SubdMsgHandler
virtual ~SubdMsgHandler()
Definition
snl_fei_SubdMsgHandler.cpp:33
snl_fei::SubdMsgHandler::getSendProcs
std::vector< int > & getSendProcs()
Definition
snl_fei_SubdMsgHandler.cpp:37
snl_fei::SubdMsgHandler::sendPattern_
fei::comm_map * sendPattern_
Definition
snl_fei_SubdMsgHandler.hpp:57
snl_fei::SubdMsgHandler::sharedIDTable_
fei::SharedIDs< int > * sharedIDTable_
Definition
snl_fei_SubdMsgHandler.hpp:60
snl_fei::SubdMsgHandler::recvPattern_
fei::comm_map * recvPattern_
Definition
snl_fei_SubdMsgHandler.hpp:58
snl_fei::SubdMsgHandler::recvProcs_
std::vector< int > recvProcs_
Definition
snl_fei_SubdMsgHandler.hpp:64
snl_fei::SubdMsgHandler::recordCollection_
RecordCollection * recordCollection_
Definition
snl_fei_SubdMsgHandler.hpp:59
snl_fei::SubdMsgHandler::SubdMsgHandler
SubdMsgHandler(RecordCollection *recordCollection, fei::SharedIDs< int > *sharedIDTable, fei::SharedIDs< int > *subdomainIDTable)
Definition
snl_fei_SubdMsgHandler.cpp:20
snl_fei::SubdMsgHandler::sendProcs_
std::vector< int > sendProcs_
Definition
snl_fei_SubdMsgHandler.hpp:63
snl_fei::SubdMsgHandler::getSendMessageLength
int getSendMessageLength(int destProc, int &messageLength)
Definition
snl_fei_SubdMsgHandler.cpp:49
snl_fei::SubdMsgHandler::processRecvMessage
int processRecvMessage(int srcProc, std::vector< int > &message)
Definition
snl_fei_SubdMsgHandler.cpp:94
fei_ErrMacros.hpp
ERReturn
#define ERReturn(a)
Definition
fei_ErrMacros.hpp:37
fei_SharedIDs.hpp
fei_TemplateUtils.hpp
FEI_ENDL
#define FEI_ENDL
Definition
fei_iostream.hpp:34
FEI_COUT
#define FEI_COUT
Definition
fei_iostream.hpp:33
fei_macros.hpp
fei::copyKeysToVector
void copyKeysToVector(const MAP_TYPE &map_obj, std::vector< int > &keyvector)
Definition
fei_TemplateUtils.hpp:81
snl_fei_RecordCollection.hpp
snl_fei_SubdMsgHandler.hpp
Generated by
1.17.0