45 #include <stk_mesh/base/GetEntities.hpp>
46 #include <stk_mesh/base/GetBuckets.hpp>
47 #include <stk_mesh/base/FieldBase.hpp>
49 #include "Epetra_Vector.h"
50 #include "Epetra_MultiVector.h"
51 #include "Epetra_IntVector.h"
52 #include "Epetra_MpiComm.h"
53 #include "Epetra_Map.h"
54 #include "Epetra_LocalMap.h"
55 #include "Epetra_Import.h"
57 #include "Teuchos_FancyOStream.hpp"
59 namespace panzer_stk {
61 namespace periodic_helpers {
65 const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
72 int myVal = failure ? 1 : 0;
74 Comm.
SumAll(&myVal,&sumVal,1);
77 std::vector<int> requiredInts(locallyRequiredIds.size());
78 for(std::size_t i=0;i<requiredInts.size();i++)
79 requiredInts[i] = locallyRequiredIds[i];
81 std::vector<int> providedInts(locallyMatchedIds.size());
82 for(std::size_t i=0;i<locallyMatchedIds.size();i++)
83 providedInts[i] = locallyMatchedIds[i].first;
86 int* requiredIntsPtr = NULL;
87 if (requiredInts.size() > 0)
88 requiredIntsPtr = &requiredInts[0];
89 int* providedIntsPtr = NULL;
90 if (providedInts.size() > 0)
91 providedIntsPtr = &providedInts[0];
92 Epetra_Map requiredMap(-1,requiredInts.size(),requiredIntsPtr,0,Comm);
93 Epetra_Map providedMap(-1,providedInts.size(),providedIntsPtr,0,Comm);
98 for(std::size_t i=0;i<locallyMatchedIds.size();i++)
99 providedVector[i] = locallyMatchedIds[i].second;
104 int * myMappedIds = requiredVector.
Values();
107 =
Teuchos::rcp(
new std::vector<std::pair<std::size_t,std::size_t> >(requiredInts.size()));
108 for(std::size_t i=0;i<result->size();i++) {
109 (*result)[i].first = requiredInts[i];
110 (*result)[i].second = myMappedIds[i];
123 const std::string & sideName,
const std::string type_)
130 std::stringstream ss;
131 ss <<
"Can't find part=\"" << sideName <<
"\"" << std::endl;
132 stk::mesh::Part * side = metaData->get_part(sideName,ss.str().c_str());
133 stk::mesh::Selector mySides = *side & (metaData->locally_owned_part() | metaData->globally_shared_part());
135 stk::mesh::EntityRank rank;
136 unsigned int offset = 0;
137 if(type_ ==
"coord"){
139 }
else if(type_ ==
"edge"){
142 }
else if(type_ ==
"face"){
146 ss <<
"Can't do BCs of type " << type_ << std::endl;
150 std::vector<stk::mesh::Bucket*>
const& nodeBuckets =
151 bulkData->get_buckets(rank, mySides);
155 std::size_t nodeCount = 0;
156 for(std::size_t b=0;b<nodeBuckets.size();b++)
157 nodeCount += nodeBuckets[b]->size();
160 =
Teuchos::rcp(
new std::vector<std::size_t>(nodeCount));
163 for(std::size_t b=0,index=0;b<nodeBuckets.size();b++) {
164 stk::mesh::Bucket & bucket = *nodeBuckets[b];
166 for(std::size_t n=0;n<bucket.size();n++,index++)
167 (*sideIds)[index] = bulkData->identifier(bucket[n]) + offset;
173 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
176 const std::string & sideName,
const std::string type_)
185 std::stringstream ss;
186 ss <<
"Can't find part=\"" << sideName <<
"\"" << std::endl;
187 stk::mesh::Part * side = metaData->get_part(sideName,ss.str().c_str());
188 stk::mesh::Selector mySides = (*side) & metaData->locally_owned_part();
190 stk::mesh::EntityRank rank;
192 unsigned int offset = 0;
193 if(type_ ==
"coord"){
196 }
else if(type_ ==
"edge"){
200 }
else if(type_ ==
"face"){
205 ss <<
"Can't do BCs of type " << type_ << std::endl;
209 std::vector<stk::mesh::Bucket*>
const& nodeBuckets =
210 bulkData->get_buckets(rank, mySides);
214 std::size_t nodeCount = 0;
215 for(std::size_t b=0;b<nodeBuckets.size();b++)
216 nodeCount += nodeBuckets[b]->size();
219 =
Teuchos::rcp(
new std::vector<std::size_t>(nodeCount));
224 for(std::size_t b=0,index=0;b<nodeBuckets.size();b++) {
225 stk::mesh::Bucket & bucket = *nodeBuckets[b];
226 double const* array = stk::mesh::field_data(*field, bucket);
228 for(std::size_t n=0;n<bucket.size();n++,index++) {
229 (*sideIds)[index] = bulkData->identifier(bucket[n]) + offset;
233 for(std::size_t d=0;d<physicalDim;d++)
234 coord[d] = array[physicalDim*n + d];
238 for(std::size_t d=physicalDim;d<3;d++)
243 return std::make_pair(sideIds,sideCoords);
246 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
249 const std::string & sideName,
const std::string type_)
259 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
263 std::vector<std::size_t> & local_side_ids = *sidePair.first;
264 std::vector<Teuchos::Tuple<double,3> > & local_side_coords = *sidePair.second;
265 int nodeCount = local_side_ids.size();
273 for(std::size_t n=0;n<local_side_ids.size();n++) {
274 std::size_t nodeId = local_side_ids[n];
277 (*localIdVec)[n] = nodeId;
278 for(
unsigned d=0;d<physicalDim;d++)
279 (*(*localCoordVec)(d))[n] = coords[d];
302 =
Teuchos::rcp(
new std::vector<std::size_t>(dist_nodeCount));
307 for(std::size_t n=0;n<dist_side_ids->size();n++) {
308 (*dist_side_ids)[n] = (*distIdVec)[n];
311 for(
unsigned d=0;d<physicalDim;d++)
312 coords[d] = (*(*distCoordVec)(d))[n];
315 for(
unsigned d=physicalDim;d<3;d++)
319 return std::make_pair(dist_side_ids,dist_side_coords);
int NumGlobalElements() const
Teuchos::RCP< std::vector< std::size_t > > getLocalSideIds(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const
get max entity ID of type entityRank
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getLocalSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing.
unsigned getDimension() const
get the dimension
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int SumAll(double *PartialSums, double *GlobalSums, int Count) const
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
stk::mesh::EntityRank getFaceRank() const
Teuchos::RCP< stk::mesh::MetaData > getMetaData() const
const VectorFieldType & getEdgesField() const
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...
stk::mesh::EntityRank getEdgeRank() const
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getGlobalPairing(const std::vector< std::size_t > &locallyRequiredIds, const std::vector< std::pair< std::size_t, std::size_t > > &locallyMatchedIds, const STK_Interface &mesh, bool failure)
const VectorFieldType & getFacesField() const
#define TEUCHOS_ASSERT(assertion_test)
stk::mesh::EntityRank getNodeRank() const
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
const VectorFieldType & getCoordinatesField() const