11 #include "PanzerAdaptersSTK_config.hpp"
13 #ifdef PANZER_HAVE_EPETRA_STACK
18 #include "Kokkos_DynRankView.hpp"
20 #include <stk_mesh/base/FieldBase.hpp>
22 namespace panzer_stk {
25 const Epetra_Vector & x,
const std::vector<std::size_t> & localCellIds,
26 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc);
29 std::map<std::string,
Teuchos::RCP<std::vector<std::size_t> > > & localIds);
33 std::vector<std::string> blocks;
37 for(std::size_t eb=0;eb<blocks.size();eb++) {
38 const std::string & blockId = blocks[eb];
41 std::vector<stk::mesh::Entity> elements;
45 for(std::size_t el=0;el<elements.size();el++) {
47 double * solnData = stk::mesh::field_data(*field,elements[el]);
49 solnData[0] = data[localId];
56 write_solution_data(dofMngr,mesh,*x(0),prefix,postfix);
61 typedef Kokkos::DynRankView<double,PHX::Device> FieldContainer;
64 std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > localIds;
65 build_local_ids(mesh,localIds);
68 for(
const auto & itr : localIds) {
69 const auto blockId = itr.first;
70 const auto & localCellIds = *(itr.second);
72 std::map<std::string,FieldContainer> data;
75 gather_in_block(blockId,dofMngr,x,localCellIds,data);
78 for(
const auto & dataItr : data)
84 const Epetra_Vector & x,
const std::vector<std::size_t> & localCellIds,
85 std::map<std::string,Kokkos::DynRankView<double,PHX::Device> > & fc)
89 for(std::size_t fieldIndex=0;fieldIndex<fieldNums.size();fieldIndex++) {
90 int fieldNum = fieldNums[fieldIndex];
95 fc[fieldStr] = Kokkos::DynRankView<double,PHX::Device>(
"fc",localCellIds.size(),elmtOffset.size());
96 auto field = Kokkos::create_mirror_view(fc[fieldStr]);
100 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
101 std::vector<panzer::GlobalOrdinal> GIDs;
102 std::vector<int> LIDs;
103 std::size_t cellLocalId = localCellIds[worksetCellIndex];
108 LIDs.resize(GIDs.size());
109 for(std::size_t i=0;i<GIDs.size();i++)
110 LIDs[i] = x.Map().LID(GIDs[i]);
113 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
114 int offset = elmtOffset[basis];
115 int lid = LIDs[offset];
116 field(worksetCellIndex,basis) = x[lid];
119 Kokkos::deep_copy(fc[fieldStr], field);
124 std::map<std::string,
Teuchos::RCP<std::vector<std::size_t> > > & localIds)
127 std::vector<std::string> blockIds;
130 std::vector<std::string>::const_iterator idItr;
131 for(idItr=blockIds.begin();idItr!=blockIds.end();++idItr) {
132 std::string blockId = *idItr;
134 localIds[blockId] =
Teuchos::rcp(
new std::vector<std::size_t>);
135 std::vector<std::size_t> & localBlockIds = *localIds[blockId];
138 std::vector<stk::mesh::Entity> blockElmts;
141 std::vector<stk::mesh::Entity>::const_iterator itr;
142 for(itr=blockElmts.begin();itr!=blockElmts.end();++itr)
145 std::sort(localBlockIds.begin(),localBlockIds.end());
151 #endif // PANZER_HAVE_EPETRA_STACK
virtual const std::string & getFieldString(int num) const =0
Reverse lookup of the field string from a field number.
void setSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
void getElementBlockNames(std::vector< std::string > &names) const
stk::mesh::Field< double > SolutionFieldType
std::size_t elementLocalId(stk::mesh::Entity elmt) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
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.
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
virtual void getElementGIDs(panzer::LocalOrdinal localElmtId, std::vector< panzer::GlobalOrdinal > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
#define TEUCHOS_ASSERT(assertion_test)
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const