Panzer  Version of the Day
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< >
52 Teuchos::RCP< std::vector< Teuchos::RCP<PHX::Evaluator<panzer::Traits> > > >
54 buildClosureModels(const std::string& model_id,
55  const Teuchos::ParameterList& models,
57  const Teuchos::RCP<panzer::IntegrationRule>& ir,
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;
65  using Teuchos::ParameterList;
66  using PHX::Evaluator;
67 
68  // build user evaluators
69  RCP< std::vector< RCP<Evaluator<panzer::Traits> > > > user_evals =
70  userCMF_->buildClosureModels(model_id,models,fl,ir,default_params,user_data,global_data,fm);
71 
72  // add user evaluators to evaluator list
73  RCP< std::vector< RCP<Evaluator<panzer::Traits> > > > evaluators =
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
85  Teuchos::RCP<std::map<std::string,double>> varScaleFactors;
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
97  Teuchos::ParameterList pl;
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);
103  Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
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
119  Teuchos::ParameterList pl;
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);
125  Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
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
141  Teuchos::ParameterList pl;
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  Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
148  fm.registerEvaluator<panzer::Traits::Residual>(eval);
149  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
150 
151  evaluators->push_back(eval);
152 
153  blockIdEvaluated_[block_id] = true;
154  }
155 
156  // if a requested field is found then add in cell quantity evaluator
157  BlockIdToFields::const_iterator nodalItr = blockIdToNodalFields_.find(block_id);
158  if(nodalItr!=blockIdToNodalFields_.end() ) {
159  Teuchos::RCP<std::vector<std::string> > fieldNames = Teuchos::rcp(new std::vector<std::string>(nodalItr->second));
160 
161  Teuchos::RCP<const panzer::PureBasis> basis = Teuchos::rcp(new panzer::PureBasis("HGrad",1,ir->workset_size,ir->topology));
162 
163  // setup scatter nodal fields
164  Teuchos::RCP<PHX::Evaluator<panzer::Traits> > eval
165  = Teuchos::rcp(new panzer_stk::ScatterFields<panzer::Traits::Residual,panzer::Traits>(block_id+"Nodal_Fields",mesh_,basis,*fieldNames));
166  fm.registerEvaluator<panzer::Traits::Residual>(eval);
167  fm.requireField<panzer::Traits::Residual>(*eval->evaluatedFields()[0]);
168 
169  evaluators->push_back(eval);
170 
171  blockIdEvaluated_[block_id] = true;
172  }
173  }
174 
175  evaluators->insert(evaluators->end(),user_evals->begin(),user_evals->end());
176 
177  return evaluators;
178 }
179 
180 #ifdef HAVE_PANZER_EXPLICIT_INSTANTIATION
181 
183 
186 
188 
189 #endif
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
#define PANZER_INSTANTIATE_TEMPLATE_CLASS_ONE_T(name)
Description and data layouts associated with a particular basis.