Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
disc-fe
src
evaluators
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
56
#include "
Panzer_Workset_Utilities.hpp
"
57
#include "
Panzer_PureBasis.hpp
"
58
#include "
Panzer_CommonArrayFactories.hpp
"
59
#include "
Panzer_HierarchicParallelism.hpp
"
60
#include "Kokkos_ViewFactory.hpp"
61
62
#include "Teuchos_FancyOStream.hpp"
63
64
#include <cstring>
65
66
template
<
typename
EvalT,
typename
Traits>
67
panzer::ProjectToFaces<EvalT, Traits>::
68
ProjectToFaces
(
const
Teuchos::ParameterList& p)
69
{
70
dof_name_
= (p.get< std::string >(
"DOF Name"
));
71
72
if
(p.isType< Teuchos::RCP<PureBasis> >(
"Basis"
))
73
basis_
= p.get< Teuchos::RCP<PureBasis> >(
"Basis"
);
74
else
75
basis_
= p.get< Teuchos::RCP<const PureBasis> >(
"Basis"
);
76
77
Teuchos::RCP<PHX::DataLayout> basis_layout =
basis_
->functional;
78
Teuchos::RCP<PHX::DataLayout> vector_layout =
basis_
->functional_grad;
79
80
// some sanity checks
81
TEUCHOS_ASSERT(
basis_
->isVectorBasis());
82
83
result_
= PHX::MDField<ScalarT,Cell,BASIS>(
dof_name_
,basis_layout);
84
this->addEvaluatedField(
result_
);
85
86
normals_
= PHX::MDField<const ScalarT,Cell,BASIS,Dim>(
dof_name_
+
"_Normals"
,vector_layout);
87
this->addDependentField(
normals_
);
88
89
vector_values_
= PHX::MDField<const ScalarT,Cell,BASIS,Dim>(
dof_name_
+
"_Vector"
,vector_layout);
90
this->addDependentField(
vector_values_
);
91
92
this->setName(
"Project To Faces"
);
93
}
94
95
// **********************************************************************
96
template
<
typename
EvalT,
typename
Traits>
97
void
panzer::ProjectToFaces<EvalT, Traits>::
98
postRegistrationSetup
(
typename
Traits::SetupData
d,
99
PHX::FieldManager<Traits>
&
/* fm */
)
100
{
101
num_faces_
=
result_
.extent(1);
102
num_dim_
=
vector_values_
.extent(2);
103
104
TEUCHOS_ASSERT(
result_
.extent(1) ==
normals_
.extent(1));
105
TEUCHOS_ASSERT(
vector_values_
.extent(2) ==
normals_
.extent(2));
106
}
107
108
// **********************************************************************
109
template
<
typename
EvalT,
typename
Traits>
110
void
panzer::ProjectToFaces<EvalT, Traits>::
111
evaluateFields
(
typename
Traits::EvalData
workset)
112
{
113
114
// Restricting HDiv field, multiplied by the normal to the faces, into HVol on the faces.
115
// This code assumes affine mapping and the projection into 1 quadrature point for each face,
116
// which is identified with the face. This makes sense only for low order bases, for which
117
// HVol is constant
118
119
//TODO: make this work w/ high order basis
120
const
int
intDegree =
basis_
->order();
121
TEUCHOS_ASSERT(intDegree == 1);
122
123
auto
result =
result_
.get_static_view();
124
auto
vector_values =
vector_values_
.get_static_view();
125
auto
normals =
normals_
.get_static_view();
126
auto
num_faces =
num_faces_
;
127
auto
num_dim =
num_dim_
;
128
129
auto
policy =
panzer::HP::inst
().
teamPolicy
<
ScalarT
,PHX::exec_space>(workset.
num_cells
);
130
Kokkos::parallel_for(
"panzer::ProjectToFaces"
,policy,KOKKOS_LAMBDA(
const
Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) {
131
const
auto
cell = team.league_rank();
132
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_faces),[&] (
const
int
p) {
133
result(cell,p) =
ScalarT
(0.0);
134
for
(
int
dim = 0; dim < num_dim; ++dim)
135
result(cell,p) += vector_values(cell,p,dim) * normals(cell,p,dim);
136
});
137
});
138
}
139
140
141
#endif
Panzer_CommonArrayFactories.hpp
Panzer_HierarchicParallelism.hpp
Panzer_PureBasis.hpp
Panzer_Workset_Utilities.hpp
PHX::FieldManager
Definition
Panzer_BCStrategy_Base.hpp:53
panzer::HP::inst
static HP & inst()
Private ctor.
Definition
Panzer_HierarchicParallelism.cpp:62
panzer::HP::teamPolicy
Kokkos::TeamPolicy< TeamPolicyProperties... > teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
Definition
Panzer_HierarchicParallelism.hpp:132
panzer::ProjectToFaces::result_
PHX::MDField< ScalarT, Cell, BASIS > result_
Definition
Panzer_ProjectToFaces_decl.hpp:88
panzer::ProjectToFaces::num_dim_
int num_dim_
Definition
Panzer_ProjectToFaces_decl.hpp:84
panzer::ProjectToFaces::normals_
PHX::MDField< const ScalarT, Cell, BASIS, Dim > normals_
Definition
Panzer_ProjectToFaces_decl.hpp:86
panzer::ProjectToFaces::ScalarT
EvalT::ScalarT ScalarT
Definition
Panzer_ProjectToFaces_decl.hpp:79
panzer::ProjectToFaces::vector_values_
PHX::MDField< const ScalarT, Cell, BASIS, Dim > vector_values_
Definition
Panzer_ProjectToFaces_decl.hpp:87
panzer::ProjectToFaces::dof_name_
std::string dof_name_
Definition
Panzer_ProjectToFaces_decl.hpp:81
panzer::ProjectToFaces::basis_
Teuchos::RCP< const PureBasis > basis_
Definition
Panzer_ProjectToFaces_decl.hpp:82
panzer::ProjectToFaces::ProjectToFaces
ProjectToFaces(const Teuchos::ParameterList &p)
Definition
Panzer_ProjectToFaces_impl.hpp:68
panzer::ProjectToFaces::evaluateFields
void evaluateFields(typename Traits::EvalData d)
Definition
Panzer_ProjectToFaces_impl.hpp:111
panzer::ProjectToFaces::num_faces_
int num_faces_
Definition
Panzer_ProjectToFaces_decl.hpp:83
panzer::ProjectToFaces::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
Definition
Panzer_ProjectToFaces_impl.hpp:98
panzer::WorksetDetails::num_cells
int num_cells
DEPRECATED - use: numCells().
Definition
Panzer_Workset.hpp:116
panzer::Traits::EvalData
const panzer::Workset & EvalData
Definition
Panzer_Traits.hpp:129
panzer::Traits::SetupData
const SD & SetupData
Definition
Panzer_Traits.hpp:127
Generated by
1.17.0