SingularDirichletBC.h 19.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/** \file SingularDirichletBC.h */

#ifndef SINGULAR_DIRICHLET_BC_H
#define SINGULAR_DIRICHLET_BC_H

#include "AMDiS.h"

namespace AMDiS {

/**
 * data structure that holds DOF-Index and double value for singular dirichlet boundary condition.
 **/
struct SingularDirichletBC {
  SingularDirichletBC(int i_, int j_, DegreeOfFreedom idx_, double value_) :
    row(i_), col(j_), idx(idx_), value(value_) {}

  int row, col;
  DegreeOfFreedom idx;
  double value;
};

/**
 * data structure that holds all periodic associations.
 **/
struct ManualPeriodicBC {
  ManualPeriodicBC(size_t row_, std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > &indices_) :
    row(row_), indices(indices_) {}

  size_t row;
  std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > indices;
};

namespace details {
    
  /**
   * traverses the mesh and stores all DegreeOfFreedom, that lie on the boundary with index 'nr'
   * and have coordinates that give true in the 'meshIndicator', into a vector of 'indices'.
   **/
  inline void getBoundaryIndices(const FiniteElemSpace* feSpace,
			  BoundaryType nr,
			  AbstractFunction<bool, WorldVector<double> >* meshIndicator,
42
			  std::set<DegreeOfFreedom> &indices)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  {
    Mesh* mesh = feSpace->getMesh();
    int dim = mesh->getDim();
    const BasisFunction *basFcts = feSpace->getBasisFcts();
    int numBasFcts = basFcts->getNumber();
    std::vector<DegreeOfFreedom> localIndices(numBasFcts);

    indices.clear();

    WorldVector<double> coord;
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1,
      Mesh::CALL_LEAF_EL | Mesh::FILL_BOUND | Mesh::FILL_COORDS);
    while (elInfo) {
      for (int face = 0; face < dim + 1; face++) {
	if (elInfo->getBoundary(face) == nr) {
	  basFcts->getLocalIndices(elInfo->getElement(), feSpace->getAdmin(), localIndices);

	  for (int i = 0; i < numBasFcts; i++) {
	    elInfo->coordToWorld(*(basFcts->getCoords(i)), coord);
	    if ((*meshIndicator)(coord))
64
	      indices.insert(localIndices[i]);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	  }
	  break;
	}
      }

      elInfo = stack.traverseNext(elInfo);
    }
  }

