Class documentation of Concepts

Loading...
Searching...
No Matches
space.hh
Go to the documentation of this file.
1
6#ifndef spcSpace_hh
7#define spcSpace_hh
8
9#include <cstring>
10#include <climits>
11#include <set>
12#include <map>
14#include "basics/typedefs.hh"
15#include "basics/exceptions.hh"
16#include "basics/level.hh"
18#include "geometry/connector.hh"
19#include "space/element.hh"
20
21namespace concepts {
22
23 // ********************************************************* SpaceNotBuilt **
24
36 class SpaceNotBuilt : public ExceptionBase {};
37
38 // ***************************************************************** Space **
39
43 template<class F>
44 class Space : public virtual OutputOperator {
45 public:
46 typedef Element<F> type;
47 typedef Scan<Element<F> > Scanner;
48
50 virtual uint getOutputDimension() const{
51 return 1u;
52 };
53
55 virtual uint dim() const = 0;
56
58 virtual uint nelm() const = 0;
59
61 virtual Scanner* scan() const = 0;
62 protected:
63 virtual std::ostream& info(std::ostream& os) const;
64
65 };
66
67 // ********************************************** Scan<ElementWithCell<F> > **
68
69 template<class F>
70 class Scan<ElementWithCell<F> > : public Scan<Element<F> > {
71 public:
72 virtual ElementWithCell<F>& operator++(int) = 0;
73 };
74
75 // ***************************************************************** Space **
76
80 template<class F>
81 class SpaceOnCells : public Space<F> {
82 public:
85
87 virtual Scanner* scan() const = 0;
88
90 virtual uint dim() const = 0;
91
93 virtual uint nelm() const = 0;
94
95 protected:
96 virtual std::ostream& info(std::ostream& os) const;
97 };
98
99
100
101
102 template<uint dimC> class CellType;
103
104 template<> class CellType<1>{
105 public:
106 typedef concepts::Cell1 cell;
107 };
108
109 template<> class CellType<2>{
110 public:
111 typedef concepts::Cell2 cell;
112 };
113
114 template<> class CellType<3>{
115 public:
116 typedef concepts::Cell3 cell;
117 };
118
119
126 template<uint dimC, class F>
128
129 public:
130 virtual const std::set<typename CellType<dimC>::cell * > allCells() const = 0;
131
132 protected:
133 virtual std::ostream& info(std::ostream& os) const;
134
135 };
136
137 // **************************************************** AdaptiveControlTag **
138
156 enum tagInfo { NO_TAG = 0, MEMBER = 1, PASSIVE = 2, VLD_IDX = 4, VLD_P = 8 };
168
171
173 uchar operator=(const uchar& t) { return data_ = t; }
174
178 bool isMember() const { return (data_ & MEMBER); }
180 void takeIn() { data_ |= MEMBER; }
182 void takeOut() { data_ &= ~MEMBER; }
183
187 bool isActive() const { return !(data_ & PASSIVE); }
193 bool isPassive() const { return (data_ & PASSIVE); }
194 void activate() { data_ &= ~PASSIVE; }
195 void deactivate() { data_ |= PASSIVE; }
196
200 bool idxValid() const { return (data_ & VLD_IDX); }
201 void validateIdx() { data_ |= VLD_IDX; }
202 void invalidateIdx() { data_ &= ~VLD_IDX; }
203
207 bool pValid() const { return (data_ & VLD_P); }
208 void validateP() { data_ |= VLD_P; }
209 void invalidateP() { data_ &= ~VLD_P; }
210 };
211
212 std::ostream& operator<<(std::ostream& os, const AdaptiveControlTag& c);
213
214 // ************************************************************ IndexRange **
215
226 struct IndexRange {
233
235 IndexRange() { idx_[0] = idx_[1] = 0; }
241 std::set<uint> operator()();
250 bool operator==(uint i) const;
252 bool operator==(const IndexRange& i) const;
254 bool operator<(const IndexRange& i) const;
256 inline uint dim() const { return idx_[1] - idx_[0] + 1; }
258 inline bool exist(uint i) const {
259 return (i >= idx_[0] && i <= idx_[1]);
260 }
261 };
262
263 std::ostream& operator<<(std::ostream& os, const IndexRange& i);
264
265 std::ostream& operator<<(std::ostream& os,
266 const std::map<uint, IndexRange>& map);
267
268 // ******************************************************* AdaptiveControl **
269
276 template<class F = uint>
289
290 template<class F>
291 std::ostream& operator<<(std::ostream& os, const AdaptiveControl<F>& c);
292
293 // ******************************************************** AdaptiveAdjust **
294
304 template<uint levelDim = 1>
306 public:
312 short& l_;
313
319 AdaptiveAdjust(short l) : level_(l), l_(level_.l_[0]) {}
320 };
321
322 template<uint levelDim>
323 std::ostream& operator<<(std::ostream& os,
324 const AdaptiveAdjust<levelDim>& a);
325
326 // ************************************************************ Adaptivity **
327
337 template<class F = Connector, class Tadj = class AdaptiveAdjust<1> >
339 public:
340 virtual ~Adaptivity() { }
342 virtual void adjust(const F& cell, const Tadj& a) = 0;
343 };
344
345 // ********************************************************* AdaptiveSpace **
346
355 template<class F, class Tadj = class AdaptiveAdjust<1> >
357 public:
361 virtual void adjust(const Element<F>& elm, const Tadj& a) = 0;
362
363 virtual ~AdaptiveSpace() { }
364 };
365
366 // ************************************************************ DummySpace **
367
372 template<typename F>
373 class DummySpace : public Space<F> {
374 public:
376 DummySpace(uint dim) : dim_(dim) {}
377 virtual uint dim() const { return dim_; }
378 virtual uint nelm() const { return 0; }
379 virtual Scan* scan() const { return 0; }
380 protected:
381 virtual std::ostream& info(std::ostream& os) const {
382 return os << "DummySpace<" << number<F>::name()
383 << ">(dim = " << dim_ << ')'; }
384 private:
385 uint dim_;
386 };
387
388 // ************************************************************** Subspace **
389
392 class Subspace {
393 public:
395 virtual uint& lastIdx() = 0;
397 virtual uint offset() const = 0;
398 virtual ~Subspace() {}
399 };
400
401 // ************************************************************ SpaceDebug **
407 template<typename F = Real>
408 class SpaceDebug : public virtual OutputOperator {
409 public:
410 SpaceDebug(const Space<F>& spc) : spc_(spc) {}
411 protected:
412 virtual std::ostream& info(std::ostream& os) const;
413 private:
414 const Space<F>& spc_;
415 };
416
417 template<typename F>
418 std::ostream& SpaceDebug<F>::info(std::ostream& os) const {
419 os << spc_ << std::endl;
420 std::unique_ptr<typename Space<F>::Scanner> sc(spc_.scan());
421 uint i = 1;
422 while (*sc) {
423 const Element<F>& elm = (*sc)++;
424 os << i++ << ". element = " << elm << std::endl;
425 }
426 return os;
427 }
428
429} // namespace concepts
430
431#endif // spcSpace_hh
AdaptiveAdjust()
Default constructor.
Definition space.hh:315
Level< levelDim > level_
Level in several dimensions.
Definition space.hh:308
virtual void adjust(const Element< F > &elm, const Tadj &a)=0
virtual void adjust(const F &cell, const Tadj &a)=0
Adjusts in the next rebuild step for this cell.
One dimensional cell.
Definition cell.hh:75
Two dimensional cell.
Definition cell.hh:89
Three dimensional cell.
Definition cell.hh:112
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
Definition space.hh:379
virtual uint dim() const
Returns the dimension of the space.
Definition space.hh:377
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition space.hh:381
virtual uint nelm() const
Returns the number of elements in the space.
Definition space.hh:378
virtual ElementWithCell< F > & operator++(int)=0
Returns the next element in the scanned set.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition space.hh:418
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint dim() const =0
Returns the dimension of the space.
virtual Scanner * scan() const =0
Returns a scanner to iterate over the elements of the space.
virtual uint nelm() const =0
Returns the number of elements in the space.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint getOutputDimension() const
Returns the default output dimension, when we consider plotting a real-valued operator on this space.
Definition space.hh:50
virtual uint dim() const =0
Returns the dimension of the space.
virtual Scanner * scan() const =0
Returns a scanner to iterate over the elements of the space.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint nelm() const =0
Returns the number of elements in the space.
virtual uint & lastIdx()=0
Returns last global index of the space.
virtual uint offset() const =0
Returns the offset.
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
unsigned char uchar
Abbreviation for unsigned char.
Definition typedefs.hh:48
uchar operator=(const uchar &t)
Assignement operator.
Definition space.hh:173
AdaptiveControlTag(uchar t=0)
Constructor.
Definition space.hh:170
void takeIn()
Takes into the space.
Definition space.hh:180
void takeOut()
Takes out of the space.
Definition space.hh:182
AdaptiveControl()
Default constructor.
AdaptiveControlTag tag_
Control information.
Definition space.hh:279
uint dim() const
Number of indices.
Definition space.hh:256
bool exist(uint i) const
Returns if an index is inside the index range.
Definition space.hh:258
bool operator==(uint i) const
Comparison with beginning index.
bool operator<(const IndexRange &i) const
Comparison of beginning indices.
IndexRange & operator=(const IndexRange &i)
Assigment operator.
bool operator==(const IndexRange &i) const
Comparison.
IndexRange(uint idx)
Constructor, where is only on index assigned.
IndexRange & operator=(uint i)
Assigment operator.
IndexRange(uint idxBegin, uint idxEnd)
Constructor for several successive indices.
IndexRange()
Default constructor.
Definition space.hh:235
std::set< uint > operator()()
Returns a set of the indices.
IndexRange & operator+=(uint i)
Shift operator.