Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_IntrepidOrientation.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 "PanzerDiscFE_config.hpp"
46
47namespace panzer {
48
49 void buildIntrepidOrientation(std::vector<Intrepid2::Orientation> & orientation,
50 panzer::ConnManager & connMgr)
51 {
52 using Teuchos::rcp_dynamic_cast;
53 using Teuchos::RCP;
54 using Teuchos::rcp;
55
56 orientation.clear();
57
58 // Retrive element blocks and its meta data
59 const int numElementBlocks = connMgr.numElementBlocks();
60
61 std::vector<std::string> elementBlockIds;
62 std::vector<shards::CellTopology> elementBlockTopologies;
63
64 connMgr.getElementBlockIds(elementBlockIds);
65 connMgr.getElementBlockTopologies(elementBlockTopologies);
66
67 TEUCHOS_TEST_FOR_EXCEPTION(numElementBlocks <= 0 &&
68 numElementBlocks != static_cast<int>(elementBlockIds.size()) &&
69 numElementBlocks != static_cast<int>(elementBlockTopologies.size()),
70 std::logic_error,
71 "panzer::buildIntrepidOrientation: Number of element blocks does not match to element block meta data");
72
73 // Currently panzer support only one type of elements for whole mesh (use the first cell topology)
74 const auto cellTopo = elementBlockTopologies.at(0);
75 const int numVertexPerCell = cellTopo.getVertexCount();
76
77 const auto fp = NodalFieldPattern(cellTopo);
78 connMgr.buildConnectivity(fp);
79
80 // Count and pre-alloc orientations
81 int total_elems = 0;
82 for (int i=0;i<numElementBlocks;++i) {
83 total_elems += connMgr.getElementBlock(elementBlockIds.at(i)).size();
84 }
85
86 orientation.resize(total_elems);
87 // Loop over element blocks
88 for (int i=0;i<numElementBlocks;++i) {
89 // get elements in a block
90 const auto &elementBlock = connMgr.getElementBlock(elementBlockIds.at(i));
91
92 const int numElementsPerBlock = elementBlock.size();
93
94 // construct orientation information
95 for (int c=0;c<numElementsPerBlock;++c) {
96 const int localCellId = elementBlock.at(c);
97 Kokkos::View<const panzer::GlobalOrdinal*,Kokkos::HostSpace>
98 nodes(connMgr.getConnectivity(localCellId), numVertexPerCell);
99 orientation[localCellId] = (Intrepid2::Orientation::getOrientation(cellTopo, nodes));
100 }
101 }
102 }
103
104 Teuchos::RCP<std::vector<Intrepid2::Orientation> >
105 buildIntrepidOrientation(const Teuchos::RCP<const GlobalIndexer> globalIndexer)
106 {
107 using Teuchos::rcp_dynamic_cast;
108 using Teuchos::RCP;
109 using Teuchos::rcp;
110
111 auto orientation = rcp(new std::vector<Intrepid2::Orientation>);
112
113 {
114 RCP<const GlobalIndexer> ugi
115 = rcp_dynamic_cast<const GlobalIndexer>(globalIndexer);
116
117 if (ugi!=Teuchos::null) {
118 const auto connMgr = ugi->getConnManager()->noConnectivityClone();
119
120 TEUCHOS_TEST_FOR_EXCEPTION(connMgr == Teuchos::null,std::logic_error,
121 "panzer::buildIntrepidOrientation: ConnManager is null!");
122
123 buildIntrepidOrientation(*orientation, *connMgr);
124 return orientation;
125 }
126 }
127
128 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
129 "panzer::buildIntrepidOrientation: Could not cast GlobalIndexer");
130 }
131
132} // end namespace panzer
Pure virtual base class for supplying mesh connectivity information to the DOF Manager.
virtual std::size_t numElementBlocks() const =0
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockID) const =0
virtual void buildConnectivity(const FieldPattern &fp)=0
virtual const GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const =0
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const =0
void buildIntrepidOrientation(std::vector< Intrepid2::Orientation > &orientation, panzer::ConnManager &connMgr)