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
49 
52 
53 // Phalanx
54 #include "Phalanx_Evaluator.hpp"
55 #include "Phalanx_Evaluator_Derived.hpp"
56 #include "Phalanx_TemplateManager.hpp"
57 
58 // Teuchos
60 
61 // #include "Sacado_mpl_placeholders.hpp"
62 // using namespace Sacado::mpl::placeholders;
63 
64 namespace panzer {
65 
66 class GlobalIndexer; // forward declaration
67 
103 template <typename Traits>
105 public:
106  virtual ~LinearObjFactory() {}
107 
123  template <typename BuilderT>
124  void buildGatherScatterEvaluators(const BuilderT & builder);
125 
132  virtual void readVector(const std::string & identifier,LinearObjContainer & loc,int id) const = 0;
133 
140  virtual void writeVector(const std::string & identifier,const LinearObjContainer & loc,int id) const = 0;
141 
146 
155 
160 
169 
175 
176 #ifdef PANZER_HAVE_EPETRA_STACK
177 
181  virtual Teuchos::RCP<WriteVector_GlobalEvaluationData> buildWriteDomainContainer() const = 0;
182 #endif
183 
184  virtual void globalToGhostContainer(const LinearObjContainer & container,
185  LinearObjContainer & ghostContainer,int) const = 0;
186  virtual void ghostToGlobalContainer(const LinearObjContainer & ghostContainer,
187  LinearObjContainer & container,int) const = 0;
188 
194  virtual void initializeContainer(int,LinearObjContainer & loc) const = 0;
195 
201  virtual void initializeGhostedContainer(int,LinearObjContainer & loc) const = 0;
202 
229  virtual void adjustForDirichletConditions(const LinearObjContainer & localBCRows,
230  const LinearObjContainer & globalBCRows,
231  LinearObjContainer & ghostedObjs,
232  bool zeroVectorRows=false, bool adjustX=false) const = 0;
233 
242  virtual void applyDirichletBCs(const LinearObjContainer & counter,
243  LinearObjContainer & result) const = 0;
244 
247  virtual Teuchos::MpiComm<int> getComm() const = 0;
248 
250  template <typename EvalT>
252  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterManager_->template getAsBase<EvalT>()->clone(pl)); }
253 
255  template <typename EvalT>
257  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherManager_->template getAsBase<EvalT>()->clone(pl)); }
258 
260  template <typename EvalT>
262  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherTangentManager_->template getAsBase<EvalT>()->clone(pl)); }
263 
265  template <typename EvalT>
267  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherDomainManager_->template getAsBase<EvalT>()->clone(pl)); }
268 
270  template <typename EvalT>
272  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(gatherOrientManager_->template getAsBase<EvalT>()->clone(pl)); }
273 
275  template <typename EvalT>
277  { return Teuchos::rcp_dynamic_cast<PHX::Evaluator<Traits> >(scatterDirichletManager_->template getAsBase<EvalT>()->clone(pl)); }
278 
281 
284 
285  virtual void beginFill(LinearObjContainer & /* loc */) const {}
286  virtual void endFill(LinearObjContainer & /* loc */) const {}
287 
288 private:
289  typedef PHX::TemplateManager<typename Traits::EvalTypes,
293 
294  // managers to build the scatter/gather evaluators
301 
302  template <typename BuilderT>
305 
307  : builder_(builder) {}
308 
309  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
310  { return builder_->template buildScatter<EvalT>(); }
311  };
312 
313  template <typename BuilderT>
316 
318  : builder_(builder) {}
319 
320  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
321  { return builder_->template buildScatterDirichlet<EvalT>(); }
322  };
323 
324  template <typename BuilderT>
325  struct Gather_Builder {
327 
329  : builder_(builder) {}
330 
331  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
332  { return builder_->template buildGather<EvalT>(); }
333  };
334 
335  template <typename BuilderT>
338 
340  : builder_(builder) {}
341 
342  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
343  { return builder_->template buildGatherTangent<EvalT>(); }
344  };
345 
346  template <typename BuilderT>
349 
351  : builder_(builder) {}
352 
353  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
354  { return builder_->template buildGatherDomain<EvalT>(); }
355  };
356 
357  template <typename BuilderT>
360 
362  : builder_(builder) {}
363 
364  template <typename EvalT> Teuchos::RCP<panzer::CloneableEvaluator> build() const
365  { return builder_->template buildGatherOrientation<EvalT>(); }
366  };
367 };
368 
369 template<typename Traits>
370 template <typename BuilderT>
371 inline void LinearObjFactory<Traits>::
372 buildGatherScatterEvaluators(const BuilderT & builder)
373 {
374  using Teuchos::rcp;
375  using Teuchos::rcpFromRef;
376 
377  scatterManager_ = rcp(new Evaluator_TemplateManager);
378  scatterManager_->buildObjects(Scatter_Builder<BuilderT>(rcpFromRef(builder)));
379 
380  scatterDirichletManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
381  scatterDirichletManager_->buildObjects(ScatterDirichlet_Builder<BuilderT>(rcpFromRef(builder)));
382 
383  gatherManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
384  gatherManager_->buildObjects(Gather_Builder<BuilderT>(rcpFromRef(builder)));
385 
386  gatherTangentManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
387  gatherTangentManager_->buildObjects(GatherTangent_Builder<BuilderT>(rcpFromRef(builder)));
388 
389  gatherDomainManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
390  gatherDomainManager_->buildObjects(GatherDomain_Builder<BuilderT>(rcpFromRef(builder)));
391 
392  gatherOrientManager_ = Teuchos::rcp(new Evaluator_TemplateManager);
393  gatherOrientManager_->buildObjects(GatherOrientation_Builder<BuilderT>(rcpFromRef(builder)));
394 }
395 
396 }
397 
398 #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