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 GlobalIndexer; // 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 
281 
282  virtual void beginFill(LinearObjContainer & /* loc */) const {}
283  virtual void endFill(LinearObjContainer & /* loc */) const {}
284 
285 private:
286  typedef PHX::TemplateManager<typename Traits::EvalTypes,
288  PHX::EvaluatorDerived<_,Traits> >
290 
291  // managers to build the scatter/gather evaluators
298 
299  template <typename BuilderT>
302 
304  : builder_(builder) {}
305 
306  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
307  { return builder_->template buildScatter<EvalT>(); }
308  };
309 
310  template <typename BuilderT>
313 
315  : builder_(builder) {}
316 
317  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
318  { return builder_->template buildScatterDirichlet<EvalT>(); }
319  };
320 
321  template <typename BuilderT>
322  struct Gather_Builder {
324 
326  : builder_(builder) {}
327 
328  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
329  { return builder_->template buildGather<EvalT>(); }
330  };
331 
332  template <typename BuilderT>
335 
337  : builder_(builder) {}
338 
339  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
340  { return builder_->template buildGatherTangent<EvalT>(); }
341  };
342 
343  template <typename BuilderT>
346 
348  : builder_(builder) {}
349 
350  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
351  { return builder_->template buildGatherDomain<EvalT>(); }
352  };
353 
354  template <typename BuilderT>
357 
359  : builder_(builder) {}
360 
361  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
362  { return builder_->template buildGatherOrientation<EvalT>(); }
363  };
364 };
365 
366 template<typename Traits>
367 template <typename BuilderT>
368 inline void LinearObjFactory<Traits>::
369 buildGatherScatterEvaluators(const BuilderT & builder)
370 {
371  using Teuchos::rcp;
372  using Teuchos::rcpFromRef;
373 
374  scatterManager_ = rcp(new Evaluator_TemplateManager);
375  scatterManager_->buildObjects(Scatter_Builder<BuilderT>(rcpFromRef(builder)));
376 
377  scatterDirichletManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
378  scatterDirichletManager_->buildObjects(ScatterDirichlet_Builder<BuilderT>(rcpFromRef(builder)));
379 
380  gatherManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
381  gatherManager_->buildObjects(Gather_Builder<BuilderT>(rcpFromRef(builder)));
382 
383  gatherTangentManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
384  gatherTangentManager_->buildObjects(GatherTangent_Builder<BuilderT>(rcpFromRef(builder)));
385 
386  gatherDomainManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
387  gatherDomainManager_->buildObjects(GatherDomain_Builder<BuilderT>(rcpFromRef(builder)));
388 
389  gatherOrientManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
390  gatherOrientManager_->buildObjects(GatherOrientation_Builder<BuilderT>(rcpFromRef(builder)));
391 }
392 
393 }
394 
395 #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 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< 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