Panzer  Version of the Day
Panzer_ProjectToFaces_impl.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_PROJECT_TO_FACES_IMPL_HPP
44 #define PANZER_PROJECT_TO_FACES_IMPL_HPP
45 
46 #include "Teuchos_Assert.hpp"
47 #include "Phalanx_DataLayout.hpp"
48 
49 #include "Intrepid2_Cubature.hpp"
50 #include "Intrepid2_DefaultCubatureFactory.hpp"
51 #include "Intrepid2_FunctionSpaceTools.hpp"
52 #include "Intrepid2_Kernels.hpp"
53 #include "Intrepid2_CellTools.hpp"
54 #include "Intrepid2_OrientationTools.hpp"
55 
57 #include "Panzer_PureBasis.hpp"
59 #include "Kokkos_ViewFactory.hpp"
60 
61 #include "Teuchos_FancyOStream.hpp"
62 
63 #include <cstring>
64 
65 template<typename EvalT,typename Traits>
67 ProjectToFaces(const Teuchos::ParameterList& p)
68 {
69  dof_name = (p.get< std::string >("DOF Name"));
70 
71  if(p.isType< Teuchos::RCP<PureBasis> >("Basis"))
72  basis = p.get< Teuchos::RCP<PureBasis> >("Basis");
73  else
74  basis = p.get< Teuchos::RCP<const PureBasis> >("Basis");
75 
76  Teuchos::RCP<PHX::DataLayout> basis_layout = basis->functional;
77  Teuchos::RCP<PHX::DataLayout> vector_layout = basis->functional_grad;
78 
79  // some sanity checks
80  TEUCHOS_ASSERT(basis->isVectorBasis());
81 
82  result = PHX::MDField<ScalarT,Cell,BASIS>(dof_name,basis_layout);
83  this->addEvaluatedField(result);
84 
85  normals = PHX::MDField<const ScalarT,Cell,BASIS,Dim>(dof_name+"_Normals",vector_layout);
86  this->addDependentField(normals);
87 
88  vector_values.resize(1);
89  vector_values[0] = PHX::MDField<const ScalarT,Cell,BASIS,Dim>(dof_name+"_Vector",vector_layout);
90  this->addDependentField(vector_values[0]);
91 
92  this->setName("Project To Faces");
93 
94  num_faces = result.extent(1);
95  num_dim = vector_values[0].extent(2);
96 }
97 
98 // **********************************************************************
99 template<typename EvalT,typename Traits>
102  PHX::FieldManager<Traits>& /* fm */)
103 {
104  num_faces = result.extent(1);
105  num_dim = vector_values[0].extent(2);
106 
107  TEUCHOS_ASSERT(result.extent(1) == normals.extent(1));
108  TEUCHOS_ASSERT(vector_values[0].extent(2) == normals.extent(2));
109 }
110 
111 // **********************************************************************
112 template<typename EvalT,typename Traits>
115 {
116 
117  // Restricting HDiv field, multiplied by the normal to the faces, into HVol on the faces.
118  // This code assumes affine mapping and the projection into 1 quadrature point for each face,
119  // which is identified with the face. This makes sense only for low order bases, for which
120  // HVol is constant
121 
122  //TODO: make this work w/ high order basis
123  const int intDegree = basis->order();
124  TEUCHOS_ASSERT(intDegree == 1);
125 
126  // TODO: parallel for.
127  for (index_t cell = 0; cell < workset.num_cells; ++cell) {
128  for (int p = 0; p < num_faces; ++p) {
129  result(cell,p) = ScalarT(0.0);
130  for (int dim = 0; dim < num_dim; ++dim)
131  result(cell,p) += vector_values[0](cell,p,dim) * normals(cell,p,dim);
132  }
133  }
134 }
135 
136 
137 #endif
int num_cells
DEPRECATED - use: numCells()
void evaluateFields(typename Traits::EvalData d)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we&#39;re performing.