Class documentation of Concepts

Loading...
Searching...
No Matches
spacePreBuilder.hh
Go to the documentation of this file.
1
8#ifndef hpSpacePreBuilder_hh
9#define hpSpacePreBuilder_hh
10
11#include "basics/debug.hh"
12#include "basics/exceptions.hh"
15#include "geometry/cellConditions.hh"
16#include "geometry/mesh.hh"
18#include "spaceSet.hh"
19
20#define SubSpaceHelper_D 0
21
22namespace concepts {
23
24 // forward declarations
25 template<class F, class G>
26 class BuildTColumnsBase;
27
28 // *********************************************************** NotValidDof **
29
34 class NotValidDof : public ExceptionBase {};
35
36 // ******************************************************* SpacePreBuilder **
37
38 class SpacePreBuilder : public virtual OutputOperator {
39 public:
43 virtual ~SpacePreBuilder() {}
44
46 virtual concepts::Mesh& mesh() const = 0;
49 virtual void rebuildMesh() = 0;
52 virtual void rebuildDof() = 0;
65 const concepts::Connector& cntr, uint i = 0,
66 uint spcNo = 0) = 0;
76 (uint dim, const concepts::Connector& cntr, uint spcNo = 0) const = 0;
77 protected:
78 virtual std::ostream& info(std::ostream& os) const;
79 };
80
81 // *********************************************************** SpaceHelper **
82
89 template<class F, class G>
90 class SpaceHelper : public virtual OutputOperator {
91// friend class BuildTColumnsBase<F,G>;
92 public:
99 const CellConditions* cc = 0) :
100 prebuild_(&prebuild),
101 bc_(bc ? new const BoundaryConditions(*bc) : nullptr),
102 cc_(cc ? new const CellConditions (*cc) : nullptr) {}
103 virtual ~SpaceHelper() {}
105 const BoundaryConditions* bc() const { return bc_.get(); }
107 const CellConditions* cc() const { return cc_.get(); }
110 return bc_.reset(bc ? new BoundaryConditions(*bc) : 0);
111 }
113 G& prebuild() { return *prebuild_; }
115 virtual void reset() = 0;
117 virtual uint& idx() = 0;
118 virtual const uint& idx() const = 0;
123 virtual uint spcNo() const { return 0; }
125 bool passive(const concepts::Connector& cntr) const {
126 return passive_.exist(&cntr);
127 }
130 passive_.insert(&cntr);
131 }
132 const concepts::Set<const concepts::Connector*> passive() const {
133 return passive_;
134 }
135 protected:
136 virtual std::ostream& info(std::ostream& os) const;
137 private:
139 G* prebuild_;
141 std::unique_ptr<const BoundaryConditions> bc_;
143 std::unique_ptr<const CellConditions> cc_;
146 };
147
148 template<class F, class G>
149 std::ostream& SpaceHelper<F,G>::info(std::ostream& os) const {
150 os << concepts::typeOf(*this)<<"(";
151 if (bc_.get()) {
152 os << *bc_; if (cc_.get()) os << ", ";
153 }
154 if (cc_.get()) os << *cc_;
155
156 return os << ')';
157 }
158
159 // ******************************************************** SubspaceHelper **
160
161 template<class F, class G>
162 class SubspaceHelper : public SpaceHelper<F,G> {
163 public:
174 const CellConditions* cc = 0, uint* const offset = 0,
175 uint* const idx = 0)
176 : SpaceHelper<F,G>(prebuild, bc, cc), spcNo_(spcNo), offset_(offset),
177 ownIndex_(idx == 0), idx_(ownIndex_ ? new uint(this->offset()) : idx) {
178 DEBUGL(SubSpaceHelper_D, *this);
179 }
180 virtual ~SubspaceHelper() {
181 if (ownIndex_) delete idx_;
182 DEBUGL(SubSpaceHelper_D, "done");
183 }
184 virtual void reset() { *idx_ = offset(); }
190 virtual uint& idx() {
191 DEBUGL(SubSpaceHelper_D, "idx = " << *idx_);
192 return *idx_; }
193 virtual const uint& idx() const {
194 DEBUGL(SubSpaceHelper_D, "idx = " << *idx_);
195 return *idx_;
196 }
197 bool ownIndex() const { return ownIndex_; }
198 virtual uint spcNo() const { return spcNo_; }
200 uint offset() const { return offset_ ? *offset_ : 0; }
201 protected:
202 virtual std::ostream& info(std::ostream& os) const;
203 private:
204 uint spcNo_;
206 uint* const offset_;
208 bool ownIndex_;
210 uint* const idx_;
211
212 };
213
214 template<class F, class G>
215 std::ostream& SubspaceHelper<F,G>::info(std::ostream& os) const {
216 os << concepts::typeOf(*this)<<"(";
217 if (this->bc()) os << *this->bc() << ", ";
218 if (this->cc()) os << *this->cc() << ", ";
219 if (offset_ == 0) os << "(own)"; else os << "(given)";
220 os << " offset = " << offset() << ", ";
221 if (ownIndex_) os << "(own)"; else os << "(given)";
222 return os << " idx = " << idx() << ")";
223 }
224
225 // ***************************************************** BuildTColumnsBase **
226
243 template<class F, class G>
244 class BuildTColumnsBase : public virtual OutputOperator {
245 public:
252 virtual ~BuildTColumnsBase() {}
253
255 inline SpaceHelper<F,G>& spc() const;
257 inline G& prebuild() const;
258
270 protected:
273 virtual std::ostream& info(std::ostream& os) const;
274 };
275
276 template<class F, class G>
278 conceptsAssert(spc_, Assertion());
279 return *spc_;
280 }
281
282 template<class F, class G>
284 conceptsAssert(spc_, Assertion());
285 return spc_->prebuild();
286 }
287
288 template<class F, class G>
289 std::ostream& BuildTColumnsBase<F,G>::info(std::ostream& os) const {
290 return os << concepts::typeOf(*this)<<"(" << *spc_ << ")";
291 }
292
293}
294
295#endif // hpSpacePreBuilder_hh
bool exist(F val) const
Returns true, if a value is in the set.
Definition set.hh:296
virtual BuildTColumnsBase< F, G > * clone(SpaceHelper< F, G > *spc=0) const =0
SpaceHelper< F, G > & spc() const
Returns pointer to space helper class.
SpaceHelper< F, G > * spc_
Space to build the degrees of freedom from.
BuildTColumnsBase()
Default constructor.
BuildTColumnsBase(SpaceHelper< F, G > &spc)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
G & prebuild() const
Returns the space pre builder.
virtual void reset()=0
Reset the index counter.
SpaceHelper(G &prebuild, const BoundaryConditions *bc=0, const CellConditions *cc=0)
void setPassive(const concepts::Connector &cntr)
Mark a connector as passive.
G & prebuild()
Returns space pre builder.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const BoundaryConditions * bc() const
Returns boundary conditions.
virtual uint spcNo() const
bool passive(const concepts::Connector &cntr) const
Returns if an entitiy of dimension dim is marked as passive.
const CellConditions * cc() const
Returns cell conditions.
virtual uint & idx()=0
Returns the current index.
void set_bc(const BoundaryConditions *bc)
Reset boundary conditions to bc.
virtual concepts::Set< concepts::IndexRange > indices(uint dim, const concepts::Connector &cntr, uint spcNo=0) const =0
virtual ~SpacePreBuilder()
Destructor.
virtual concepts::Mesh & mesh() const =0
Returns mesh.
virtual concepts::IndexRange & setIndex(uint &firstIdx, uint noIdx, uint dim, const concepts::Connector &cntr, uint i=0, uint spcNo=0)=0
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void rebuildMesh()=0
virtual void rebuildDof()=0
virtual void reset()
Reset the index counter.
virtual uint spcNo() const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
SubspaceHelper(G &prebuild, uint spcNo, const BoundaryConditions *bc=0, const CellConditions *cc=0, uint *const offset=0, uint *const idx=0)
uint offset() const
Returns the offset.
#define conceptsAssert(cond, exc)
#define DEBUGL(doit, msg)
Definition debug.hh:40
std::string typeOf(const T &t)
Definition output.hh:43
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320