Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_IOClosureModel_Factory.cpp
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 #include "PanzerAdaptersSTK_config.hpp"
44 #include "Panzer_Traits.hpp"
45 #include "Panzer_STK_IOClosureModel_Factory.hpp"
46 #include "Panzer_STK_ScatterCellAvgQuantity.hpp"
47 #include "Panzer_STK_ScatterCellAvgVector.hpp"
48 #include "Panzer_STK_ScatterCellQuantity.hpp"
49 #include "Panzer_STK_ScatterFields.hpp"
50 
51 template< >
54 buildClosureModels(const std::string& model_id,
55  const Teuchos::ParameterList& models,
58  const Teuchos::ParameterList& default_params,
59  const Teuchos::ParameterList& user_data,
60  const Teuchos::RCP<panzer::GlobalData>& global_data,
62 {
63  using Teuchos::RCP;
64  using Teuchos::rcp;
66  using PHX::Evaluator;
67 
68  // build user evaluators
70  userCMF_->buildClosureModels(model_id,models,fl,ir,default_params,user_data,global_data,fm);
71 
72  // add user evaluators to evaluator list
74  rcp(new std::vector< RCP<Evaluator<panzer::Traits> > > );
75 
76  // extract element block id
77  std::string block_id = default_params.get<std::string>("Block ID");
78 
79  if(!blockIdEvaluated_[block_id]) {
80  typedef std::map<std::string,std::vector<std::string> > BlockIdToFields;
81 
82  int worksetsize = ir->dl_scalar->extent(0);
83 
84  // if a requested field is found then add in cell avg quantity evaluator
85  BlockIdToFields::const_iterator cellAvgItr = blockIdToCellAvgFields_.find(block_id);
86  if(cellAvgItr!=blockIdToCellAvgFields_.end() ) {
87  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgItr->second));
88 
89  // setup averge cell fields
91  pl.set("Mesh",mesh_);
92  pl.set("IR",ir);
93  pl.set("Field Names",fieldNames);
94  pl.set("Scatter Name", block_id+"_Cell_Avg_Fields");
97  fm.registerEvaluator<panzer::Traits::Residual>(eval);
98  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
99 
100  evaluators->push_back(eval);
101 
102  blockIdEvaluated_[block_id] = true;
103  }
104 
105  // if a requested field is found then add in cell avg vector evaluator
106  BlockIdToFields::const_iterator cellAvgVecItr = blockIdToCellAvgVectors_.find(block_id);
107  if(cellAvgVecItr != blockIdToCellAvgVectors_.end() ) {
108  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgVecItr->second));
109 
110  // setup cell average vectors
112  pl.set("Mesh",mesh_);
113  pl.set("IR",ir);
114  pl.set("Field Names",fieldNames);
115  pl.set("Scatter Name", block_id+"_Cell_Avg_Vectors");
118  fm.registerEvaluator<panzer::Traits::Residual>(eval);
119  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
120 
121  evaluators->push_back(eval);
122 
123  blockIdEvaluated_[block_id] = true;
124  }
125 
126  // if a requested field is found then add in cell quantity evaluator
127  BlockIdToFields::const_iterator cellItr = blockIdToCellFields_.find(block_id);
128  if(cellItr!=blockIdToCellFields_.end() ) {
129  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellItr->second));
130 
131  // setup averge cell fields
133  pl.set("Mesh",mesh_);
134  pl.set("Workset Size",worksetsize);
135  pl.set("Field Names",fieldNames);
136  pl.set("Scatter Name", block_id+"_Cell_Fields");
139  fm.registerEvaluator<panzer::Traits::Residual>(eval);
140  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
141 
142  evaluators->push_back(eval);
143 
144  blockIdEvaluated_[block_id] = true;
145  }
146 
147  // if a requested field is found then add in cell quantity evaluator
148  BlockIdToFields::const_iterator nodalItr = blockIdToNodalFields_.find(block_id);
149  if(nodalItr!=blockIdToNodalFields_.end() ) {
150  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(nodalItr->second));
151 
153 
154  // setup scatter nodal fields
156  = Teuchos::rcp(new panzer_stk::ScatterFields<panzer::Traits::Residual,panzer::Traits>(block_id+"Nodal_Fields",mesh_,basis,*fieldNames));
157  fm.registerEvaluator<panzer::Traits::Residual>(eval);
158  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
159 
160  evaluators->push_back(eval);
161 
162  blockIdEvaluated_[block_id] = true;
163  }
164  }
165 
166  evaluators->insert(evaluators->end(),user_evals->begin(),user_evals->end());
167 
168  return evaluators;
169 }
170 
171 #ifdef HAVE_PANZER_EXPLICIT_INSTANTIATION
172 
174 
177 
179 
180 #endif
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define PANZER_INSTANTIATE_TEMPLATE_CLASS_ONE_T(name)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
Teuchos::RCP< const shards::CellTopology > topology
Description and data layouts associated with a particular basis.
Teuchos::RCP< std::vector< Teuchos::RCP< PHX::Evaluator< panzer::Traits > > > > buildClosureModels(const std::string &model_id, const Teuchos::ParameterList &models, const panzer::FieldLayoutLibrary &fl, const Teuchos::RCP< panzer::IntegrationRule > &ir, const Teuchos::ParameterList &default_params, const Teuchos::ParameterList &user_data, const Teuchos::RCP< panzer::GlobalData > &global_data, PHX::FieldManager< panzer::Traits > &fm) const