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 //
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_LinearObjFactory_hpp__
44 #define __Panzer_LinearObjFactory_hpp__
45 
46 // Panzer
51 
52 // Phalanx
53 #include "Phalanx_Evaluator.hpp"
54 #include "Phalanx_Evaluator_Derived.hpp"
55 #include "Phalanx_TemplateManager.hpp"
56 
57 // Teuchos
59 
60 // #include "Sacado_mpl_placeholders.hpp"
61 // using namespace Sacado::mpl::placeholders;
62 
63 namespace panzer {
64 
65 class UniqueGlobalIndexerBase; // forward declaration
66 
102 template <typename Traits>
104 public:
105  virtual ~LinearObjFactory() {}
106 
122  template <typename BuilderT>
123  void buildGatherScatterEvaluators(const BuilderT & builder);
124 
131  virtual void readVector(const std::string & identifier,LinearObjContainer & loc,int id) const = 0;
132 
139  virtual void writeVector(const std::string & identifier,const LinearObjContainer & loc,int id) const = 0;
140 
145 
154 
159 
168 
174 
180 
181  virtual void globalToGhostContainer(const LinearObjContainer & container,
182  LinearObjContainer & ghostContainer,int) const = 0;
183  virtual void ghostToGlobalContainer(const LinearObjContainer & ghostContainer,
184  LinearObjContainer & container,int) const = 0;
185 
191  virtual void initializeContainer(int,LinearObjContainer & loc) const = 0;
192 
198  virtual void initializeGhostedContainer(int,LinearObjContainer & loc) const = 0;
199 
226  virtual void adjustForDirichletConditions(const LinearObjContainer & localBCRows,
227  const LinearObjContainer & globalBCRows,
228  LinearObjContainer & ghostedObjs,
229  bool zeroVectorRows=false, bool adjustX=false) const = 0;
230 
239  virtual void applyDirichletBCs(const LinearObjContainer & counter,
240  LinearObjContainer & result) const = 0;
241 
244  virtual Teuchos::MpiComm<int> getComm() const = 0;
245 
247  template <typename EvalT>
249  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterManager_->template getAsBase<EvalT>()->clone(pl)); }
250 
252  template <typename EvalT>
254  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherManager_->template getAsBase<EvalT>()->clone(pl)); }
255 
257  template <typename EvalT>
259  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherTangentManager_->template getAsBase<EvalT>()->clone(pl)); }
260 
262  template <typename EvalT>
264  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherDomainManager_->template getAsBase<EvalT>()->clone(pl)); }
265 
267  template <typename EvalT>
269  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherOrientManager_->template getAsBase<EvalT>()->clone(pl)); }
270 
272  template <typename EvalT>
274  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterDirichletManager_->template getAsBase<EvalT>()->clone(pl)); }
275 
278  { return getRangeGlobalIndexer(); }
279 
282 
285 
286  virtual void beginFill(LinearObjContainer & /* loc */) const {}
287  virtual void endFill(LinearObjContainer & /* loc */) const {}
288 
289 private:
290  typedef PHX::TemplateManager<typename Traits::EvalTypes,
292  PHX::EvaluatorDerived<_,Traits> >
294 
295  // managers to build the scatter/gather evaluators
302 
303  template <typename BuilderT>
306 
308  : builder_(builder) {}
309 
310  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
311  { return builder_->template buildScatter<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 buildScatterDirichlet<EvalT>(); }
323  };
324 
325  template <typename BuilderT>
326  struct Gather_Builder {
328 
330  : builder_(builder) {}
331 
332  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
333  { return builder_->template buildGather<EvalT>(); }
334  };
335 
336  template <typename BuilderT>
339 
341  : builder_(builder) {}
342 
343  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
344  { return builder_->template buildGatherTangent<EvalT>(); }
345  };
346 
347  template <typename BuilderT>
350 
352  : builder_(builder) {}
353 
354  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
355  { return builder_->template buildGatherDomain<EvalT>(); }
356  };
357 
358  template <typename BuilderT>
361 
363  : builder_(builder) {}
364 
365  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
366  { return builder_->template buildGatherOrientation<EvalT>(); }
367  };
368 };
369 
370 template<typename Traits>
371 template <typename BuilderT>
372 inline void LinearObjFactory<Traits>::
373 buildGatherScatterEvaluators(const BuilderT & builder)
374 {
375  using Teuchos::rcp;
376  using Teuchos::rcpFromRef;
377 
378  scatterManager_ = rcp(new Evaluator_TemplateManager);
379  scatterManager_->buildObjects(Scatter_Builder<BuilderT>(rcpFromRef(builder)));
380 
381  scatterDirichletManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
382  scatterDirichletManager_->buildObjects(ScatterDirichlet_Builder<BuilderT>(rcpFromRef(builder)));
383 
384  gatherManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
385  gatherManager_->buildObjects(Gather_Builder<BuilderT>(rcpFromRef(builder)));
386 
387  gatherTangentManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
388  gatherTangentManager_->buildObjects(GatherTangent_Builder<BuilderT>(rcpFromRef(builder)));
389 
390  gatherDomainManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
391  gatherDomainManager_->buildObjects(GatherDomain_Builder<BuilderT>(rcpFromRef(builder)));
392 
393  gatherOrientManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
394  gatherOrientManager_->buildObjects(GatherOrientation_Builder<BuilderT>(rcpFromRef(builder)));
395 }
396 
397 }
398 
399 #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)
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 Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > getDomainGlobalIndexer() const =0
Get the domain global indexer object associated with this factory.
virtual Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > getRangeGlobalIndexer() const =0
Get the range global indexer object associated with this factory.
virtual void writeVector(const std::string &identifier, const LinearObjContainer &loc, int id) const =0
GatherTangent_Builder(const Teuchos::RCP< const BuilderT > &builder)
virtual Teuchos::RCP< WriteVector_GlobalEvaluationData > buildWriteDomainContainer() const =0
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< 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
PANZER_DEPRECATED Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > getUniqueGlobalIndexerBase() const
Get the range global indexer object associated with this factory.