Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_IntrepidOrientation.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_IntrepidOrientation_hpp__
44 #define __Panzer_IntrepidOrientation_hpp__
45 
46 #include "Intrepid2_Orientation.hpp"
47 
48 #include "PanzerDiscFE_config.hpp"
49 #include "Panzer_ConnManager.hpp"
52 
53 namespace panzer {
54 
55  template <typename LocalOrdinal,typename GlobalOrdinal>
56  void
57  buildIntrepidOrientation(std::vector<Intrepid2::Orientation> & orientation,
59  //const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LocalOrdinal,GlobalOrdinal> > globalIndexer) {
60  using Teuchos::rcp_dynamic_cast;
61  using Teuchos::RCP;
62  using Teuchos::rcp;
63 
64  orientation.clear();
65 
66  // Cast connMgr with template types
67  //const auto connMgrBase = globalIndexer->getConnManagerBase();
68  //const auto connMgr = rcp_dynamic_cast<ConnManager<LocalOrdinal,GlobalOrdinal> >(connMgrBase->noConnectivityClone());
69 
70  //TEUCHOS_TEST_FOR_EXCEPTION(connMgr == Teuchos::null,std::logic_error,
71  // "panzer::buildIntrepidOrientation: Could not cast ConnManagerBase");
72 
73  // Retrive element blocks and its meta data
74  const int numElementBlocks = connMgr.numElementBlocks();
75 
76  std::vector<std::string> elementBlockIds;
77  std::vector<shards::CellTopology> elementBlockTopologies;
78 
79  connMgr.getElementBlockIds(elementBlockIds);
80  connMgr.getElementBlockTopologies(elementBlockTopologies);
81 
82  TEUCHOS_TEST_FOR_EXCEPTION(numElementBlocks <= 0 &&
83  numElementBlocks != static_cast<int>(elementBlockIds.size()) &&
84  numElementBlocks != static_cast<int>(elementBlockTopologies.size()),
85  std::logic_error,
86  "panzer::buildIntrepidOrientation: Number of element blocks does not match to element block meta data");
87 
88  // Currently panzer support only one type of elements for whole mesh (use the first cell topology)
89  const auto cellTopo = elementBlockTopologies.at(0);
90  const int numVertexPerCell = cellTopo.getVertexCount();
91 
92  const auto fp = NodalFieldPattern(cellTopo);
93  connMgr.buildConnectivity(fp);
94 
95  // Count and pre-alloc orientations
96  int total_elems = 0;
97  for (int i=0;i<numElementBlocks;++i) {
98  total_elems += connMgr.getElementBlock(elementBlockIds.at(i)).size();
99  }
100 
101  orientation.resize(total_elems);
102  // Loop over element blocks
103  for (int i=0;i<numElementBlocks;++i) {
104  // get elements in a block
105  const auto &elementBlock = connMgr.getElementBlock(elementBlockIds.at(i));
106 
107  const int numElementsPerBlock = elementBlock.size();
108 
109  // construct orientation information
110  for (int c=0;c<numElementsPerBlock;++c) {
111  const int localCellId = elementBlock.at(c);
112  Kokkos::View<const GlobalOrdinal*, Kokkos::DefaultHostExecutionSpace>
113  nodes(connMgr.getConnectivity(localCellId), numVertexPerCell);
114  orientation[localCellId] = (Intrepid2::Orientation::getOrientation(cellTopo, nodes));
115  }
116  }
117  }
118 
125 }
126 
127 #endif
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const =0
Teuchos::RCP< std::vector< Intrepid2::Orientation > > buildIntrepidOrientation(const Teuchos::RCP< const UniqueGlobalIndexerBase > globalIndexer)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual std::size_t numElementBlocks() const =0
virtual const GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const =0
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockID) const =0
virtual void buildConnectivity(const FieldPattern &fp)=0