Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_LinearObjFactory.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_LinearObjFactory_hpp__
12 #define __Panzer_LinearObjFactory_hpp__
13 
14 // Panzer
17 
20 
21 // Phalanx
22 #include "Phalanx_Evaluator.hpp"
23 #include "Phalanx_Evaluator_Derived.hpp"
24 #include "Phalanx_TemplateManager.hpp"
25 
26 // Teuchos
28 
29 // #include "Sacado_mpl_placeholders.hpp"
30 // using namespace Sacado::mpl::placeholders;
31 
32 namespace panzer {
33 
34 class GlobalIndexer; // forward declaration
35 
71 template <typename Traits>
73 public:
74  virtual ~LinearObjFactory() {}
75 
91  template <typename BuilderT>
92  void buildGatherScatterEvaluators(const BuilderT & builder);
93 
100  virtual void readVector(const std::string & identifier,LinearObjContainer & loc,int id) const = 0;
101 
108  virtual void writeVector(const std::string & identifier,const LinearObjContainer & loc,int id) const = 0;
109 
114 
123 
128 
137 
143 
144 #ifdef PANZER_HAVE_EPETRA_STACK
145 
149  virtual Teuchos::RCP<WriteVector_GlobalEvaluationData> buildWriteDomainContainer() const = 0;
150 #endif
151 
152  virtual void globalToGhostContainer(const LinearObjContainer & container,
153  LinearObjContainer & ghostContainer,int) const = 0;
154  virtual void ghostToGlobalContainer(const LinearObjContainer & ghostContainer,
155  LinearObjContainer & container,int) const = 0;
156 
162  virtual void initializeContainer(int,LinearObjContainer & loc) const = 0;
163 
169  virtual void initializeGhostedContainer(int,LinearObjContainer & loc) const = 0;
170 
197  virtual void adjustForDirichletConditions(const LinearObjContainer & localBCRows,
198  const LinearObjContainer & globalBCRows,
199  LinearObjContainer & ghostedObjs,
200  bool zeroVectorRows=false, bool adjustX=false) const = 0;
201 
210  virtual void applyDirichletBCs(const LinearObjContainer & counter,
211  LinearObjContainer & result) const = 0;
212 
215  virtual Teuchos::MpiComm<int> getComm() const = 0;
216 
218  template <typename EvalT>
220  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterManager_->template getAsBase<EvalT>()->clone(pl)); }
221 
223  template <typename EvalT>
225  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherManager_->template getAsBase<EvalT>()->clone(pl)); }
226 
228  template <typename EvalT>
230  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherTangentManager_->template getAsBase<EvalT>()->clone(pl)); }
231 
233  template <typename EvalT>
235  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherDomainManager_->template getAsBase<EvalT>()->clone(pl)); }
236 
238  template <typename EvalT>
240  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherOrientManager_->template getAsBase<EvalT>()->clone(pl)); }
241 
243  template <typename EvalT>
245  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterDirichletManager_->template getAsBase<EvalT>()->clone(pl)); }
246 
249 
252 
253  virtual void beginFill(LinearObjContainer & /* loc */) const {}
254  virtual void endFill(LinearObjContainer & /* loc */) const {}
255 
256 private:
257  typedef PHX::TemplateManager<typename Traits::EvalTypes,
261 
262  // managers to build the scatter/gather evaluators
269 
270  template <typename BuilderT>
273 
275  : builder_(builder) {}
276 
277  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
278  { return builder_->template buildScatter<EvalT>(); }
279  };
280 
281  template <typename BuilderT>
284 
286  : builder_(builder) {}
287 
288  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
289  { return builder_->template buildScatterDirichlet<EvalT>(); }
290  };
291 
292  template <typename BuilderT>
293  struct Gather_Builder {
295 
297  : builder_(builder) {}
298 
299  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
300  { return builder_->template buildGather<EvalT>(); }
301  };
302 
303  template <typename BuilderT>
306 
308  : builder_(builder) {}
309 
310  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
311  { return builder_->template buildGatherTangent<EvalT>(); }
312  };
313 
314  template <typename BuilderT>
317 
319  : builder_(builder) {}
320 
321  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
322  { return builder_->template buildGatherDomain<EvalT>(); }
323  };
324 
325  template <typename BuilderT>
328 
330  : builder_(builder) {}
331 
332  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
333  { return builder_->template buildGatherOrientation<EvalT>(); }
334  };
335 };
336 
337 template<typename Traits>
338 template <typename BuilderT>
339 inline void LinearObjFactory<Traits>::
340 buildGatherScatterEvaluators(const BuilderT & builder)
341 {
342  using Teuchos::rcp;
343  using Teuchos::rcpFromRef;
344 
345  scatterManager_ = rcp(new Evaluator_TemplateManager);
346  scatterManager_->buildObjects(Scatter_Builder<BuilderT>(rcpFromRef(builder)));
347 
348  scatterDirichletManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
349  scatterDirichletManager_->buildObjects(ScatterDirichlet_Builder<BuilderT>(rcpFromRef(builder)));
350 
351  gatherManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
352  gatherManager_->buildObjects(Gather_Builder<BuilderT>(rcpFromRef(builder)));
353 
354  gatherTangentManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
355  gatherTangentManager_->buildObjects(GatherTangent_Builder<BuilderT>(rcpFromRef(builder)));
356 
357  gatherDomainManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
358  gatherDomainManager_->buildObjects(GatherDomain_Builder<BuilderT>(rcpFromRef(builder)));
359 
360  gatherOrientManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
361  gatherOrientManager_->buildObjects(GatherOrientation_Builder<BuilderT>(rcpFromRef(builder)));
362 }
363 
364 }
365 
366 #endif // __Panzer_LinearObjFactory_hpp__
Teuchos::RCP< panzer::CloneableEvaluator > build() const
virtual Teuchos::MpiComm< int > getComm() const =0
Teuchos::RCP< Evaluator_TemplateManager > gatherManager_
GatherDomain_Builder(const Teuchos::RCP< const BuilderT > &builder)
virtual Teuchos::RCP< const panzer::GlobalIndexer > getRangeGlobalIndexer() const =0
Get the range global indexer object associated with this factory.
Teuchos::RCP< Evaluator_TemplateManager > scatterDirichletManager_
GatherOrientation_Builder(const Teuchos::RCP< const BuilderT > &builder)
Teuchos::RCP< panzer::CloneableEvaluator > build() const
Teuchos::RCP< panzer::CloneableEvaluator > build() const
Scatter_Builder(const Teuchos::RCP< const BuilderT > &builder)
virtual void adjustForDirichletConditions(const LinearObjContainer &localBCRows, const LinearObjContainer &globalBCRows, LinearObjContainer &ghostedObjs, bool zeroVectorRows=false, bool adjustX=false) const =0
Teuchos::RCP< PHX::Evaluator< Traits > > buildGatherDomain(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.
Teuchos::RCP< PHX::Evaluator< Traits > > buildGatherTangent(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.
virtual Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > buildReadOnlyDomainContainer() const =0
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveGhostedLinearObjContainer() const =0
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we&#39;re performing.
Teuchos::RCP< Evaluator_TemplateManager > gatherTangentManager_
Teuchos::RCP< PHX::Evaluator< Traits > > buildScatterDirichlet(const Teuchos::ParameterList &pl) const
Use preconstructed dirichlet scatter evaluators.
virtual void initializeContainer(int, LinearObjContainer &loc) const =0
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void applyDirichletBCs(const LinearObjContainer &counter, LinearObjContainer &result) const =0
virtual void endFill(LinearObjContainer &) const
virtual Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const =0
Teuchos::RCP< Evaluator_TemplateManager > gatherOrientManager_
Teuchos::RCP< PHX::Evaluator< Traits > > buildGather(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.
PHX::TemplateManager< typename Traits::EvalTypes, panzer::CloneableEvaluator, PHX::EvaluatorDerived< _, Traits > > Evaluator_TemplateManager
virtual void writeVector(const std::string &identifier, const LinearObjContainer &loc, int id) const =0
GatherTangent_Builder(const Teuchos::RCP< const BuilderT > &builder)
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const =0
virtual void beginFill(LinearObjContainer &) const
Sacado::mpl::vector< Residual, Jacobian, Tangent, Hessian > EvalTypes
Teuchos::RCP< PHX::Evaluator< Traits > > buildGatherOrientation(const Teuchos::ParameterList &pl) const
Use preconstructed gather evaluators.
Teuchos::RCP< panzer::CloneableEvaluator > build() const
Teuchos::RCP< Evaluator_TemplateManager > scatterManager_
Teuchos::RCP< panzer::CloneableEvaluator > build() const
Gather_Builder(const Teuchos::RCP< const BuilderT > &builder)
virtual Teuchos::RCP< const panzer::GlobalIndexer > getDomainGlobalIndexer() const =0
Get the domain global indexer object associated with this factory.
virtual Teuchos::RCP< LinearObjContainer > buildPrimitiveLinearObjContainer() const =0
virtual void globalToGhostContainer(const LinearObjContainer &container, LinearObjContainer &ghostContainer, int) const =0
virtual void initializeGhostedContainer(int, LinearObjContainer &loc) const =0
virtual Teuchos::RCP< LinearObjContainer > buildGhostedLinearObjContainer() const =0
Teuchos::RCP< PHX::Evaluator< Traits > > buildScatter(const Teuchos::ParameterList &pl) const
Use preconstructed scatter evaluators.
void buildGatherScatterEvaluators(const BuilderT &builder)
Teuchos::RCP< Evaluator_TemplateManager > gatherDomainManager_
ScatterDirichlet_Builder(const Teuchos::RCP< const BuilderT > &builder)
Teuchos::RCP< panzer::CloneableEvaluator > build() const
Non-templated empty base class for template managers.
virtual void ghostToGlobalContainer(const LinearObjContainer &ghostContainer, LinearObjContainer &container, int) const =0