Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_OrientationContainer_impl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef __Panzer_OrientationContainer_impl_hpp__
12 #define __Panzer_OrientationContainer_impl_hpp__
13 
14 #include "PanzerDiscFE_config.hpp"
15 
16 #include "Panzer_GlobalIndexer.hpp"
17 
18 namespace panzer {
19 
20 template <typename Scalar,typename Array,typename LocalOrdinal,typename GlobalOrdinal>
23  const std::string & fieldName)
24  : globalIndexer_(globalIndexer)
25  , fieldName_(fieldName)
26 {
27 }
28 
29 template <typename Scalar,typename Array,typename LocalOrdinal,typename GlobalOrdinal>
30 void
32 getOrientations(const std::string & blockId,
33  const std::vector<std::size_t> & cell_local_ids,
34  Array & orientationsArray) const
35 {
36  int fieldNum = globalIndexer_->getFieldNum(fieldName_);
37  const std::vector<int> & elmtOffset = globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
38 
39  // gather operation for each cell in workset
40  for(std::size_t cellIndex=0;cellIndex<cell_local_ids.size();++cellIndex) {
41  std::vector<double> orientation;
42  std::size_t cellLocalId = cell_local_ids[cellIndex];
43 
44  globalIndexer_->getElementOrientation(cellLocalId,orientation);
45 
46  // loop over basis functions and fill the fields
47  for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
48  int offset = elmtOffset[basis];
49  orientationsArray(cellIndex,basis) = orientation[offset];
50  }
51  }
52 }
53 
54 template <typename Scalar,typename Array>
57  const std::string & fieldName)
58 {
59  using Teuchos::rcp_dynamic_cast;
60  using Teuchos::RCP;
61  using Teuchos::rcp;
62 
63  // int, int
64  {
65  typedef int LO;
66  typedef int GO;
67 
69  = rcp_dynamic_cast<const GlobalIndexer>(globalIndexer);
70  if(ugi!=Teuchos::null)
71  return rcp(new OrientationContainer<Scalar,Array,LO,GO>(ugi,fieldName));
72  }
73 
74  // int, panzer::GlobalOrdinal
75  {
76  typedef int LO;
77  typedef panzer::GlobalOrdinal GO;
78 
80  = rcp_dynamic_cast<const GlobalIndexer>(globalIndexer);
81  if(ugi!=Teuchos::null)
82  return rcp(new OrientationContainer<Scalar,Array,LO,GO>(ugi,fieldName));
83  }
84 
85  // int, pair<int,int>
86  {
87  typedef int LO;
88  typedef std::pair<int,int> GO;
89 
91  = rcp_dynamic_cast<const GlobalIndexer>(globalIndexer);
92  if(ugi!=Teuchos::null)
93  return rcp(new OrientationContainer<Scalar,Array,LO,GO>(ugi,fieldName));
94  }
95 
96  // int, pair<int,panzer::GlobalOrdinal>
97  {
98  typedef int LO;
99  typedef std::pair<int,panzer::GlobalOrdinal> GO;
100 
102  = rcp_dynamic_cast<const GlobalIndexer>(globalIndexer);
103  if(ugi!=Teuchos::null)
104  return rcp(new OrientationContainer<Scalar,Array,LO,GO>(ugi,fieldName));
105  }
106 
107  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
108  "panzer::buildOrientationContainer: Could not cast GlobalIndexer");
109 }
110 
111 } // end namespace panzer
112 
113 #endif
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const panzer::OrientationContainerBase< Scalar, Array > > buildOrientationContainer(const Teuchos::RCP< const panzer::GlobalIndexer > &globalIndexer, const std::string &fieldName)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void getOrientations(const std::string &blockId, const std::vector< std::size_t > &cell_local_ids, Array &orientations) const
OrientationContainer(const Teuchos::RCP< const panzer::GlobalIndexer > &globalIndexer, const std::string &fieldName)