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"
13 #include "basics/outputOperator.hh"
16 #include "geometry/mesh.hh"
17 #include "geometry/connectorSet.hh"
18 #include "spaceSet.hh"
19 
20 #define SubSpaceHelper_D 0
21 
22 namespace concepts {
23 
24  // forward declarations
25  template<class F, class G>
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;
63  virtual concepts::IndexRange&
64  setIndex(uint& firstIdx, uint noIdx, uint dim,
65  const concepts::Connector& cntr, uint i = 0,
66  uint spcNo = 0) throw(NotValidDof) = 0;
76  (uint dim, const concepts::Connector& cntr, uint spcNo = 0) const
77  throw(concepts::MissingFeature) = 0;
78  protected:
79  virtual std::ostream& info(std::ostream& os) const;
80  };
81 
82  // *********************************************************** SpaceHelper **
83 
90  template<class F, class G>
91  class SpaceHelper : public virtual OutputOperator {
92 // friend class BuildTColumnsBase<F,G>;
93  public:
99  SpaceHelper(G& prebuild, const BoundaryConditions* bc = 0,
100  const CellConditions* cc = 0) :
101  prebuild_(&prebuild),
102  bc_(bc ? new const BoundaryConditions(*bc) : nullptr),
103  cc_(cc ? new const CellConditions (*cc) : nullptr) {}
104  virtual ~SpaceHelper() {}
106  const BoundaryConditions* bc() const { return bc_.get(); }
108  const CellConditions* cc() const { return cc_.get(); }
110  void set_bc(const BoundaryConditions* bc) {
111  return bc_.reset(bc ? new BoundaryConditions(*bc) : 0);
112  }
114  G& prebuild() { return *prebuild_; }
116  virtual void reset() = 0;
118  virtual uint& idx() = 0;
119  virtual const uint& idx() const = 0;
124  virtual uint spcNo() const { return 0; }
126  bool passive(const concepts::Connector& cntr) const {
127  return passive_.exist(&cntr);
128  }
130  void setPassive(const concepts::Connector& cntr) {
131  passive_.insert(&cntr);
132  }
134  return passive_;
135  }
136  protected:
137  virtual std::ostream& info(std::ostream& os) const;
138  private:
142  std::unique_ptr<const BoundaryConditions> bc_;
144  std::unique_ptr<const CellConditions> cc_;
147  };
148 
149  template<class F, class G>
150  std::ostream& SpaceHelper<F,G>::info(std::ostream& os) const {
151  os << concepts::typeOf(*this)<<"(";
152  if (bc_.get()) {
153  os << *bc_; if (cc_.get()) os << ", ";
154  }
155  if (cc_.get()) os << *cc_;
156 
157  return os << ')';
158  }
159 
160  // ******************************************************** SubspaceHelper **
161 
162  template<class F, class G>
163  class SubspaceHelper : public SpaceHelper<F,G> {
164  public:
174  SubspaceHelper(G& prebuild, uint spcNo, const BoundaryConditions* bc = 0,
175  const CellConditions* cc = 0, uint* const offset = 0,
176  uint* const idx = 0)
177  : SpaceHelper<F,G>(prebuild, bc, cc), spcNo_(spcNo), offset_(offset),
178  ownIndex_(idx == 0), idx_(ownIndex_ ? new uint(this->offset()) : idx) {
179  DEBUGL(SubSpaceHelper_D, *this);
180  }
181  virtual ~SubspaceHelper() {
182  if (ownIndex_) delete idx_;
183  DEBUGL(SubSpaceHelper_D, "done");
184  }
185  virtual void reset() { *idx_ = offset(); }
191  virtual uint& idx() {
192  DEBUGL(SubSpaceHelper_D, "idx = " << *idx_);
193  return *idx_; }
194  virtual const uint& idx() const {
195  DEBUGL(SubSpaceHelper_D, "idx = " << *idx_);
196  return *idx_;
197  }
198  bool ownIndex() const { return ownIndex_; }
199  virtual uint spcNo() const { return spcNo_; }
201  uint offset() const { return offset_ ? *offset_ : 0; }
202  protected:
203  virtual std::ostream& info(std::ostream& os) const;
204  private:
205  uint spcNo_;
207  uint* const offset_;
209  bool ownIndex_;
211  uint* const idx_;
212 
213  };
214 
215  template<class F, class G>
216  std::ostream& SubspaceHelper<F,G>::info(std::ostream& os) const {
217  os << concepts::typeOf(*this)<<"(";
218  if (this->bc()) os << *this->bc() << ", ";
219  if (this->cc()) os << *this->cc() << ", ";
220  if (offset_ == 0) os << "(own)"; else os << "(given)";
221  os << " offset = " << offset() << ", ";
222  if (ownIndex_) os << "(own)"; else os << "(given)";
223  return os << " idx = " << idx() << ")";
224  }
225 
226  // ***************************************************** BuildTColumnsBase **
227 
244  template<class F, class G>
245  class BuildTColumnsBase : public virtual OutputOperator {
246  public:
248  BuildTColumnsBase() : spc_(0) {}
252  BuildTColumnsBase(SpaceHelper<F,G>& spc) : spc_(&spc) {}
253  virtual ~BuildTColumnsBase() {}
254 
256  inline SpaceHelper<F,G>& spc() const;
258  inline G& prebuild() const;
259 
270  virtual BuildTColumnsBase<F,G>* clone(SpaceHelper<F,G>* spc = 0) const = 0;
271  protected:
274  virtual std::ostream& info(std::ostream& os) const;
275  };
276 
277  template<class F, class G>
279  conceptsAssert(spc_, Assertion());
280  return *spc_;
281  }
282 
283  template<class F, class G>
285  conceptsAssert(spc_, Assertion());
286  return spc_->prebuild();
287  }
288 
289  template<class F, class G>
290  std::ostream& BuildTColumnsBase<F,G>::info(std::ostream& os) const {
291  return os << concepts::typeOf(*this)<<"(" << *spc_ << ")";
292  }
293 
294 }
295 
296 #endif // hpSpacePreBuilder_hh
virtual void reset()
Reset the index counter.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
uint offset() const
Returns the offset.
Base class for exceptions.
Definition: exceptions.hh:86
void set_bc(const BoundaryConditions *bc)
Reset boundary conditions to bc.
G * prebuild_
Space pre builder.
Class for a range of global indices.
Definition: space.hh:226
Set with operations, output operator, and method of the particular element types.
Definition: traces.hh:18
virtual void rebuildMesh()=0
Rebuilds the mesh due to adjustments, set inner degrees of freedom.
std::unique_ptr< const CellConditions > cc_
Cell conditions.
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
SubspaceHelper(G &prebuild, uint spcNo, const BoundaryConditions *bc=0, const CellConditions *cc=0, uint *const offset=0, uint *const idx=0)
Constructor.
virtual uint & idx()
Returns the next index for the space.
BuildTColumnsBase()
Default constructor.
const BoundaryConditions * bc() const
Returns boundary conditions.
SpaceHelper< F, G > & spc() const
Returns pointer to space helper class.
BuildTColumnsBase(SpaceHelper< F, G > &spc)
Constructor.
#define DEBUGL(doit, msg)
virtual void reset()=0
Reset the index counter.
uint *const offset_
Pointer to dimension of the previous space.
#define SubSpaceHelper_D
bool ownIndex_
If index is created here.
virtual void rebuildDof()=0
Rebuilds the potential degrees of freedom.
Exception class for assertions.
Definition: exceptions.hh:258
Base class for classes for building T columns for elements in a space with help of space pre builder.
SpaceHelper< F, G > * spc_
Space to build the degrees of freedom from.
virtual concepts::Mesh & mesh() const =0
Returns mesh.
Exception class to express that an inquired dof is not valid.
virtual concepts::Set< concepts::IndexRange > indices(uint dim, const concepts::Connector &cntr, uint spcNo=0) const =0
Returns all indices of entities of a cell of a particular dimension.
virtual BuildTColumnsBase< F, G > * clone(SpaceHelper< F, G > *spc=0) const =0
Virtual copy constructor with a twist.
G & prebuild() const
Returns the space pre builder.
concepts::Set< const concepts::Connector * > passive_
Set of passive connectors.
virtual ~SpacePreBuilder()
Destructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void setPassive(const concepts::Connector &cntr)
Mark a connector as passive.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const CellConditions * cc() const
Returns cell conditions.
uint *const idx_
Last index of the space, is offset plus dimension.
virtual uint & idx()=0
Returns the current index.
Exception class to express a missing feature.
Definition: exceptions.hh:206
const concepts::Set< const concepts::Connector * > passive() const
virtual const uint & idx() const
virtual uint spcNo() const
Returns a number to distinguish between global indices on same topological entity.
An abstract class for meshes.
Definition: mesh.hh:76
virtual std::ostream & info(std::ostream &os) const
Class which helps to build the T Columns of the elements of a space, with the help of a space pre bui...
virtual const uint & idx() const =0
G & prebuild()
Returns space pre builder.
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
std::unique_ptr< const BoundaryConditions > bc_
Boundary conditions.
Class providing an output operator.
virtual uint spcNo() const
Returns a number to distinguish between global indices on same topological entity.
SpaceHelper(G &prebuild, const BoundaryConditions *bc=0, const CellConditions *cc=0)
Constructor.
bool passive(const concepts::Connector &cntr) const
Returns if an entitiy of dimension dim is marked as passive.
virtual concepts::IndexRange & setIndex(uint &firstIdx, uint noIdx, uint dim, const concepts::Connector &cntr, uint i=0, uint spcNo=0)=0
Sets the index range of the dof inside cell cntr and returns it.
An abstract class for elements of the topology.
Definition: connector.hh:85
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich