Panzer  Version of the Day
Panzer_ReorderADValues_Evaluator_decl.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_ReorderADValues_Evaluator_decl_hpp__
44 #define __Panzer_ReorderADValues_Evaluator_decl_hpp__
45 
46 #include "Phalanx_config.hpp"
47 #include "Phalanx_Evaluator_Macros.hpp"
48 #include "Phalanx_MDField.hpp"
49 
51 
52 #include "PanzerDiscFE_config.hpp"
53 #include "Panzer_Dimension.hpp"
54 #include "Panzer_Traits.hpp"
56 
58 
59 namespace panzer {
60 
61 class UniqueGlobalIndexerBase;
62 
69 template<typename EvalT, typename TRAITS>
71  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
72  public PHX::EvaluatorDerived<EvalT, TRAITS> {
73 public:
74  typedef typename EvalT::ScalarT ScalarT;
75 
76  ReorderADValues_Evaluator(const std::string & outPrefix,
77  const std::vector<std::string> & inFieldNames,
78  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
79  const std::string & elementBlock,
80  const UniqueGlobalIndexerBase & indexerSrc,
81  const UniqueGlobalIndexerBase & indexerDest);
82 
83  ReorderADValues_Evaluator(const std::string & outPrefix,
84  const std::vector<std::string> & inFieldNames,
85  const std::vector<std::string> & inDOFs,
86  const std::vector<std::string> & outDOFs,
87  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
88  const std::string & elementBlock,
89  const UniqueGlobalIndexerBase & indexerSrc,
90  const UniqueGlobalIndexerBase & indexerDest);
91 
92  void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm);
93 
94  void evaluateFields(typename TRAITS::EvalData d);
95 
96 private:
97  // fields to be modified
98  std::vector< PHX::MDField<const ScalarT> > inFields_;
99 
100  // fields that need to be modified
101  std::vector< PHX::MDField<ScalarT> > outFields_;
102 };
103 
104 // **************************************************************
105 // **************************************************************
106 // * Specializations
107 // **************************************************************
108 // **************************************************************
109 
110 
111 // **************************************************************
112 // Jacobian
113 // **************************************************************
114 template<typename TRAITS>
115 class ReorderADValues_Evaluator<typename TRAITS::Jacobian,TRAITS>
116  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
117  public PHX::EvaluatorDerived<typename TRAITS::Jacobian, TRAITS> {
118 
119 public:
120 
121  ReorderADValues_Evaluator(const std::string & outPrefix,
122  const std::vector<std::string> & inFieldNames,
123  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
124  const std::string & elementBlock,
125  const UniqueGlobalIndexerBase & indexerSrc,
126  const UniqueGlobalIndexerBase & indexerDest);
127 
128  ReorderADValues_Evaluator(const std::string & outPrefix,
129  const std::vector<std::string> & inFieldNames,
130  const std::vector<std::string> & inDOFs,
131  const std::vector<std::string> & outDOFs,
132  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
133  const std::string & elementBlock,
134  const UniqueGlobalIndexerBase & indexerSrc,
135  const UniqueGlobalIndexerBase & indexerDest);
136 
137  void postRegistrationSetup(typename TRAITS::SetupData d,
139 
140  void evaluateFields(typename TRAITS::EvalData workset);
141 
142 private:
143  typedef typename TRAITS::Jacobian::ScalarT ScalarT;
144 
145  void buildSrcToDestMap(const std::string & elementBlock,
146  const UniqueGlobalIndexerBase & indexerSrc,
147  const UniqueGlobalIndexerBase & indexerDest);
148 
149  // Build a source to destination map using all the pairs
150  // of field numers in the <code>fieldNumberMaps</code>
151  void buildSrcToDestMap(const std::string & elementBlock,
152  const std::map<int,int> & fieldNumberMaps,
153  const UniqueGlobalIndexerBase & indexerSrc,
154  const UniqueGlobalIndexerBase & indexerDest);
155 
156  // fields to be modified
157  std::vector< PHX::MDField<const ScalarT> > inFields_;
158 
159  // fields that need to be modified
160  std::vector< PHX::MDField<ScalarT> > outFields_;
161 
162  // This allows indexing into a destination sized vector and
163  // maps to a source vector. If a value is less then 0
164  // then that implies that value is not mapped. That is a strange
165  // case but this structure supports it
166  std::vector<int> dstFromSrcMap_;
167 
170 };
171 
172 }
173 
174 // **************************************************************
175 #endif
ReorderADValues_Evaluator(const std::string &outPrefix, const std::vector< std::string > &inFieldNames, const std::vector< Teuchos::RCP< PHX::DataLayout > > &fieldLayouts, const std::string &elementBlock, const UniqueGlobalIndexerBase &indexerSrc, const UniqueGlobalIndexerBase &indexerDest)
PHX::MDField< ScalarT > vector
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
std::vector< PHX::MDField< ScalarT > > outFields_
std::vector< PHX::MDField< const ScalarT > > inFields_
Reorders the ad values of a specified field to match a different unique global indexer.
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)