  /**
   * traverses the mesh and stores all DegreeOfFreedom, that have coordinates that give true
   * in the 'meshIndicator', into a vector of 'indices'.
   **/
  inline void getBoundaryIndices(const FiniteElemSpace* feSpace,
			  AbstractFunction<bool, WorldVector<double> >* meshIndicator,
80
			  std::set<DegreeOfFreedom> &indices)
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  {
    Mesh* mesh = feSpace->getMesh();
    int dim = mesh->getDim();
    const BasisFunction *basFcts = feSpace->getBasisFcts();
    int numBasFcts = basFcts->getNumber();
    std::vector<DegreeOfFreedom> localIndices(numBasFcts);

    indices.clear();

    WorldVector<double> coord;
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1,
      Mesh::CALL_LEAF_EL | Mesh::FILL_BOUND | Mesh::FILL_COORDS);
    while (elInfo) {
      for (int face = 0; face < dim + 1; face++) {
	if (elInfo->getBoundary(face) != 0) {
	  basFcts->getLocalIndices(elInfo->getElement(), feSpace->getAdmin(), localIndices);

	  for (int i = 0; i < numBasFcts; i++) {
	    elInfo->coordToWorld(*(basFcts->getCoords(i)), coord);
	    if ((*meshIndicator)(coord))
102
	      indices.insert(localIndices[i]);
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	  }
	  break;
	}
      }

      elInfo = stack.traverseNext(elInfo);
    }
  }

  inline void getImplicitIndices(const FiniteElemSpace* feSpace,
			  AbstractFunction<double, WorldVector<double> >* signedDistFct,
			  std::vector<DegreeOfFreedom> &indices)
  {
    const BasisFunction *vecBasisFcts = feSpace->getBasisFcts();
    int nVecBasisFcts = vecBasisFcts->getNumber();

    std::vector<DegreeOfFreedom> vecLocalIndices(nVecBasisFcts);
    
    DOFVector<short int> visited(feSpace, "visited"); visited.set(0);
    WorldVector<double> coord;
    TraverseStack stack;
    Flag traverseFlag = Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS;
    ElInfo *elInfo = stack.traverseFirst(feSpace->getMesh(), -1, traverseFlag);

    while (elInfo) {
      Element *el = elInfo->getElement();
      vecBasisFcts->getLocalIndices(el, feSpace->getAdmin(), vecLocalIndices);

      for (int i = 0; i < nVecBasisFcts; i++) {
	if ( visited[vecLocalIndices[i]] == 0 ) {
	  elInfo->coordToWorld(*(vecBasisFcts->getCoords(i)), coord);
	  if ( (*signedDistFct)(coord) <= DBL_TOL ) { // eventuell nur Koordinaten an Gitterknoten bekommen!
	    indices.push_back(vecLocalIndices[i]);
	  }
	  visited[vecLocalIndices[i]] = 1;
	}
      }
      elInfo = stack.traverseNext(elInfo); 
    }
  }
  
  inline void getImplicitIndices(const FiniteElemSpace* feSpace,
			  DOFVector<double>* signedDistDOF,
			  std::vector<DegreeOfFreedom> &indices)
  {
   
    const BasisFunction *vecBasisFcts = feSpace->getBasisFcts();
    int nVecBasisFcts = vecBasisFcts->getNumber();

    std::vector<DegreeOfFreedom> vecLocalIndices(nVecBasisFcts);
    ElementVector signedDistLocalCoeffs(nVecBasisFcts);

    DimVec<double> *baryCoords = NULL;
    DOFVector<short int> visited(feSpace, "visited"); visited.set(0);
    TraverseStack stack;
    Flag traverseFlag = Mesh::CALL_LEAF_EL;
    ElInfo *elInfo = stack.traverseFirst(feSpace->getMesh(), -1, traverseFlag);

    while (elInfo) {
      Element *el = elInfo->getElement();

      vecBasisFcts->getLocalIndices(el, feSpace->getAdmin(), vecLocalIndices);
      signedDistDOF->getLocalVector(el, signedDistLocalCoeffs);

      for (int i = 0; i < nVecBasisFcts; i++) {
	if ( visited[vecLocalIndices[i]] == 0 ) {
	  baryCoords = vecBasisFcts->getCoords(i);

	  double dist = vecBasisFcts->evalUh(*baryCoords, signedDistLocalCoeffs);
	  if (dist <= DBL_TOL) {
	    indices.push_back(vecLocalIndices[i]);
	  }
	  visited[vecLocalIndices[i]] = 1;
	}
      }
      elInfo = stack.traverseNext(elInfo); 
    }
  }
  
  /**
   * get al list of pairs that describes wich DegreeOfFreedom are assiciated in the given mesh
   * with given feSpace. Uses the function getBoundaryIndices().
   * The 'nr' and 'meshIndicator' describe one boundary of the mesh and to each DegreeOfFreedom
   * the 'periodicMap' associates a second DegreeOfFreedom.
   **/
Praetorius, Simon's avatar
Praetorius, Simon committed
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//   inline void getPeriodicAssociation(const FiniteElemSpace* feSpace,
// 			      BoundaryType nr,
// 			      AbstractFunction<bool, WorldVector<double> >* meshIndicator,
// 			      AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap,
// 			      std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > &association)
//   {
//     std::set<DegreeOfFreedom> indices;
//     details::getBoundaryIndices(feSpace, nr, meshIndicator, indices);
// 
//     association.clear();
// 
//     DOFVector<WorldVector<double> > coords(feSpace, "coords");
//     feSpace->getMesh()->getDofIndexCoords(coords);
//     std::set<DegreeOfFreedom>::iterator it;
//     for (it = indices.begin(); it != indices.end(); it++)
//     {
//       DegreeOfFreedom idx2;
//       WorldVector<double> p;
//       p = (*periodicMap)(coords[*it]);
//       TEST_EXIT(coords.getDofIdxAtPoint(p,idx2))("periodic association not found!\n");
// 
//       association.push_back(std::make_pair(min(*it, idx2), max(*it, idx2)));
//     }
//   }
212
213
214
215
216
217
218

  /**
   * get al list of pairs that describes wich DegreeOfFreedom are assiciated in the given mesh
   * with given feSpace. Uses the function getBoundaryIndices().
   * The 'meshIndicator' describes one boundary of the mesh and to each DegreeOfFreedom
   * the 'periodicMap' associates a second DegreeOfFreedom.
   **/
