FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
base
snl_fei_BlkSizeMsgHandler.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_BlkSizeMsgHandler.hpp
>
12
13
#include <
fei_utils.hpp
>
14
15
#include <
snl_fei_Utils.hpp
>
16
#include <
fei_FieldMask.hpp
>
17
#include <
snl_fei_RecordCollection.hpp
>
18
#include <
fei_VectorSpace.hpp
>
19
#include <
fei_ParameterSet.hpp
>
20
#include <
fei_Graph.hpp
>
21
#include <
snl_fei_Constraint.hpp
>
22
#include <
fei_TemplateUtils.hpp
>
23
24
#include <
fei_EqnBuffer.hpp
>
25
#include <
fei_EqnCommMgr.hpp
>
26
#include <
SNL_FEI_Structure.hpp
>
27
28
#undef fei_file
29
#define fei_file "snl_fei_BlkSizeMsgHandler.cpp"
30
#include <
fei_ErrMacros.hpp
>
31
32
//----------------------------------------------------------------------------
33
snl_fei::BlkSizeMsgHandler::BlkSizeMsgHandler
(
fei::VectorSpace
* vspace,
34
fei::Graph
* graph,
35
MPI_Comm
comm)
36
:
remote_colIndices_
(NULL),
37
local_colIndices_
(NULL),
38
vecSpace_
(vspace),
39
ptBlkMap_
(NULL),
40
graph_
(graph),
41
comm_
(comm),
42
sendProcs_
(0, 64),
43
recvProcs_
(0, 64),
44
firstExchange_
(true)
45
{
46
remote_colIndices_
=
new
fei::comm_map
(0,1);
47
local_colIndices_
=
new
fei::comm_map
(0,1);
48
49
ptBlkMap_
= vspace->
getPointBlockMap
();
50
}
51
52
//----------------------------------------------------------------------------
53
snl_fei::BlkSizeMsgHandler::~BlkSizeMsgHandler
()
54
{
55
delete
remote_colIndices_
;
56
delete
local_colIndices_
;
57
}
58
59
//----------------------------------------------------------------------------
60
int
snl_fei::BlkSizeMsgHandler::do_the_exchange
()
61
{
62
int
local_proc =
fei::localProc
(
comm_
);
63
if
(
fei::numProcs
(
comm_
) < 2) {
64
return
(0);
65
}
66
67
fei::Graph::table_type
* localgraph =
graph_
->getLocalGraph();
68
fei::Graph::table_type::iterator
69
g_iter = localgraph->
begin
(),
70
g_end = localgraph->
end
();
71
72
//First create a table that maps remote processors to column-indices from our
73
//graph.
74
//These are remotely-owned column-indices for which we will need block-sizes.
75
76
for
(; g_iter != g_end; ++g_iter) {
77
fei::Graph::table_type::row_type
* row = (*g_iter).second;
78
79
fei::Graph::table_type::row_type::const_iterator
80
iter = row->
begin
(),
81
iter_end = row->
end
();
82
83
int
owner;
84
85
for
(; iter != iter_end; ++iter) {
86
int
col = *iter;
87
owner =
vecSpace_
->getOwnerProcBlkIndex(col);
88
89
if
(owner != local_proc) {
90
remote_colIndices_
->addIndices(owner, 1, &col);
91
}
92
}
93
}
94
95
//Next, we need to send our lists of remotely-owned column-indices to the
96
//owning processors. After that, those processors can respond by sending us
97
//the sizes for those column-indices.
98
fei::copyKeysToVector
(
remote_colIndices_
->getMap(),
sendProcs_
);
99
100
CHK_ERR
(
fei::mirrorProcs
(
comm_
,
sendProcs_
,
recvProcs_
) );
101
102
firstExchange_
=
true
;
103
104
CHK_ERR
(
fei::exchange
(
comm_
,
this
) );
105
106
firstExchange_
=
false
;
107
108
CHK_ERR
(
fei::exchange
(
comm_
,
this
) );
109
110
return
(0);
111
}
112
113
//----------------------------------------------------------------------------
114
std::vector<int>&
snl_fei::BlkSizeMsgHandler::getSendProcs
()
115
{
116
if
(
firstExchange_
) {
117
return
(
sendProcs_
);
118
}
119
else
{
120
return
(
recvProcs_
);
121
}
122
}
123
124
//----------------------------------------------------------------------------
125
std::vector<int>&
snl_fei::BlkSizeMsgHandler::getRecvProcs
()
126
{
127
if
(
firstExchange_
) {
128
return
(
recvProcs_
);
129
}
130
else
{
131
return
(
sendProcs_
);
132
}
133
}
134
135
//----------------------------------------------------------------------------
136
int
snl_fei::BlkSizeMsgHandler::getSendMessageLength
(
int
destProc,
137
int
& messageLength)
138
{
139
if
(
firstExchange_
) {
140
fei::comm_map::row_type
* cols =
remote_colIndices_
->getRow(destProc);
141
messageLength = cols->size();
142
return
(0);
143
}
144
else
{
145
fei::comm_map::row_type
* cols =
local_colIndices_
->getRow(destProc);
146
messageLength = cols->size()*2;
147
return
(0);
148
}
149
}
150
151
//----------------------------------------------------------------------------
152
int
snl_fei::BlkSizeMsgHandler::getSendMessage
(
int
destProc,
153
std::vector<int>& message)
154
{
155
if
(
firstExchange_
) {
156
fei::comm_map::row_type
* cols =
remote_colIndices_
->getRow(destProc);
157
message.resize(cols->size());
158
fei::copySetToArray
(*cols, message.size(), &message[0]);
159
return
(0);
160
}
161
else
{
162
fei::comm_map::row_type
* cols =
local_colIndices_
->getRow(destProc);
163
164
message.resize(cols->size()*2);
165
166
fei::comm_map::row_type::const_iterator
167
iter = cols->begin(),
168
iter_end = cols->end();
169
170
int
offset = 0;
171
for
(; iter != iter_end; ++iter) {
172
CHK_ERR
(
ptBlkMap_
->getBlkEqnInfo(*iter,
173
message[offset], message[offset+1]) );
174
offset += 2;
175
}
176
177
return
( 0 );
178
}
179
}
180
181
//----------------------------------------------------------------------------
182
int
snl_fei::BlkSizeMsgHandler::processRecvMessage
(
int
srcProc,
183
std::vector<int>& message)
184
{
185
if
(
firstExchange_
) {
186
for
(
unsigned
i=0; i<message.size(); ++i) {
187
local_colIndices_
->addIndices(srcProc, 1, &(message[i]));
188
}
189
}
190
else
{
191
fei::comm_map::row_type
* cols =
remote_colIndices_
->getRow(srcProc);
192
fei::comm_map::row_type::const_iterator
193
iter = cols->begin(),
194
iter_end = cols->end();
195
196
int
offset = 0;
197
for
(; iter != iter_end; ++iter) {
198
int
ptEqn = message[offset];
199
int
blkSize = message[offset+1];
200
for
(
int
i=0; i<blkSize; ++i) {
201
CHK_ERR
(
ptBlkMap_
->setEqn(ptEqn+i, *iter, blkSize) );
202
}
203
offset += 2;
204
}
205
}
206
207
return
(0);
208
}
209
SNL_FEI_Structure.hpp
fei::Graph
Definition
fei_Graph.hpp:20
fei::Graph::table_type
snl_fei::RaggedTable< snl_fei::MapContig< fei::ctg_set< int > * >, fei::ctg_set< int > > table_type
Definition
fei_Graph.hpp:28
fei::VectorSpace
Definition
fei_VectorSpace.hpp:62
fei::VectorSpace::getPointBlockMap
snl_fei::PointBlockMap * getPointBlockMap()
Definition
fei_VectorSpace.hpp:819
fei::ctg_set::end
static const_iterator end()
Definition
fei_ctg_set.hpp:155
fei::ctg_set::begin
const_iterator begin() const
Definition
fei_ctg_set.hpp:145
snl_fei::BlkSizeMsgHandler::local_colIndices_
fei::comm_map * local_colIndices_
Definition
snl_fei_BlkSizeMsgHandler.hpp:47
snl_fei::BlkSizeMsgHandler::getRecvProcs
std::vector< int > & getRecvProcs()
Definition
snl_fei_BlkSizeMsgHandler.cpp:125
snl_fei::BlkSizeMsgHandler::processRecvMessage
int processRecvMessage(int srcProc, std::vector< int > &message)
Definition
snl_fei_BlkSizeMsgHandler.cpp:182
snl_fei::BlkSizeMsgHandler::~BlkSizeMsgHandler
virtual ~BlkSizeMsgHandler()
Definition
snl_fei_BlkSizeMsgHandler.cpp:53
snl_fei::BlkSizeMsgHandler::getSendProcs
std::vector< int > & getSendProcs()
Definition
snl_fei_BlkSizeMsgHandler.cpp:114
snl_fei::BlkSizeMsgHandler::BlkSizeMsgHandler
BlkSizeMsgHandler(fei::VectorSpace *vspace, fei::Graph *graph, MPI_Comm comm)
Definition
snl_fei_BlkSizeMsgHandler.cpp:33
snl_fei::BlkSizeMsgHandler::sendProcs_
std::vector< int > sendProcs_
Definition
snl_fei_BlkSizeMsgHandler.hpp:52
snl_fei::BlkSizeMsgHandler::firstExchange_
bool firstExchange_
Definition
snl_fei_BlkSizeMsgHandler.hpp:55
snl_fei::BlkSizeMsgHandler::graph_
fei::Graph * graph_
Definition
snl_fei_BlkSizeMsgHandler.hpp:50
snl_fei::BlkSizeMsgHandler::getSendMessageLength
int getSendMessageLength(int destProc, int &messageLength)
Definition
snl_fei_BlkSizeMsgHandler.cpp:136
snl_fei::BlkSizeMsgHandler::ptBlkMap_
snl_fei::PointBlockMap * ptBlkMap_
Definition
snl_fei_BlkSizeMsgHandler.hpp:49
snl_fei::BlkSizeMsgHandler::recvProcs_
std::vector< int > recvProcs_
Definition
snl_fei_BlkSizeMsgHandler.hpp:53
snl_fei::BlkSizeMsgHandler::getSendMessage
int getSendMessage(int destProc, std::vector< int > &message)
Definition
snl_fei_BlkSizeMsgHandler.cpp:152
snl_fei::BlkSizeMsgHandler::do_the_exchange
int do_the_exchange()
Definition
snl_fei_BlkSizeMsgHandler.cpp:60
snl_fei::BlkSizeMsgHandler::remote_colIndices_
fei::comm_map * remote_colIndices_
Definition
snl_fei_BlkSizeMsgHandler.hpp:46
snl_fei::BlkSizeMsgHandler::vecSpace_
fei::VectorSpace * vecSpace_
Definition
snl_fei_BlkSizeMsgHandler.hpp:48
snl_fei::BlkSizeMsgHandler::comm_
MPI_Comm comm_
Definition
snl_fei_BlkSizeMsgHandler.hpp:51
snl_fei::RaggedTable< snl_fei::MapContig< fei::ctg_set< int > * >, fei::ctg_set< int > >::iterator
snl_fei::MapContig< fei::ctg_set< int > * >::iterator iterator
Definition
snl_fei_RaggedTable.hpp:72
snl_fei::RaggedTable::begin
iterator begin()
Definition
snl_fei_RaggedTable.hpp:205
snl_fei::RaggedTable< snl_fei::MapContig< fei::ctg_set< int > * >, fei::ctg_set< int > >::row_type
fei::ctg_set< int > row_type
Definition
snl_fei_RaggedTable.hpp:44
snl_fei::RaggedTable::end
iterator end()
Definition
snl_fei_RaggedTable.hpp:212
fei_EqnBuffer.hpp
fei_EqnCommMgr.hpp
fei_ErrMacros.hpp
CHK_ERR
#define CHK_ERR(a)
Definition
fei_ErrMacros.hpp:26
fei_FieldMask.hpp
fei_Graph.hpp
fei_ParameterSet.hpp
fei_TemplateUtils.hpp
fei_VectorSpace.hpp
fei_macros.hpp
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
fei_utils.hpp
fei::localProc
int localProc(MPI_Comm comm)
Definition
fei_CommUtils.cpp:13
fei::copySetToArray
void copySetToArray(const SET_TYPE &set_obj, int lenList, int *list)
Definition
fei_TemplateUtils.hpp:30
fei::copyKeysToVector
void copyKeysToVector(const MAP_TYPE &map_obj, std::vector< int > &keyvector)
Definition
fei_TemplateUtils.hpp:81
fei::mirrorProcs
int mirrorProcs(MPI_Comm comm, std::vector< int > &toProcs, std::vector< int > &fromProcs)
Definition
fei_CommUtils.cpp:45
fei::exchange
int exchange(MPI_Comm comm, MessageHandler< T > *msgHandler)
Definition
fei_CommUtils.hpp:597
fei::comm_map
snl_fei::RaggedTable< std::map< int, std::set< int > * >, std::set< int > > comm_map
Definition
fei_CommUtils.hpp:51
fei::numProcs
int numProcs(MPI_Comm comm)
Definition
fei_CommUtils.cpp:25
snl_fei_BlkSizeMsgHandler.hpp
snl_fei_Constraint.hpp
snl_fei_RecordCollection.hpp
snl_fei_Utils.hpp
Generated by
1.17.0