DUNE-ACFEM (2.5.1)

forcesfunctionalmodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_FORCESFUNCTIONALMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_FORCESFUNCTIONALMODEL_HH__
3 
4 #include "../modelexpressionbase.hh"
5 
6 namespace Dune {
7 
8  namespace ACFem {
9 
39  template<class LinearFunctional>
41  : public ModelExpression<ForcesFunctionalModel<LinearFunctional> >
42  {
47  public:
48  typedef LinearFunctional LinearFunctionalType;
49  typedef typename LinearFunctionalType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
50 
51  explicit
52  ForcesFunctionalModel(const DiscreteLinearFunctional<DiscreteFunctionSpaceType,
53  typename LinearFunctionalType::TraitsType>&
54  functional,
55  const std::string& name = "")
56  : functional_(functional),
57  name_("-" + (name == "" ? functional_().name() : "name"))
58  {}
59 
60  std::string name() const
61  {
62  return name_;
63  }
64 
65  template<class DiscreteFunctionSpace>
66  typename TraitsType::template ForcesFunctionalTraits<DiscreteFunctionSpace>::FunctionalType
67  forcesFunctional(const DiscreteFunctionSpace& space) const
68  {
69  return *functional_();
70  }
71 
72  protected:
74  const std::string name_;
75  };
76 
77  template<class LinearFunctional>
78  struct ModelTraits<ForcesFunctionalModel<LinearFunctional> >
79  : public DefaultModelTraits<typename LinearFunctional::DiscreteFunctionSpaceType::FunctionSpaceType,
80  typename LinearFunctional::GridPartType>
81  {
82  protected:
83  typedef
84  DefaultModelTraits<typename LinearFunctional::DiscreteFunctionSpaceType::FunctionSpaceType,
85  typename LinearFunctional::GridPartType>
86  BaseType;
87  public:
89  isLinear = true,
90  isSymmetric = true,
91  isSemiDefinite = true
92  };
93 
102  template<class DiscreteFunctionSpace>
103  struct ForcesFunctionalTraits
104  : public FixedForcesFunctionalTraits<DiscreteFunctionSpace, LinearFunctional>
105  {
106  protected:
107  typedef
109  BaseType;
110  public:
111  // still we define a single wrap here, as we do not know
112  // whether LinearFuncional is copy-constructible
113  typedef decltype(*std::declval<typename BaseType::FunctionalType>()) FunctionalType;
114  };
115  };
116 
118  template<class DiscreteFunctionSpace>
119  class ForcesFunctionalModel<ZeroFunctional<DiscreteFunctionSpace> >
120  : public ZeroModel<typename DiscreteFunctionSpace::FunctionSpaceType,
121  typename DiscreteFunctionSpace::GridPartType>
122  {
123  typedef
124  ZeroModel<typename DiscreteFunctionSpace::FunctionSpaceType,
125  typename DiscreteFunctionSpace::GridPartType>
126  BaseType;
127  public:
128  typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
130 
131  explicit
132  ForcesFunctionalModel(const DiscreteLinearFunctional<DiscreteFunctionSpaceType,
133  typename LinearFunctionalType::TraitsType>&
134  functional,
135  const std::string& name = "")
136  : BaseType("-" + (name == "" ? asImp(functional).name() : name))
137  {}
138  };
139 
141 
143 
145 
146  } // namespace ACFem
147 
148 } //Namespace Dune
149 
150 
151 #endif // __DUNE_ACFEM_MODELS_MODULES_FORCESFUNCTIONALMODEL_HH__
152 
Default model implementation.
Definition: modelinterface.hh:330
Interface class for a discrete linear functional.
Definition: linearfunctional.hh:52
Interface class for second order elliptic models.
Definition: modelinterface.hh:192
This is the famous "do-nothing" functional.
Definition: zerofunctional.hh:42
Define a simple zero model to optimize expression templates.
Definition: zeromodel.hh:28
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
A structure defining some trivial default values for the template structure ModelTraits<ModelType>,...
Definition: modelinterface.hh:57
Utiliy class to aid in the definition of ModelInterface::ForcesFunctionalTraits.
Definition: modelinterface.hh:551
Wrap an existing DiscreteLinearFunctional into a model which only conatains this ModelConstituent.
Definition: forcesfunctionalmodel.hh:42
Traits-template which has to be specialized for each individual model.
Definition: modelinterface.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 13, 22:30, 2024)