Praetorius, Simon's avatar
Praetorius, Simon committed
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
//     inline void getPeriodicAssociation(const FiniteElemSpace* feSpace,
// 			      AbstractFunction<bool, WorldVector<double> >* meshIndicator,
// 			      AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap,
// 			      std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > &association)
//   {
//     std::set<DegreeOfFreedom> indices;
//     details::getBoundaryIndices(feSpace, meshIndicator, indices);
//     MSG_DBG("Nr of indices: %d\n", indices.size());
// 
//     association.clear();
// 
//     DOFVector<WorldVector<double> > coords(feSpace, "coords");
//     feSpace->getMesh()->getDofIndexCoords(coords);
//     std::set<DegreeOfFreedom>::iterator it;
//     for (it = indices.begin(); it != indices.end(); it++)
//     {
//       DegreeOfFreedom idx2;
//       WorldVector<double> p;
//       p = (*periodicMap)(coords[*it]);
//       TEST_EXIT(coords.getDofIdxAtPoint(p,idx2))("periodic association not found!\n");
// 
//       association.push_back(std::make_pair(min(*it, idx2), max(*it, idx2));
//     }
//     
//     MSG_DBG("Nr of associations: %d\n", association.size());
//   }
  
246
  inline void getPeriodicAssociation(const FiniteElemSpace* feSpace,
Praetorius, Simon's avatar
Praetorius, Simon committed
247
248
249
				     std::set<DegreeOfFreedom> indices,
				     AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap,
				     std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > &association)
250
251
252
253
  {
    association.clear();

    DOFVector<WorldVector<double> > coords(feSpace, "coords");
254
    feSpace->getMesh()->getDofIndexCoords(coords);
255
    std::set<DegreeOfFreedom>::iterator it;
Praetorius, Simon's avatar
Praetorius, Simon committed
256
257
258
    
    DegreeOfFreedom idx_;
    WorldVector<double> p;
259
    for (it = indices.begin(); it != indices.end(); it++)
260
    {
261
      p = (*periodicMap)(coords[*it]);
Praetorius, Simon's avatar
Praetorius, Simon committed
262
263
      TEST_EXIT(coords.getDofIdxAtPoint(p,idx_))("periodic association not found!\n");
      association.push_back(std::make_pair(std::min(*it, idx_), std::max(*it, idx_)));
264
    }
265
266
    
    MSG_DBG("Nr of associations: %d\n", association.size());
267
268
  }
  
269
270
  
  inline void getDOFValues(const FiniteElemSpace* feSpace, AbstractFunction<double, WorldVector<double> >* values, std::vector<DegreeOfFreedom> &indices, std::vector<double> &dofValues)
271
272
273
274
275
276
277
278
  {
    WorldVector<double> x;
    for (size_t i = 0; i < indices.size(); i++) {
      if (feSpace->getMesh()->getDofIndexCoords(indices[i], feSpace, x))
	dofValues.push_back((*values)(x));
    }
  }
  
279
  inline void getDOFValues(const FiniteElemSpace* feSpace, DOFVector<double>* values, std::vector<DegreeOfFreedom> &indices, std::vector<double> &dofValues)
280
  {
281
    for (size_t i = 0; i < indices.size(); i++) {
282
      dofValues.push_back((*values)[indices[i]]);
283
    }
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
  }
} // end namespace



/**
 * data structure that holds all possible variation of description of coords and value
 * of (singular/implicit) dirichlet boundary condition.
 **/
struct DirichletBcData {

  // pos = WorldVector
  DirichletBcData(int i_, int j_, WorldVector<double> pos_, double val_)
  : row(i_), col(j_), pos(pos_), val0(val_),
    posType(0), valueType(0),
    idx(0), SignedDistFct(NULL), SignedDistDOF(NULL), val1(NULL), val2(NULL),
    boundary_nr(0), meshIndicator(NULL) {}

  DirichletBcData(int i_, int j_, WorldVector<double> pos_, DOFVector<double> &val_)
  : row(i_), col(j_), pos(pos_), val1(&val_),
    posType(0), valueType(1),
    idx(0), SignedDistFct(NULL), SignedDistDOF(NULL), val0(0.0), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  {}

  DirichletBcData(int i_, int j_, WorldVector<double> pos_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), pos(pos_), val2(&val_),
    posType(0), valueType(2),
    idx(0), SignedDistFct(NULL), SignedDistDOF(NULL), val0(0.0), val1(NULL),
    boundary_nr(0), meshIndicator(NULL)  {}

