Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_UniqueGlobalIndexer_Utilities.cpp
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 #include "PanzerDofMgr_config.hpp"
44 
46 
47 using Teuchos::RCP;
48 
49 namespace panzer {
50 namespace orientation_helpers {
51 
52 void computePatternEdgeIndices(const FieldPattern & pattern,std::vector<std::pair<int,int> > & edgeIndices)
53 {
54  unsigned dim = 1;
55  shards::CellTopology cellTopo = pattern.getCellTopology();
56  for(unsigned e=0;e<cellTopo.getEdgeCount();e++) {
57  // get local vertex ids for a this edge
58  unsigned local_v0 = cellTopo.getNodeMap(dim,e,0);
59  unsigned local_v1 = cellTopo.getNodeMap(dim,e,1);
60 
61  // get sub cell indices for geometric pattern
62  const std::vector<int> & v0_indices = pattern.getSubcellIndices(0,local_v0);
63  const std::vector<int> & v1_indices = pattern.getSubcellIndices(0,local_v1);
64 
65  TEUCHOS_ASSERT(v0_indices.size()>0); // there must be a node
66  TEUCHOS_ASSERT(v1_indices.size()>0); // there must be a node
67 
68  // take the first index on each vertex and make a edge lookup
69  edgeIndices.push_back(std::make_pair(v0_indices[0],v1_indices[0]));
70  }
71 }
72 
73 void computePatternFaceIndices(const FieldPattern & pattern,std::vector<std::vector<int> > & faceIndices)
74 {
75  // this only works for 3D field patterns
76  // TEUCHOS_ASSERT(pattern.getDimension()==3);
77  //
78  unsigned node_dim = 0; // by assumption
79  unsigned subcell_dim = 2;
80 
81  if(pattern.getDimension()==3) {
82  shards::CellTopology cellTopo = pattern.getCellTopology();
83 
84  faceIndices.resize(cellTopo.getSubcellCount(subcell_dim));
85 
86  for(unsigned f=0;f<cellTopo.getSubcellCount(subcell_dim);f++) {
87  shards::CellTopology faceTopo(cellTopo.getBaseCellTopologyData(subcell_dim,f));
88 
89  for(unsigned v=0;v<faceTopo.getNodeCount();v++) {
90  // get local vertex ids for a this edge
91  unsigned local_v = cellTopo.getNodeMap(subcell_dim,f,v);
92 
93  // get sub cell indices for geometric pattern
94  const std::vector<int> & v_indices = pattern.getSubcellIndices(node_dim,local_v);
95 
96  TEUCHOS_ASSERT(v_indices.size()>0); // there must be a node
97 
98  // take the first index on each vertex and make a edge lookup
99  faceIndices[f].push_back(v_indices[0]);
100  }
101  }
102  }
103  else if(pattern.getDimension()==2) {
104  shards::CellTopology cellTopo = pattern.getCellTopology();
105 
106  faceIndices.resize(1);
107 
108  for(unsigned v=0;v<cellTopo.getNodeCount();v++)
109  faceIndices[0].push_back(v);
110  }
111 }
112 
113 } // end orientation_helpers
114 } // end panzer
virtual int getDimension() const =0
void computePatternFaceIndices(const FieldPattern &pattern, std::vector< std::vector< int > > &faceIndices)
virtual shards::CellTopology getCellTopology() const =0
virtual const std::vector< int > & getSubcellIndices(int dim, int cellIndex) const =0
#define TEUCHOS_ASSERT(assertion_test)
void computePatternEdgeIndices(const FieldPattern &pattern, std::vector< std::pair< int, int > > &edgeIndices)