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  // see if there's a scaling parameter object
86  if (user_data.isParameter("Variable Scale Factors Map"))
87  {
88  varScaleFactors = user_data.get<Teuchos::RCP<std::map<std::string,double>>>("Variable Scale Factors Map");
89  }
90 
91  // if a requested field is found then add in cell avg quantity evaluator
92  BlockIdToFields::const_iterator cellAvgItr = blockIdToCellAvgFields_.find(block_id);
93  if(cellAvgItr!=blockIdToCellAvgFields_.end() ) {
94  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgItr->second));
95 
96  // setup averge cell fields
98  pl.set("Mesh",mesh_);
99  pl.set("IR",ir);
100  pl.set("Field Names",fieldNames);
101  pl.set("Scatter Name", block_id+"_Cell_Avg_Fields");
102  pl.set("Variable Scale Factors Map", varScaleFactors);
105  fm.registerEvaluator<panzer::Traits::Residual>(eval);
106  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
107 
108  evaluators->push_back(eval);
109 
110  blockIdEvaluated_[block_id] = true;
111  }
112 
113  // if a requested field is found then add in cell avg vector evaluator
114  BlockIdToFields::const_iterator cellAvgVecItr = blockIdToCellAvgVectors_.find(block_id);
115  if(cellAvgVecItr != blockIdToCellAvgVectors_.end() ) {
116  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgVecItr->second));
117 
118  // setup cell average vectors
120  pl.set("Mesh",mesh_);
121  pl.set("IR",ir);
122  pl.set("Field Names",fieldNames);
123  pl.set("Scatter Name", block_id+"_Cell_Avg_Vectors");
124  pl.set("Variable Scale Factors Map", varScaleFactors);
127  fm.registerEvaluator<panzer::Traits::Residual>(eval);
128  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
129 
130  evaluators->push_back(eval);
131 
132  blockIdEvaluated_[block_id] = true;
133  }
134 
135  // if a requested field is found then add in cell quantity evaluator
136  BlockIdToFields::const_iterator cellItr = blockIdToCellFields_.find(block_id);
137  if(cellItr!=blockIdToCellFields_.end() ) {
138  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellItr->second));
139 
140  // setup averge cell fields
142  pl.set("Mesh",mesh_);
143  pl.set("Workset Size",worksetsize);
144  pl.set("Field Names",fieldNames);
145  pl.set("Scatter Name", block_id+"_Cell_Fields");
146  pl.set("Variable Scale Factors Map", varScaleFactors);
149  fm.registerEvaluator<panzer::Traits::Residual>(eval);
150  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
151 
152  evaluators->push_back(eval);
153 
154  blockIdEvaluated_[block_id] = true;
155  }
156 
157  // if a requested field is found then add in cell quantity evaluator
158  BlockIdToFields::const_iterator nodalItr = blockIdToNodalFields_.find(block_id);
159  if(nodalItr!=blockIdToNodalFields_.end() ) {
160  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(nodalItr->second));
161 
163 
164  // setup scaling factors as accepted by ScatterFields, if present
165  std::vector<double> scale_factors_(fieldNames->size(),1.0);
166  if (!varScaleFactors.is_null()) {
167  for(size_t f=0; f < fieldNames->size(); ++f) {
168  std::map<std::string,double>::const_iterator f2s_itr = varScaleFactors->find((*fieldNames)[f]);
169  if(f2s_itr != varScaleFactors->end()) {
170  scale_factors_[f] = f2s_itr->second;
171  }
172  }
173  }
174 
175  // setup scatter nodal fields
177  = Teuchos::rcp(new panzer_stk::ScatterFields<panzer::Traits::Residual,panzer::Traits>(block_id+"Nodal_Fields",mesh_,basis,*fieldNames,scale_factors_));
178  fm.registerEvaluator<panzer::Traits::Residual>(eval);
179  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
180 
181  evaluators->push_back(eval);
182 
183  blockIdEvaluated_[block_id] = true;
184  }
185  }
186 
187  evaluators->insert(evaluators->end(),user_evals->begin(),user_evals->end());
188 
189  return evaluators;
190 }
191 
192 #ifdef HAVE_PANZER_EXPLICIT_INSTANTIATION
193 
195 
198 
200 
201 #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)
bool isParameter(const std::string &name) const
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
bool is_null() const