  // pos = idx
  DirichletBcData(int i_, int j_, DegreeOfFreedom idx_, double val_)
  : row(i_), col(j_), idx(idx_), val0(val_),
    posType(1), valueType(0),
    SignedDistFct(NULL), SignedDistDOF(NULL), val1(NULL), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, DegreeOfFreedom idx_, DOFVector<double> &val_)
  : row(i_), col(j_), idx(idx_), val1(&val_),
    posType(1), valueType(1),
    SignedDistFct(NULL), SignedDistDOF(NULL), val0(0.0), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, DegreeOfFreedom idx_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), idx(idx_), val2(&val_),
    posType(1), valueType(2),
    SignedDistFct(NULL), SignedDistDOF(NULL), val0(0.0), val1(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  // pos = SignedDistFct
  DirichletBcData(int i_, int j_, AbstractFunction<double, WorldVector<double> > *SignedDistFct_, double val_)
  : row(i_), col(j_), SignedDistFct(SignedDistFct_), val0(val_),
    posType(2), valueType(0),
    idx(0), SignedDistDOF(NULL), val1(NULL), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, AbstractFunction<double, WorldVector<double> > *SignedDistFct_, DOFVector<double> &val_)
  : row(i_), col(j_), SignedDistFct(SignedDistFct_), val1(&val_),
    posType(2), valueType(1),
    idx(0), SignedDistDOF(NULL), val0(0.0), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, AbstractFunction<double, WorldVector<double> > *SignedDistFct_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), SignedDistFct(SignedDistFct_), val2(&val_),
    posType(2), valueType(2),
    idx(0), SignedDistDOF(NULL), val0(0.0), val1(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  // pos = SignedDistDOF
  DirichletBcData(int i_, int j_, DOFVector<double> *SignedDistDOF_, double val_)
  : row(i_), col(j_), SignedDistDOF(SignedDistDOF_), val0(val_),
    posType(3), valueType(0),
    idx(0), SignedDistFct(NULL), val1(NULL), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, DOFVector<double> *SignedDistDOF_, DOFVector<double> &val_)
  : row(i_), col(j_), SignedDistDOF(SignedDistDOF_), val1(&val_),
    posType(3), valueType(1),
    idx(0), SignedDistFct(NULL), val0(0.0), val2(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, DOFVector<double> *SignedDistDOF_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), SignedDistDOF(SignedDistDOF_), val2(&val_),
    posType(3), valueType(2),
    idx(0), SignedDistFct(NULL), val0(0.0), val1(NULL),
    boundary_nr(0), meshIndicator(NULL)  { pos.set(0.0); }
    
  // pos = meshindicator + boundary_nr
  DirichletBcData(int i_, int j_, BoundaryType nr, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, double val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val0(val_),
    posType(4), valueType(0),
    idx(0), SignedDistFct(NULL), val1(NULL), val2(NULL),
    boundary_nr(nr), meshIndicator(meshIndicator_)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, BoundaryType nr, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, DOFVector<double> &val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val1(&val_),
    posType(4), valueType(1),
    idx(0), SignedDistFct(NULL), val0(0.0), val2(NULL),
    boundary_nr(nr), meshIndicator(meshIndicator_)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, BoundaryType nr, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val2(&val_),
    posType(4), valueType(2),
    idx(0), SignedDistFct(NULL), val0(0.0), val1(NULL),
    boundary_nr(nr), meshIndicator(meshIndicator_)  { pos.set(0.0); }
    
  // pos = meshindicator
  DirichletBcData(int i_, int j_, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, double val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val0(val_),
    posType(4), valueType(0),
    idx(0), SignedDistFct(NULL), val1(NULL), val2(NULL),
    boundary_nr(0), meshIndicator(meshIndicator_)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, DOFVector<double> &val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val1(&val_),
    posType(4), valueType(1),
    idx(0), SignedDistFct(NULL), val0(0.0), val2(NULL),
    boundary_nr(0), meshIndicator(meshIndicator_)  { pos.set(0.0); }

  DirichletBcData(int i_, int j_, AbstractFunction<bool, WorldVector<double> > *meshIndicator_, AbstractFunction<double, WorldVector<double> > &val_)
  : row(i_), col(j_), SignedDistDOF(NULL), val2(&val_),
    posType(4), valueType(2),
    idx(0), SignedDistFct(NULL), val0(0.0), val1(NULL),
    boundary_nr(0), meshIndicator(meshIndicator_)  { pos.set(0.0); }
    
  void addToList(const FiniteElemSpace *feSpace, std::vector<SingularDirichletBC> &list)
  {
    std::vector<DegreeOfFreedom> indices_;
    std::vector<double> values_;
    DegreeOfFreedom idx_ = 0;

    switch (posType) {
      case 0:
	if (val1 == NULL && SignedDistDOF == NULL) {
	  val1 = new DOFVector<double>(feSpace, "vel1");
	}
	if (val1 != NULL) {
	  if (!val1->getDofIdxAtPoint(pos, idx_))
	    idx_ = 0;
	} else if (SignedDistDOF != NULL) {
	  if (!SignedDistDOF->getDofIdxAtPoint(pos, idx_))
	    idx_ = 0;
	}
	indices_.push_back(idx_);
	break;
	
      case 1:
	indices_.push_back(idx);
	break;
	
      case 2:
	details::getImplicitIndices(feSpace, SignedDistFct, indices_);
	break;
	
      case 3:
	details::getImplicitIndices(feSpace, SignedDistDOF, indices_);
	break;
	
      case 4:
443
	std::set<DegreeOfFreedom> indices__;
444
	if (boundary_nr == 0)
445
	  details:: getBoundaryIndices(feSpace, meshIndicator, indices__);
446
	else
447
448
449
450
	  details:: getBoundaryIndices(feSpace, boundary_nr, meshIndicator, indices__);
	std::set<DegreeOfFreedom>::iterator it;
	for (it = indices__.begin(); it != indices__.end(); it++)
	  indices_.push_back(*it);
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
	break;
    }

    switch (valueType) {
      case 0:
	values_.resize(indices_.size(), val0);
	break;
	
      case 1:
	details::getDOFValues(feSpace, val1, indices_, values_);
	break;
	
      case 2:
	details::getDOFValues(feSpace, val2, indices_, values_);
	break;
    }

    DOFVector<WorldVector<double> > coords(feSpace, "coords");
469
    feSpace->getMesh()->getDofIndexCoords(coords);
470
471
    

472
    for (size_t i = 0; i < indices_.size(); i++) {
473
      list.push_back(SingularDirichletBC(row, col, indices_[i], values_[i]));
474
    }
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
    
    MSG_DBG("Dirichle BC at %d DOFs added.\n",indices_.size());
  }


  int row,col;

private:
  int posType; 		// 0..WorldVector, 1..DegreeOfFreedom, 2..SignedDistFct, 3..signedDistDOF, 4..meshIndicator
  int valueType; 	// 0..double, 1..DOFVector, 2..AbstractFunction

  // pos
  WorldVector<double> pos;
  DegreeOfFreedom idx;
  AbstractFunction<double, WorldVector<double> > *SignedDistFct;
  DOFVector<double> *SignedDistDOF;

  BoundaryType boundary_nr;
  AbstractFunction<bool, WorldVector<double> >* meshIndicator;
  
  // value
  double val0;
  DOFVector<double> *val1;
  AbstractFunction<double, WorldVector<double> > *val2;
};


struct PeriodicBcData {

  // pos = WorldVector
  PeriodicBcData(int row_, BoundaryType nr_, AbstractFunction<bool, WorldVector<double> >* meshIndicator_,
		 AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap_)
  : row(row_), nr(nr_), meshIndicator(meshIndicator_), periodicMap(periodicMap_) {}

  PeriodicBcData(int row_, AbstractFunction<bool, WorldVector<double> >* meshIndicator_,
		 AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap_)
  : row(row_), nr(0), meshIndicator(meshIndicator_), periodicMap(periodicMap_) {}

  void addToList(const FiniteElemSpace *feSpace, std::vector<ManualPeriodicBC> &list)
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
515
    std::set<DegreeOfFreedom> indices;
516
    if (nr == 0)
Praetorius, Simon's avatar
Praetorius, Simon committed
517
      details::getBoundaryIndices(feSpace, meshIndicator, indices);
518
    else
Praetorius, Simon's avatar
Praetorius, Simon committed
519
520
521
522
      details::getBoundaryIndices(feSpace, nr, meshIndicator, indices);
    
    std::vector<std::pair<DegreeOfFreedom, DegreeOfFreedom> > associations;
    details::getPeriodicAssociation(feSpace, indices, periodicMap, associations);
523
524
    list.push_back(ManualPeriodicBC(row, associations));
  }
525
  int row;
526
527
528
529
530
531
532
533
534
535
536
537

protected:


  BoundaryType nr;
  AbstractFunction<bool, WorldVector<double> >* meshIndicator;
  AbstractFunction<WorldVector<double>, WorldVector<double> >* periodicMap;
};

} // end namespace 

#endif // SINGULAR_DIRICHLET_BC_H