Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ClosureModel_Factory_Composite_impl.hpp
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 #ifndef PANZER_CLOSURE_MODEL_FACTORY_COMPOSITE_IMPL_HPP
12 #define PANZER_CLOSURE_MODEL_FACTORY_COMPOSITE_IMPL_HPP
13 
14 #include <iostream>
15 #include <sstream>
16 #include <string>
17 #include <vector>
18 #include <list>
19 #include "Panzer_GlobalData.hpp"
22 #include "Teuchos_StandardParameterEntryValidators.hpp"
25 
26 // ********************************************************************
27 template<typename EvalT>
30  m_factories(factories)
31 { }
32 
33 // ********************************************************************
34 template<typename EvalT>
37 buildClosureModels(const std::string& model_id,
38  const Teuchos::ParameterList& models,
41  const Teuchos::ParameterList& default_params,
42  const Teuchos::ParameterList& user_data,
43  const Teuchos::RCP<panzer::GlobalData>& global_data,
45 {
46 
47  using std::string;
48  using std::vector;
49  using Teuchos::RCP;
50  using Teuchos::rcp;
52  using PHX::Evaluator;
53 
55  rcp(new vector< RCP<Evaluator<panzer::Traits> > > );
56 
57  if (!models.isSublist(model_id)) {
58  std::stringstream msg;
59  msg << "Falied to find requested model, \"" << model_id
60  << "\" for equation set:\n" << std::endl;
61  TEUCHOS_TEST_FOR_EXCEPTION(!models.isSublist(model_id), std::logic_error, msg.str());
62  }
63 
64  const ParameterList& my_model = models.sublist(model_id);
65 
66  // pull out the nonlist (not associated with any model) parameters
67  // this will be used by each stored closure model
68  Teuchos::ParameterList nonlist_params(models.name()); // make sure it maintains the models name
69  for (ParameterList::ConstIterator model_it = models.begin();
70  model_it != models.end(); ++model_it) {
71 
72  std::string key = model_it->first;
73  if(!model_it->second.isList())
74  nonlist_params.setEntry(key,model_it->second);
75  }
76 
77  // build a copy of parameter list containing only the closure model of current relevance
78  // with any supplemental non-list information contained in the parameter list
79  ParameterList copy_of_my_model = nonlist_params;
80  copy_of_my_model.sublist(model_id) = my_model; // copy my_model into copy of models
81 
82  // Loop over factories
83  for (std::vector<Teuchos::RCP<panzer::ClosureModelFactory_TemplateManager<panzer::Traits> > >::const_iterator factory = m_factories.begin(); factory != m_factories.end(); ++factory) {
84 
85  (*factory)->getAsObject<EvalT>()->setThrowOnModelNotFound(false);
86  RCP< vector< RCP<Evaluator<panzer::Traits> > > > tmp_evaluators =
87  (*factory)->getAsObject<EvalT>()->buildClosureModels(model_id,copy_of_my_model,fl,ir,default_params,user_data,global_data,fm);
88 
89  if (tmp_evaluators->size() > 0) {
90  for (vector< RCP<Evaluator<panzer::Traits> > >::const_iterator eval = tmp_evaluators->begin(); eval != tmp_evaluators->end(); ++eval)
91  evaluators->push_back(*eval);
92  }
93 
94  }
95 
96 /*
97  // for each model, try each factory until you get a nonnull
98  // return, meaning you have built the evaluators for that model
99  for (ParameterList::ConstIterator model_it = my_model.begin();
100  model_it != my_model.end(); ++model_it) {
101 
102  std::string model_key = model_it->first;
103 
104  // Duplicate models sublist with just the particular model you
105  // want to build
106  ParameterList copy_of_models = nonlist_params;
107  // Teuchos::ParameterList* tmp;
108  // copy_of_models.sublist(model_id).sublist(model_key) = model_it->second.getValue(tmp);
109  copy_of_models.sublist(model_id).setEntry(model_key,model_it->second);
110 
111  std::cout << "COPY OF MODELS = " << model_id << std::endl;
112  copy_of_models.print(std::cout);
113 
114  // Loop over factories
115  for (std::vector<Teuchos::RCP<panzer::ClosureModelFactory_TemplateManager<panzer::Traits> > >::const_iterator factory = m_factories.begin(); factory != m_factories.end(); ++factory) {
116 
117  RCP< vector< RCP<Evaluator<panzer::Traits> > > > tmp_evaluators =
118  (*factory)->getAsObject<EvalT>()->buildClosureModels(model_id,set,copy_of_models,default_params,user_data,global_data,fm);
119 
120  if (tmp_evaluators->size() > 0) {
121 
122  for (vector< RCP<Evaluator<panzer::Traits> > >::const_iterator eval = tmp_evaluators->begin(); eval != tmp_evaluators->end(); ++eval)
123  evaluators->push_back(*eval);
124 
125  }
126 
127  }
128 
129  }
130  */
131 
132  return evaluators;
133 }
134 
135 #endif
const std::string & name() const
ParameterList & setEntry(const std::string &name, U &&entry)
ConstIterator end() const
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 TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
PHX::TemplateManager< TypeSeq, BaseT, ObjectT >::iterator begin()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
ConstIterator begin() const
PHX::TemplateManager< TypeSeq, BaseT, ObjectT >::iterator end()
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
ClosureModelFactoryComposite(const std::vector< Teuchos::RCP< panzer::ClosureModelFactory_TemplateManager< panzer::Traits > > > &factories)