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 #include <stk_mesh/base/MetaData.hpp>
55 #include <stk_mesh/base/CoordinateSystems.hpp>
56 
57 #include "Kokkos_Core.hpp"
58 
59 #include <Shards_CellTopology.hpp>
60 #include <Shards_CellTopologyData.h>
61 
62 #include <PanzerAdaptersSTK_config.hpp>
63 #include <Kokkos_ViewFactory.hpp>
64 
65 #include <unordered_map>
66 
67 #ifdef PANZER_HAVE_IOSS
68 #include <stk_io/StkMeshIoBroker.hpp>
69 #endif
70 
71 #ifdef PANZER_HAVE_PERCEPT
72 namespace percept {
73  class PerceptMesh;
74  class URP_Heterogeneous_3D;
75 }
76 #endif
77 
78 namespace panzer_stk {
79 
80 class PeriodicBC_MatcherBase;
81 
86 public:
87  ElementDescriptor(stk::mesh::EntityId gid,const std::vector<stk::mesh::EntityId> & nodes);
88  virtual ~ElementDescriptor();
89 
90  stk::mesh::EntityId getGID() const { return gid_; }
91  const std::vector<stk::mesh::EntityId> & getNodes() const { return nodes_; }
92 protected:
93  stk::mesh::EntityId gid_;
94  std::vector<stk::mesh::EntityId> nodes_;
95 
97 };
98 
102 buildElementDescriptor(stk::mesh::EntityId elmtId,std::vector<stk::mesh::EntityId> & nodes);
103 
105 public:
106  typedef double ProcIdData; // ECC: Not sure why?
107  typedef stk::mesh::Field<double> SolutionFieldType;
108  typedef stk::mesh::Field<double,stk::mesh::Cartesian> VectorFieldType;
109  typedef stk::mesh::Field<ProcIdData> ProcIdFieldType;
110 
111  // some simple exception classes
112  struct ElementBlockException : public std::logic_error
113  { ElementBlockException(const std::string & what) : std::logic_error(what) {} };
114 
115  struct SidesetException : public std::logic_error
116  { SidesetException(const std::string & what) : std::logic_error(what) {} };
117 
118  STK_Interface();
119 
122  STK_Interface(unsigned dim);
123 
125 
126  // functions called before initialize
128 
131  void addElementBlock(const std::string & name,const CellTopologyData * ctData);
132 
135  void addSideset(const std::string & name,const CellTopologyData * ctData);
136 
139  void addNodeset(const std::string & name);
140 
143  void addSolutionField(const std::string & fieldName,const std::string & blockId);
144 
147  void addCellField(const std::string & fieldName,const std::string & blockId);
148 
157  void addMeshCoordFields(const std::string & blockId,
158  const std::vector<std::string> & coordField,
159  const std::string & dispPrefix);
160 
162 
174  void initialize(stk::ParallelMachine parallelMach,bool setupIO=true,
175  const bool buildRefinementSupport = false);
176 
182  void instantiateBulkData(stk::ParallelMachine parallelMach);
183 
184  // functions to manage and manipulate bulk data
186 
189  void beginModification();
190 
193  void endModification();
194 
200  void addNode(stk::mesh::EntityId gid, const std::vector<double> & coord);
201 
202  void addElement(const Teuchos::RCP<ElementDescriptor> & ed,stk::mesh::Part * block);
203 
204  void addEdges();
205 
206  void addFaces();
207 
210  void addEntityToSideset(stk::mesh::Entity entity,stk::mesh::Part * sideset);
211 
214  void addEntityToNodeset(stk::mesh::Entity entity,stk::mesh::Part * nodeset);
215 
216  // Methods to interrogate the mesh topology and structure
218 
222  { return *coordinatesField_; }
223 
227  { return *edgesField_; }
228 
230  { return *facesField_; }
231 
234  const double * getNodeCoordinates(stk::mesh::EntityId nodeId) const;
235 
238  const double * getNodeCoordinates(stk::mesh::Entity node) const;
239 
242  void getSubcellIndices(unsigned entityRank,stk::mesh::EntityId elementId,
243  std::vector<stk::mesh::EntityId> & subcellIds) const;
244 
247  void getMyElements(std::vector<stk::mesh::Entity> & elements) const;
248 
251  void getMyElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
252 
256  void getNeighborElements(std::vector<stk::mesh::Entity> & elements) const;
257 
260  void getNeighborElements(const std::string & blockID,std::vector<stk::mesh::Entity> & elements) const;
261 
269  void getMySides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
270 
279  void getMySides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
280 
288  void getAllSides(const std::string & sideName,std::vector<stk::mesh::Entity> & sides) const;
289 
299  void getAllSides(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & sides) const;
300 
310  void getMyNodes(const std::string & sideName,const std::string & blockName,std::vector<stk::mesh::Entity> & nodes) const;
311 
320  stk::mesh::Entity findConnectivityById(stk::mesh::Entity src, stk::mesh::EntityRank tgt_rank, unsigned rel_id) const;
321 
322  // Utility functions
324 
332  void
334  const std::string& filename);
335 
350  void
352  const std::string& filename);
353 
366  void
368  double timestep);
369 
389  void
391  const std::string& key,
392  const int& value);
393 
413  void
415  const std::string& key,
416  const double& value);
417 
437  void
439  const std::string& key,
440  const std::vector<int>& value);
441 
461  void
463  const std::string& key,
464  const std::vector<double>& value);
465 
466  // Accessor functions
468 
471 
474 
475  bool isWritable() const;
476 
477  bool isModifiable() const
478  { if(bulkData_==Teuchos::null) return false;
479  return bulkData_->in_modifiable_state(); }
480 
482  unsigned getDimension() const
483  { return dimension_; }
484 
486  std::size_t getNumElementBlocks() const
487  { return elementBlocks_.size(); }
488 
496  void getElementBlockNames(std::vector<std::string> & names) const;
497 
505  void getSidesetNames(std::vector<std::string> & name) const;
506 
514  void getNodesetNames(std::vector<std::string> & name) const;
515 
517  stk::mesh::Part * getOwnedPart() const
518  { return &getMetaData()->locally_owned_part(); } // I don't like the pointer access here, but it will do for now!
519 
521  stk::mesh::Part * getElementBlockPart(const std::string & name) const
522  {
523  std::map<std::string, stk::mesh::Part*>::const_iterator itr = elementBlocks_.find(name); // Element blocks
524  if(itr==elementBlocks_.end()) return 0;
525  return itr->second;
526  }
527 
529  std::size_t getNumSidesets() const
530  { return sidesets_.size(); }
531 
532  stk::mesh::Part * getSideset(const std::string & name) const
533  { return sidesets_.find(name)->second; }
534 
536  std::size_t getNumNodesets() const
537  { return nodesets_.size(); }
538 
539  stk::mesh::Part * getNodeset(const std::string & name) const
540  { return nodesets_.find(name)->second; }
541 
543  std::size_t getEntityCounts(unsigned entityRank) const;
544 
546  stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const;
547 
548  // Utilities
550 
552  void getElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements) const;
553 
555  void getNodeIdsForElement(stk::mesh::Entity element,std::vector<stk::mesh::EntityId> & nodeIds) const;
556 
559  void getOwnedElementsSharingNode(stk::mesh::Entity node,std::vector<stk::mesh::Entity> & elements,
560  std::vector<int> & relIds) const;
561 
564  void getOwnedElementsSharingNode(stk::mesh::EntityId nodeId,std::vector<stk::mesh::Entity> & elements,
565  std::vector<int> & relIds, unsigned int matchType) const;
566 
567 
569  void getElementsSharingNodes(const std::vector<stk::mesh::EntityId> nodeId,std::vector<stk::mesh::Entity> & elements) const;
570 
572  void buildSubcells();
573 
576  std::size_t elementLocalId(stk::mesh::Entity elmt) const;
577 
580  std::size_t elementLocalId(stk::mesh::EntityId gid) const;
581 
584  inline stk::mesh::EntityId elementGlobalId(std::size_t lid) const
585  { return bulkData_->identifier((*orderedElementVector_)[lid]); }
586 
589  inline stk::mesh::EntityId elementGlobalId(stk::mesh::Entity elmt) const
590  { return bulkData_->identifier(elmt); }
591 
594  inline unsigned entityOwnerRank(stk::mesh::Entity entity) const
595  { return bulkData_->parallel_owner_rank(entity); }
596 
599  inline bool isValid(stk::mesh::Entity entity) const
600  { return bulkData_->is_valid(entity); }
601 
604  std::string containingBlockId(stk::mesh::Entity elmt) const;
605 
610  stk::mesh::Field<double> * getSolutionField(const std::string & fieldName,
611  const std::string & blockId) const;
612 
617  stk::mesh::Field<double> * getCellField(const std::string & fieldName,
618  const std::string & blockId) const;
619 
621 
623  bool isInitialized() const { return initialized_; }
624 
629 
644  template <typename ArrayT>
645  void setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
646  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
647 
662  template <typename ArrayT>
663  void getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
664  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const;
665 
680  template <typename ArrayT>
681  void setCellFieldData(const std::string & fieldName,const std::string & blockId,
682  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue=1.0);
683 
692  template <typename ArrayT>
693  void getElementVertices(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
694 
703  template <typename ArrayT>
704  void getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
705 
715  template <typename ArrayT>
716  void getElementVertices(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
717 
727  template <typename ArrayT>
728  void getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
729 
738  template <typename ArrayT>
739  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds, ArrayT & vertices) const;
740 
749  template <typename ArrayT>
750  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
751 
761  template <typename ArrayT>
762  void getElementVerticesNoResize(const std::vector<std::size_t> & localIds,const std::string & eBlock, ArrayT & vertices) const;
763 
773  template <typename ArrayT>
774  void getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
775 
776  // const stk::mesh::FEMInterface & getFEMInterface() const
777  // { return *femPtr_; }
778 
779  stk::mesh::EntityRank getElementRank() const { return stk::topology::ELEMENT_RANK; }
780  stk::mesh::EntityRank getSideRank() const { return metaData_->side_rank(); }
781  stk::mesh::EntityRank getFaceRank() const { return stk::topology::FACE_RANK; }
782  stk::mesh::EntityRank getEdgeRank() const { return stk::topology::EDGE_RANK; }
783  stk::mesh::EntityRank getNodeRank() const { return stk::topology::NODE_RANK; }
784 
787  void initializeFromMetaData();
788 
791  void buildLocalElementIDs();
792 
795  const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
797  { return periodicBCs_; }
798 
801  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
803  { return periodicBCs_; }
804 
811  { periodicBCs_.push_back(bc); }
812 
819  { periodicBCs_.insert(periodicBCs_.end(),bc_vec.begin(),bc_vec.end()); }
820 
821  std::pair<Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >, Teuchos::RCP<std::vector<unsigned int> > >
822  getPeriodicNodePairing() const;
823 
826  bool validBlockId(const std::string & blockId) const;
827 
830  void print(std::ostream & os) const;
831 
834  void printMetaData(std::ostream & os) const;
835 
838  Teuchos::RCP<const shards::CellTopology> getCellTopology(const std::string & eBlock) const;
839 
844  double getCurrentStateTime() const { return currentStateTime_; }
845 
851  double getInitialStateTime() const { return initialStateTime_; }
852 
857  void setInitialStateTime(double value) { initialStateTime_ = value; }
858 
861  void rebalance(const Teuchos::ParameterList & params);
862 
866  void setBlockWeight(const std::string & blockId,double weight)
867  { blockWeights_[blockId] = weight; }
868 
875  void setUseFieldCoordinates(bool useFieldCoordinates)
876  { useFieldCoordinates_ = useFieldCoordinates; }
877 
880  { return useFieldCoordinates_; }
881 
883  void setUseLowerCaseForIO(bool useLowerCase)
884  { useLowerCase_ = useLowerCase; }
885 
887  bool getUseLowerCaseForIO() const
888  { return useLowerCase_; }
889 
900  template <typename ArrayT>
901  void getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const;
902 
903  template <typename ArrayT>
904  void getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
905  const std::string & eBlock, ArrayT & vertices) const;
906 
916  template <typename ArrayT>
917  void getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
918 
919  template <typename ArrayT>
920  void getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const;
921 
927  void refineMesh(const int numberOfLevels, const bool deleteParentElements);
928 
929 public: // static operations
930  static const std::string coordsString;
931  static const std::string nodesString;
932  static const std::string edgesString;
933  static const std::string facesString;
934 
935 protected:
936 
939  void buildEntityCounts();
940 
943  void buildMaxEntityIds();
944 
948  void initializeFieldsInSTK(const std::map<std::pair<std::string,std::string>,SolutionFieldType*> & nameToField,
949  bool setupIO);
950 
955  Teuchos::RCP<Teuchos::MpiComm<int> > getSafeCommunicator(stk::ParallelMachine parallelMach) const;
956 
963 
967  bool isMeshCoordField(const std::string & eBlock,const std::string & fieldName,int & axis) const;
968 
984  template <typename ArrayT>
985  void setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
986  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues);
987 
988  std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > periodicBCs_;
989 
992 #ifdef PANZER_HAVE_PERCEPT
995 #endif
996 
997  std::map<std::string, stk::mesh::Part*> elementBlocks_; // Element blocks
998  std::map<std::string, stk::mesh::Part*> sidesets_; // Side sets
999  std::map<std::string, stk::mesh::Part*> nodesets_; // Node sets
1000  std::map<std::string, Teuchos::RCP<shards::CellTopology> > elementBlockCT_;
1001 
1002  // for storing/accessing nodes
1003  stk::mesh::Part * nodesPart_;
1004  std::vector<stk::mesh::Part*> nodesPartVec_;
1005  stk::mesh::Part * edgesPart_;
1006  std::vector<stk::mesh::Part*> edgesPartVec_;
1007  stk::mesh::Part * facesPart_;
1008  std::vector<stk::mesh::Part*> facesPartVec_;
1009 
1015 
1016  // maps field names to solution field stk mesh handles
1017  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToSolution_;
1018  std::map<std::pair<std::string,std::string>,SolutionFieldType*> fieldNameToCellField_;
1019 
1020  unsigned dimension_;
1021 
1023 
1024  // how many elements, faces, edges, and nodes are there globally
1025  std::vector<std::size_t> entityCounts_;
1026 
1027  // what is maximum entity ID
1028  std::vector<stk::mesh::EntityId> maxEntityId_;
1029 
1030  unsigned procRank_;
1031  std::size_t currentLocalId_;
1032 
1034 
1035  double initialStateTime_; // the time stamp at the time this object was constructed (default 0.0)
1036  double currentStateTime_; // the time stamp set by the user when writeToExodus is called (default 0.0)
1037 
1038 #ifdef PANZER_HAVE_IOSS
1039  // I/O support
1041  int meshIndex_;
1042 
1047  enum class GlobalVariable
1048  {
1049  ADD,
1050  WRITE
1051  }; // end of enum class GlobalVariable
1052 
1069  void
1070  globalToExodus(
1071  const GlobalVariable& flag);
1072 
1076  Teuchos::ParameterList globalData_;
1077 #endif
1078 
1079  // uses lazy evaluation
1081 
1082  // for element block weights
1083  std::map<std::string,double> blockWeights_;
1084 
1085  std::unordered_map<stk::mesh::EntityId,std::size_t> localIDHash_;
1086 
1087  // Store mesh displacement fields by element block. This map
1088  // goes like this meshCoordFields_[eBlock][axis_index] => coordinate FieldName
1089  // goes like this meshDispFields_[eBlock][axis_index] => displacement FieldName
1090  std::map<std::string,std::vector<std::string> > meshCoordFields_; // coordinate fields written by user
1091  std::map<std::string,std::vector<std::string> > meshDispFields_; // displacement fields, output to exodus
1092 
1094 
1096 
1097  // Object describing how to sort a vector of elements using
1098  // local ID as the key, very short lived object
1100  public:
1101  LocalIdCompare(const STK_Interface * mesh) : mesh_(mesh) {}
1102 
1103  // Compares two stk mesh entities based on local ID
1104  bool operator() (stk::mesh::Entity a,stk::mesh::Entity b)
1105  { return mesh_->elementLocalId(a) < mesh_->elementLocalId(b);}
1106 
1107  private:
1109  };
1110 };
1111 
1112 template <typename ArrayT>
1113 void STK_Interface::setSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1114  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1115 {
1116  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1117 
1118  int field_axis = -1;
1119  if(isMeshCoordField(blockId,fieldName,field_axis)) {
1120  setDispFieldData(fieldName,blockId,field_axis,localElementIds,solutionValues);
1121  return;
1122  }
1123 
1124  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1125 
1126  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1127  std::size_t localId = localElementIds[cell];
1128  stk::mesh::Entity element = elements[localId];
1129 
1130  // loop over nodes set solution values
1131  const size_t num_nodes = bulkData_->num_nodes(element);
1132  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1133  for(std::size_t i=0; i<num_nodes; ++i) {
1134  stk::mesh::Entity node = nodes[i];
1135 
1136  double * solnData = stk::mesh::field_data(*field,node);
1137  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1138  solnData[0] = scaleValue*solutionValues(cell,i);
1139  }
1140  }
1141 }
1142 
1143 template <typename ArrayT>
1144 void STK_Interface::setDispFieldData(const std::string & fieldName,const std::string & blockId,int axis,
1145  const std::vector<std::size_t> & localElementIds,const ArrayT & dispValues)
1146 {
1147  TEUCHOS_ASSERT(axis>=0); // sanity check
1148 
1149  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1150 
1151  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1152  const VectorFieldType & coord_field = this->getCoordinatesField();
1153 
1154  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1155  std::size_t localId = localElementIds[cell];
1156  stk::mesh::Entity element = elements[localId];
1157 
1158  // loop over nodes set solution values
1159  const size_t num_nodes = bulkData_->num_nodes(element);
1160  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1161  for(std::size_t i=0; i<num_nodes; ++i) {
1162  stk::mesh::Entity node = nodes[i];
1163 
1164  double * solnData = stk::mesh::field_data(*field,node);
1165  double * coordData = stk::mesh::field_data(coord_field,node);
1166  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1167  solnData[0] = dispValues(cell,i)-coordData[axis];
1168  }
1169  }
1170 }
1171 
1172 template <typename ArrayT>
1173 void STK_Interface::getSolutionFieldData(const std::string & fieldName,const std::string & blockId,
1174  const std::vector<std::size_t> & localElementIds,ArrayT & solutionValues) const
1175 {
1176  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1177 
1178  solutionValues = Kokkos::createDynRankView(solutionValues,
1179  "solutionValues",
1180  localElementIds.size(),
1181  bulkData_->num_nodes(elements[localElementIds[0]]));
1182 
1183  SolutionFieldType * field = this->getSolutionField(fieldName,blockId);
1184 
1185  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1186  std::size_t localId = localElementIds[cell];
1187  stk::mesh::Entity element = elements[localId];
1188 
1189  // loop over nodes set solution values
1190  const size_t num_nodes = bulkData_->num_nodes(element);
1191  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1192  for(std::size_t i=0; i<num_nodes; ++i) {
1193  stk::mesh::Entity node = nodes[i];
1194 
1195  double * solnData = stk::mesh::field_data(*field,node);
1196  // TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1197  solutionValues(cell,i) = solnData[0];
1198  }
1199  }
1200 }
1201 
1202 template <typename ArrayT>
1203 void STK_Interface::setCellFieldData(const std::string & fieldName,const std::string & blockId,
1204  const std::vector<std::size_t> & localElementIds,const ArrayT & solutionValues,double scaleValue)
1205 {
1206  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1207 
1208  SolutionFieldType * field = this->getCellField(fieldName,blockId);
1209 
1210  for(std::size_t cell=0;cell<localElementIds.size();cell++) {
1211  std::size_t localId = localElementIds[cell];
1212  stk::mesh::Entity element = elements[localId];
1213 
1214  double * solnData = stk::mesh::field_data(*field,element);
1215  TEUCHOS_ASSERT(solnData!=0); // only needed if blockId is not specified
1216  solnData[0] = scaleValue*solutionValues(cell,0);
1217  }
1218 }
1219 
1220 template <typename ArrayT>
1221 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1222 {
1223  if(!useFieldCoordinates_) {
1224  //
1225  // gather from the intrinsic mesh coordinates (non-lagrangian)
1226  //
1227 
1228  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1229 
1230  // convert to a vector of entity objects
1231  std::vector<stk::mesh::Entity> selected_elements;
1232  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1233  selected_elements.push_back(elements[localElementIds[cell]]);
1234 
1235  getElementVertices_FromCoords(selected_elements,vertices);
1236  }
1237  else {
1238  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1239  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1240  "without specifying an element block.");
1241  }
1242 }
1243 
1244 template <typename ArrayT>
1245 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1246 {
1247  if(!useFieldCoordinates_) {
1248  getElementVertices_FromCoords(elements,vertices);
1249  }
1250  else {
1251  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1252  "STK_Interface::getElementVertices: Cannot call this method when field coordinates are used "
1253  "without specifying an element block.");
1254  }
1255 }
1256 
1257 template <typename ArrayT>
1258 void STK_Interface::getElementVertices(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1259 {
1260  if(!useFieldCoordinates_) {
1261  getElementVertices_FromCoords(elements,vertices);
1262  }
1263  else {
1264  getElementVertices_FromField(elements,eBlock,vertices);
1265  }
1266 }
1267 
1268 template <typename ArrayT>
1269 void STK_Interface::getElementVertices(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1270 {
1271  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1272 
1273  // convert to a vector of entity objects
1274  std::vector<stk::mesh::Entity> selected_elements;
1275  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1276  selected_elements.push_back(elements[localElementIds[cell]]);
1277 
1278  if(!useFieldCoordinates_) {
1279  getElementVertices_FromCoords(selected_elements,vertices);
1280  }
1281  else {
1282  getElementVertices_FromField(selected_elements,eBlock,vertices);
1283  }
1284 }
1285 
1286 template <typename ArrayT>
1287 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds, ArrayT & vertices) const
1288 {
1289  if(!useFieldCoordinates_) {
1290  //
1291  // gather from the intrinsic mesh coordinates (non-lagrangian)
1292  //
1293 
1294  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1295 
1296  // convert to a vector of entity objects
1297  std::vector<stk::mesh::Entity> selected_elements;
1298  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1299  selected_elements.push_back(elements[localElementIds[cell]]);
1300 
1301  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1302  }
1303  else {
1304  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1305  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1306  "without specifying an element block.");
1307  }
1308 }
1309 
1310 template <typename ArrayT>
1311 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1312 {
1313  if(!useFieldCoordinates_) {
1314  getElementVertices_FromCoordsNoResize(elements,vertices);
1315  }
1316  else {
1317  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
1318  "STK_Interface::getElementVerticesNoResize: Cannot call this method when field coordinates are used "
1319  "without specifying an element block.");
1320  }
1321 }
1322 
1323 template <typename ArrayT>
1324 void STK_Interface::getElementVerticesNoResize(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1325 {
1326  if(!useFieldCoordinates_) {
1327  getElementVertices_FromCoordsNoResize(elements,vertices);
1328  }
1329  else {
1330  getElementVertices_FromFieldNoResize(elements,eBlock,vertices);
1331  }
1332 }
1333 
1334 template <typename ArrayT>
1335 void STK_Interface::getElementVerticesNoResize(const std::vector<std::size_t> & localElementIds,const std::string & eBlock, ArrayT & vertices) const
1336 {
1337  const std::vector<stk::mesh::Entity> & elements = *(this->getElementsOrderedByLID());
1338 
1339  // convert to a vector of entity objects
1340  std::vector<stk::mesh::Entity> selected_elements;
1341  for(std::size_t cell=0;cell<localElementIds.size();cell++)
1342  selected_elements.push_back(elements[localElementIds[cell]]);
1343 
1344  if(!useFieldCoordinates_) {
1345  getElementVertices_FromCoordsNoResize(selected_elements,vertices);
1346  }
1347  else {
1348  getElementVertices_FromFieldNoResize(selected_elements,eBlock,vertices);
1349  }
1350 }
1351 
1352 template <typename ArrayT>
1353 void STK_Interface::getElementVertices_FromCoords(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1354 {
1355  // nothing to do! silently return
1356  if(elements.size()==0) {
1357  vertices = Kokkos::createDynRankView(vertices,"vertices",0,0,0);
1358  return;
1359  }
1360 
1361  //
1362  // gather from the intrinsic mesh coordinates (non-lagrangian)
1363  //
1364 
1365  // get *master* cell toplogy...(belongs to first element)
1366  unsigned masterVertexCount
1367  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1368 
1369  // allocate space
1370  vertices = Kokkos::createDynRankView(vertices,"vertices",elements.size(),masterVertexCount,getDimension());
1371 
1372  // loop over each requested element
1373  unsigned dim = getDimension();
1374  for(std::size_t cell=0;cell<elements.size();cell++) {
1375  stk::mesh::Entity element = elements[cell];
1376  TEUCHOS_ASSERT(element!=0);
1377 
1378  unsigned vertexCount
1379  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1380  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount!=masterVertexCount,std::runtime_error,
1381  "In call to STK_Interface::getElementVertices all elements "
1382  "must have the same vertex count!");
1383 
1384  // loop over all element nodes
1385  const size_t num_nodes = bulkData_->num_nodes(element);
1386  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1387  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1388  "In call to STK_Interface::getElementVertices cardinality of "
1389  "element node relations must be the vertex count!");
1390  for(std::size_t node=0; node<num_nodes; ++node) {
1391  const double * coord = getNodeCoordinates(nodes[node]);
1392 
1393  // set each dimension of the coordinate
1394  for(unsigned d=0;d<dim;d++)
1395  vertices(cell,node,d) = coord[d];
1396  }
1397  }
1398 }
1399 
1400 template <typename ArrayT>
1401 void STK_Interface::getElementVertices_FromCoordsNoResize(const std::vector<stk::mesh::Entity> & elements, ArrayT & vertices) const
1402 {
1403  // nothing to do! silently return
1404  if(elements.size()==0) {
1405  return;
1406  }
1407 
1408  //
1409  // gather from the intrinsic mesh coordinates (non-lagrangian)
1410  //
1411 
1412  // get *master* cell toplogy...(belongs to first element)
1413  unsigned masterVertexCount
1414  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1415 
1416  // loop over each requested element
1417  unsigned dim = getDimension();
1418  for(std::size_t cell=0;cell<elements.size();cell++) {
1419  stk::mesh::Entity element = elements[cell];
1420  TEUCHOS_ASSERT(element!=0);
1421 
1422  unsigned vertexCount
1423  = stk::mesh::get_cell_topology(bulkData_->bucket(element).topology()).getCellTopologyData()->vertex_count;
1424  TEUCHOS_TEST_FOR_EXCEPTION(vertexCount!=masterVertexCount,std::runtime_error,
1425  "In call to STK_Interface::getElementVertices all elements "
1426  "must have the same vertex count!");
1427 
1428  // loop over all element nodes
1429  const size_t num_nodes = bulkData_->num_nodes(element);
1430  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1431  TEUCHOS_TEST_FOR_EXCEPTION(num_nodes!=masterVertexCount,std::runtime_error,
1432  "In call to STK_Interface::getElementVertices cardinality of "
1433  "element node relations must be the vertex count!");
1434  for(std::size_t node=0; node<num_nodes; ++node) {
1435  const double * coord = getNodeCoordinates(nodes[node]);
1436 
1437  // set each dimension of the coordinate
1438  for(unsigned d=0;d<dim;d++)
1439  vertices(cell,node,d) = coord[d];
1440  }
1441  }
1442 }
1443 
1444 template <typename ArrayT>
1445 void STK_Interface::getElementVertices_FromField(const std::vector<stk::mesh::Entity> & elements,const std::string & eBlock, ArrayT & vertices) const
1446 {
1448 
1449  // nothing to do! silently return
1450  if(elements.size()==0) {
1451  vertices = Kokkos::createDynRankView(vertices,"vertices",0,0,0);
1452  return;
1453  }
1454 
1455  // get *master* cell toplogy...(belongs to first element)
1456  unsigned masterVertexCount
1457  = stk::mesh::get_cell_topology(bulkData_->bucket(elements[0]).topology()).getCellTopologyData()->vertex_count;
1458 
1459  // allocate space
1460  vertices = Kokkos::createDynRankView(vertices,"vertices",elements.size(),masterVertexCount,getDimension());
1461 
1462  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
1463  if(itr==meshCoordFields_.end()) {
1464  // no coordinate field set for this element block
1465  TEUCHOS_ASSERT(false);
1466  }
1467 
1468  const std::vector<std::string> & coordField = itr->second;
1469  std::vector<SolutionFieldType*> fields(getDimension());
1470  for(std::size_t d=0;d<fields.size();d++) {
1471  fields[d] = this->getSolutionField(coordField[d],eBlock);
1472  }
1473 
1474  for(std::size_t cell=0;cell<elements.size();cell++) {
1475  stk::mesh::Entity element = elements[cell];
1476 
1477  // loop over nodes set solution values
1478  const size_t num_nodes = bulkData_->num_nodes(element);
1479  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1480  for(std::size_t i=0; i<num_nodes; ++i) {
1481  stk::mesh::Entity node = nodes[i];
1482 
1483  const double * coord = getNodeCoordinates(node);
1484 
1485  for(unsigned d=0;d<getDimension();d++) {
1486  double * solnData = stk::mesh::field_data(*fields[d],node);
1487 
1488  // recall mesh field coordinates are stored as displacements
1489  // from the mesh coordinates, make sure to add them together
1490  vertices(cell,i,d) = solnData[0]+coord[d];
1491  }
1492  }
1493  }
1494 }
1495 
1496 template <typename ArrayT>
1497 void STK_Interface::getElementVertices_FromFieldNoResize(const std::vector<stk::mesh::Entity> & elements,
1498  const std::string & eBlock, ArrayT & vertices) const
1499 {
1501 
1502  // nothing to do! silently return
1503  if(elements.size()==0) {
1504  return;
1505  }
1506 
1507  std::map<std::string,std::vector<std::string> >::const_iterator itr = meshCoordFields_.find(eBlock);
1508  if(itr==meshCoordFields_.end()) {
1509  // no coordinate field set for this element block
1510  TEUCHOS_ASSERT(false);
1511  }
1512 
1513  const std::vector<std::string> & coordField = itr->second;
1514  std::vector<SolutionFieldType*> fields(getDimension());
1515  for(std::size_t d=0;d<fields.size();d++) {
1516  fields[d] = this->getSolutionField(coordField[d],eBlock);
1517  }
1518 
1519  for(std::size_t cell=0;cell<elements.size();cell++) {
1520  stk::mesh::Entity element = elements[cell];
1521 
1522  // loop over nodes set solution values
1523  const size_t num_nodes = bulkData_->num_nodes(element);
1524  stk::mesh::Entity const* nodes = bulkData_->begin_nodes(element);
1525  for(std::size_t i=0; i<num_nodes; ++i) {
1526  stk::mesh::Entity node = nodes[i];
1527 
1528  const double * coord = getNodeCoordinates(node);
1529 
1530  for(unsigned d=0;d<getDimension();d++) {
1531  double * solnData = stk::mesh::field_data(*fields[d],node);
1532 
1533  // recall mesh field coordinates are stored as displacements
1534  // from the mesh coordinates, make sure to add them together
1535  vertices(cell,i,d) = solnData[0]+coord[d];
1536  }
1537  }
1538  }
1539 }
1540 
1541 }
1542 
1543 #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
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 print(std::ostream &os) const
unsigned entityOwnerRank(stk::mesh::Entity entity) const
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 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 count
std::vector< stk::mesh::Part * > edgesPartVec_
std::map< std::string, double > blockWeights_
#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 getElementVertices(const std::vector< std::size_t > &localIds, ArrayT &vertices) const
void addEntityToSideset(stk::mesh::Entity entity, stk::mesh::Part *sideset)
void getElementVertices_FromCoords(const std::vector< stk::mesh::Entity > &elements, ArrayT &vertices) const
void addSolutionField(const std::string &fieldName, const std::string &blockId)
std::map< std::string, Teuchos::RCP< shards::CellTopology > > elementBlockCT_
stk::mesh::EntityId getMaxEntityId(unsigned entityRank) const
get max entity ID of type entityRank
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
stk::mesh::Field< double > * getSolutionField(const std::string &fieldName, const std::string &blockId) const
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
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
std::size_t elementLocalId(stk::mesh::Entity elmt) 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 setUseFieldCoordinates(bool useFieldCoordinates)
stk::mesh::EntityRank getSideRank() const
void initialize(stk::ParallelMachine parallelMach, bool setupIO=true, const bool buildRefinementSupport=false)
static const std::string coordsString
stk::mesh::Field< double, stk::mesh::Cartesian > VectorFieldType
std::size_t getNumElementBlocks() const
get the block count
Teuchos::RCP< stk::mesh::BulkData > getBulkData() const
void getElementVertices_FromField(const std::vector< stk::mesh::Entity > &elements, const std::string &eBlock, ArrayT &vertices) const
void writeToExodus(const std::string &filename)
Write this mesh and associated fields to the given output file.
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 edgesString
std::string containingBlockId(stk::mesh::Entity elmt) const
stk::mesh::EntityRank getFaceRank() 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 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 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 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)
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
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 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)
void setupExodusFile(const std::string &filename)
Set up an output Exodus file for writing results.
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
#define TEUCHOS_ASSERT(assertion_test)
void getMyElements(std::vector< stk::mesh::Entity > &elements) const
stk::mesh::EntityRank getNodeRank() 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
bool operator()(stk::mesh::Entity a, stk::mesh::Entity b)
stk::mesh::EntityRank getElementRank() 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 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_