47 #include <Xyce_config.h>
52 #include <N_UTL_fwd.h>
53 #include <N_UTL_Misc.h>
58 #include "N_LAS_Vector.h"
59 #include "N_LAS_Matrix.h"
60 #include "N_ERH_ErrorMgr.h"
72 Xyce::NodeNamePairMap & op_in,
73 #ifdef Xyce_PARALLEL_MPI
74 Xyce::NodeNamePairMap & allNodes_in, N_PDS_Comm * pdsCommPtr
76 Xyce::NodeNamePairMap & allNodes_in
79 allNodes_(allNodes_in),
82 #ifdef Xyce_PARALLEL_MPI
83 pdsCommPtr_ (pdsCommPtr),
123 (
const N_LAS_Vector * solution, N_LAS_Vector * residual_vector)
125 residualPtr_ = residual_vector;
126 solutionPtr_ = solution;
128 #ifdef Xyce_PARALLEL_MPI
129 pmap_ = residualPtr_->pmap();
145 Xyce::NodeNamePairMap::iterator op_i;
146 Xyce::NodeNamePairMap::iterator op_end = op_.end();
147 int i, row, rowLen, global_row, numRows;
148 std::vector<int> col;
149 std::vector<double> val;
150 std::vector<double> resTmp;
153 std::map<int,std::string> rowOut;
159 numRows = jacobian->getLocalNumRows();
162 for (row=0 ; row<numRows ; ++row)
164 #ifdef Xyce_PARALLEL_MPI
165 global_row = pmap_->localToGlobalIndex(row);
169 rowLen = jacobian->getRowLength(global_row);
173 jacobian->getRowCopy(global_row, rowLen, rowLen, &val[0], &col[0]);
175 for (i=0 ; i<rowLen ; ++i)
178 if (GID == global_row)
189 skipGID.insert(global_row);
192 #ifdef Xyce_PARALLEL_MPI
193 int numG = skipGID.size();
195 pdsCommPtr_->sumAll(&numG, &numG_tot, 1);
197 pdsCommPtr_->scanSum(&numG, &myPos, 1);
199 std::vector<int> buf(numG_tot,0);
200 std::vector<int> buf_g(numG_tot,0);
201 std::set<int>::iterator skip_i=skipGID.begin();
202 std::set<int>::iterator skip_end=skipGID.end();
203 for ( ; skip_i != skip_end ; ++skip_i)
204 buf[myPos++] = *skip_i;
205 pdsCommPtr_->sumAll (&buf[0], &buf_g[0], numG_tot);
207 for (i=0 ; i < numG_tot ; i++)
208 skipGID.insert(buf_g[i]);
214 std::set<int>::iterator skipLIDEnd = skipLID.end();
215 std::set<int>::iterator skipGIDEnd = skipGID.end();
216 for ( ; op_i != op_end ; ++op_i)
218 row = (*op_i).second.first;
219 if (skipLID.find(row) == skipLIDEnd)
221 #ifdef Xyce_PARALLEL_MPI
222 global_row = pmap_->localToGlobalIndex(row);
226 rowLen = jacobian->getRowLength(global_row);
229 jacobian->getRowCopy(global_row, rowLen, rowLen, &val[0], &col[0]);
231 N_LAS_Vector & residual = (*residualPtr_);
233 for (i=0 ; i<rowLen ; i++)
238 if (skipGID.find(GID) == skipGIDEnd)
240 if (GID == global_row)
251 residual[row] += val[i] *
252 (
const_cast<N_LAS_Vector*
>(solutionPtr_))->getElementByGlobalIndex(GID);
255 jacobian->shirleyPutRow(global_row, rowLen, &val[0], &col[0]);