Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_PhysicsBlock.hpp
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#ifndef PANZER_PHYSICS_BLOCK_HPP
44#define PANZER_PHYSICS_BLOCK_HPP
45
46#include <string>
47#include <vector>
48#include <map>
49
50#include "Teuchos_RCP.hpp"
51#include "Phalanx_FieldManager.hpp"
52#include "Panzer_Traits.hpp"
53#include "Panzer_CellData.hpp"
60
61namespace Teuchos {
62 class ParameterList;
63}
64
65namespace shards {
66 class CellTopology;
67}
68
69namespace panzer {
70 class PureBasis;
71 class IntegrationRule;
72 struct EquationSetFactory;
73 struct GlobalData;
74 class PhysicsBlock;
75}
76
77namespace panzer {
78
79
83 void buildPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
84 const std::map<std::string,Teuchos::RCP<const shards::CellTopology> >& block_ids_to_cell_topo,
85 const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
86 const int default_integration_order,
87 const std::size_t workset_size,
88 const Teuchos::RCP<const panzer::EquationSetFactory>& eqset_factory,
89 const Teuchos::RCP<panzer::GlobalData>& global_data,
90 const bool build_transient_support,
91 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks,
92 const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
93
100 void readPhysicsBlocks(const std::map<std::string,std::string>& block_ids_to_physics_ids,
101 const Teuchos::RCP<Teuchos::ParameterList>& physics_blocks_plist,
102 std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physicsBlocks);
103
111 Teuchos::RCP<panzer::PhysicsBlock> findPhysicsBlock(const std::string element_block_id,
112 const std::vector<Teuchos::RCP<panzer::PhysicsBlock> > & physics_blocks,
113 bool throw_on_failure = true);
114
117
118 public:
120 explicit PhysicsBlock()
122 m_active_evaluation_types(Sacado::mpl::size<panzer::Traits::EvalTypes>::value,true)
123 { std::cout << "WARNING: Default constructor for panzer::PhysicsBlock is for testing purposes only!" << std::endl; }
124
127 PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
128 const std::string & element_block_id,
129 const int default_integration_order,
130 const panzer::CellData & cell_data,
131 const Teuchos::RCP<const panzer::EquationSetFactory>& factory,
132 const Teuchos::RCP<panzer::GlobalData>& global_data,
133 const bool build_transient_support,
134 const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
135
141 PhysicsBlock(const Teuchos::RCP<Teuchos::ParameterList>& physics_block_plist,
142 const std::string & element_block_id);
143
145 const panzer::CellData & cell_data);
146
151 PhysicsBlock(const std::string & element_block_id,
152 const std::string & physics_block_id,
153 const int integration_order,
154 const panzer::CellData & cell_data,
155 const Teuchos::RCP<panzer::GlobalData>& global_data,
156 const Teuchos::RCP<panzer::PureBasis> & fields);
157
161 void initialize(const int default_integration_order,
162 const bool build_transient_support,
163 const panzer::CellData & cell_data,
164 const Teuchos::RCP<const panzer::EquationSetFactory>& factory,
165 const Teuchos::RCP<panzer::GlobalData>& global_data,
166 const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
167
169 void setActiveEvaluationTypes(const std::vector<bool>& aet);
170
173
175 const Teuchos::ParameterList& user_data) const;
176
179 const Teuchos::ParameterList& user_data) const;
180
182 const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
183 const Teuchos::ParameterList& user_data) const;
184
187 const Teuchos::ParameterList& user_data) const;
188
191 const Teuchos::ParameterList& models,
192 const Teuchos::ParameterList& user_data) const;
193
196 const std::string& model_name,
197 const Teuchos::ParameterList& models,
199 const Teuchos::ParameterList& user_data) const;
200
203 const std::string& model_name,
204 const Teuchos::ParameterList& models,
205 const Teuchos::ParameterList& user_data) const;
206
207 template<typename EvalT>
209 const Teuchos::ParameterList& user_data) const;
210
211 template<typename EvalT>
214 const Teuchos::ParameterList& user_data) const;
215
216 template<typename EvalT>
218 const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
219 const Teuchos::ParameterList& user_data) const;
220
221 template<typename EvalT>
224 const Teuchos::ParameterList& user_data) const;
225
226 template<typename EvalT>
229 const Teuchos::ParameterList& models,
230 const Teuchos::ParameterList& user_data) const;
231
232 template<typename EvalT>
235 const std::string& model_name,
236 const Teuchos::ParameterList& models,
238 const Teuchos::ParameterList& user_data) const;
239
240 const std::vector<std::string>& getDOFNames() const;
241 const std::vector<StrPureBasisPair>& getProvidedDOFs() const;
242
243 const std::vector<std::vector<std::string> > & getCoordinateDOFs() const;
244
246 const std::vector<StrPureBasisPair>& getTangentFields() const;
247
251
253 const std::map<std::string,Teuchos::RCP<panzer::PureBasis> >& getBases() const;
254
256 const std::map<int,Teuchos::RCP<panzer::IntegrationRule> >& getIntegrationRules() const;
257
258 const shards::CellTopology getBaseCellTopology() const;
259
260 std::string physicsBlockID() const;
261 std::string elementBlockID() const;
262
263 const panzer::CellData & cellData() const;
264
269 Teuchos::RCP<PhysicsBlock> copyWithCellData(const panzer::CellData & cell_data) const;
270
271 Teuchos::RCP<panzer::GlobalData> globalData() const;
272
273 Teuchos::RCP<const FieldLibrary> getFieldLibrary() const
274 { return m_field_lib.getConst(); }
275
276 Teuchos::RCP<const FieldLibraryBase> getFieldLibraryBase() const
277 { return m_field_lib.getConst(); }
278
279 // return the Physics Block parameter list
280 Teuchos::RCP<const Teuchos::ParameterList> getParameterList() const
281 { return m_input_parameters; }
282
283 protected:
284 void initialize(const Teuchos::RCP<Teuchos::ParameterList>& input_parameters,
285 const int& default_integration_order,
286 const std::string & element_block_id,
287 const panzer::CellData & cell_data,
288 const bool build_transient_support,
289 const std::vector<std::string>& tangent_param_names = std::vector<std::string>());
290
291 std::string m_physics_id;
296 Teuchos::RCP<Teuchos::ParameterList> m_input_parameters;
298 Teuchos::RCP<panzer::GlobalData> m_global_data;
299
300 std::vector<std::string> m_dof_names;
301 std::vector<StrPureBasisPair> m_provided_dofs;
302 std::vector<StrPureBasisPair> m_tangent_fields;
303 std::vector<std::vector<std::string> > m_coordinate_dofs; // coordinate DOFs (defines them)
304
306 std::map<std::string,Teuchos::RCP<panzer::PureBasis> > m_bases;
308 std::map<int,Teuchos::RCP<panzer::IntegrationRule> > m_integration_rules;
309
310 std::vector< Teuchos::RCP<panzer::EquationSet_TemplateManager<panzer::Traits> > > m_equation_sets;
311 Teuchos::RCP<FieldLibrary> m_field_lib;
312 Teuchos::RCP<const panzer::EquationSetFactory> m_eqset_factory;
313
315 std::vector<bool> m_active_evaluation_types;
316 };
317
318}
319
320// ************************************************************
321// template implementations
322// ************************************************************
323
324template<typename EvalT>
326 const Teuchos::ParameterList& user_data) const
327{
328 using std::vector;
329 using Teuchos::RCP;
331
332 // Loop over equation set template managers
333 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
334 eq_set = m_equation_sets.begin();
335 int idx = 0;
336 for (;eq_set != m_equation_sets.end(); ++eq_set,++idx) {
337 if (m_active_evaluation_types[idx]) {
339
340 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
341 eqstm.getAsObject<EvalT>()->buildAndRegisterEquationSetEvaluators(fm, *m_field_lib, user_data);
342 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
343 }
344 }
345}
346
347template<typename EvalT>
350 const Teuchos::ParameterList& user_data) const
351{
352 using std::vector;
353 using Teuchos::RCP;
355
356 // Loop over equation set template managers
357 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
358 eq_set = m_equation_sets.begin();
359 int idx = 0;
360 for (;eq_set != m_equation_sets.end(); ++eq_set,++idx) {
361 if (m_active_evaluation_types[idx]) {
362
364
365 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
366 eqstm.getAsObject<EvalT>()->buildAndRegisterGatherAndOrientationEvaluators(fm,*m_field_lib,lof,user_data);
367 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
368 }
369 }
370}
371
372template<typename EvalT>
374 const Teuchos::Ptr<const panzer::LinearObjFactory<panzer::Traits> > & lof,
375 const Teuchos::ParameterList& user_data) const
376{
377 using std::vector;
378 using Teuchos::RCP;
380
381 // Loop over equation set template managers
382 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
383 eq_set = m_equation_sets.begin();
384 for (;eq_set != m_equation_sets.end(); ++eq_set) {
386
387 // Loop over integration rules
388 for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
389 ir_iter != m_integration_rules.end(); ++ ir_iter) {
390
391 Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
392
393 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
394 eqstm.getAsObject<EvalT>()->buildAndRegisterDOFProjectionsToIPEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,lof,user_data);
395 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
396 }
397
398 }
399}
400
401template<typename EvalT>
404 const Teuchos::ParameterList& user_data) const
405{
406 using std::vector;
407 using Teuchos::RCP;
409
410 // Loop over equation set template managers
411 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
412 eq_set = m_equation_sets.begin();
413 for (;eq_set != m_equation_sets.end(); ++eq_set) {
414
416
417 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
418 eqstm.getAsObject<EvalT>()->buildAndRegisterScatterEvaluators(fm,*m_field_lib,lof,user_data);
419 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
420 }
421}
422
423template<typename EvalT>
426 const Teuchos::ParameterList& models,
427 const Teuchos::ParameterList& user_data) const
428{
429 using std::vector;
430 using Teuchos::RCP;
432
433 // Loop over equation set template managers
434 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
435 eq_set = m_equation_sets.begin();
436 for (;eq_set != m_equation_sets.end(); ++eq_set) {
437
439
440 // Loop over integration rules
441 for (std::map<int,Teuchos::RCP<panzer::IntegrationRule> >::const_iterator ir_iter = m_integration_rules.begin();
442 ir_iter != m_integration_rules.end(); ++ ir_iter) {
443
444 Teuchos::RCP<panzer::IntegrationRule> ir = ir_iter->second;
445
446 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
447 eqstm.getAsObject<EvalT>()->buildAndRegisterClosureModelEvaluators(fm,*m_field_lib->buildFieldLayoutLibrary(*ir),ir,factory,models,user_data);
448 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
449 }
450
451 }
452}
453
454template<typename EvalT>
457 const std::string& model_name,
458 const Teuchos::ParameterList& models,
460 const Teuchos::ParameterList& user_data) const
461{
462 using std::vector;
463 using Teuchos::RCP;
465
466 // Loop over equation set template managers
467 vector< RCP<EquationSet_TemplateManager<panzer::Traits> > >::const_iterator
468 eq_set = m_equation_sets.begin();
469 for (;eq_set != m_equation_sets.end(); ++eq_set) {
470 std::vector<StrBasisPair> providedDOFs;
471
473
474 const int di = eqstm.getAsObject<EvalT>()->setDetailsIndex(this->getDetailsIndex());
475 eqstm.getAsObject<EvalT>()->buildAndRegisterInitialConditionEvaluators(fm, *m_field_lib, factory, model_name, models, lof, user_data);
476 eqstm.getAsObject<EvalT>()->setDetailsIndex(di);
477 }
478}
479
480#endif
Data for determining cell topology and dimensionality.
int getDetailsIndex() const
Get the WorksetDetails index.
int setDetailsIndex(const int details_index)
Object that contains information on the physics and discretization of a block of elements with the SA...
void initialize(const int default_integration_order, const bool build_transient_support, const panzer::CellData &cell_data, const Teuchos::RCP< const panzer::EquationSetFactory > &factory, const Teuchos::RCP< panzer::GlobalData > &global_data, const std::vector< std::string > &tangent_param_names=std::vector< std::string >())
const std::vector< StrPureBasisPair > & getTangentFields() const
Returns list of tangent fields from DOFs and tangent param names.
Teuchos::RCP< FieldLibrary > m_field_lib
const std::map< int, Teuchos::RCP< panzer::IntegrationRule > > & getIntegrationRules() const
Returns the unique set of point rules, key is the unique panzer::PointRule::name()
std::string elementBlockID() const
void buildAndRegisterEquationSetEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
std::vector< StrPureBasisPair > m_provided_dofs
void buildAndRegisterGatherAndOrientationEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
void buildAndRegisterEquationSetEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::ParameterList &user_data) const
std::vector< StrPureBasisPair > m_tangent_fields
Teuchos::RCP< const FieldLibraryBase > getFieldLibraryBase() const
void buildAndRegisterDOFProjectionsToIPEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
std::vector< std::vector< std::string > > m_coordinate_dofs
void buildAndRegisterInitialConditionEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const std::string &model_name, const Teuchos::ParameterList &models, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::vector< std::string > m_dof_names
void buildAndRegisterScatterEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::vector< Teuchos::RCP< panzer::EquationSet_TemplateManager< panzer::Traits > > > m_equation_sets
Teuchos::RCP< const FieldLibrary > getFieldLibrary() const
void buildPhysicsBlocks(const std::map< std::string, std::string > &block_ids_to_physics_ids, const std::map< std::string, Teuchos::RCP< const shards::CellTopology > > &block_ids_to_cell_topo, const Teuchos::RCP< Teuchos::ParameterList > &physics_blocks_plist, const int default_integration_order, const std::size_t workset_size, const Teuchos::RCP< const panzer::EquationSetFactory > &eqset_factory, const Teuchos::RCP< panzer::GlobalData > &global_data, const bool build_transient_support, std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< std::string > &tangent_param_names=std::vector< std::string >())
Nonmember function for building the physics blocks from a Teuchos::ParameterList for a given list of ...
Teuchos::RCP< PhysicsBlock > copyWithCellData(const panzer::CellData &cell_data) const
Teuchos::RCP< panzer::GlobalData > m_global_data
Teuchos::RCP< panzer::PhysicsBlock > findPhysicsBlock(const std::string element_block_id, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physics_blocks, bool throw_on_failure=true)
Nonmember function for searching and returning a spcific physics block given an element block id....
WorksetNeeds getWorksetNeeds() const
void buildAndRegisterClosureModelEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
const shards::CellTopology getBaseCellTopology() const
Teuchos::RCP< panzer::GlobalData > globalData() const
void buildAndRegisterScatterEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
const std::vector< std::string > & getDOFNames() const
Teuchos::RCP< Teuchos::ParameterList > m_input_parameters
store the input parameter list for copy ctors
void buildAndRegisterClosureModelEvaluators(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const Teuchos::ParameterList &models, const Teuchos::ParameterList &user_data) const
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Used to save memory by disabling unneeded evaluation types.
const std::map< std::string, Teuchos::RCP< panzer::PureBasis > > & getBases() const
Returns the unique set of bases, key is the unique panzer::PureBasis::name() of the basis.
void readPhysicsBlocks(const std::map< std::string, std::string > &block_ids_to_physics_ids, const Teuchos::RCP< Teuchos::ParameterList > &physics_blocks_plist, std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks)
Nonmember function for reading and constructing physics blocks from a Teuchos::ParameterList for a gi...
void activateAllEvaluationTypes()
Used to reactivate all evaluation types if some were temporarily disabled with a call to setActiveEva...
std::map< std::string, Teuchos::RCP< panzer::PureBasis > > m_bases
map of unique bases, key is the panzer::PureBasis::name() corresponding to its value
const panzer::CellData & cellData() const
std::vector< bool > m_active_evaluation_types
Returns true for evaluation types that are active.
void buildAndRegisterDOFProjectionsToIPEvaluators(PHX::FieldManager< panzer::Traits > &fm, const Teuchos::Ptr< const panzer::LinearObjFactory< panzer::Traits > > &lof, const Teuchos::ParameterList &user_data) const
const std::vector< StrPureBasisPair > & getProvidedDOFs() const
void buildAndRegisterInitialConditionEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &factory, const std::string &model_name, const Teuchos::ParameterList &models, const panzer::LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::map< int, Teuchos::RCP< panzer::IntegrationRule > > m_integration_rules
map of unique integration rules, key is panzer::IntegrationRule::order() corresponding to its value
void buildAndRegisterGatherAndOrientationEvaluatorsForType(PHX::FieldManager< panzer::Traits > &fm, const LinearObjFactory< panzer::Traits > &lof, const Teuchos::ParameterList &user_data) const
std::string physicsBlockID() const
const std::vector< std::vector< std::string > > & getCoordinateDOFs() const
Teuchos::RCP< const panzer::EquationSetFactory > m_eqset_factory