43 #include "PanzerAdaptersSTK_config.hpp" 48 #include "Kokkos_DynRankView.hpp" 50 #include <stk_mesh/base/FieldBase.hpp> 54 template <
typename GlobalOrdinal>
56 const Epetra_Vector & x,
const std::vector<std::size_t> & localCellIds,
57 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc);
59 #ifdef PANZER_HAVE_FEI 60 void scatter_to_vector(
const std::string & blockId,
const panzer::DOFManagerFEI<int,int> & dofMngr,
61 const std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc,
62 const std::vector<std::size_t> & localCellIds,
67 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > & localIds);
71 std::vector<std::string> blocks;
75 for(std::size_t eb=0;eb<blocks.size();eb++) {
76 const std::string & blockId = blocks[eb];
79 std::vector<stk::mesh::Entity> elements;
83 for(std::size_t el=0;el<elements.size();el++) {
85 double * solnData = stk::mesh::field_data(*
field,elements[el]);
86 TEUCHOS_ASSERT(solnData!=0);
87 solnData[0] = data[localId];
92 template <
typename GlobalOrdinal>
100 #ifdef PANZER_HAVE_LONG_LONG_INT 105 template <
typename GlobalOrdinal>
108 typedef Kokkos::DynRankView<double,PHX::Device> FieldContainer;
111 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > localIds;
115 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > >::const_iterator itr;
116 for(itr=localIds.begin();itr!=localIds.end();++itr) {
117 std::string blockId = itr->first;
118 const std::vector<std::size_t> & localCellIds = *(itr->second);
120 std::map<std::string,FieldContainer> data;
126 std::map<std::string,FieldContainer>::iterator dataItr;
127 for(dataItr=data.begin();dataItr!=data.end();++dataItr)
134 #ifdef PANZER_HAVE_LONG_LONG_INT 139 #ifdef PANZER_HAVE_FEI 140 void read_solution_data(
const panzer::DOFManagerFEI<int,int> & dofMngr,
const panzer_stk::STK_Interface & mesh,Epetra_MultiVector & x)
142 read_solution_data(dofMngr,mesh,*x(0));
145 void read_solution_data(
const panzer::DOFManagerFEI<int,int> & dofMngr,
const panzer_stk::STK_Interface & mesh,Epetra_Vector & x)
147 typedef Kokkos::DynRankView<double,PHX::Device> FieldContainer;
150 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > localIds;
154 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > >::const_iterator itr;
155 for(itr=localIds.begin();itr!=localIds.end();++itr) {
156 std::string blockId = itr->first;
157 const std::vector<std::size_t> & localCellIds = *(itr->second);
159 std::map<std::string,FieldContainer> data;
160 const std::set<int> & fieldNums = dofMngr.getFields(blockId);
163 std::set<int>::const_iterator fieldItr;
164 for(fieldItr=fieldNums.begin();fieldItr!=fieldNums.end();++fieldItr) {
165 std::string fieldStr = dofMngr.getFieldString(*fieldItr);
170 scatter_to_vector(blockId,dofMngr,data,localCellIds,x);
175 template <
typename GlobalOrdinal>
177 const Epetra_Vector & x,
const std::vector<std::size_t> & localCellIds,
178 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc)
182 for(std::size_t fieldIndex=0;fieldIndex<fieldNums.size();fieldIndex++) {
183 int fieldNum = fieldNums[fieldIndex];
188 fc[fieldStr] = Kokkos::DynRankView<double,PHX::Device>(
"fc",localCellIds.size(),elmtOffset.size());
191 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
192 std::vector<GlobalOrdinal> GIDs;
193 std::vector<int> LIDs;
194 std::size_t cellLocalId = localCellIds[worksetCellIndex];
199 LIDs.resize(GIDs.size());
200 for(std::size_t i=0;i<GIDs.size();i++)
201 LIDs[i] = x.Map().LID(GIDs[i]);
207 fc[fieldStr](worksetCellIndex,
basis) = x[lid];
213 #ifdef PANZER_HAVE_FEI 214 void scatter_to_vector(
const std::string & blockId,
const panzer::DOFManagerFEI<int,int> & dofMngr,
215 const std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc,
216 const std::vector<std::size_t> & localCellIds,
220 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> >::const_iterator fieldItr;
221 for(fieldItr=fc.begin();fieldItr!=fc.end();++fieldItr) {
222 std::string fieldStr = fieldItr->first;
223 int fieldNum = dofMngr.getFieldNum(fieldStr);
224 const Kokkos::DynRankView<double,PHX::Device> & data = fieldItr->second;
227 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
228 std::vector<int> GIDs, LIDs;
229 std::size_t cellLocalId = localCellIds[worksetCellIndex];
231 dofMngr.getElementGIDs(cellLocalId,GIDs);
234 LIDs.resize(GIDs.size());
235 for(std::size_t i=0;i<GIDs.size();i++)
236 LIDs[i] = x.Map().LID(GIDs[i]);
238 const std::vector<int> & elmtOffset = dofMngr.getGIDFieldOffsets(blockId,fieldNum);
244 x[lid] = data(worksetCellIndex,
basis);
252 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > & localIds)
255 std::vector<std::string> blockIds;
258 std::vector<std::string>::const_iterator idItr;
259 for(idItr=blockIds.begin();idItr!=blockIds.end();++idItr) {
260 std::string blockId = *idItr;
262 localIds[blockId] = Teuchos::rcp(
new std::vector<std::size_t>);
263 std::vector<std::size_t> & localBlockIds = *localIds[blockId];
266 std::vector<stk::mesh::Entity> blockElmts;
269 std::vector<stk::mesh::Entity>::const_iterator itr;
270 for(itr=blockElmts.begin();itr!=blockElmts.end();++itr)
273 std::sort(localBlockIds.begin(),localBlockIds.end());
virtual void getElementGIDs(LocalOrdinalT localElmtId, std::vector< GlobalOrdinalT > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
void setSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
std::size_t elementLocalId(stk::mesh::Entity elmt) const
stk::mesh::Field< double > SolutionFieldType
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
void write_solution_data(const panzer::UniqueGlobalIndexer< int, GlobalOrdinal > &dofMngr, panzer_stk::STK_Interface &mesh, const Epetra_MultiVector &x, const std::string &prefix, const std::string &postfix)
virtual const std::vector< int > & getGIDFieldOffsets(const std::string &blockId, int fieldNum) const =0
Use the field pattern so that you can find a particular field in the GIDs array.
void getElementBlockNames(std::vector< std::string > &names) const
static void gather_in_block(const std::string &blockId, const panzer::UniqueGlobalIndexer< int, GlobalOrdinal > &dofMngr, const Epetra_Vector &x, const std::vector< std::size_t > &localCellIds, std::map< std::string, Kokkos::DynRankView< double, PHX::Device > > &fc)
template void write_solution_data< int >(const panzer::UniqueGlobalIndexer< int, int > &dofMngr, panzer_stk::STK_Interface &mesh, const Epetra_MultiVector &x, const std::string &prefix, const std::string &postfix)
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const
static void build_local_ids(const panzer_stk::STK_Interface &mesh, std::map< std::string, Teuchos::RCP< std::vector< std::size_t > > > &localIds)
PHX::MDField< const ScalarT, Cell, IP > field
virtual const std::string & getFieldString(int num) const =0
Reverse lookup of the field string from a field number.
void getSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, ArrayT &solutionValues) const
void write_cell_data(panzer_stk::STK_Interface &mesh, const std::vector< double > &data, const std::string &fieldName)
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0