Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_Interface.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef __Panzer_STK_Interface_hpp__
12 #define __Panzer_STK_Interface_hpp__
13 
14 #include <Teuchos_RCP.hpp>
16 
17 #include <stk_mesh/base/Types.hpp>
18 #include <stk_mesh/base/MetaData.hpp>
19 #include <stk_mesh/base/BulkData.hpp>
20 #include <stk_mesh/base/Field.hpp>
21 #include <stk_mesh/base/FieldBase.hpp>
22 
23 #include "Kokkos_Core.hpp"
24 
25 #include <Shards_CellTopology.hpp>
26 #include <Shards_CellTopologyData.h>
27 
28 #include <PanzerAdaptersSTK_config.hpp>
29 #include <Kokkos_ViewFactory.hpp>
30 
31 #include <unordered_map>
32 
33 #ifdef PANZER_HAVE_IOSS
34 #include <stk_io/StkMeshIoBroker.hpp>
35 #endif
36 
37 #ifdef PANZER_HAVE_PERCEPT
38 namespace percept {
39  class PerceptMesh;
40  class URP_Heterogeneous_3D;
41 }
42 #endif
43 
44 namespace panzer_stk {
45 
46 class PeriodicBC_MatcherBase;
47 
52 public:
53  ElementDescriptor(stk::mesh::EntityId gid,const std::vector<stk::mesh::EntityId> & nodes);
54  virtual ~ElementDescriptor();
55 
56  stk::mesh::EntityId getGID() const { return gid_; }
57  const std::vector<stk::mesh::EntityId> & getNodes() const { return nodes_; }
58 protected:
59  stk::mesh::EntityId gid_;
60  std::vector<stk::mesh::EntityId> nodes_;
61 
63 };
64 
68 buildElementDescriptor(stk::mesh::EntityId elmtId,std::vector<stk::mesh::EntityId> & nodes);
69 
71 public:
72  typedef double ProcIdData; // ECC: Not sure why?
73  typedef stk::mesh::Field<double> SolutionFieldType;
74  typedef stk::mesh::Field<double> VectorFieldType;
75  typedef stk::mesh::Field<ProcIdData> ProcIdFieldType;
76 
77  // some simple exception classes
78  struct ElementBlockException : public std::logic_error
79  { ElementBlockException(const std::string & what) : std::logic_error(what) {} };
80 
81  struct SidesetException : public std::logic_error
82  { SidesetException(const std::string & what) : std::logic_error(what) {} };
83 
84  struct EdgeBlockException : public std::logic_error
85  { EdgeBlockException(const std::string & what) : std::logic_error(what) {} };
86 
87  struct FaceBlockException : public std::logic_error
88  { FaceBlockException(const std::string & what) : std::logic_error(what) {} };
89 
90  STK_Interface();
91 
94  STK_Interface(unsigned dim);
95 
97 
98  // functions called before initialize
100 
103  void addElementBlock(const std::string & name,const CellTopologyData * ctData);
104 
107 // void addEdgeBlock(const std::string & name,const CellTopologyData * ctData);
108  void addEdgeBlock(const std::string & elemBlockName,
109  const std::string & edgeBlockName,
110  const stk::topology & topology);
111  void addEdgeBlock(const std::string & elemBlockName,
112  const std::string & edgeBlockName,
113  const CellTopologyData * ctData);
114 
117  void addFaceBlock(const std::string & elemBlockName,
118  const std::string & faceBlockName,
119  const stk::topology & topology);
120  void addFaceBlock(const std::string & elemBlockName,
121  const std::string & faceBlockName,
122  const CellTopologyData * ctData);
123 
126  void addSideset(const std::string & name,const CellTopologyData * ctData);
127 
130  void addNodeset(const std::string & name);
131 
134  void addSolutionField(const std::string & fieldName,const std::string & blockId);
135 
138  void addCellField(const std::string & fieldName,const std::string & blockId);
139 
142  void addEdgeField(const std::string & fieldName,const std::string & blockId);
143 
146  void addFaceField(const std::string & fieldName,const std::string & blockId);
147 
156  void addMeshCoordFields(const std::string & blockId,
157  const std::vector<std::string> & coordField,
158  const std::string & dispPrefix);
159 
164  void addInformationRecords(const std::vector<std::string> & info_records);
165 
167 
179  void initialize(stk::ParallelMachine parallelMach,bool setupIO=true,
180  const bool buildRefinementSupport = false);
181 
187  void instantiateBulkData(stk::ParallelMachine parallelMach);
188 
189  // functions to manage and manipulate bulk data
191 
194  void beginModification();
195 
198  void endModification();
199 
205  void addNode(stk::mesh::EntityId gid, const std::vector<double> & coord);
206 
207  void addElement(const Teuchos::RCP<ElementDescriptor> & ed,stk::mesh::Part * block);
208 
209  void addEdges();
210 
211  void addFaces();
212 
215  void addEntityToSideset(stk::mesh::Entity entity,stk::mesh::Part * sideset);
216 
219  void addEntityToNodeset(stk::mesh::Entity entity,stk::mesh::Part * nodeset);
220 
223  void addEntityToEdgeBlock(stk::mesh::Entity entity,stk::mesh::Part * edgeblock);
226  void addEntitiesToEdgeBlock(std::vector<stk::mesh::Entity> entities,stk::mesh::Part * edgeblock);
227 
230  void addEntityToFaceBlock(stk::mesh::Entity entity,stk::mesh::Part * faceblock);
233  void addEntitiesToFaceBlock(std::vector<stk::mesh::Entity> entities,stk::mesh::Part * faceblock);
234 
235  // Methods to interrogate the mesh topology and structure
237 
241  { return *coordinatesField_; }
242 
246  { return *edgesField_; }
247 
249  { return *facesField_; }
250 
253  const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const;
254 
257  const double * getNodeCoordinates(stk::mesh::Entity node) const;
258 
261  void getSubcellIndices(unsigned entityRank,stk::mesh::EntityId elementId,
262  std::vector<stk::mesh::EntityId> & subcellIds) const;
263 
266  void getMyElements(std::vector<stk::mesh::Entity> & elements) const;
267 
270  void getMyElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
271 
275  void getNeighborElements(std::vector<stk::mesh::Entity> & elements) const;
276 
279  void getNeighborElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
280 
283  void getMyEdges(std::vector<stk::mesh::Entity> & edges) const;
284 
292  void getMyEdges(const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges) const;
293 
302  void getMyEdges(const std::string & edgeBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & edges) const;
303 
311  void getAllEdges(const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges) const;
312 
321  void getAllEdges(const std::string & edgeBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & edges) const;
322 
325  void getMyFaces(std::vector<stk::mesh::Entity> & faces) const;
326 
334  void getMyFaces(const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces) const;
335 
344  void getMyFaces(const std::string & faceBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & faces) const;
345 
353  void getAllFaces(const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces) const;
354 
363  void getAllFaces(const std::string & faceBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & faces) const;
364 
372  void getMySides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
373 
382  void getMySides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
383 
391  void getAllSides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
392 
401  void getAllSides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
402 
412  void getMyNodes(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & nodes) const;
413 
422  stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const;
423 
424  // Utility functions
426 
435  void
436  writeToExodus(const std::string& filename,
437  const bool append = false);
438 
456  void
457  setupExodusFile(const std::string& filename,
458  const bool append = false,
459  const bool append_after_restart_time = false,
460  const double restart_time = 0.0);
461 
462  void
463  setupExodusFile(const std::string& filename,
464  const std::vector<Ioss::Property>& ioss_properties,
465  const bool append = false,
466  const bool append_after_restart_time = false,
467  const double restart_time = 0.0);
468 
481  void
483  double timestep);
484 
504  void
506  const std::string& key,
507  const int& value);
508 
528  void
530  const std::string& key,
531  const double& value);
532 
552  void
554  const std::string& key,
555  const std::vector<int>& value);
556 
576  void
578  const std::string& key,
579  const std::vector<double>& value);
580 
581  // Accessor functions
583 
586 
589 
590 #ifdef PANZER_HAVE_PERCEPT
591  Teuchos::RCP<percept::PerceptMesh> getRefinedMesh() const
593  { TEUCHOS_ASSERT(Teuchos::nonnull(refinedMesh_)); return refinedMesh_; }
594 #endif
595 
596  bool isWritable() const;
597 
598  bool isModifiable() const
599  { if(bulkData_==Teuchos::null) return false;
600  return bulkData_->in_modifiable_state(); }
601 
603  unsigned getDimension() const
604  { return dimension_; }
605 
607  std::size_t getNumElementBlocks() const
608  { return elementBlocks_.size(); }
609 
617  void getElementBlockNames(std::vector<std::string> & names) const;
618 
626  void getSidesetNames(std::vector<std::string> & name) const;
627 
635  void getNodesetNames(std::vector<std::string> & name) const;
636 
644  void getEdgeBlockNames(std::vector<std::string> & names) const;
645 
653  void getFaceBlockNames(std::vector<std::string> & names) const;
654 
656  stk::mesh::Part * getOwnedPart() const
657  { return &getMetaData()->locally_owned_part(); } // I don't like the pointer access here, but it will do for now!
658 
660  stk::mesh::Part * getElementBlockPart(const std::string & name) const
661  {
662  std::map<std::string, stk::mesh::Part*>::const_iterator itr = elementBlocks_.find(name); // Element blocks
663  if(itr==elementBlocks_.end()) return 0;
664  return itr->second;
665  }
666 
668  stk::mesh::Part * getEdgeBlock(const std::string & name) const
669  {
670  std::map<std::string, stk::mesh::Part*>::const_iterator itr = edgeBlocks_.find(name); // edge blocks
671  if(itr==edgeBlocks_.end()) return 0;
672  return itr->second;
673  }
674 
676  stk::mesh::Part * getFaceBlock(const std::string & name) const
677  {
678  std::map<std::string, stk::mesh::Part*>::const_iterator itr = faceBlocks_.find(name); // face blocks
679  if(itr==faceBlocks_.end()) return 0;
680  return itr->second;
681  }
682 
684  std::size_t getNumSidesets() const
685  { return sidesets_.size(); }
686 
687  stk::mesh::Part * getSideset(const std::string & name) const
688  {
689  auto itr = sidesets_.find(name);
690  return (itr != sidesets_.end()) ? itr->second : nullptr;
691  }
692 
694  std::size_t getNumNodesets() const
695  { return nodesets_.size(); }
696 
697  stk::mesh::Part * getNodeset(const std::string & name) const
698  {
699  auto itr = nodesets_.find(name);
700  return (itr != nodesets_.end()) ? itr->second : nullptr;
701  }
702 
704  std::size_t getEntityCounts(unsigned entityRank) const;
705 
707  stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const;
708 
709  // Utilities
711 
713  void getElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements) const;
714 
716  void getNodeIdsForElement(stk::mesh::Entity element,std::vector<stk::mesh::EntityId> & nodeIds) const;
717 
720  void getOwnedElementsSharingNode(stk::mesh::Entity node,std::vector<stk::mesh::Entity> & elements,
721  std::vector<int> & relIds) const;
722 
725  void getOwnedElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements,
726  std::vector<int> & relIds, unsigned int matchType) const;
727 
728 
730  void getElementsSharingNodes(const std::vector<stk::mesh::EntityId> nodeId,std::vector<stk::mesh::Entity> & elements) const;
731 
733  void buildSubcells();
734 
737  std::size_t elementLocalId(stk::mesh::Entity elmt) const;
738 
741  std::size_t elementLocalId(stk::mesh::EntityId gid) const;
742 
745  inline stk::mesh::EntityId elementGlobalId(std::size_t lid) const
746  { return bulkData_->identifier((*orderedElementVector_)[lid]); }
747 
750  inline stk::mesh::EntityId elementGlobalId(stk::mesh::Entity elmt) const
751  { return bulkData_->identifier(elmt); }
752 
755  bool isEdgeLocal(stk::mesh::Entity edge) const;
756 
759  bool isEdgeLocal(stk::mesh::EntityId gid) const;
760 
763  std::size_t edgeLocalId(stk::mesh::Entity elmt) const;
764 
767  std::size_t edgeLocalId(stk::mesh::EntityId gid) const;
768 
771  inline stk::mesh::EntityId edgeGlobalId(std::size_t lid) const
772  { return bulkData_->identifier((*orderedEdgeVector_)[lid]); }
773 
776  inline stk::mesh::EntityId edgeGlobalId(stk::mesh::Entity edge) const
777  { return bulkData_->identifier(edge); }
778 
781  bool isFaceLocal(stk::mesh::Entity face) const;
782 
785  bool isFaceLocal(stk::mesh::EntityId gid) const;
786 
789  std::size_t faceLocalId(stk::mesh::Entity elmt) const;
790 
793  std::size_t faceLocalId(stk::mesh::EntityId gid) const;
794 
797  inline stk::mesh::EntityId faceGlobalId(std::size_t lid) const
798  { return bulkData_->identifier((*orderedFaceVector_)[lid]); }
799 
802  inline stk::mesh::EntityId faceGlobalId(stk::mesh::Entity face) const
803  { return bulkData_->identifier(face); }
804 
807  inline unsigned entityOwnerRank(stk::mesh::Entity entity) const
808  { return bulkData_->parallel_owner_rank(entity); }
809 
812  inline bool isValid(stk::mesh::Entity entity) const
813  { return bulkData_->is_valid(entity); }
814 
817  std::string containingBlockId(stk::mesh::Entity elmt) const;
818 
823  stk::mesh::Field<double> * getSolutionField(const std::string & fieldName,
824  const std::string & blockId) const;
825 
830  stk::mesh::Field<double> * getCellField(const std::string & fieldName,
831  const std::string & blockId) const;
832 
837  stk::mesh::Field<double> * getEdgeField(const std::string & fieldName,
838  const std::string & blockId) const;
839 
844  stk::mesh::Field<double> * getFaceField(const std::string & fieldName,
845  const std::string & blockId) const;
846 
848 
850  bool isInitialized() const { return initialized_; }
851 
856 
871  template <typename ArrayT>
872  void setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
873  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
874 
889  template <typename ArrayT>
890  void getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
891  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const;
892 
907  template <typename ArrayT>
908  void setCellFieldData(const std::string & fieldName,const std::string & blockId,
909  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
910 
915 
920 
935  template <typename ArrayT>
936  void setEdgeFieldData(const std::string & fieldName,const std::string & blockId,
937  const std::vector<std::size_t> & localEdgeIds,const ArrayT & edgeValues,double scaleValue=1.0);
938 
953  template <typename ArrayT>
954  void setFaceFieldData(const std::string & fieldName,const std::string & blockId,
955  const std::vector<std::size_t> & localFaceIds,const ArrayT & faceValues,double scaleValue=1.0);
956 
958 
967  template <typename ArrayT>
968  void getElementVertices(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
969 
978  template <typename ArrayT>
979  void getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
980 
990  template <typename ArrayT>
991  void getElementVertices(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
992 
1002  template <typename ArrayT>
1003  void getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1004 
1013  template <typename ArrayT>
1014  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
1015 
1024  template <typename ArrayT>
1025  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1026 
1036  template <typename ArrayT>
1037  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
1038 
1048  template <typename ArrayT>
1049  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1050 
1052 
1062  template <typename ArrayT>
1063  void getElementNodes(const std::vector<std::size_t> & localIds, ArrayT & nodes) const;
1064 
1073  template <typename ArrayT>
1074  void getElementNodes(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1075 
1085  template <typename ArrayT>
1086  void getElementNodes(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & nodes) const;
1087 
1097  template <typename ArrayT>
1098  void getElementNodes(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1099 
1108  template <typename ArrayT>
1109  void getElementNodesNoResize(const std::vector<std::size_t> & localIds, ArrayT & nodes) const;
1110 
1119  template <typename ArrayT>
1120  void getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1121 
1131  template <typename ArrayT>
1132  void getElementNodesNoResize(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & nodes) const;
1133 
1143  template <typename ArrayT>
1144  void getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1145 
1146  // const stk::mesh::FEMInterface & getFEMInterface() const
1147  // { return *femPtr_; }
1148 
1149  stk::mesh::EntityRank getElementRank() const { return stk::topology::ELEMENT_RANK; }
1150  stk::mesh::EntityRank getSideRank() const { return metaData_->side_rank(); }
1151  stk::mesh::EntityRank getFaceRank() const { return stk::topology::FACE_RANK; }
1152  stk::mesh::EntityRank getEdgeRank() const { return stk::topology::EDGE_RANK; }
1153  stk::mesh::EntityRank getNodeRank() const { return stk::topology::NODE_RANK; }
1154 
1157  void initializeFromMetaData();
1158 
1161  void buildLocalElementIDs();
1162 
1165  void buildLocalEdgeIDs();
1166 
1169  void buildLocalFaceIDs();
1170 
1173  const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1175  { return periodicBCs_; }
1176 
1179  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1181  { return periodicBCs_; }
1182 
1185  const bool & useBoundingBoxSearch() const
1186  { return useBBoxSearch_; }
1187 
1189  void setBoundingBoxSearchFlag(const bool & searchFlag)
1190  { useBBoxSearch_ = searchFlag; return; }
1191 
1198  { periodicBCs_.push_back(bc); }
1199 
1206  { periodicBCs_.insert(periodicBCs_.end(),bc_vec.begin(),bc_vec.end()); }
1207 
1210  std::pair<Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >, Teuchos::RCP<std::vector<unsigned int> > >
1211  getPeriodicNodePairing() const;
1212 
1215  bool validBlockId(const std::string & blockId) const;
1216 
1219  void print(std::ostream & os) const;
1220 
1223  void printMetaData(std::ostream & os) const;
1224 
1227  Teuchos::RCP<const shards::CellTopology> getCellTopology(const std::string & eBlock) const;
1228 
1233  double getCurrentStateTime() const { return currentStateTime_; }
1234 
1240  double getInitialStateTime() const { return initialStateTime_; }
1241 
1246  void setInitialStateTime(double value) { initialStateTime_ = value; }
1247 
1250  void rebalance(const Teuchos::ParameterList & params);
1251 
1255  void setBlockWeight(const std::string & blockId,double weight)
1256  { blockWeights_[blockId] = weight; }
1257 
1264  void setUseFieldCoordinates(bool useFieldCoordinates)
1265  { useFieldCoordinates_ = useFieldCoordinates; }
1266 
1269  { return useFieldCoordinates_; }
1270 
1272  void setUseLowerCaseForIO(bool useLowerCase)
1273  { useLowerCase_ = useLowerCase; }
1274 
1277  { return useLowerCase_; }
1278 
1280 
1291  template <typename ArrayT>
1292  void getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1293 
1294  template <typename ArrayT>
1295  void getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1296  const std::string & eBlock, ArrayT & vertices) const;
1297 
1307  template <typename ArrayT>
1308  void getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1309 
1310  template <typename ArrayT>
1311  void getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1312 
1314 
1325  template <typename ArrayT>
1326  void getElementNodes_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1327 
1328  template <typename ArrayT>
1329  void getElementNodes_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1330  const std::string & eBlock, ArrayT & nodes) const;
1331 
1341  template <typename ArrayT>
1342  void getElementNodes_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1343 
1344  template <typename ArrayT>
1345  void getElementNodes_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1346 
1352  void refineMesh(const int numberOfLevels, const bool deleteParentElements);
1353 
1354 public: // static operations
1355  static const std::string coordsString;
1356  static const std::string nodesString;
1357  static const std::string edgesString;
1358  static const std::string edgeBlockString;
1359  static const std::string faceBlockString;
1360  static const std::string facesString;
1361 
1362 protected:
1363 
1366  void buildEntityCounts();
1367 
1370  void buildMaxEntityIds();
1371 
1375  void initializeFieldsInSTK(const std::map<std::pair<std::string,std::string>,SolutionFieldType*> & nameToField,
1376  bool setupIO);
1377 
1382  Teuchos::RCP<Teuchos::MpiComm<int> > getSafeCommunicator(stk::ParallelMachine parallelMach) const;
1383 
1390 
1394  bool isMeshCoordField(const std::string & eBlock,const std::string & fieldName,int & axis) const;
1395 
1411  template <typename ArrayT>
1412  void setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
1413  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues);
1414 
1415  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > periodicBCs_;
1416  bool useBBoxSearch_ = false; // TODO swap this to change default periodic BC search (see also PeriodicBC_Parser.cpp)
1417 
1420 #ifdef PANZER_HAVE_PERCEPT
1423 #endif
1424 
1425  std::map<std::string, stk::mesh::Part*> elementBlocks_; // Element blocks
1426  std::map<std::string, stk::mesh::Part*> sidesets_; // Side sets
1427  std::map<std::string, stk::mesh::Part*> nodesets_; // Node sets
1428  std::map<std::string, stk::mesh::Part*> edgeBlocks_; // Edge blocks
1429  std::map<std::string, stk::mesh::Part*> faceBlocks_; // Face blocks
1430 
1431  std::map<std::string, Teuchos::RCP<shards::CellTopology> > elementBlockCT_;
1432 
1433  // for storing/accessing nodes
1434  stk::mesh::Part * nodesPart_;
1435  std::vector<stk::mesh::Part*> nodesPartVec_;
1436  stk::mesh::Part * edgesPart_;
1437  std::vector<stk::mesh::Part*> edgesPartVec_;
1438  stk::mesh::Part * facesPart_;
1439  std::vector<stk::mesh::Part*> facesPartVec_;
1440 
1446 
1447  // maps field names to solution field stk mesh handles
1448  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToSolution_;
1449  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToCellField_;
1450  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToEdgeField_;
1451  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToFaceField_;
1452 
1453  // use a set to maintain a list of unique information records
1454  std::set<std::string> informationRecords_;
1455 
1456  unsigned dimension_;
1457 
1459 
1460  // how many elements, faces, edges, and nodes are there globally
1461  std::vector<std::size_t> entityCounts_;
1462 
1463  // what is maximum entity ID
1464  std::vector<stk::mesh::EntityId> maxEntityId_;
1465 
1466  unsigned procRank_;
1467  std::size_t currentLocalId_;
1468 
1470 
1471  double initialStateTime_; // the time stamp at the time this object was constructed (default 0.0)
1472  double currentStateTime_; // the time stamp set by the user when writeToExodus is called (default 0.0)
1473 
1474 #ifdef PANZER_HAVE_IOSS
1475  // I/O support
1477  int meshIndex_;
1478 
1483  enum class GlobalVariable
1484  {
1485  ADD,
1486  WRITE
1487  }; // end of enum class GlobalVariable
1488 
1505  void
1506  globalToExodus(
1507  const GlobalVariable& flag);
1508 
1512  Teuchos::ParameterList globalData_;
1513 #endif
1514 
1515  // uses lazy evaluation
1517 
1518  // uses lazy evaluation
1520 
1521  // uses lazy evaluation
1523 
1524  // for element block weights
1525  std::map<std::string,double> blockWeights_;
1526 
1527  std::unordered_map<stk::mesh::EntityId,std::size_t> localIDHash_;
1528  std::unordered_map<stk::mesh::EntityId,std::size_t> localEdgeIDHash_;
1529  std::unordered_map<stk::mesh::EntityId,std::size_t> localFaceIDHash_;
1530 
1531  // Store mesh displacement fields by element block. This map
1532  // goes like this meshCoordFields_[eBlock][axis_index] => coordinate FieldName
1533  // goes like this meshDispFields_[eBlock][axis_index] => displacement FieldName
1534  std::map<std::string,std::vector<std::string> > meshCoordFields_; // coordinate fields written by user
1535  std::map<std::string,std::vector<std::string> > meshDispFields_; // displacement fields, output to exodus
1536 
1538 
1540 
1541  // Object describing how to sort a vector of elements using
1542  // local ID as the key, very short lived object
1544  public:
1545  LocalIdCompare(const STK_Interface * mesh) : mesh_(mesh) {}
1546 
1547  // Compares two stk mesh entities based on local ID
1548  bool operator() (stk::mesh::Entity a,stk::mesh::Entity b)
1549  { return mesh_->elementLocalId(a) < mesh_->elementLocalId(b);}
1550 
1551  private:
1553  };
1554 };
1555 
1556 template <typename ArrayT>
1557 void STK_Interface::setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1558  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1559 {
1560  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1561  auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1562  Kokkos::deep_copy(solutionValues_h, solutionValues);
1563 
1564  int field_axis = -1;
1565  if(isMeshCoordField(blockId,fieldName,field_axis)) {
1566  setDispFieldData(fieldName,blockId,field_axis,localElementIds,solutionValues_h);
1567  return;
1568  }
1569 
1570  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1571 
1572  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1573  std::size_t localId = localElementIds[cell];
1574  stk::mesh::Entity element = elements[localId];
1575 
1576  // loop over nodes set solution values
1577  const size_t num_nodes = bulkData_->num_nodes(element);
1578  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1579  for(std::size_t i=0; i<num_nodes; ++i) {
1580  stk::mesh::Entity node = nodes[i];
1581 
1582  double * solnData = stk::mesh::field_data(*field,node);
1583  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1584  solnData[0] = scaleValue*solutionValues_h(cell,i);
1585  }
1586  }
1587 }
1588 
1589 template <typename ArrayT>
1590 void STK_Interface::setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
1591  const std::vector<std::size_t> & localElementIds,const ArrayT & dispValues)
1592 {
1593  TEUCHOS_ASSERT(axis>=0); // sanity check
1594 
1595  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1596 
1597  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1598  const VectorFieldType & coord_field = this->getCoordinatesField();
1599 
1600  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1601  std::size_t localId = localElementIds[cell];
1602  stk::mesh::Entity element = elements[localId];
1603 
1604  // loop over nodes set solution values
1605  const size_t num_nodes = bulkData_->num_nodes(element);
1606  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1607  for(std::size_t i=0; i<num_nodes; ++i) {
1608  stk::mesh::Entity node = nodes[i];
1609 
1610  double * solnData = stk::mesh::field_data(*field,node);
1611  double * coordData = stk::mesh::field_data(coord_field,node);
1612  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1613  solnData[0] = dispValues(cell,i)-coordData[axis];
1614  }
1615  }
1616 }
1617 
1618 template <typename ArrayT>
1619 void STK_Interface::getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1620  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const
1621 {
1622  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1623 
1624  solutionValues = Kokkos::createDynRankView(solutionValues,
1625  "solutionValues",
1626  localElementIds.size(),
1627  bulkData_->num_nodes(elements[localElementIds[0]]));
1628 
1629  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1630 
1631  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1632  std::size_t localId = localElementIds[cell];
1633  stk::mesh::Entity element = elements[localId];
1634 
1635  // loop over nodes set solution values
1636  const size_t num_nodes = bulkData_->num_nodes(element);
1637  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1638  for(std::size_t i=0; i<num_nodes; ++i) {
1639  stk::mesh::Entity node = nodes[i];
1640 
1641  double * solnData = stk::mesh::field_data(*field,node);
1642  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1643  solutionValues(cell,i) = solnData[0];
1644  }
1645  }
1646 }
1647 
1648 template <typename ArrayT>
1649 void STK_Interface::setCellFieldData(const std::string & fieldName,const std::string & blockId,
1650  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1651 {
1652  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1653 
1654  SolutionFieldType * field = this->getCellField(fieldName,blockId);
1655 
1656  auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1657  Kokkos::deep_copy(solutionValues_h, solutionValues);
1658 
1659  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1660  std::size_t localId = localElementIds[cell];
1661  stk::mesh::Entity element = elements[localId];
1662 
1663  double * solnData = stk::mesh::field_data(*field,element);
1664  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1665  solnData[0] = scaleValue*solutionValues_h.access(cell,0);
1666  }
1667 }
1668 
1669 template <typename ArrayT>
1670 void STK_Interface::setEdgeFieldData(const std::string & fieldName,const std::string & blockId,
1671  const std::vector<std::size_t> & localEdgeIds,const ArrayT & edgeValues,double scaleValue)
1672 {
1673  const std::vector<stk::mesh::Entity> & edges = *(this->getEdgesOrderedByLID());
1674 
1675  SolutionFieldType * field = this->getEdgeField(fieldName,blockId);
1676 
1677  auto edgeValues_h = Kokkos::create_mirror_view(edgeValues);
1678  Kokkos::deep_copy(edgeValues_h, edgeValues);
1679 
1680  for(std::size_t idx=0;idx<localEdgeIds.size();idx++) {
1681  std::size_t localId = localEdgeIds[idx];
1682  stk::mesh::Entity edge = edges[localId];
1683 
1684  double * solnData = stk::mesh::field_data(*field,edge);
1685  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1686  solnData[0] = scaleValue*edgeValues_h.access(idx,0);
1687  }
1688 }
1689 
1690 template <typename ArrayT>
1691 void STK_Interface::setFaceFieldData(const std::string & fieldName,const std::string & blockId,
1692  const std::vector<std::size_t> & localFaceIds,const ArrayT & faceValues,double scaleValue)
1693 {
1694  const std::vector<stk::mesh::Entity> & faces = *(this->getFacesOrderedByLID());
1695 
1696  SolutionFieldType * field = this->getFaceField(fieldName,blockId);
1697 
1698  auto faceValues_h = Kokkos::create_mirror_view(faceValues);
1699  Kokkos::deep_copy(faceValues_h, faceValues);
1700 
1701  for(std::size_t idx=0;idx<localFaceIds.size();idx++) {
1702  std::size_t localId = localFaceIds[idx];
1703  stk::mesh::Entity face = faces[localId];
1704 
1705  double * solnData = stk::mesh::field_data(*field,face);
1706  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1707  solnData[0] = scaleValue*faceValues_h.access(idx,0);
1708  }
1709 }
1710 
1712 
1713 template <typename ArrayT>
1714 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1715 {
1716  if(!useFieldCoordinates_) {
1717  //
1718  // gather from the intrinsic mesh coordinates (non-lagrangian)
1719  //
1720 
1721  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1722 
1723  // convert to a vector of entity objects
1724  std::vector<stk::mesh::Entity> selected_elements;
1725  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1726  selected_elements.push_back(elements[localElementIds[cell]]);
1727 
1728  getElementVertices_FromCoords(selected_elements,vertices);
1729  }
1730  else {
1731  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1732  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1733  "without specifying an element block.");
1734  }
1735 }
1736 
1737 template <typename ArrayT>
1738 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1739 {
1740  if(!useFieldCoordinates_) {
1741  getElementVertices_FromCoords(elements,vertices);
1742  }
1743  else {
1744  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1745  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1746  "without specifying an element block.");
1747  }
1748 }
1749 
1750 template <typename ArrayT>
1751 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1752 {
1753  if(!useFieldCoordinates_) {
1754  getElementVertices_FromCoords(elements,vertices);
1755  }
1756  else {
1757  getElementVertices_FromField(elements,eBlock,vertices);
1758  }
1759 }
1760 
1761 template <typename ArrayT>
1762 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1763 {
1764  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1765 
1766  // convert to a vector of entity objects
1767  std::vector<stk::mesh::Entity> selected_elements;
1768  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1769  selected_elements.push_back(elements[localElementIds[cell]]);
1770 
1771  if(!useFieldCoordinates_) {
1772  getElementVertices_FromCoords(selected_elements,vertices);
1773  }
1774  else {
1775  getElementVertices_FromField(selected_elements,eBlock,vertices);
1776  }
1777 }
1778 
1779 template <typename ArrayT>
1780 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1781 {
1782  if(!useFieldCoordinates_) {
1783  //
1784  // gather from the intrinsic mesh coordinates (non-lagrangian)
1785  //
1786 
1787  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1788 
1789  // convert to a vector of entity objects
1790  std::vector<stk::mesh::Entity> selected_elements;
1791  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1792  selected_elements.push_back(elements[localElementIds[cell]]);
1793 
1794  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1795  }
1796  else {
1797  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1798  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1799  "without specifying an element block.");
1800  }
1801 }
1802 
1803 template <typename ArrayT>
1804 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1805 {
1806  if(!useFieldCoordinates_) {
1807  getElementVertices_FromCoordsNoResize(elements,vertices);
1808  }
1809  else {
1810  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1811  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1812  "without specifying an element block.");
1813  }
1814 }
1815 
1816 template <typename ArrayT>
1817 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1818 {
1819  if(!useFieldCoordinates_) {
1820  getElementVertices_FromCoordsNoResize(elements,vertices);
1821  }
1822  else {
1823  getElementVertices_FromFieldNoResize(elements,eBlock,vertices);
1824  }
1825 }
1826 
1827 template <typename ArrayT>
1828 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1829 {
1830  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1831 
1832  // convert to a vector of entity objects
1833  std::vector<stk::mesh::Entity> selected_elements;
1834  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1835  selected_elements.push_back(elements[localElementIds[cell]]);
1836 
1837  if(!useFieldCoordinates_) {
1838  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1839  }
1840  else {
1841  getElementVertices_FromFieldNoResize(selected_elements,eBlock,vertices);
1842  }
1843 }
1844 
1845 template <typename ArrayT>
1846 void STK_Interface::getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1847 {
1848  // nothing to do! silently return
1849  if(elements.size() == 0) {
1850  vertices = Kokkos::createDynRankView(vertices, "vertices", 0, 0, 0);
1851  return;
1852  }
1853 
1854  //
1855  // gather from the intrinsic mesh coordinates (non-lagrangian)
1856  //
1857 
1858  // get *master* cell toplogy...(belongs to first element)
1859  const auto masterVertexCount
1860  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1861 
1862  // allocate space
1863  vertices = Kokkos::createDynRankView(vertices, "vertices", elements.size(), masterVertexCount,getDimension());
1864  auto vertices_h = Kokkos::create_mirror_view(vertices);
1865  Kokkos::deep_copy(vertices_h, vertices);
1866 
1867  // loop over each requested element
1868  const auto dim = getDimension();
1869  for(std::size_t cell = 0; cell < elements.size(); cell++) {
1870  const auto element = elements[cell];
1871  TEUCHOS_ASSERT(element != 0);
1872 
1873  const auto vertexCount
1874  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1875  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount != masterVertexCount, std::runtime_error,
1876  "In call to STK_Interface::getElementVertices all elements "
1877  "must have the same vertex count!");
1878 
1879  // loop over all element nodes
1880  const size_t num_nodes = bulkData_->num_nodes(element);
1881  auto const* nodes = bulkData_->begin_nodes(element);
1882  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1883  "In call to STK_Interface::getElementVertices cardinality of "
1884  "element node relations must be the vertex count!");
1885  for(std::size_t node = 0; node < num_nodes; ++node) {
1886  const double * coord = getNodeCoordinates(nodes[node]);
1887 
1888  // set each dimension of the coordinate
1889  for(unsigned d=0;d<dim;d++)
1890  vertices_h(cell,node,d) = coord[d];
1891  }
1892  }
1893  Kokkos::deep_copy(vertices, vertices_h);
1894 }
1895 
1896 template <typename ArrayT>
1897 void STK_Interface::getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1898 {
1899  // nothing to do! silently return
1900  if(elements.size()==0) {
1901  return;
1902  }
1903 
1904  //
1905  // gather from the intrinsic mesh coordinates (non-lagrangian)
1906  //
1907 
1908  // get *master* cell toplogy...(belongs to first element)
1909  unsigned masterVertexCount
1910  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1911 
1912  // loop over each requested element
1913  unsigned dim = getDimension();
1914  auto vertices_h = Kokkos::create_mirror_view(vertices);
1915  for(std::size_t cell=0;cell<elements.size();cell++) {
1916  stk::mesh::Entity element = elements[cell];
1917  TEUCHOS_ASSERT(element!=0);
1918 
1919  unsigned vertexCount
1920  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1921  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount!=masterVertexCount,std::runtime_error,
1922  "In call to STK_Interface::getElementVertices all elements "
1923  "must have the same vertex count!");
1924 
1925  // loop over all element nodes
1926  const size_t num_nodes = bulkData_->num_nodes(element);
1927  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1928  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1929  "In call to STK_Interface::getElementVertices cardinality of "
1930  "element node relations must be the vertex count!");
1931  for(std::size_t node=0; node<num_nodes; ++node) {
1932  const double * coord = getNodeCoordinates(nodes[node]);
1933 
1934  // set each dimension of the coordinate
1935  for(unsigned d=0;d<dim;d++)
1936  vertices_h(cell,node,d) = coord[d];
1937  }
1938  }
1939  Kokkos::deep_copy(vertices, vertices_h);
1940 }
1941 
1942 template <typename ArrayT>
1943 void STK_Interface::getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1944 {
1946 
1947  // nothing to do! silently return
1948  if(elements.size()==0) {
1949  vertices = Kokkos::createDynRankView(vertices,"vertices",0,0,0);
1950  return;
1951  }
1952 
1953  // get *master* cell toplogy...(belongs to first element)
1954  unsigned masterVertexCount
1955  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1956 
1957  // allocate space
1958  vertices = Kokkos::createDynRankView(vertices,"vertices",elements.size(),masterVertexCount,getDimension());
1959  auto vertices_h = Kokkos::create_mirror_view(vertices);
1960  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
1961  if(itr==meshCoordFields_.end()) {
1962  // no coordinate field set for this element block
1963  TEUCHOS_ASSERT(false);
1964  }
1965 
1966  const std::vector<std::string> & coordField = itr->second;
1967  std::vector<SolutionFieldType*> fields(getDimension());
1968  for(std::size_t d=0;d<fields.size();d++) {
1969  fields[d] = this->getSolutionField(coordField[d],eBlock);
1970  }
1971 
1972  for(std::size_t cell=0;cell<elements.size();cell++) {
1973  stk::mesh::Entity element = elements[cell];
1974 
1975  // loop over nodes set solution values
1976  const size_t num_nodes = bulkData_->num_nodes(element);
1977  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1978  for(std::size_t i=0; i<num_nodes; ++i) {
1979  stk::mesh::Entity node = nodes[i];
1980 
1981  const double * coord = getNodeCoordinates(node);
1982 
1983  for(unsigned d=0;d<getDimension();d++) {
1984  double * solnData = stk::mesh::field_data(*fields[d],node);
1985 
1986  // recall mesh field coordinates are stored as displacements
1987  // from the mesh coordinates, make sure to add them together
1988  vertices_h(cell,i,d) = solnData[0]+coord[d];
1989  }
1990  }
1991  }
1992  Kokkos::deep_copy(vertices, vertices_h);
1993 }
1994 
1995 template <typename ArrayT>
1996 void STK_Interface::getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1997  const std::string & eBlock, ArrayT & vertices) const
1998 {
2000 
2001  // nothing to do! silently return
2002  if(elements.size()==0) {
2003  return;
2004  }
2005 
2006  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2007  if(itr==meshCoordFields_.end()) {
2008  // no coordinate field set for this element block
2009  TEUCHOS_ASSERT(false);
2010  }
2011 
2012  const std::vector<std::string> & coordField = itr->second;
2013  std::vector<SolutionFieldType*> fields(getDimension());
2014  for(std::size_t d=0;d<fields.size();d++) {
2015  fields[d] = this->getSolutionField(coordField[d],eBlock);
2016  }
2017 
2018  for(std::size_t cell=0;cell<elements.size();cell++) {
2019  stk::mesh::Entity element = elements[cell];
2020 
2021  // loop over nodes set solution values
2022  const size_t num_nodes = bulkData_->num_nodes(element);
2023  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
2024  for(std::size_t i=0; i<num_nodes; ++i) {
2025  stk::mesh::Entity node = nodes[i];
2026 
2027  const double * coord = getNodeCoordinates(node);
2028 
2029  for(unsigned d=0;d<getDimension();d++) {
2030  double * solnData = stk::mesh::field_data(*fields[d],node);
2031 
2032  // recall mesh field coordinates are stored as displacements
2033  // from the mesh coordinates, make sure to add them together
2034  vertices(cell,i,d) = solnData[0]+coord[d];
2035  }
2036  }
2037  }
2038 }
2039 
2041 
2042 template <typename ArrayT>
2043 void STK_Interface::getElementNodes(const std::vector<std::size_t> & localElementIds, ArrayT & nodes) const
2044 {
2045  if(!useFieldCoordinates_) {
2046  //
2047  // gather from the intrinsic mesh coordinates (non-lagrangian)
2048  //
2049 
2050  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2051 
2052  // convert to a vector of entity objects
2053  std::vector<stk::mesh::Entity> selected_elements;
2054  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2055  selected_elements.push_back(elements[localElementIds[cell]]);
2056 
2057  getElementNodes_FromCoords(selected_elements,nodes);
2058  }
2059  else {
2060  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2061  "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2062  "without specifying an element block.");
2063  }
2064 }
2065 
2066 template <typename ArrayT>
2067 void STK_Interface::getElementNodes(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2068 {
2069  if(!useFieldCoordinates_) {
2070  getElementNodes_FromCoords(elements,nodes);
2071  }
2072  else {
2073  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2074  "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2075  "without specifying an element block.");
2076  }
2077 }
2078 
2079 template <typename ArrayT>
2080 void STK_Interface::getElementNodes(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2081 {
2082  if(!useFieldCoordinates_) {
2083  getElementNodes_FromCoords(elements,nodes);
2084  }
2085  else {
2086  getElementNodes_FromField(elements,eBlock,nodes);
2087  }
2088 }
2089 
2090 template <typename ArrayT>
2091 void STK_Interface::getElementNodes(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & nodes) const
2092 {
2093  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2094 
2095  // convert to a vector of entity objects
2096  std::vector<stk::mesh::Entity> selected_elements;
2097  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2098  selected_elements.push_back(elements[localElementIds[cell]]);
2099 
2100  if(!useFieldCoordinates_) {
2101  getElementNodes_FromCoords(selected_elements,nodes);
2102  }
2103  else {
2104  getElementNodes_FromField(selected_elements,eBlock,nodes);
2105  }
2106 }
2107 
2108 template <typename ArrayT>
2109 void STK_Interface::getElementNodesNoResize(const std::vector<std::size_t> & localElementIds, ArrayT & nodes) const
2110 {
2111  if(!useFieldCoordinates_) {
2112  //
2113  // gather from the intrinsic mesh coordinates (non-lagrangian)
2114  //
2115 
2116  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2117 
2118  // convert to a vector of entity objects
2119  std::vector<stk::mesh::Entity> selected_elements;
2120  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2121  selected_elements.push_back(elements[localElementIds[cell]]);
2122 
2123  getElementNodes_FromCoordsNoResize(selected_elements,nodes);
2124  }
2125  else {
2126  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2127  "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2128  "without specifying an element block.");
2129  }
2130 }
2131 
2132 template <typename ArrayT>
2133 void STK_Interface::getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2134 {
2135  if(!useFieldCoordinates_) {
2136  getElementNodes_FromCoordsNoResize(elements,nodes);
2137  }
2138  else {
2139  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2140  "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2141  "without specifying an element block.");
2142  }
2143 }
2144 
2145 template <typename ArrayT>
2146 void STK_Interface::getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2147 {
2148  if(!useFieldCoordinates_) {
2149  getElementNodes_FromCoordsNoResize(elements,nodes);
2150  }
2151  else {
2152  getElementNodes_FromFieldNoResize(elements,eBlock,nodes);
2153  }
2154 }
2155 
2156 template <typename ArrayT>
2157 void STK_Interface::getElementNodesNoResize(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & nodes) const
2158 {
2159  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2160 
2161  // convert to a vector of entity objects
2162  std::vector<stk::mesh::Entity> selected_elements;
2163  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2164  selected_elements.push_back(elements[localElementIds[cell]]);
2165 
2166  if(!useFieldCoordinates_) {
2167  getElementNodes_FromCoordsNoResize(selected_elements,nodes);
2168  }
2169  else {
2170  getElementNodes_FromFieldNoResize(selected_elements,eBlock,nodes);
2171  }
2172 }
2173 
2174 template <typename ArrayT>
2175 void STK_Interface::getElementNodes_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2176 {
2177  // nothing to do! silently return
2178  if(elements.size() == 0) {
2179  nodes = Kokkos::createDynRankView(nodes, "nodes", 0, 0, 0);
2180  return;
2181  }
2182 
2183  //
2184  // gather from the intrinsic mesh coordinates (non-lagrangian)
2185  //
2186 
2187  // get *master* cell toplogy...(belongs to first element)
2188  const auto masterNodeCount
2189  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2190 
2191  // allocate space
2192  nodes = Kokkos::createDynRankView(nodes, "nodes", elements.size(), masterNodeCount,getDimension());
2193  auto nodes_h = Kokkos::create_mirror_view(nodes);
2194  Kokkos::deep_copy(nodes_h, nodes);
2195 
2196  // loop over each requested element
2197  const auto dim = getDimension();
2198  for(std::size_t cell = 0; cell < elements.size(); cell++) {
2199  const auto element = elements[cell];
2200  TEUCHOS_ASSERT(element != 0);
2201 
2202  const auto nodeCount
2203  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2204  TEUCHOS_TEST_FOR_EXCEPTION(nodeCount != masterNodeCount, std::runtime_error,
2205  "In call to STK_Interface::getElementNodes all elements "
2206  "must have the same node count!");
2207 
2208  // loop over all element nodes
2209  const size_t num_nodes = bulkData_->num_nodes(element);
2210  auto const* elem_nodes = bulkData_->begin_nodes(element);
2211  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterNodeCount,std::runtime_error,
2212  "In call to STK_Interface::getElementNodes cardinality of "
2213  "element node relations must be the node count!");
2214  for(std::size_t node = 0; node < num_nodes; ++node) {
2215  const double * coord = getNodeCoordinates(elem_nodes[node]);
2216 
2217  // set each dimension of the coordinate
2218  for(unsigned d=0;d<dim;d++)
2219  nodes_h(cell,node,d) = coord[d];
2220  }
2221  }
2222  Kokkos::deep_copy(nodes, nodes_h);
2223 }
2224 
2225 template <typename ArrayT>
2226 void STK_Interface::getElementNodes_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2227 {
2228  // nothing to do! silently return
2229  if(elements.size()==0) {
2230  return;
2231  }
2232 
2233  //
2234  // gather from the intrinsic mesh coordinates (non-lagrangian)
2235  //
2236 
2237  // get *master* cell toplogy...(belongs to first element)
2238  unsigned masterNodeCount
2239  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2240 
2241  // loop over each requested element
2242  unsigned dim = getDimension();
2243  auto nodes_h = Kokkos::create_mirror_view(nodes);
2244  for(std::size_t cell=0;cell<elements.size();cell++) {
2245  stk::mesh::Entity element = elements[cell];
2246  TEUCHOS_ASSERT(element!=0);
2247 
2248  unsigned nodeCount
2249  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2250  TEUCHOS_TEST_FOR_EXCEPTION(nodeCount!=masterNodeCount,std::runtime_error,
2251  "In call to STK_Interface::getElementNodes all elements "
2252  "must have the same node count!");
2253 
2254  // loop over all element nodes
2255  const size_t num_nodes = bulkData_->num_nodes(element);
2256  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2257  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterNodeCount,std::runtime_error,
2258  "In call to STK_Interface::getElementNodes cardinality of "
2259  "element node relations must be the node count!");
2260  for(std::size_t node=0; node<num_nodes; ++node) {
2261  const double * coord = getNodeCoordinates(elem_nodes[node]);
2262 
2263  // set each dimension of the coordinate
2264  for(unsigned d=0;d<dim;d++)
2265  nodes_h(cell,node,d) = coord[d];
2266  }
2267  }
2268  Kokkos::deep_copy(nodes, nodes_h);
2269 }
2270 
2271 template <typename ArrayT>
2272 void STK_Interface::getElementNodes_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2273 {
2275 
2276  // nothing to do! silently return
2277  if(elements.size()==0) {
2278  nodes = Kokkos::createDynRankView(nodes,"nodes",0,0,0);
2279  return;
2280  }
2281 
2282  // get *master* cell toplogy...(belongs to first element)
2283  unsigned masterNodeCount
2284  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2285 
2286  // allocate space
2287  nodes = Kokkos::createDynRankView(nodes,"nodes",elements.size(),masterNodeCount,getDimension());
2288  auto nodes_h = Kokkos::create_mirror_view(nodes);
2289  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2290  if(itr==meshCoordFields_.end()) {
2291  // no coordinate field set for this element block
2292  TEUCHOS_ASSERT(false);
2293  }
2294 
2295  const std::vector<std::string> & coordField = itr->second;
2296  std::vector<SolutionFieldType*> fields(getDimension());
2297  for(std::size_t d=0;d<fields.size();d++) {
2298  fields[d] = this->getSolutionField(coordField[d],eBlock);
2299  }
2300 
2301  // loop over elements
2302  for(std::size_t cell=0;cell<elements.size();cell++) {
2303  stk::mesh::Entity element = elements[cell];
2304 
2305  // loop over nodes set solution values
2306  const size_t num_nodes = bulkData_->num_nodes(element);
2307  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2308  for(std::size_t i=0; i<num_nodes; ++i) {
2309  stk::mesh::Entity node = elem_nodes[i];
2310 
2311  const double * coord = getNodeCoordinates(node);
2312 
2313  for(unsigned d=0;d<getDimension();d++) {
2314  double * solnData = stk::mesh::field_data(*fields[d],node);
2315 
2316  // recall mesh field coordinates are stored as displacements
2317  // from the mesh coordinates, make sure to add them together
2318  nodes_h(cell,i,d) = solnData[0]+coord[d];
2319  }
2320  }
2321  }
2322  Kokkos::deep_copy(nodes, nodes_h);
2323 }
2324 
2325 template <typename ArrayT>
2326 void STK_Interface::getElementNodes_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
2327  const std::string & eBlock, ArrayT & nodes) const
2328 {
2330 
2331  // nothing to do! silently return
2332  if(elements.size()==0) {
2333  return;
2334  }
2335 
2336  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2337  if(itr==meshCoordFields_.end()) {
2338  // no coordinate field set for this element block
2339  TEUCHOS_ASSERT(false);
2340  }
2341 
2342  const std::vector<std::string> & coordField = itr->second;
2343  std::vector<SolutionFieldType*> fields(getDimension());
2344  for(std::size_t d=0;d<fields.size();d++) {
2345  fields[d] = this->getSolutionField(coordField[d],eBlock);
2346  }
2347 
2348  // loop over elements
2349  for(std::size_t cell=0;cell<elements.size();cell++) {
2350  stk::mesh::Entity element = elements[cell];
2351 
2352  // loop over nodes set solution values
2353  const size_t num_nodes = bulkData_->num_nodes(element);
2354  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2355  for(std::size_t i=0; i<num_nodes; ++i) {
2356  stk::mesh::Entity node = elem_nodes[i];
2357 
2358  const double * coord = getNodeCoordinates(node);
2359 
2360  for(unsigned d=0;d<getDimension();d++) {
2361  double * solnData = stk::mesh::field_data(*fields[d],node);
2362 
2363  // recall mesh field coordinates are stored as displacements
2364  // from the mesh coordinates, make sure to add them together
2365  nodes(cell,i,d) = solnData[0]+coord[d];
2366  }
2367  }
2368  }
2369 }
2370 
2371 }
2372 
2373 #endif
Teuchos::RCP< ElementDescriptor > buildElementDescriptor(stk::mesh::EntityId elmtId, std::vector< stk::mesh::EntityId > &nodes)
Teuchos::RCP< Teuchos::MpiComm< int > > getSafeCommunicator(stk::ParallelMachine parallelMach) const
void getSidesetNames(std::vector< std::string > &name) const
std::pair< Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > >, Teuchos::RCP< std::vector< unsigned int > > > getPeriodicNodePairing() const
const bool & useBoundingBoxSearch() const
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedEdgeVector_
Kokkos::DynRankView< typename InputArray::value_type, PHX::Device > createDynRankView(const InputArray &a, const std::string &name, const DimensionPack...dims)
Wrapper to simplify Panzer use of Sacado ViewFactory.
void addNodeset(const std::string &name)
Teuchos::RCP< stk::mesh::BulkData > bulkData_
void getFaceBlockNames(std::vector< std::string > &names) const
void print(std::ostream &os) const
void getElementNodesNoResize(const std::vector< std::size_t > &localIds, ArrayT &nodes) const
unsigned entityOwnerRank(stk::mesh::Entity entity) const
void getMyEdges(std::vector< stk::mesh::Entity > &edges) const
void setEdgeFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localEdgeIds, const ArrayT &edgeValues, double scaleValue=1.0)
stk::mesh::Field< double > VectorFieldType
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getElementsOrderedByLID() const
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::vector< stk::mesh::Part * > facesPartVec_
std::vector< stk::mesh::EntityId > nodes_
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToSolution_
void getElementVerticesNoResize(const std::vector< std::size_t > &localIds, ArrayT &vertices) const
void addEntityToNodeset(stk::mesh::Entity entity, stk::mesh::Part *nodeset)
void addGlobalToExodus(const std::string &key, const int &value)
Add an int global variable to the information to be written to the Exodus output file.
void setDispFieldData(const std::string &fieldName, const std::string &blockId, int axis, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues)
void getElementNodes_FromCoordsNoResize(const std::vector< stk::mesh::Entity > &elements, ArrayT &nodes) const
void getElementBlockNames(std::vector< std::string > &names) const
void addPeriodicBC(const Teuchos::RCP< const PeriodicBC_MatcherBase > &bc)
void getSubcellIndices(unsigned entityRank, stk::mesh::EntityId elementId, std::vector< stk::mesh::EntityId > &subcellIds) const
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getPeriodicBCVector()
void getElementsSharingNodes(const std::vector< stk::mesh::EntityId > nodeId, std::vector< stk::mesh::Entity > &elements) const
get a set of elements sharing multiple nodes
stk::mesh::Field< double > SolutionFieldType
stk::mesh::Part * getElementBlockPart(const std::string &name) const
get the block part
std::vector< stk::mesh::Part * > edgesPartVec_
bool nonnull(const std::shared_ptr< T > &p)
bool isFaceLocal(stk::mesh::Entity face) const
std::map< std::string, double > blockWeights_
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getEdgesOrderedByLID() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::size_t getEntityCounts(unsigned entityRank) const
get the global counts for the entity of specified rank
void printMetaData(std::ostream &os) const
void getElementNodes_FromFieldNoResize(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &nodes) const
void getElementVertices(const std::vector< std::size_t > &localIds, ArrayT &vertices) const
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
std::map< std::string, stk::mesh::Part * > faceBlocks_
stk::mesh::EntityId edgeGlobalId(std::size_t lid) const
void getElementVertices_FromCoords(const std::vector< stk::mesh::Entity > &elements, ArrayT &vertices) const
void getElementNodes(const std::vector< std::size_t > &localIds, ArrayT &nodes) const
void addSolutionField(const std::string &fieldName, const std::string &blockId)
std::map< std::string, Teuchos::RCP< shards::CellTopology > > elementBlockCT_
void addEntityToFaceBlock(stk::mesh::Entity entity, stk::mesh::Part *faceblock)
stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const
get max entity ID of type entityRank
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToFaceField_
std::map< std::string, stk::mesh::Part * > sidesets_
std::vector< std::size_t > entityCounts_
bool validBlockId(const std::string &blockId) const
stk::mesh::Part * getNodeset(const std::string &name) const
void getEdgeBlockNames(std::vector< std::string > &names) const
stk::mesh::Part * getFaceBlock(const std::string &name) const
get the block part
void addInformationRecords(const std::vector< std::string > &info_records)
stk::mesh::EntityId faceGlobalId(std::size_t lid) const
void getAllFaces(const std::string &faceBlockName, std::vector< stk::mesh::Entity > &faces) const
stk::mesh::Field< double > * getSolutionField(const std::string &fieldName, const std::string &blockId) const
void addEdgeBlock(const std::string &elemBlockName, const std::string &edgeBlockName, const stk::topology &topology)
const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const
stk::mesh::Part * getSideset(const std::string &name) const
static const std::string nodesString
void instantiateBulkData(stk::ParallelMachine parallelMach)
void getElementVertices_FromFieldNoResize(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &vertices) const
std::set< std::string > informationRecords_
void getMySides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
std::size_t getNumSidesets() const
get the side set count
stk::mesh::EntityId elementGlobalId(stk::mesh::Entity elmt) const
stk::mesh::Field< double > * getEdgeField(const std::string &fieldName, const std::string &blockId) const
std::size_t elementLocalId(stk::mesh::Entity elmt) const
stk::mesh::EntityId faceGlobalId(stk::mesh::Entity face) const
void getElementVertices_FromCoordsNoResize(const std::vector< stk::mesh::Entity > &elements, ArrayT &vertices) const
unsigned getDimension() const
get the dimension
void addElement(const Teuchos::RCP< ElementDescriptor > &ed, stk::mesh::Part *block)
std::map< std::string, std::vector< std::string > > meshDispFields_
void setupExodusFile(const std::string &filename, const bool append=false, const bool append_after_restart_time=false, const double restart_time=0.0)
Set up an output Exodus file for writing results.
void setUseFieldCoordinates(bool useFieldCoordinates)
stk::mesh::EntityRank getSideRank() const
void getAllEdges(const std::string &edgeBlockName, std::vector< stk::mesh::Entity > &edges) const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
static const std::string coordsString
void setFaceFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localFaceIds, const ArrayT &faceValues, double scaleValue=1.0)
std::size_t getNumElementBlocks() const
get the block count
void getElementNodes_FromField(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &nodes) const
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
std::map< std::string, stk::mesh::Part * > edgeBlocks_
void getElementVertices_FromField(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &vertices) const
stk::mesh::EntityId elementGlobalId(std::size_t lid) const
std::map< std::string, stk::mesh::Part * > elementBlocks_
std::vector< stk::mesh::Part * > nodesPartVec_
static const std::string edgeBlockString
static const std::string edgesString
std::string containingBlockId(stk::mesh::Entity elmt) const
stk::mesh::EntityRank getFaceRank() const
std::size_t edgeLocalId(stk::mesh::Entity elmt) const
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > periodicBCs_
void getOwnedElementsSharingNode(stk::mesh::Entity node, std::vector< stk::mesh::Entity > &elements, std::vector< int > &relIds) const
void addNode(stk::mesh::EntityId gid, const std::vector< double > &coord)
void addEntitiesToEdgeBlock(std::vector< stk::mesh::Entity > entities, stk::mesh::Part *edgeblock)
void setBlockWeight(const std::string &blockId, double weight)
void buildSubcells()
force the mesh to build subcells: edges and faces
Teuchos::RCP< Teuchos::MpiComm< int > > mpiComm_
void setInitialStateTime(double value)
Teuchos::RCP< stk::mesh::MetaData > metaData_
Teuchos::RCP< stk::mesh::MetaData > getMetaData() const
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedElementVector_
std::size_t getNumNodesets() const
get the side set count
bool isInitialized() const
Has initialize been called on this mesh object?
void writeToExodus(const std::string &filename, const bool append=false)
Write this mesh and associated fields to the given output file.
void getMyNodes(const std::string &sideName, const std::string &blockName, std::vector< stk::mesh::Entity > &nodes) const
void getSolutionFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, ArrayT &solutionValues) const
void addEdgeField(const std::string &fieldName, const std::string &blockId)
void addMeshCoordFields(const std::string &blockId, const std::vector< std::string > &coordField, const std::string &dispPrefix)
stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const
void setUseLowerCaseForIO(bool useLowerCase)
bool isMeshCoordField(const std::string &eBlock, const std::string &fieldName, int &axis) const
void getAllSides(const std::string &sideName, std::vector< stk::mesh::Entity > &sides) const
void addSideset(const std::string &name, const CellTopologyData *ctData)
static const std::string faceBlockString
std::unordered_map< stk::mesh::EntityId, std::size_t > localFaceIDHash_
void addEntityToEdgeBlock(stk::mesh::Entity entity, stk::mesh::Part *edgeblock)
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToEdgeField_
stk::mesh::Part * getEdgeBlock(const std::string &name) const
get the block part
void setCellFieldData(const std::string &fieldName, const std::string &blockId, const std::vector< std::size_t > &localElementIds, const ArrayT &solutionValues, double scaleValue=1.0)
const VectorFieldType & getEdgesField() const
std::unordered_map< stk::mesh::EntityId, std::size_t > localEdgeIDHash_
ProcIdFieldType * getProcessorIdField()
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we&#39;ll contribute, or in which we&#39;ll store, the result of computing this integral...
void rebalance(const Teuchos::ParameterList &params)
std::map< std::string, std::vector< std::string > > meshCoordFields_
stk::mesh::EntityRank getEdgeRank() const
static const std::string facesString
void addEntitiesToFaceBlock(std::vector< stk::mesh::Entity > entities, stk::mesh::Part *faceblock)
void initializeFieldsInSTK(const std::map< std::pair< std::string, std::string >, SolutionFieldType * > &nameToField, bool setupIO)
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
get the comm associated with this mesh
const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getPeriodicBCVector() const
const VectorFieldType & getFacesField() const
void refineMesh(const int numberOfLevels, const bool deleteParentElements)
stk::mesh::Field< double > * getFaceField(const std::string &fieldName, const std::string &blockId) const
std::size_t faceLocalId(stk::mesh::Entity elmt) const
void addFaceBlock(const std::string &elemBlockName, const std::string &faceBlockName, const stk::topology &topology)
Teuchos::RCP< std::vector< stk::mesh::Entity > > orderedFaceVector_
std::unordered_map< stk::mesh::EntityId, std::size_t > localIDHash_
bool isValid(stk::mesh::Entity entity) const
std::vector< stk::mesh::EntityId > maxEntityId_
stk::mesh::Field< ProcIdData > ProcIdFieldType
void addPeriodicBCs(const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > &bc_vec)
void getElementsSharingNode(stk::mesh::EntityId nodeId, std::vector< stk::mesh::Entity > &elements) const
get a set of elements sharing a single node
void addFaceField(const std::string &fieldName, const std::string &blockId)
#define TEUCHOS_ASSERT(assertion_test)
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
stk::mesh::EntityRank getNodeRank() const
void getMyFaces(std::vector< stk::mesh::Entity > &faces) const
void addCellField(const std::string &fieldName, const std::string &blockId)
void getNodeIdsForElement(stk::mesh::Entity element, std::vector< stk::mesh::EntityId > &nodeIds) const
get a list of node ids for nodes connected to an element
Teuchos::RCP< const std::vector< stk::mesh::Entity > > getFacesOrderedByLID() const
bool operator()(stk::mesh::Entity a, stk::mesh::Entity b)
stk::mesh::EntityRank getElementRank() const
void getElementNodes_FromCoords(const std::vector< stk::mesh::Entity > &elements, ArrayT &nodes) const
stk::mesh::EntityId edgeGlobalId(stk::mesh::Entity edge) const
void addElementBlock(const std::string &name, const CellTopologyData *ctData)
const std::vector< stk::mesh::EntityId > & getNodes() const
stk::mesh::Field< double > * getCellField(const std::string &fieldName, const std::string &blockId) const
const VectorFieldType & getCoordinatesField() const
stk::mesh::Part * getOwnedPart() const
Get a pointer to the locally owned part.
stk::mesh::EntityId getGID() const
void setBoundingBoxSearchFlag(const bool &searchFlag)
bool isEdgeLocal(stk::mesh::Entity edge) const
void getNeighborElements(std::vector< stk::mesh::Entity > &elements) const
void getNodesetNames(std::vector< std::string > &name) const
Teuchos::RCP< const shards::CellTopology > getCellTopology(const std::string &eBlock) const
std::map< std::pair< std::string, std::string >, SolutionFieldType * > fieldNameToCellField_
std::map< std::string, stk::mesh::Part * > nodesets_