Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
disc-fe
src
evaluators
Panzer_CellExtreme_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_CellExtreme_impl_hpp__
44
#define __Panzer_CellExtreme_impl_hpp__
45
46
#include <limits>
47
48
#include "Intrepid2_FunctionSpaceTools.hpp"
49
#include "
Panzer_IntegrationRule.hpp
"
50
#include "
Panzer_Workset_Utilities.hpp
"
51
#include "Phalanx_DataLayout_MDALayout.hpp"
52
53
namespace
panzer
{
54
55
//**********************************************************************
56
template
<
typename
EvalT,
typename
Traits>
57
CellExtreme<EvalT, Traits>::
58
CellExtreme
(
59
const
Teuchos::ParameterList& p) :
quad_index
(0)
60
{
61
Teuchos::RCP<Teuchos::ParameterList> valid_params = this->
getValidParameters
();
62
p.validateParameters(*valid_params);
63
64
// setup default value
65
use_max
=
true
;
66
if
(p.isType<
bool
>(
"Use Max"
))
67
use_max
= p.get<
bool
>(
"Use Max"
);
68
69
Teuchos::RCP<panzer::IntegrationRule> ir = p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR"
);
70
quad_order
= ir->cubature_degree;
71
72
Teuchos::RCP<PHX::DataLayout> dl_cell = Teuchos::rcp(
new
PHX::MDALayout<Cell>(ir->dl_scalar->extent(0)));
73
extreme
= PHX::MDField<ScalarT>( p.get<std::string>(
"Extreme Name"
), dl_cell);
74
scalar
= PHX::MDField<const ScalarT,Cell,IP>( p.get<std::string>(
"Field Name"
), ir->dl_scalar);
75
76
this->addEvaluatedField(
extreme
);
77
this->addDependentField(
scalar
);
78
79
multiplier
= 1.0;
80
if
(p.isType<
double
>(
"Multiplier"
))
81
multiplier
= p.get<
double
>(
"Multiplier"
);
82
83
if
(p.isType<Teuchos::RCP<
const
std::vector<std::string> > >(
"Field Multipliers"
)) {
84
const
std::vector<std::string>& field_multiplier_names =
85
*(p.get<Teuchos::RCP<const std::vector<std::string> > >(
"Field Multipliers"
));
86
87
for
(std::vector<std::string>::const_iterator name =
88
field_multiplier_names.begin();
89
name != field_multiplier_names.end(); ++name) {
90
PHX::MDField<const ScalarT,Cell,IP> tmp_field(*name, p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR"
)->dl_scalar);
91
field_multipliers
.push_back(tmp_field);
92
}
93
}
94
95
for
(
typename
std::vector<PHX::MDField<const ScalarT,Cell,IP> >::iterator field =
field_multipliers
.begin();
96
field !=
field_multipliers
.end(); ++field)
97
this->addDependentField(*field);
98
99
std::string n =
"CellExtreme: "
+
extreme
.fieldTag().name();
100
this->setName(n);
101
}
102
103
//**********************************************************************
104
template
<
typename
EvalT,
typename
Traits>
105
void
106
CellExtreme<EvalT, Traits>::
107
postRegistrationSetup
(
108
typename
Traits::SetupData
sd,
109
PHX::FieldManager<Traits>
&
/* fm */
)
110
{
111
num_qp
=
scalar
.extent(1);
112
quad_index
=
panzer::getIntegrationRuleIndex
(
quad_order
,(*sd.
worksets_
)[0], this->wda);
113
}
114
115
//**********************************************************************
116
template
<
typename
EvalT,
typename
Traits>
117
void
118
CellExtreme<EvalT, Traits>::
119
evaluateFields
(
120
typename
Traits::EvalData
workset)
121
{
122
for
(index_t cell = 0; cell < workset.
num_cells
; ++cell) {
123
124
for
(std::size_t qp = 0; qp <
num_qp
; ++qp) {
125
ScalarT
current=
multiplier
*
scalar
(cell,qp);
126
for
(
typename
std::vector<PHX::MDField<const ScalarT,Cell,IP> >::iterator field =
field_multipliers
.begin();
127
field !=
field_multipliers
.end(); ++field)
128
current *= (*field)(cell,qp);
129
130
// take first quad point value
131
if
(qp==0)
132
extreme
(cell) = current;
133
134
// take largest value in the cell
135
if
(
use_max
)
136
extreme
(cell) =
extreme
(cell)<current ? current :
extreme
(cell);
137
else
// use_min
138
extreme
(cell) =
extreme
(cell)>current ? current :
extreme
(cell);
139
}
140
}
141
}
142
143
//**********************************************************************
144
template
<
typename
EvalT,
typename
TRAITS>
145
Teuchos::RCP<Teuchos::ParameterList>
146
CellExtreme<EvalT, TRAITS>::getValidParameters
()
const
147
{
148
Teuchos::RCP<Teuchos::ParameterList> p = Teuchos::rcp(
new
Teuchos::ParameterList);
149
p->set<std::string>(
"Extreme Name"
,
"?"
);
150
p->set<std::string>(
"Field Name"
,
"?"
);
151
152
Teuchos::RCP<panzer::IntegrationRule> ir;
153
p->set(
"IR"
, ir);
154
p->set<
bool
>(
"Use Max"
,
true
);
155
p->set<
double
>(
"Multiplier"
, 1.0);
156
157
Teuchos::RCP<const std::vector<std::string> > fms;
158
p->set(
"Field Multipliers"
, fms);
159
return
p;
160
}
161
162
//**********************************************************************
163
164
}
165
166
#endif
Panzer_IntegrationRule.hpp
Panzer_Workset_Utilities.hpp
PHX::FieldManager
Definition
Panzer_BCStrategy_Base.hpp:53
panzer::CellExtreme::multiplier
double multiplier
Definition
Panzer_CellExtreme.hpp:99
panzer::CellExtreme::num_qp
std::size_t num_qp
Definition
Panzer_CellExtreme.hpp:101
panzer::CellExtreme::extreme
PHX::MDField< ScalarT > extreme
Definition
Panzer_CellExtreme.hpp:94
panzer::CellExtreme::use_max
bool use_max
Definition
Panzer_CellExtreme.hpp:105
panzer::CellExtreme::getValidParameters
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Definition
Panzer_CellExtreme_impl.hpp:146
panzer::CellExtreme::ScalarT
typename EvalT::ScalarT ScalarT
Definition
Panzer_CellExtreme.hpp:92
panzer::CellExtreme::quad_order
int quad_order
Definition
Panzer_CellExtreme.hpp:103
panzer::CellExtreme::field_multipliers
std::vector< PHX::MDField< const ScalarT, Cell, IP > > field_multipliers
Definition
Panzer_CellExtreme.hpp:98
panzer::CellExtreme::CellExtreme
CellExtreme(const Teuchos::ParameterList &p)
Definition
Panzer_CellExtreme_impl.hpp:58
panzer::CellExtreme::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Definition
Panzer_CellExtreme_impl.hpp:107
panzer::CellExtreme::scalar
PHX::MDField< const ScalarT, Cell, IP > scalar
Definition
Panzer_CellExtreme.hpp:96
panzer::CellExtreme::quad_index
std::size_t quad_index
Definition
Panzer_CellExtreme.hpp:102
panzer::CellExtreme::evaluateFields
void evaluateFields(typename Traits::EvalData d)
Definition
Panzer_CellExtreme_impl.hpp:119
panzer::WorksetDetails::num_cells
int num_cells
DEPRECATED - use: numCells().
Definition
Panzer_Workset.hpp:116
panzer
Computes .
Definition
Panzer_BasisValues_Evaluator_decl.hpp:54
panzer::getIntegrationRuleIndex
std::vector< int >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Definition
Panzer_Workset_Utilities.cpp:97
panzer::Traits::SD::worksets_
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_
Definition
Panzer_Traits.hpp:124
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