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 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #include "PanzerAdaptersSTK_config.hpp"
12 #include "Panzer_Traits.hpp"
13 #include "Panzer_STK_IOClosureModel_Factory.hpp"
14 #include "Panzer_STK_ScatterCellAvgQuantity.hpp"
15 #include "Panzer_STK_ScatterCellAvgVector.hpp"
16 #include "Panzer_STK_ScatterCellQuantity.hpp"
17 #include "Panzer_STK_ScatterFields.hpp"
18 
19 template< >
22 buildClosureModels(const std::string& model_id,
23  const Teuchos::ParameterList& models,
26  const Teuchos::ParameterList& default_params,
27  const Teuchos::ParameterList& user_data,
28  const Teuchos::RCP<panzer::GlobalData>& global_data,
30 {
31  using Teuchos::RCP;
32  using Teuchos::rcp;
34  using PHX::Evaluator;
35 
36  // build user evaluators
38  userCMF_->buildClosureModels(model_id,models,fl,ir,default_params,user_data,global_data,fm);
39 
40  // add user evaluators to evaluator list
42  rcp(new std::vector< RCP<Evaluator<panzer::Traits> > > );
43 
44  // extract element block id
45  std::string block_id = default_params.get<std::string>("Block ID");
46 
47  if(!blockIdEvaluated_[block_id]) {
48  typedef std::map<std::string,std::vector<std::string> > BlockIdToFields;
49 
50  int worksetsize = ir->dl_scalar->extent(0);
51 
52  // see if there's a scaling parameter object
54  if (user_data.isParameter("Variable Scale Factors Map"))
55  {
56  varScaleFactors = user_data.get<Teuchos::RCP<std::map<std::string,double>>>("Variable Scale Factors Map");
57  }
58 
59  // if a requested field is found then add in cell avg quantity evaluator
60  BlockIdToFields::const_iterator cellAvgItr = blockIdToCellAvgFields_.find(block_id);
61  if(cellAvgItr!=blockIdToCellAvgFields_.end() ) {
62  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgItr->second));
63 
64  // setup averge cell fields
66  pl.set("Mesh",mesh_);
67  pl.set("IR",ir);
68  pl.set("Field Names",fieldNames);
69  pl.set("Scatter Name", block_id+"_Cell_Avg_Fields");
70  pl.set("Variable Scale Factors Map", varScaleFactors);
73  fm.registerEvaluator<panzer::Traits::Residual>(eval);
74  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
75 
76  evaluators->push_back(eval);
77 
78  blockIdEvaluated_[block_id] = true;
79  }
80 
81  // if a requested field is found then add in cell avg vector evaluator
82  BlockIdToFields::const_iterator cellAvgVecItr = blockIdToCellAvgVectors_.find(block_id);
83  if(cellAvgVecItr != blockIdToCellAvgVectors_.end() ) {
84  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellAvgVecItr->second));
85 
86  // setup cell average vectors
88  pl.set("Mesh",mesh_);
89  pl.set("IR",ir);
90  pl.set("Field Names",fieldNames);
91  pl.set("Scatter Name", block_id+"_Cell_Avg_Vectors");
92  pl.set("Variable Scale Factors Map", varScaleFactors);
95  fm.registerEvaluator<panzer::Traits::Residual>(eval);
96  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
97 
98  evaluators->push_back(eval);
99 
100  blockIdEvaluated_[block_id] = true;
101  }
102 
103  // if a requested field is found then add in cell quantity evaluator
104  BlockIdToFields::const_iterator cellItr = blockIdToCellFields_.find(block_id);
105  if(cellItr!=blockIdToCellFields_.end() ) {
106  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(cellItr->second));
107 
108  // setup averge cell fields
110  pl.set("Mesh",mesh_);
111  pl.set("Workset Size",worksetsize);
112  pl.set("Field Names",fieldNames);
113  pl.set("Scatter Name", block_id+"_Cell_Fields");
114  pl.set("Variable Scale Factors Map", varScaleFactors);
117  fm.registerEvaluator<panzer::Traits::Residual>(eval);
118  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
119 
120  evaluators->push_back(eval);
121 
122  blockIdEvaluated_[block_id] = true;
123  }
124 
125  // if a requested field is found then add in cell quantity evaluator
126  BlockIdToFields::const_iterator nodalItr = blockIdToNodalFields_.find(block_id);
127  if(nodalItr!=blockIdToNodalFields_.end() ) {
128  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(nodalItr->second));
129 
131 
132  // setup scaling factors as accepted by ScatterFields, if present
133  std::vector<double> scale_factors_(fieldNames->size(),1.0);
134  if (!varScaleFactors.is_null()) {
135  for(size_t f=0; f < fieldNames->size(); ++f) {
136  std::map<std::string,double>::const_iterator f2s_itr = varScaleFactors->find((*fieldNames)[f]);
137  if(f2s_itr != varScaleFactors->end()) {
138  scale_factors_[f] = f2s_itr->second;
139  }
140  }
141  }
142 
143  // setup scatter nodal fields
145  = Teuchos::rcp(new panzer_stk::ScatterFields<panzer::Traits::Residual,panzer::Traits>(block_id+"Nodal_Fields",mesh_,basis,*fieldNames,scale_factors_));
146  fm.registerEvaluator<panzer::Traits::Residual>(eval);
147  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
148 
149  evaluators->push_back(eval);
150 
151  blockIdEvaluated_[block_id] = true;
152  }
153  }
154 
155  evaluators->insert(evaluators->end(),user_evals->begin(),user_evals->end());
156 
157  return evaluators;
158 }
159 
160 #ifdef HAVE_PANZER_EXPLICIT_INSTANTIATION
161 
163 
166 
168 
169 #endif
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T &&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