Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 GlobalIndexer;
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 GlobalIndexer & indexerSrc,
81  const GlobalIndexer & 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 GlobalIndexer & indexerSrc,
90  const GlobalIndexer & indexerDest);
91 
92  void evaluateFields(typename TRAITS::EvalData d);
93 
94 private:
95  // fields to be modified
96  std::vector< PHX::MDField<const ScalarT> > inFields_;
97 
98  // fields that need to be modified
99  std::vector< PHX::MDField<ScalarT> > outFields_;
100 };
101 
102 // **************************************************************
103 // **************************************************************
104 // * Specializations
105 // **************************************************************
106 // **************************************************************
107 
108 
109 // **************************************************************
110 // Jacobian
111 // **************************************************************
112 template<typename TRAITS>
113 class ReorderADValues_Evaluator<typename TRAITS::Jacobian,TRAITS>
114  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
115  public PHX::EvaluatorDerived<typename TRAITS::Jacobian, TRAITS> {
116 
117 public:
118 
119  ReorderADValues_Evaluator(const std::string & outPrefix,
120  const std::vector<std::string> & inFieldNames,
121  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
122  const std::string & elementBlock,
123  const GlobalIndexer & indexerSrc,
124  const GlobalIndexer & indexerDest);
125 
126  ReorderADValues_Evaluator(const std::string & outPrefix,
127  const std::vector<std::string> & inFieldNames,
128  const std::vector<std::string> & inDOFs,
129  const std::vector<std::string> & outDOFs,
130  const std::vector<Teuchos::RCP<PHX::DataLayout> > & fieldLayouts,
131  const std::string & elementBlock,
132  const GlobalIndexer & indexerSrc,
133  const GlobalIndexer & indexerDest);
134 
135  void evaluateFields(typename TRAITS::EvalData workset);
136 
137 private:
138  typedef typename TRAITS::Jacobian::ScalarT ScalarT;
139 
140  void buildSrcToDestMap(const std::string & elementBlock,
141  const GlobalIndexer & indexerSrc,
142  const GlobalIndexer & indexerDest);
143 
144  // Build a source to destination map using all the pairs
145  // of field numers in the <code>fieldNumberMaps</code>
146  void buildSrcToDestMap(const std::string & elementBlock,
147  const std::map<int,int> & fieldNumberMaps,
148  const GlobalIndexer & indexerSrc,
149  const GlobalIndexer & indexerDest);
150 
151  // fields to be modified
152  std::vector< PHX::MDField<const ScalarT> > inFields_;
153 
154  // fields that need to be modified
155  std::vector< PHX::MDField<ScalarT> > outFields_;
156 
157  // This allows indexing into a destination sized vector and
158  // maps to a source vector. If a value is less then 0
159  // then that implies that value is not mapped. That is a strange
160  // case but this structure supports it
161  std::vector<int> dstFromSrcMap_;
162 
165 };
166 
167 }
168 
169 // **************************************************************
170 #endif
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.
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 GlobalIndexer &indexerSrc, const GlobalIndexer &indexerDest)