43 #ifndef PANZER_SCATTER_DIRICHLET_RESIDUAL_EPETRA_SG_IMPL_HPP
44 #define PANZER_SCATTER_DIRICHLET_RESIDUAL_EPETRA_SG_IMPL_HPP
46 #include "Panzer_config.hpp"
50 #include "Phalanx_DataLayout_MDALayout.hpp"
56 template<
typename TRAITS,
typename LO,
typename GO>
60 : globalIndexer_(indexer)
61 , globalDataKey_(
"Residual Scatter Container")
63 std::string scatterName = p.
get<std::string>(
"Scatter Name");
68 const std::vector<std::string>& names =
77 side_subcell_dim_ = p.
get<
int>(
"Side Subcell Dimension");
78 local_side_id_ = p.
get<
int>(
"Local Side ID");
83 for (std::size_t eq = 0; eq < names.size(); ++eq) {
84 scatterFields_[eq] = PHX::MDField<ScalarT,Cell,NODE>(names[eq],dl);
91 this->addEvaluatedField(*scatterHolder_);
93 if (p.
isType<std::string>(
"Global Data Key"))
94 globalDataKey_ = p.
get<std::string>(
"Global Data Key");
96 this->setName(scatterName+
" Scatter Residual (SGResidual)");
100 template<
typename TRAITS,
typename LO,
typename GO>
110 std::string fieldName = fieldMap_->find(
scatterFields_[fd].fieldTag().name())->second;
111 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
122 template<
typename TRAITS,
typename LO,
typename GO>
130 dirichletCounter_ = epetraContainer->
get_f();
138 template<
typename TRAITS,
typename LO,
typename GO>
142 std::vector<GO> GIDs;
143 std::vector<int> LIDs;
146 std::string blockId = this->wda(workset).block_id;
147 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
158 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
159 std::size_t cellLocalId = localCellIds[worksetCellIndex];
161 globalIndexer_->getElementGIDs(cellLocalId,GIDs);
164 LIDs.resize(GIDs.size());
165 for(std::size_t i=0;i<GIDs.size();i++)
166 LIDs[i] = map.
LID(GIDs[i]);
168 std::vector<bool> is_owned(GIDs.size(),
false);
169 globalIndexer_->ownedIndices(GIDs,is_owned);
172 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
173 int fieldNum = fieldIds_[fieldIndex];
176 const std::pair<std::vector<int>,std::vector<int> > & indicePair
177 = globalIndexer_->getGIDFieldOffsets_closure(blockId,fieldNum, side_subcell_dim_, local_side_id_);
178 const std::vector<int> & elmtOffset = indicePair.first;
179 const std::vector<int> & basisIdMap = indicePair.second;
188 int basisId = basisIdMap[
basis];
194 for(itr=sgEpetraContainer_->begin();itr!=sgEpetraContainer_->end();++itr,++stochIndex)
195 (*(*itr)->get_f())[lid] = field.coeff(stochIndex);
198 (*dirichletCounter_)[lid] = 1.0;
208 template<
typename TRAITS,
typename LO,
typename GO>
212 : globalIndexer_(indexer)
213 , globalDataKey_(
"Residual Scatter Container")
215 std::string scatterName = p.
get<std::string>(
"Scatter Name");
220 const std::vector<std::string>& names =
229 side_subcell_dim_ = p.
get<
int>(
"Side Subcell Dimension");
230 local_side_id_ = p.
get<
int>(
"Local Side ID");
234 for (std::size_t eq = 0; eq < names.size(); ++eq) {
235 scatterFields_[eq] = PHX::MDField<ScalarT,Cell,NODE>(names[eq],dl);
242 this->addEvaluatedField(*scatterHolder_);
244 if (p.
isType<std::string>(
"Global Data Key"))
245 globalDataKey_ = p.
get<std::string>(
"Global Data Key");
247 this->setName(scatterName+
" Scatter Residual (SGJacobian)");
251 template<
typename TRAITS,
typename LO,
typename GO>
262 std::string fieldName = fieldMap_->find(
scatterFields_[fd].fieldTag().name())->second;
263 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
275 template<
typename TRAITS,
typename LO,
typename GO>
283 dirichletCounter_ = epetraContainer->
get_f();
291 template<
typename TRAITS,
typename LO,
typename GO>
295 std::vector<GO> GIDs;
296 std::vector<int> LIDs;
299 std::string blockId = this->wda(workset).block_id;
300 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
311 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
312 std::size_t cellLocalId = localCellIds[worksetCellIndex];
314 globalIndexer_->getElementGIDs(cellLocalId,GIDs);
317 LIDs.resize(GIDs.size());
318 for(std::size_t i=0;i<GIDs.size();i++)
319 LIDs[i] = map.
LID(GIDs[i]);
321 std::vector<bool> is_owned(GIDs.size(),
false);
322 globalIndexer_->ownedIndices(GIDs,is_owned);
325 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
326 int fieldNum = fieldIds_[fieldIndex];
329 const std::pair<std::vector<int>,std::vector<int> > & indicePair
330 = globalIndexer_->getGIDFieldOffsets_closure(blockId,fieldNum, side_subcell_dim_, local_side_id_);
331 const std::vector<int> & elmtOffset = indicePair.first;
332 const std::vector<int> & basisIdMap = indicePair.second;
339 int basisId = basisIdMap[
basis];
348 for(itr=sgEpetraContainer_->begin();itr!=sgEpetraContainer_->end();++itr,++stochIndex) {
355 int * rowIndices = 0;
356 double * rowValues = 0;
360 for(
int i=0;i<numEntries;i++)
364 (*r)[lid] = scatterField.val().coeff(stochIndex);
367 std::vector<double> jacRow(scatterField.size(),0.0);
369 for(
int sensIndex=0;sensIndex<scatterField.size();++sensIndex)
370 jacRow[sensIndex] = scatterField.fastAccessDx(sensIndex).coeff(stochIndex);
377 (*dirichletCounter_)[lid] = 1.0;
panzer::Traits::SGJacobian::ScalarT ScalarT
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
std::vector< PHX::MDField< const ScalarT, panzer::Cell, panzer::Point > > scatterFields_
T & get(const std::string &name, T def_value)
bool is_null(const std::shared_ptr< T > &p)
PHX::MDField< ScalarT, Cell, IP > field
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
const Epetra_Map & RowMap() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const Teuchos::RCP< Epetra_Vector > get_f() const
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
bool isType(const std::string &name) const
CoeffVector::iterator iterator
panzer::Traits::SGResidual::ScalarT ScalarT
#define TEUCHOS_ASSERT(assertion_test)
Pushes residual values into the residual vector for a Newton-based solve.