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 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef __Panzer_STK_Interface_hpp__
44 #define __Panzer_STK_Interface_hpp__
45 
46 #include <Teuchos_RCP.hpp>
48 
49 #include <stk_mesh/base/Types.hpp>
50 #include <stk_mesh/base/MetaData.hpp>
51 #include <stk_mesh/base/BulkData.hpp>
52 #include <stk_mesh/base/Field.hpp>
53 #include <stk_mesh/base/FieldBase.hpp>
54 
55 #include "Kokkos_Core.hpp"
56 
57 #include <Shards_CellTopology.hpp>
58 #include <Shards_CellTopologyData.h>
59 
60 #include <PanzerAdaptersSTK_config.hpp>
61 #include <Kokkos_ViewFactory.hpp>
62 
63 #include <unordered_map>
64 
65 #ifdef PANZER_HAVE_IOSS
66 #include <stk_io/StkMeshIoBroker.hpp>
67 #endif
68 
69 #ifdef PANZER_HAVE_PERCEPT
70 namespace percept {
71  class PerceptMesh;
72  class URP_Heterogeneous_3D;
73 }
74 #endif
75 
76 namespace panzer_stk {
77 
78 class PeriodicBC_MatcherBase;
79 
84 public:
85  ElementDescriptor(stk::mesh::EntityId gid,const std::vector<stk::mesh::EntityId> & nodes);
86  virtual ~ElementDescriptor();
87 
88  stk::mesh::EntityId getGID() const { return gid_; }
89  const std::vector<stk::mesh::EntityId> & getNodes() const { return nodes_; }
90 protected:
91  stk::mesh::EntityId gid_;
92  std::vector<stk::mesh::EntityId> nodes_;
93 
95 };
96 
100 buildElementDescriptor(stk::mesh::EntityId elmtId,std::vector<stk::mesh::EntityId> & nodes);
101 
103 public:
104  typedef double ProcIdData; // ECC: Not sure why?
105  typedef stk::mesh::Field<double> SolutionFieldType;
106  typedef stk::mesh::Field<double> VectorFieldType;
107  typedef stk::mesh::Field<ProcIdData> ProcIdFieldType;
108 
109  // some simple exception classes
110  struct ElementBlockException : public std::logic_error
111  { ElementBlockException(const std::string & what) : std::logic_error(what) {} };
112 
113  struct SidesetException : public std::logic_error
114  { SidesetException(const std::string & what) : std::logic_error(what) {} };
115 
116  struct EdgeBlockException : public std::logic_error
117  { EdgeBlockException(const std::string & what) : std::logic_error(what) {} };
118 
119  struct FaceBlockException : public std::logic_error
120  { FaceBlockException(const std::string & what) : std::logic_error(what) {} };
121 
122  STK_Interface();
123 
126  STK_Interface(unsigned dim);
127 
129 
130  // functions called before initialize
132 
135  void addElementBlock(const std::string & name,const CellTopologyData * ctData);
136 
139 // void addEdgeBlock(const std::string & name,const CellTopologyData * ctData);
140  void addEdgeBlock(const std::string & elemBlockName,
141  const std::string & edgeBlockName,
142  const stk::topology & topology);
143  void addEdgeBlock(const std::string & elemBlockName,
144  const std::string & edgeBlockName,
145  const CellTopologyData * ctData);
146 
149  void addFaceBlock(const std::string & elemBlockName,
150  const std::string & faceBlockName,
151  const stk::topology & topology);
152  void addFaceBlock(const std::string & elemBlockName,
153  const std::string & faceBlockName,
154  const CellTopologyData * ctData);
155 
158  void addSideset(const std::string & name,const CellTopologyData * ctData);
159 
162  void addNodeset(const std::string & name);
163 
166  void addSolutionField(const std::string & fieldName,const std::string & blockId);
167 
170  void addCellField(const std::string & fieldName,const std::string & blockId);
171 
174  void addEdgeField(const std::string & fieldName,const std::string & blockId);
175 
178  void addFaceField(const std::string & fieldName,const std::string & blockId);
179 
188  void addMeshCoordFields(const std::string & blockId,
189  const std::vector<std::string> & coordField,
190  const std::string & dispPrefix);
191 
196  void addInformationRecords(const std::vector<std::string> & info_records);
197 
199 
211  void initialize(stk::ParallelMachine parallelMach,bool setupIO=true,
212  const bool buildRefinementSupport = false);
213 
219  void instantiateBulkData(stk::ParallelMachine parallelMach);
220 
221  // functions to manage and manipulate bulk data
223 
226  void beginModification();
227 
230  void endModification();
231 
237  void addNode(stk::mesh::EntityId gid, const std::vector<double> & coord);
238 
239  void addElement(const Teuchos::RCP<ElementDescriptor> & ed,stk::mesh::Part * block);
240 
241  void addEdges();
242 
243  void addFaces();
244 
247  void addEntityToSideset(stk::mesh::Entity entity,stk::mesh::Part * sideset);
248 
251  void addEntityToNodeset(stk::mesh::Entity entity,stk::mesh::Part * nodeset);
252 
255  void addEntityToEdgeBlock(stk::mesh::Entity entity,stk::mesh::Part * edgeblock);
258  void addEntitiesToEdgeBlock(std::vector<stk::mesh::Entity> entities,stk::mesh::Part * edgeblock);
259 
262  void addEntityToFaceBlock(stk::mesh::Entity entity,stk::mesh::Part * faceblock);
265  void addEntitiesToFaceBlock(std::vector<stk::mesh::Entity> entities,stk::mesh::Part * faceblock);
266 
267  // Methods to interrogate the mesh topology and structure
269 
273  { return *coordinatesField_; }
274 
278  { return *edgesField_; }
279 
281  { return *facesField_; }
282 
285  const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const;
286 
289  const double * getNodeCoordinates(stk::mesh::Entity node) const;
290 
293  void getSubcellIndices(unsigned entityRank,stk::mesh::EntityId elementId,
294  std::vector<stk::mesh::EntityId> & subcellIds) const;
295 
298  void getMyElements(std::vector<stk::mesh::Entity> & elements) const;
299 
302  void getMyElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
303 
307  void getNeighborElements(std::vector<stk::mesh::Entity> & elements) const;
308 
311  void getNeighborElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
312 
315  void getMyEdges(std::vector<stk::mesh::Entity> & edges) const;
316 
324  void getMyEdges(const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges) const;
325 
334  void getMyEdges(const std::string & edgeBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & edges) const;
335 
343  void getAllEdges(const std::string & edgeBlockName,std::vector<stk::mesh::Entity> & edges) const;
344 
353  void getAllEdges(const std::string & edgeBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & edges) const;
354 
357  void getMyFaces(std::vector<stk::mesh::Entity> & faces) const;
358 
366  void getMyFaces(const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces) const;
367 
376  void getMyFaces(const std::string & faceBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & faces) const;
377 
385  void getAllFaces(const std::string & faceBlockName,std::vector<stk::mesh::Entity> & faces) const;
386 
395  void getAllFaces(const std::string & faceBlockName,const std::string & blockName,std::vector<stk::mesh::Entity> & faces) const;
396 
404  void getMySides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
405 
414  void getMySides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
415 
423  void getAllSides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
424 
433  void getAllSides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
434 
444  void getMyNodes(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & nodes) const;
445 
454  stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const;
455 
456  // Utility functions
458 
467  void
468  writeToExodus(const std::string& filename,
469  const bool append = false);
470 
488  void
489  setupExodusFile(const std::string& filename,
490  const bool append = false,
491  const bool append_after_restart_time = false,
492  const double restart_time = 0.0);
493 
506  void
508  double timestep);
509 
529  void
531  const std::string& key,
532  const int& value);
533 
553  void
555  const std::string& key,
556  const double& value);
557 
577  void
579  const std::string& key,
580  const std::vector<int>& value);
581 
601  void
603  const std::string& key,
604  const std::vector<double>& value);
605 
606  // Accessor functions
608 
611 
614 
615 #ifdef PANZER_HAVE_PERCEPT
616  Teuchos::RCP<percept::PerceptMesh> getRefinedMesh() const
618  { TEUCHOS_ASSERT(Teuchos::nonnull(refinedMesh_)); return refinedMesh_; }
619 #endif
620 
621  bool isWritable() const;
622 
623  bool isModifiable() const
624  { if(bulkData_==Teuchos::null) return false;
625  return bulkData_->in_modifiable_state(); }
626 
628  unsigned getDimension() const
629  { return dimension_; }
630 
632  std::size_t getNumElementBlocks() const
633  { return elementBlocks_.size(); }
634 
642  void getElementBlockNames(std::vector<std::string> & names) const;
643 
651  void getSidesetNames(std::vector<std::string> & name) const;
652 
660  void getNodesetNames(std::vector<std::string> & name) const;
661 
669  void getEdgeBlockNames(std::vector<std::string> & names) const;
670 
678  void getFaceBlockNames(std::vector<std::string> & names) const;
679 
681  stk::mesh::Part * getOwnedPart() const
682  { return &getMetaData()->locally_owned_part(); } // I don't like the pointer access here, but it will do for now!
683 
685  stk::mesh::Part * getElementBlockPart(const std::string & name) const
686  {
687  std::map<std::string, stk::mesh::Part*>::const_iterator itr = elementBlocks_.find(name); // Element blocks
688  if(itr==elementBlocks_.end()) return 0;
689  return itr->second;
690  }
691 
693  stk::mesh::Part * getEdgeBlock(const std::string & name) const
694  {
695  std::map<std::string, stk::mesh::Part*>::const_iterator itr = edgeBlocks_.find(name); // edge blocks
696  if(itr==edgeBlocks_.end()) return 0;
697  return itr->second;
698  }
699 
701  stk::mesh::Part * getFaceBlock(const std::string & name) const
702  {
703  std::map<std::string, stk::mesh::Part*>::const_iterator itr = faceBlocks_.find(name); // face blocks
704  if(itr==faceBlocks_.end()) return 0;
705  return itr->second;
706  }
707 
709  std::size_t getNumSidesets() const
710  { return sidesets_.size(); }
711 
712  stk::mesh::Part * getSideset(const std::string & name) const
713  {
714  auto itr = sidesets_.find(name);
715  return (itr != sidesets_.end()) ? itr->second : nullptr;
716  }
717 
719  std::size_t getNumNodesets() const
720  { return nodesets_.size(); }
721 
722  stk::mesh::Part * getNodeset(const std::string & name) const
723  {
724  auto itr = nodesets_.find(name);
725  return (itr != nodesets_.end()) ? itr->second : nullptr;
726  }
727 
729  std::size_t getEntityCounts(unsigned entityRank) const;
730 
732  stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const;
733 
734  // Utilities
736 
738  void getElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements) const;
739 
741  void getNodeIdsForElement(stk::mesh::Entity element,std::vector<stk::mesh::EntityId> & nodeIds) const;
742 
745  void getOwnedElementsSharingNode(stk::mesh::Entity node,std::vector<stk::mesh::Entity> & elements,
746  std::vector<int> & relIds) const;
747 
750  void getOwnedElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements,
751  std::vector<int> & relIds, unsigned int matchType) const;
752 
753 
755  void getElementsSharingNodes(const std::vector<stk::mesh::EntityId> nodeId,std::vector<stk::mesh::Entity> & elements) const;
756 
758  void buildSubcells();
759 
762  std::size_t elementLocalId(stk::mesh::Entity elmt) const;
763 
766  std::size_t elementLocalId(stk::mesh::EntityId gid) const;
767 
770  inline stk::mesh::EntityId elementGlobalId(std::size_t lid) const
771  { return bulkData_->identifier((*orderedElementVector_)[lid]); }
772 
775  inline stk::mesh::EntityId elementGlobalId(stk::mesh::Entity elmt) const
776  { return bulkData_->identifier(elmt); }
777 
780  bool isEdgeLocal(stk::mesh::Entity edge) const;
781 
784  bool isEdgeLocal(stk::mesh::EntityId gid) const;
785 
788  std::size_t edgeLocalId(stk::mesh::Entity elmt) const;
789 
792  std::size_t edgeLocalId(stk::mesh::EntityId gid) const;
793 
796  inline stk::mesh::EntityId edgeGlobalId(std::size_t lid) const
797  { return bulkData_->identifier((*orderedEdgeVector_)[lid]); }
798 
801  inline stk::mesh::EntityId edgeGlobalId(stk::mesh::Entity edge) const
802  { return bulkData_->identifier(edge); }
803 
806  bool isFaceLocal(stk::mesh::Entity face) const;
807 
810  bool isFaceLocal(stk::mesh::EntityId gid) const;
811 
814  std::size_t faceLocalId(stk::mesh::Entity elmt) const;
815 
818  std::size_t faceLocalId(stk::mesh::EntityId gid) const;
819 
822  inline stk::mesh::EntityId faceGlobalId(std::size_t lid) const
823  { return bulkData_->identifier((*orderedFaceVector_)[lid]); }
824 
827  inline stk::mesh::EntityId faceGlobalId(stk::mesh::Entity face) const
828  { return bulkData_->identifier(face); }
829 
832  inline unsigned entityOwnerRank(stk::mesh::Entity entity) const
833  { return bulkData_->parallel_owner_rank(entity); }
834 
837  inline bool isValid(stk::mesh::Entity entity) const
838  { return bulkData_->is_valid(entity); }
839 
842  std::string containingBlockId(stk::mesh::Entity elmt) const;
843 
848  stk::mesh::Field<double> * getSolutionField(const std::string & fieldName,
849  const std::string & blockId) const;
850 
855  stk::mesh::Field<double> * getCellField(const std::string & fieldName,
856  const std::string & blockId) const;
857 
862  stk::mesh::Field<double> * getEdgeField(const std::string & fieldName,
863  const std::string & blockId) const;
864 
869  stk::mesh::Field<double> * getFaceField(const std::string & fieldName,
870  const std::string & blockId) const;
871 
873 
875  bool isInitialized() const { return initialized_; }
876 
881 
896  template <typename ArrayT>
897  void setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
898  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
899 
914  template <typename ArrayT>
915  void getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
916  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const;
917 
932  template <typename ArrayT>
933  void setCellFieldData(const std::string & fieldName,const std::string & blockId,
934  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
935 
940 
945 
960  template <typename ArrayT>
961  void setEdgeFieldData(const std::string & fieldName,const std::string & blockId,
962  const std::vector<std::size_t> & localEdgeIds,const ArrayT & edgeValues,double scaleValue=1.0);
963 
978  template <typename ArrayT>
979  void setFaceFieldData(const std::string & fieldName,const std::string & blockId,
980  const std::vector<std::size_t> & localFaceIds,const ArrayT & faceValues,double scaleValue=1.0);
981 
983 
992  template <typename ArrayT>
993  void getElementVertices(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
994 
1003  template <typename ArrayT>
1004  void getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1005 
1015  template <typename ArrayT>
1016  void getElementVertices(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
1017 
1027  template <typename ArrayT>
1028  void getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1029 
1038  template <typename ArrayT>
1039  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
1040 
1049  template <typename ArrayT>
1050  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1051 
1061  template <typename ArrayT>
1062  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
1063 
1073  template <typename ArrayT>
1074  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1075 
1077 
1087  template <typename ArrayT>
1088  void getElementNodes(const std::vector<std::size_t> & localIds, ArrayT & nodes) const;
1089 
1098  template <typename ArrayT>
1099  void getElementNodes(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1100 
1110  template <typename ArrayT>
1111  void getElementNodes(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & nodes) const;
1112 
1122  template <typename ArrayT>
1123  void getElementNodes(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1124 
1133  template <typename ArrayT>
1134  void getElementNodesNoResize(const std::vector<std::size_t> & localIds, ArrayT & nodes) const;
1135 
1144  template <typename ArrayT>
1145  void getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1146 
1156  template <typename ArrayT>
1157  void getElementNodesNoResize(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & nodes) const;
1158 
1168  template <typename ArrayT>
1169  void getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1170 
1171  // const stk::mesh::FEMInterface & getFEMInterface() const
1172  // { return *femPtr_; }
1173 
1174  stk::mesh::EntityRank getElementRank() const { return stk::topology::ELEMENT_RANK; }
1175  stk::mesh::EntityRank getSideRank() const { return metaData_->side_rank(); }
1176  stk::mesh::EntityRank getFaceRank() const { return stk::topology::FACE_RANK; }
1177  stk::mesh::EntityRank getEdgeRank() const { return stk::topology::EDGE_RANK; }
1178  stk::mesh::EntityRank getNodeRank() const { return stk::topology::NODE_RANK; }
1179 
1182  void initializeFromMetaData();
1183 
1186  void buildLocalElementIDs();
1187 
1190  void buildLocalEdgeIDs();
1191 
1194  void buildLocalFaceIDs();
1195 
1198  const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1200  { return periodicBCs_; }
1201 
1204  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
1206  { return periodicBCs_; }
1207 
1210  const bool & useBoundingBoxSearch() const
1211  { return useBBoxSearch_; }
1212 
1214  void setBoundingBoxSearchFlag(const bool & searchFlag)
1215  { useBBoxSearch_ = searchFlag; return; }
1216 
1223  { periodicBCs_.push_back(bc); }
1224 
1231  { periodicBCs_.insert(periodicBCs_.end(),bc_vec.begin(),bc_vec.end()); }
1232 
1235  std::pair<Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >, Teuchos::RCP<std::vector<unsigned int> > >
1236  getPeriodicNodePairing() const;
1237 
1240  bool validBlockId(const std::string & blockId) const;
1241 
1244  void print(std::ostream & os) const;
1245 
1248  void printMetaData(std::ostream & os) const;
1249 
1252  Teuchos::RCP<const shards::CellTopology> getCellTopology(const std::string & eBlock) const;
1253 
1258  double getCurrentStateTime() const { return currentStateTime_; }
1259 
1265  double getInitialStateTime() const { return initialStateTime_; }
1266 
1271  void setInitialStateTime(double value) { initialStateTime_ = value; }
1272 
1275  void rebalance(const Teuchos::ParameterList & params);
1276 
1280  void setBlockWeight(const std::string & blockId,double weight)
1281  { blockWeights_[blockId] = weight; }
1282 
1289  void setUseFieldCoordinates(bool useFieldCoordinates)
1290  { useFieldCoordinates_ = useFieldCoordinates; }
1291 
1294  { return useFieldCoordinates_; }
1295 
1297  void setUseLowerCaseForIO(bool useLowerCase)
1298  { useLowerCase_ = useLowerCase; }
1299 
1302  { return useLowerCase_; }
1303 
1305 
1316  template <typename ArrayT>
1317  void getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
1318 
1319  template <typename ArrayT>
1320  void getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1321  const std::string & eBlock, ArrayT & vertices) const;
1322 
1332  template <typename ArrayT>
1333  void getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1334 
1335  template <typename ArrayT>
1336  void getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
1337 
1339 
1350  template <typename ArrayT>
1351  void getElementNodes_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const;
1352 
1353  template <typename ArrayT>
1354  void getElementNodes_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1355  const std::string & eBlock, ArrayT & nodes) const;
1356 
1366  template <typename ArrayT>
1367  void getElementNodes_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1368 
1369  template <typename ArrayT>
1370  void getElementNodes_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const;
1371 
1377  void refineMesh(const int numberOfLevels, const bool deleteParentElements);
1378 
1379 public: // static operations
1380  static const std::string coordsString;
1381  static const std::string nodesString;
1382  static const std::string edgesString;
1383  static const std::string edgeBlockString;
1384  static const std::string faceBlockString;
1385  static const std::string facesString;
1386 
1387 protected:
1388 
1391  void buildEntityCounts();
1392 
1395  void buildMaxEntityIds();
1396 
1400  void initializeFieldsInSTK(const std::map<std::pair<std::string,std::string>,SolutionFieldType*> & nameToField,
1401  bool setupIO);
1402 
1407  Teuchos::RCP<Teuchos::MpiComm<int> > getSafeCommunicator(stk::ParallelMachine parallelMach) const;
1408 
1415 
1419  bool isMeshCoordField(const std::string & eBlock,const std::string & fieldName,int & axis) const;
1420 
1436  template <typename ArrayT>
1437  void setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
1438  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues);
1439 
1440  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > periodicBCs_;
1441  bool useBBoxSearch_ = false; // TODO swap this to change default periodic BC search (see also PeriodicBC_Parser.cpp)
1442 
1445 #ifdef PANZER_HAVE_PERCEPT
1448 #endif
1449 
1450  std::map<std::string, stk::mesh::Part*> elementBlocks_; // Element blocks
1451  std::map<std::string, stk::mesh::Part*> sidesets_; // Side sets
1452  std::map<std::string, stk::mesh::Part*> nodesets_; // Node sets
1453  std::map<std::string, stk::mesh::Part*> edgeBlocks_; // Edge blocks
1454  std::map<std::string, stk::mesh::Part*> faceBlocks_; // Face blocks
1455 
1456  std::map<std::string, Teuchos::RCP<shards::CellTopology> > elementBlockCT_;
1457 
1458  // for storing/accessing nodes
1459  stk::mesh::Part * nodesPart_;
1460  std::vector<stk::mesh::Part*> nodesPartVec_;
1461  stk::mesh::Part * edgesPart_;
1462  std::vector<stk::mesh::Part*> edgesPartVec_;
1463  stk::mesh::Part * facesPart_;
1464  std::vector<stk::mesh::Part*> facesPartVec_;
1465 
1471 
1472  // maps field names to solution field stk mesh handles
1473  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToSolution_;
1474  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToCellField_;
1475  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToEdgeField_;
1476  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToFaceField_;
1477 
1478  // use a set to maintain a list of unique information records
1479  std::set<std::string> informationRecords_;
1480 
1481  unsigned dimension_;
1482 
1484 
1485  // how many elements, faces, edges, and nodes are there globally
1486  std::vector<std::size_t> entityCounts_;
1487 
1488  // what is maximum entity ID
1489  std::vector<stk::mesh::EntityId> maxEntityId_;
1490 
1491  unsigned procRank_;
1492  std::size_t currentLocalId_;
1493 
1495 
1496  double initialStateTime_; // the time stamp at the time this object was constructed (default 0.0)
1497  double currentStateTime_; // the time stamp set by the user when writeToExodus is called (default 0.0)
1498 
1499 #ifdef PANZER_HAVE_IOSS
1500  // I/O support
1502  int meshIndex_;
1503 
1508  enum class GlobalVariable
1509  {
1510  ADD,
1511  WRITE
1512  }; // end of enum class GlobalVariable
1513 
1530  void
1531  globalToExodus(
1532  const GlobalVariable& flag);
1533 
1537  Teuchos::ParameterList globalData_;
1538 #endif
1539 
1540  // uses lazy evaluation
1542 
1543  // uses lazy evaluation
1545 
1546  // uses lazy evaluation
1548 
1549  // for element block weights
1550  std::map<std::string,double> blockWeights_;
1551 
1552  std::unordered_map<stk::mesh::EntityId,std::size_t> localIDHash_;
1553  std::unordered_map<stk::mesh::EntityId,std::size_t> localEdgeIDHash_;
1554  std::unordered_map<stk::mesh::EntityId,std::size_t> localFaceIDHash_;
1555 
1556  // Store mesh displacement fields by element block. This map
1557  // goes like this meshCoordFields_[eBlock][axis_index] => coordinate FieldName
1558  // goes like this meshDispFields_[eBlock][axis_index] => displacement FieldName
1559  std::map<std::string,std::vector<std::string> > meshCoordFields_; // coordinate fields written by user
1560  std::map<std::string,std::vector<std::string> > meshDispFields_; // displacement fields, output to exodus
1561 
1563 
1565 
1566  // Object describing how to sort a vector of elements using
1567  // local ID as the key, very short lived object
1569  public:
1570  LocalIdCompare(const STK_Interface * mesh) : mesh_(mesh) {}
1571 
1572  // Compares two stk mesh entities based on local ID
1573  bool operator() (stk::mesh::Entity a,stk::mesh::Entity b)
1574  { return mesh_->elementLocalId(a) < mesh_->elementLocalId(b);}
1575 
1576  private:
1578  };
1579 };
1580 
1581 template <typename ArrayT>
1582 void STK_Interface::setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1583  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1584 {
1585  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1586  auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1587  Kokkos::deep_copy(solutionValues_h, solutionValues);
1588 
1589  int field_axis = -1;
1590  if(isMeshCoordField(blockId,fieldName,field_axis)) {
1591  setDispFieldData(fieldName,blockId,field_axis,localElementIds,solutionValues_h);
1592  return;
1593  }
1594 
1595  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1596 
1597  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1598  std::size_t localId = localElementIds[cell];
1599  stk::mesh::Entity element = elements[localId];
1600 
1601  // loop over nodes set solution values
1602  const size_t num_nodes = bulkData_->num_nodes(element);
1603  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1604  for(std::size_t i=0; i<num_nodes; ++i) {
1605  stk::mesh::Entity node = nodes[i];
1606 
1607  double * solnData = stk::mesh::field_data(*field,node);
1608  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1609  solnData[0] = scaleValue*solutionValues_h(cell,i);
1610  }
1611  }
1612 }
1613 
1614 template <typename ArrayT>
1615 void STK_Interface::setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
1616  const std::vector<std::size_t> & localElementIds,const ArrayT & dispValues)
1617 {
1618  TEUCHOS_ASSERT(axis>=0); // sanity check
1619 
1620  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1621 
1622  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1623  const VectorFieldType & coord_field = this->getCoordinatesField();
1624 
1625  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1626  std::size_t localId = localElementIds[cell];
1627  stk::mesh::Entity element = elements[localId];
1628 
1629  // loop over nodes set solution values
1630  const size_t num_nodes = bulkData_->num_nodes(element);
1631  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1632  for(std::size_t i=0; i<num_nodes; ++i) {
1633  stk::mesh::Entity node = nodes[i];
1634 
1635  double * solnData = stk::mesh::field_data(*field,node);
1636  double * coordData = stk::mesh::field_data(coord_field,node);
1637  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1638  solnData[0] = dispValues(cell,i)-coordData[axis];
1639  }
1640  }
1641 }
1642 
1643 template <typename ArrayT>
1644 void STK_Interface::getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1645  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const
1646 {
1647  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1648 
1649  solutionValues = Kokkos::createDynRankView(solutionValues,
1650  "solutionValues",
1651  localElementIds.size(),
1652  bulkData_->num_nodes(elements[localElementIds[0]]));
1653 
1654  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1655 
1656  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1657  std::size_t localId = localElementIds[cell];
1658  stk::mesh::Entity element = elements[localId];
1659 
1660  // loop over nodes set solution values
1661  const size_t num_nodes = bulkData_->num_nodes(element);
1662  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1663  for(std::size_t i=0; i<num_nodes; ++i) {
1664  stk::mesh::Entity node = nodes[i];
1665 
1666  double * solnData = stk::mesh::field_data(*field,node);
1667  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1668  solutionValues(cell,i) = solnData[0];
1669  }
1670  }
1671 }
1672 
1673 template <typename ArrayT>
1674 void STK_Interface::setCellFieldData(const std::string & fieldName,const std::string & blockId,
1675  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1676 {
1677  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1678 
1679  SolutionFieldType * field = this->getCellField(fieldName,blockId);
1680 
1681  auto solutionValues_h = Kokkos::create_mirror_view(solutionValues);
1682  Kokkos::deep_copy(solutionValues_h, solutionValues);
1683 
1684  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1685  std::size_t localId = localElementIds[cell];
1686  stk::mesh::Entity element = elements[localId];
1687 
1688  double * solnData = stk::mesh::field_data(*field,element);
1689  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1690  solnData[0] = scaleValue*solutionValues_h.access(cell,0);
1691  }
1692 }
1693 
1694 template <typename ArrayT>
1695 void STK_Interface::setEdgeFieldData(const std::string & fieldName,const std::string & blockId,
1696  const std::vector<std::size_t> & localEdgeIds,const ArrayT & edgeValues,double scaleValue)
1697 {
1698  const std::vector<stk::mesh::Entity> & edges = *(this->getEdgesOrderedByLID());
1699 
1700  SolutionFieldType * field = this->getEdgeField(fieldName,blockId);
1701 
1702  auto edgeValues_h = Kokkos::create_mirror_view(edgeValues);
1703  Kokkos::deep_copy(edgeValues_h, edgeValues);
1704 
1705  for(std::size_t idx=0;idx<localEdgeIds.size();idx++) {
1706  std::size_t localId = localEdgeIds[idx];
1707  stk::mesh::Entity edge = edges[localId];
1708 
1709  double * solnData = stk::mesh::field_data(*field,edge);
1710  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1711  solnData[0] = scaleValue*edgeValues_h.access(idx,0);
1712  }
1713 }
1714 
1715 template <typename ArrayT>
1716 void STK_Interface::setFaceFieldData(const std::string & fieldName,const std::string & blockId,
1717  const std::vector<std::size_t> & localFaceIds,const ArrayT & faceValues,double scaleValue)
1718 {
1719  const std::vector<stk::mesh::Entity> & faces = *(this->getFacesOrderedByLID());
1720 
1721  SolutionFieldType * field = this->getFaceField(fieldName,blockId);
1722 
1723  auto faceValues_h = Kokkos::create_mirror_view(faceValues);
1724  Kokkos::deep_copy(faceValues_h, faceValues);
1725 
1726  for(std::size_t idx=0;idx<localFaceIds.size();idx++) {
1727  std::size_t localId = localFaceIds[idx];
1728  stk::mesh::Entity face = faces[localId];
1729 
1730  double * solnData = stk::mesh::field_data(*field,face);
1731  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1732  solnData[0] = scaleValue*faceValues_h.access(idx,0);
1733  }
1734 }
1735 
1737 
1738 template <typename ArrayT>
1739 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1740 {
1741  if(!useFieldCoordinates_) {
1742  //
1743  // gather from the intrinsic mesh coordinates (non-lagrangian)
1744  //
1745 
1746  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1747 
1748  // convert to a vector of entity objects
1749  std::vector<stk::mesh::Entity> selected_elements;
1750  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1751  selected_elements.push_back(elements[localElementIds[cell]]);
1752 
1753  getElementVertices_FromCoords(selected_elements,vertices);
1754  }
1755  else {
1756  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1757  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1758  "without specifying an element block.");
1759  }
1760 }
1761 
1762 template <typename ArrayT>
1763 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1764 {
1765  if(!useFieldCoordinates_) {
1766  getElementVertices_FromCoords(elements,vertices);
1767  }
1768  else {
1769  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1770  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1771  "without specifying an element block.");
1772  }
1773 }
1774 
1775 template <typename ArrayT>
1776 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1777 {
1778  if(!useFieldCoordinates_) {
1779  getElementVertices_FromCoords(elements,vertices);
1780  }
1781  else {
1782  getElementVertices_FromField(elements,eBlock,vertices);
1783  }
1784 }
1785 
1786 template <typename ArrayT>
1787 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1788 {
1789  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1790 
1791  // convert to a vector of entity objects
1792  std::vector<stk::mesh::Entity> selected_elements;
1793  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1794  selected_elements.push_back(elements[localElementIds[cell]]);
1795 
1796  if(!useFieldCoordinates_) {
1797  getElementVertices_FromCoords(selected_elements,vertices);
1798  }
1799  else {
1800  getElementVertices_FromField(selected_elements,eBlock,vertices);
1801  }
1802 }
1803 
1804 template <typename ArrayT>
1805 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1806 {
1807  if(!useFieldCoordinates_) {
1808  //
1809  // gather from the intrinsic mesh coordinates (non-lagrangian)
1810  //
1811 
1812  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1813 
1814  // convert to a vector of entity objects
1815  std::vector<stk::mesh::Entity> selected_elements;
1816  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1817  selected_elements.push_back(elements[localElementIds[cell]]);
1818 
1819  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1820  }
1821  else {
1822  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1823  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1824  "without specifying an element block.");
1825  }
1826 }
1827 
1828 template <typename ArrayT>
1829 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1830 {
1831  if(!useFieldCoordinates_) {
1832  getElementVertices_FromCoordsNoResize(elements,vertices);
1833  }
1834  else {
1835  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1836  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1837  "without specifying an element block.");
1838  }
1839 }
1840 
1841 template <typename ArrayT>
1842 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1843 {
1844  if(!useFieldCoordinates_) {
1845  getElementVertices_FromCoordsNoResize(elements,vertices);
1846  }
1847  else {
1848  getElementVertices_FromFieldNoResize(elements,eBlock,vertices);
1849  }
1850 }
1851 
1852 template <typename ArrayT>
1853 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1854 {
1855  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1856 
1857  // convert to a vector of entity objects
1858  std::vector<stk::mesh::Entity> selected_elements;
1859  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1860  selected_elements.push_back(elements[localElementIds[cell]]);
1861 
1862  if(!useFieldCoordinates_) {
1863  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1864  }
1865  else {
1866  getElementVertices_FromFieldNoResize(selected_elements,eBlock,vertices);
1867  }
1868 }
1869 
1870 template <typename ArrayT>
1871 void STK_Interface::getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1872 {
1873  // nothing to do! silently return
1874  if(elements.size() == 0) {
1875  vertices = Kokkos::createDynRankView(vertices, "vertices", 0, 0, 0);
1876  return;
1877  }
1878 
1879  //
1880  // gather from the intrinsic mesh coordinates (non-lagrangian)
1881  //
1882 
1883  // get *master* cell toplogy...(belongs to first element)
1884  const auto masterVertexCount
1885  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1886 
1887  // allocate space
1888  vertices = Kokkos::createDynRankView(vertices, "vertices", elements.size(), masterVertexCount,getDimension());
1889  auto vertices_h = Kokkos::create_mirror_view(vertices);
1890  Kokkos::deep_copy(vertices_h, vertices);
1891 
1892  // loop over each requested element
1893  const auto dim = getDimension();
1894  for(std::size_t cell = 0; cell < elements.size(); cell++) {
1895  const auto element = elements[cell];
1896  TEUCHOS_ASSERT(element != 0);
1897 
1898  const auto vertexCount
1899  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1900  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount != masterVertexCount, std::runtime_error,
1901  "In call to STK_Interface::getElementVertices all elements "
1902  "must have the same vertex count!");
1903 
1904  // loop over all element nodes
1905  const size_t num_nodes = bulkData_->num_nodes(element);
1906  auto const* nodes = bulkData_->begin_nodes(element);
1907  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1908  "In call to STK_Interface::getElementVertices cardinality of "
1909  "element node relations must be the vertex count!");
1910  for(std::size_t node = 0; node < num_nodes; ++node) {
1911  const double * coord = getNodeCoordinates(nodes[node]);
1912 
1913  // set each dimension of the coordinate
1914  for(unsigned d=0;d<dim;d++)
1915  vertices_h(cell,node,d) = coord[d];
1916  }
1917  }
1918  Kokkos::deep_copy(vertices, vertices_h);
1919 }
1920 
1921 template <typename ArrayT>
1922 void STK_Interface::getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1923 {
1924  // nothing to do! silently return
1925  if(elements.size()==0) {
1926  return;
1927  }
1928 
1929  //
1930  // gather from the intrinsic mesh coordinates (non-lagrangian)
1931  //
1932 
1933  // get *master* cell toplogy...(belongs to first element)
1934  unsigned masterVertexCount
1935  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1936 
1937  // loop over each requested element
1938  unsigned dim = getDimension();
1939  auto vertices_h = Kokkos::create_mirror_view(vertices);
1940  for(std::size_t cell=0;cell<elements.size();cell++) {
1941  stk::mesh::Entity element = elements[cell];
1942  TEUCHOS_ASSERT(element!=0);
1943 
1944  unsigned vertexCount
1945  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1946  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount!=masterVertexCount,std::runtime_error,
1947  "In call to STK_Interface::getElementVertices all elements "
1948  "must have the same vertex count!");
1949 
1950  // loop over all element nodes
1951  const size_t num_nodes = bulkData_->num_nodes(element);
1952  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1953  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1954  "In call to STK_Interface::getElementVertices cardinality of "
1955  "element node relations must be the vertex count!");
1956  for(std::size_t node=0; node<num_nodes; ++node) {
1957  const double * coord = getNodeCoordinates(nodes[node]);
1958 
1959  // set each dimension of the coordinate
1960  for(unsigned d=0;d<dim;d++)
1961  vertices_h(cell,node,d) = coord[d];
1962  }
1963  }
1964  Kokkos::deep_copy(vertices, vertices_h);
1965 }
1966 
1967 template <typename ArrayT>
1968 void STK_Interface::getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1969 {
1971 
1972  // nothing to do! silently return
1973  if(elements.size()==0) {
1974  vertices = Kokkos::createDynRankView(vertices,"vertices",0,0,0);
1975  return;
1976  }
1977 
1978  // get *master* cell toplogy...(belongs to first element)
1979  unsigned masterVertexCount
1980  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1981 
1982  // allocate space
1983  vertices = Kokkos::createDynRankView(vertices,"vertices",elements.size(),masterVertexCount,getDimension());
1984  auto vertices_h = Kokkos::create_mirror_view(vertices);
1985  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
1986  if(itr==meshCoordFields_.end()) {
1987  // no coordinate field set for this element block
1988  TEUCHOS_ASSERT(false);
1989  }
1990 
1991  const std::vector<std::string> & coordField = itr->second;
1992  std::vector<SolutionFieldType*> fields(getDimension());
1993  for(std::size_t d=0;d<fields.size();d++) {
1994  fields[d] = this->getSolutionField(coordField[d],eBlock);
1995  }
1996 
1997  for(std::size_t cell=0;cell<elements.size();cell++) {
1998  stk::mesh::Entity element = elements[cell];
1999 
2000  // loop over nodes set solution values
2001  const size_t num_nodes = bulkData_->num_nodes(element);
2002  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
2003  for(std::size_t i=0; i<num_nodes; ++i) {
2004  stk::mesh::Entity node = nodes[i];
2005 
2006  const double * coord = getNodeCoordinates(node);
2007 
2008  for(unsigned d=0;d<getDimension();d++) {
2009  double * solnData = stk::mesh::field_data(*fields[d],node);
2010 
2011  // recall mesh field coordinates are stored as displacements
2012  // from the mesh coordinates, make sure to add them together
2013  vertices_h(cell,i,d) = solnData[0]+coord[d];
2014  }
2015  }
2016  }
2017  Kokkos::deep_copy(vertices, vertices_h);
2018 }
2019 
2020 template <typename ArrayT>
2021 void STK_Interface::getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
2022  const std::string & eBlock, ArrayT & vertices) const
2023 {
2025 
2026  // nothing to do! silently return
2027  if(elements.size()==0) {
2028  return;
2029  }
2030 
2031  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2032  if(itr==meshCoordFields_.end()) {
2033  // no coordinate field set for this element block
2034  TEUCHOS_ASSERT(false);
2035  }
2036 
2037  const std::vector<std::string> & coordField = itr->second;
2038  std::vector<SolutionFieldType*> fields(getDimension());
2039  for(std::size_t d=0;d<fields.size();d++) {
2040  fields[d] = this->getSolutionField(coordField[d],eBlock);
2041  }
2042 
2043  for(std::size_t cell=0;cell<elements.size();cell++) {
2044  stk::mesh::Entity element = elements[cell];
2045 
2046  // loop over nodes set solution values
2047  const size_t num_nodes = bulkData_->num_nodes(element);
2048  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
2049  for(std::size_t i=0; i<num_nodes; ++i) {
2050  stk::mesh::Entity node = nodes[i];
2051 
2052  const double * coord = getNodeCoordinates(node);
2053 
2054  for(unsigned d=0;d<getDimension();d++) {
2055  double * solnData = stk::mesh::field_data(*fields[d],node);
2056 
2057  // recall mesh field coordinates are stored as displacements
2058  // from the mesh coordinates, make sure to add them together
2059  vertices(cell,i,d) = solnData[0]+coord[d];
2060  }
2061  }
2062  }
2063 }
2064 
2066 
2067 template <typename ArrayT>
2068 void STK_Interface::getElementNodes(const std::vector<std::size_t> & localElementIds, ArrayT & nodes) const
2069 {
2070  if(!useFieldCoordinates_) {
2071  //
2072  // gather from the intrinsic mesh coordinates (non-lagrangian)
2073  //
2074 
2075  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2076 
2077  // convert to a vector of entity objects
2078  std::vector<stk::mesh::Entity> selected_elements;
2079  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2080  selected_elements.push_back(elements[localElementIds[cell]]);
2081 
2082  getElementNodes_FromCoords(selected_elements,nodes);
2083  }
2084  else {
2085  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2086  "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2087  "without specifying an element block.");
2088  }
2089 }
2090 
2091 template <typename ArrayT>
2092 void STK_Interface::getElementNodes(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2093 {
2094  if(!useFieldCoordinates_) {
2095  getElementNodes_FromCoords(elements,nodes);
2096  }
2097  else {
2098  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2099  "STK_Interface::getElementNodes: Cannot call this method when field coordinates are used "
2100  "without specifying an element block.");
2101  }
2102 }
2103 
2104 template <typename ArrayT>
2105 void STK_Interface::getElementNodes(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2106 {
2107  if(!useFieldCoordinates_) {
2108  getElementNodes_FromCoords(elements,nodes);
2109  }
2110  else {
2111  getElementNodes_FromField(elements,eBlock,nodes);
2112  }
2113 }
2114 
2115 template <typename ArrayT>
2116 void STK_Interface::getElementNodes(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & nodes) const
2117 {
2118  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2119 
2120  // convert to a vector of entity objects
2121  std::vector<stk::mesh::Entity> selected_elements;
2122  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2123  selected_elements.push_back(elements[localElementIds[cell]]);
2124 
2125  if(!useFieldCoordinates_) {
2126  getElementNodes_FromCoords(selected_elements,nodes);
2127  }
2128  else {
2129  getElementNodes_FromField(selected_elements,eBlock,nodes);
2130  }
2131 }
2132 
2133 template <typename ArrayT>
2134 void STK_Interface::getElementNodesNoResize(const std::vector<std::size_t> & localElementIds, ArrayT & nodes) const
2135 {
2136  if(!useFieldCoordinates_) {
2137  //
2138  // gather from the intrinsic mesh coordinates (non-lagrangian)
2139  //
2140 
2141  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2142 
2143  // convert to a vector of entity objects
2144  std::vector<stk::mesh::Entity> selected_elements;
2145  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2146  selected_elements.push_back(elements[localElementIds[cell]]);
2147 
2148  getElementNodes_FromCoordsNoResize(selected_elements,nodes);
2149  }
2150  else {
2151  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2152  "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2153  "without specifying an element block.");
2154  }
2155 }
2156 
2157 template <typename ArrayT>
2158 void STK_Interface::getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2159 {
2160  if(!useFieldCoordinates_) {
2161  getElementNodes_FromCoordsNoResize(elements,nodes);
2162  }
2163  else {
2164  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
2165  "STK_Interface::getElementNodesNoResize: Cannot call this method when field coordinates are used "
2166  "without specifying an element block.");
2167  }
2168 }
2169 
2170 template <typename ArrayT>
2171 void STK_Interface::getElementNodesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2172 {
2173  if(!useFieldCoordinates_) {
2174  getElementNodes_FromCoordsNoResize(elements,nodes);
2175  }
2176  else {
2177  getElementNodes_FromFieldNoResize(elements,eBlock,nodes);
2178  }
2179 }
2180 
2181 template <typename ArrayT>
2182 void STK_Interface::getElementNodesNoResize(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & nodes) const
2183 {
2184  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
2185 
2186  // convert to a vector of entity objects
2187  std::vector<stk::mesh::Entity> selected_elements;
2188  for(std::size_t cell=0;cell<localElementIds.size();cell++)
2189  selected_elements.push_back(elements[localElementIds[cell]]);
2190 
2191  if(!useFieldCoordinates_) {
2192  getElementNodes_FromCoordsNoResize(selected_elements,nodes);
2193  }
2194  else {
2195  getElementNodes_FromFieldNoResize(selected_elements,eBlock,nodes);
2196  }
2197 }
2198 
2199 template <typename ArrayT>
2200 void STK_Interface::getElementNodes_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2201 {
2202  // nothing to do! silently return
2203  if(elements.size() == 0) {
2204  nodes = Kokkos::createDynRankView(nodes, "nodes", 0, 0, 0);
2205  return;
2206  }
2207 
2208  //
2209  // gather from the intrinsic mesh coordinates (non-lagrangian)
2210  //
2211 
2212  // get *master* cell toplogy...(belongs to first element)
2213  const auto masterNodeCount
2214  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2215 
2216  // allocate space
2217  nodes = Kokkos::createDynRankView(nodes, "nodes", elements.size(), masterNodeCount,getDimension());
2218  auto nodes_h = Kokkos::create_mirror_view(nodes);
2219  Kokkos::deep_copy(nodes_h, nodes);
2220 
2221  // loop over each requested element
2222  const auto dim = getDimension();
2223  for(std::size_t cell = 0; cell < elements.size(); cell++) {
2224  const auto element = elements[cell];
2225  TEUCHOS_ASSERT(element != 0);
2226 
2227  const auto nodeCount
2228  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2229  TEUCHOS_TEST_FOR_EXCEPTION(nodeCount != masterNodeCount, std::runtime_error,
2230  "In call to STK_Interface::getElementNodes all elements "
2231  "must have the same node count!");
2232 
2233  // loop over all element nodes
2234  const size_t num_nodes = bulkData_->num_nodes(element);
2235  auto const* elem_nodes = bulkData_->begin_nodes(element);
2236  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterNodeCount,std::runtime_error,
2237  "In call to STK_Interface::getElementNodes cardinality of "
2238  "element node relations must be the node count!");
2239  for(std::size_t node = 0; node < num_nodes; ++node) {
2240  const double * coord = getNodeCoordinates(elem_nodes[node]);
2241 
2242  // set each dimension of the coordinate
2243  for(unsigned d=0;d<dim;d++)
2244  nodes_h(cell,node,d) = coord[d];
2245  }
2246  }
2247  Kokkos::deep_copy(nodes, nodes_h);
2248 }
2249 
2250 template <typename ArrayT>
2251 void STK_Interface::getElementNodes_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & nodes) const
2252 {
2253  // nothing to do! silently return
2254  if(elements.size()==0) {
2255  return;
2256  }
2257 
2258  //
2259  // gather from the intrinsic mesh coordinates (non-lagrangian)
2260  //
2261 
2262  // get *master* cell toplogy...(belongs to first element)
2263  unsigned masterNodeCount
2264  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2265 
2266  // loop over each requested element
2267  unsigned dim = getDimension();
2268  auto nodes_h = Kokkos::create_mirror_view(nodes);
2269  for(std::size_t cell=0;cell<elements.size();cell++) {
2270  stk::mesh::Entity element = elements[cell];
2271  TEUCHOS_ASSERT(element!=0);
2272 
2273  unsigned nodeCount
2274  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->node_count;
2275  TEUCHOS_TEST_FOR_EXCEPTION(nodeCount!=masterNodeCount,std::runtime_error,
2276  "In call to STK_Interface::getElementNodes all elements "
2277  "must have the same node count!");
2278 
2279  // loop over all element nodes
2280  const size_t num_nodes = bulkData_->num_nodes(element);
2281  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2282  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterNodeCount,std::runtime_error,
2283  "In call to STK_Interface::getElementNodes cardinality of "
2284  "element node relations must be the node count!");
2285  for(std::size_t node=0; node<num_nodes; ++node) {
2286  const double * coord = getNodeCoordinates(elem_nodes[node]);
2287 
2288  // set each dimension of the coordinate
2289  for(unsigned d=0;d<dim;d++)
2290  nodes_h(cell,node,d) = coord[d];
2291  }
2292  }
2293  Kokkos::deep_copy(nodes, nodes_h);
2294 }
2295 
2296 template <typename ArrayT>
2297 void STK_Interface::getElementNodes_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & nodes) const
2298 {
2300 
2301  // nothing to do! silently return
2302  if(elements.size()==0) {
2303  nodes = Kokkos::createDynRankView(nodes,"nodes",0,0,0);
2304  return;
2305  }
2306 
2307  // get *master* cell toplogy...(belongs to first element)
2308  unsigned masterNodeCount
2309  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->node_count;
2310 
2311  // allocate space
2312  nodes = Kokkos::createDynRankView(nodes,"nodes",elements.size(),masterNodeCount,getDimension());
2313  auto nodes_h = Kokkos::create_mirror_view(nodes);
2314  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2315  if(itr==meshCoordFields_.end()) {
2316  // no coordinate field set for this element block
2317  TEUCHOS_ASSERT(false);
2318  }
2319 
2320  const std::vector<std::string> & coordField = itr->second;
2321  std::vector<SolutionFieldType*> fields(getDimension());
2322  for(std::size_t d=0;d<fields.size();d++) {
2323  fields[d] = this->getSolutionField(coordField[d],eBlock);
2324  }
2325 
2326  // loop over elements
2327  for(std::size_t cell=0;cell<elements.size();cell++) {
2328  stk::mesh::Entity element = elements[cell];
2329 
2330  // loop over nodes set solution values
2331  const size_t num_nodes = bulkData_->num_nodes(element);
2332  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2333  for(std::size_t i=0; i<num_nodes; ++i) {
2334  stk::mesh::Entity node = elem_nodes[i];
2335 
2336  const double * coord = getNodeCoordinates(node);
2337 
2338  for(unsigned d=0;d<getDimension();d++) {
2339  double * solnData = stk::mesh::field_data(*fields[d],node);
2340 
2341  // recall mesh field coordinates are stored as displacements
2342  // from the mesh coordinates, make sure to add them together
2343  nodes_h(cell,i,d) = solnData[0]+coord[d];
2344  }
2345  }
2346  }
2347  Kokkos::deep_copy(nodes, nodes_h);
2348 }
2349 
2350 template <typename ArrayT>
2351 void STK_Interface::getElementNodes_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
2352  const std::string & eBlock, ArrayT & nodes) const
2353 {
2355 
2356  // nothing to do! silently return
2357  if(elements.size()==0) {
2358  return;
2359  }
2360 
2361  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
2362  if(itr==meshCoordFields_.end()) {
2363  // no coordinate field set for this element block
2364  TEUCHOS_ASSERT(false);
2365  }
2366 
2367  const std::vector<std::string> & coordField = itr->second;
2368  std::vector<SolutionFieldType*> fields(getDimension());
2369  for(std::size_t d=0;d<fields.size();d++) {
2370  fields[d] = this->getSolutionField(coordField[d],eBlock);
2371  }
2372 
2373  // loop over elements
2374  for(std::size_t cell=0;cell<elements.size();cell++) {
2375  stk::mesh::Entity element = elements[cell];
2376 
2377  // loop over nodes set solution values
2378  const size_t num_nodes = bulkData_->num_nodes(element);
2379  stk::mesh::Entity const* elem_nodes = bulkData_->begin_nodes(element);
2380  for(std::size_t i=0; i<num_nodes; ++i) {
2381  stk::mesh::Entity node = elem_nodes[i];
2382 
2383  const double * coord = getNodeCoordinates(node);
2384 
2385  for(unsigned d=0;d<getDimension();d++) {
2386  double * solnData = stk::mesh::field_data(*fields[d],node);
2387 
2388  // recall mesh field coordinates are stored as displacements
2389  // from the mesh coordinates, make sure to add them together
2390  nodes(cell,i,d) = solnData[0]+coord[d];
2391  }
2392  }
2393  }
2394 }
2395 
2396 }
2397 
2398 #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_