6#ifndef spcDomainDecomp_hh
7#define spcDomainDecomp_hh
11#include "geometry/cellConditions.hh"
20#define DDSpaceConstr_D 0
21#define DDSpaceDestr_D 0
22#define DDSpaceRebuild_D 0
23#define DDSpaceGetIndices_D 0
24#define DDSpaceInfoIndices_D 0
51 virtual std::ostream&
info(std::ostream&
os)
const;
61 return os <<
"DDSpace(" << domains_ <<
" domains)";
109 inline virtual uint dim()
const;
128 virtual std::ostream&
info(std::ostream&
os)
const;
156 template<
class G,
class H>
157 void getIndices_(
const G& prebuild,
const H&
cntr,
170 std::unique_ptr<concepts::Scan2>
sc(prebuild.mesh().scan());
173 if (!cc || ((*cc)(
attr).
type() != CellCondition::INACTIVE))
174 attributes.insert(
attr);
177 DEBUGL(DDSpaceConstr_D,
"attributes in mesh = " << attributes);
187 nonvalid <<
" in given domain " << *i);
228 (*j).add(*k, CellCondition::INACTIVE);
231 DEBUGL(DDSpaceConstr_D,
"cell conditions of domains = " << cc_);
238 spaces_.push_back(spc =
new F(prebuild, bc, &*j, spcNo_,
offset, idx));
239 idx = &spc->lastIdx();
241 DEBUGL(DDSpaceConstr_D,
"spaces of domains = " << spaces_);
252 uint k = this->domains();
254 for (; i != spaces_.rend(); ++i) {
255 DEBUGL(DDSpaceDestr_D,
"Try to delete Space(" << k-- <<
") = " << **i);
259 DEBUGL(DDSpaceDestr_D,
"done");
264 os <<
"DomainDecomp(" << this->domains_ <<
" domains, ";
268 os <<
"dim = " << dim() <<
", nelm = " << nelm() <<
", ";
269 for (
uint i = 0; i < spaces_.size();) {
270 os <<
"space(" << i <<
") = " << space(i);
271#if DDSpaceInfoIndices_D
272 os <<
", I(" << i <<
") = " << indicesI(i)
273 <<
", B(" << i <<
") = " << indicesB(i);
275 os <<
", I(" << i <<
").dim = " << indicesI(i).dim()
276 <<
", B(" << i <<
").dim = " << indicesB(i).dim();
278 if (++i < spaces_.size())
os <<
", ";
286 DEBUGL(DDSpaceRebuild_D,
"Start rebuilding");
289 DEBUGL(DDSpaceRebuild_D,
"space already built - nothing to do");
304 (*i)->lastIdx() = (*i)->offset();
306 (*i)->prebuild().clearAllIndices(spcNo_);
308 for (; i != spaces_.end(); ++i) {
310 DEBUGL(DDSpaceRebuild_D,
"Space(" << k++ <<
") = " << **i);
314 *b++ = (*i)->available().second;
316 nelm_ = (*i)->nelm();
317 DEBUGL(DDSpaceRebuild_D,
"nelm = " << nelm_);
322 std::unique_ptr<typename Space<typename F::t_type>::Scanner>
sc(
nullptr);
323 for (i = spaces_.begin(); i != spaces_.end(); ++i) {
324 sc.reset((*i)->scan());
327 DEBUGL(DDSpaceRebuild_D,
"Element = " << elm);
328 DEBUGL(DDSpaceRebuild_D,
"Element = " << *elm);
329 if (elm->
T().n() > 0) {
330 DEBUGL(DDSpaceRebuild_D,
"Element(" << j <<
") = " << *elm);
338 for(
uint j = 0; j < this->domains_; ++j) {
339 this->indicesI_[j].clear();
340 this->indicesB_[j].clear();
346 std::unique_ptr<concepts::Scan2>
se(spaces_[0]->prebuild().mesh().scan());
348 getIndices_(spaces_[0]->prebuild(), (*
se)++.connector(), indices);
351 for(
uint j = 0; j < this->domains_; ++j) {
352 DEBUGL(1,
"indicesI_[" << j <<
"] = " << this->indicesI_[j]);
353 DEBUGL(1,
"indicesB_[" << j <<
"] = " << this->indicesB_[j]);
356 i = spaces_.begin(); k = 0;
357 for (; i != spaces_.end(); ++i)
358 DEBUGL(1,
"Space(" << k++ <<
") = " << **i);
365 const uint* b = spcBuild_;
367 while(i != spaces_.end() && (*i)->available().first &&
368 (*i)->available().second == *b++) ++i;
369 return i == spaces_.end();
378 return (*spaces_.begin())->dim();
397 return (*spaces_.begin())->lastIdx();
402 return (*spaces_.begin())->offset();
422 return this->indicesI_[i];
430 return this->indicesB_[i];
434 template<
class G,
class H>
438 DEBUGL(DDSpaceGetIndices_D,
"cntr = " <<
cntr);
443 DEBUGL(DDSpaceGetIndices_D,
"domain = " << d);
446 &indicesI = this->indicesI_[d];
456 DEBUGL(DDSpaceGetIndices_D,
457 cntr.key() <<
" - dim = " << dim <<
", idx = " << idx);
458 DEBUGL(DDSpaceGetIndices_D,
"indices = " << indices);
463 DEBUGL(DDSpaceGetIndices_D,
467 indicesB = indicesB ||
occured;
468 DEBUGL(DDSpaceGetIndices_D,
"indicesB = " << indicesB);
471 for(
uint j = 0; j < this->domains_; ++j)
479 indicesI = indicesI ||
recent;
480 DEBUGL(DDSpaceGetIndices_D,
"indicesI = " << indicesI);
482 indices = indices || idx;
484 DEBUGL(DDSpaceGetIndices_D,
485 "indicesI_[" << d <<
"] = " << this->indicesI_[d]);
486 DEBUGL(DDSpaceGetIndices_D,
487 "indicesB_[" << d <<
"] = " << this->indicesB_[d]);
490 DEBUGL(DDSpaceGetIndices_D,
"dim = " << dim);
495 DEBUGL(DDSpaceGetIndices_D,
"done for " <<
cntr);
497 for(
uint j = 0; (chld =
cntr.child(j)) != 0; ++j)
498 getIndices_(prebuild, *chld, indices);
#define conceptsException(exc)
void resize(const uint sz)
void zeros()
Fills the memory with zeros.
uint attrib() const
Returns the attribute.
virtual const Set< IndexRange > indicesI(uint i) const =0
Returns index set for dof inside the i th domain.
Sequence< Set< IndexRange > > indicesI_
Index sets of dof inside and at the boundary for each domain/space.
uint domains_
Number of domains/spaces.
virtual const Space< F > & space(uint i) const =0
Returns space belonging to i th domain.
const uint domains() const
Returns number of domains/spaces.
virtual const Set< IndexRange > indicesB(uint i) const =0
Returns all index sets for dof inside each domain.
virtual std::ostream & info(std::ostream &os) const
Returns all index sets for dof at boundary of each domain.
DDSpace(uint domains=0)
Constructor.
virtual uint nelm() const
Returns the number of elements in the space.
void rebuild()
Rebuilds the spaces.
virtual uint & lastIdx()
Returns last global index of the space.
virtual std::ostream & info(std::ostream &os) const
Returns all index sets for dof at boundary of each domain.
virtual uint offset() const
Returns the offset, returns 0 if space is not a subspace or first one.
virtual const Set< IndexRange > indicesI(uint i) const
Returns index set for dof inside the i th domain.
concepts::Element< typename F::t_type > Element
virtual uint dim() const
Returns the dimension of the space.
DomainDecomp(G &prebuild, Sequence< Set< uint > > domains, BoundaryConditions *bc=0, CellConditions *cc=0, uint spcNo=0, uint *offset=0)
virtual const Set< IndexRange > indicesB(uint i) const
Returns index set for dof at the boundary the i th domain.
virtual const F & space(uint i) const
Returns space belonging to i th domain.
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
virtual const TMatrixBase< F > & T() const =0
Returns the T matrix of the element.
static void destructor(Joiner< T, nlnk > *&j, bool values=true)
#define conceptsAssert(cond, exc)
#define DEBUGL(doit, msg)
#define conceptsAssert3(cond, exc, msg)
Set< F > makeSet(uint n, const F &first,...)