DUNE-ACFEM (unstable)

localobjectstorage.hh
1#ifndef __DUNE_ACFEM_LOCALOBJECTSTORAGE_HH__
2#define __DUNE_ACFEM_LOCALOBJECTSTORAGE_HH__
3
4#include <dune/fem/storage/objectstack.hh>
5
6namespace Dune {
7
8 namespace ACFem {
9
19 template<class GlobalObject, class LocalObject>
21 {
22 public:
23 typedef GlobalObject GlobalObjectType;
24 typedef LocalObject ObjectType;
25
26 public:
27 explicit LocalObjectFactory(GlobalObjectType& global)
28 : globalObject_(global)
29 {}
30
31 ObjectType *newObject() const
32 {
33 return new ObjectType(globalObject_);
34 }
35
36 protected:
37 GlobalObjectType& globalObject_;
38 };
39
47 template<class Factory, template<class> class Wrapper>
49 : public Fem::ObjectStack<Factory>
50 {
52 typedef Fem::ObjectStack<Factory> BaseType;
53 public:
54 typedef Factory LocalObjectFactoryType;
55 typedef typename LocalObjectFactoryType::ObjectType LocalObjectType;
56 typedef typename LocalObjectFactoryType::GlobalObjectType GlobalObjectType;
57 typedef Wrapper<ThisType> LocalWrapperType;
58
59 public:
60 explicit LocalObjectStack(const LocalObjectFactoryType& factory)
61 : BaseType(factory)
62 {}
63
64 private:
66 ThisType& operator=(const ThisType&);
67
68 public:
69 LocalWrapperType localObject()
70 {
71 return LocalWrapperType(*this);
72 }
73
74 template<class Entity>
75 LocalWrapperType localObject(Entity& entity)
76 {
77 return LocalWrapperType(entity, *this);
78 }
79
80 template<class Entity>
81 const LocalWrapperType localObject(Entity& entity) const
82 {
83 return LocalWrappertType(entity, *this);
84 }
85 };
86
88 template<class Storage>
90 {
91 typedef Storage StorageType;
92 typedef typename StorageType::LocalObjectFactoryType FactoryType;
93 typedef typename StorageType::GlobalObjectType GlobalObjectType;
94
95 MutableLocalObjectStorageProvider(GlobalObjectType& global)
96 : factory_(global),
97 storage_(factory_)
98 {}
99 private:
102 public:
103
104 StorageType& storage() const
105 {
106 return storage_;
107 }
108
109 protected:
110 FactoryType factory_;
111 mutable StorageType storage_;
112 };
113
119 template<class Global>
121 {
122 typedef Global StorageType;
123 typedef Global GlobalObjectType;
124
125 MutableNoStorageProvider(GlobalObjectType& global)
126 : global_(global)
127 {}
128
129 GlobalObjectType& storage() const
130 {
131 return global_;
132 }
133
134 protected:
135 GlobalObjectType& global_;
136 };
137
139
140 } // ACFem::
141
142} // Dune::
143
144#endif // __DUNE_ACFEM_LOCALOBJECTSTORAGE_HH__
Define a factory for a "local object" which has a constructor which accepts a single argument,...
Definition: localobjectstorage.hh:21
Local object stack which (hopefully) efficiently caches local objects.
Definition: localobjectstorage.hh:50
Provide a writable object stack for technical reasons.
Definition: localobjectstorage.hh:90
Provide a writable pseudo object stack which is only a reference to the global object.
Definition: localobjectstorage.hh:121
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)