LifeV
BCHandler.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief File containing BCHandler class for handling boundary conditions
30 
31  @author Miguel Fernandez <miguel.fernandez@inria.fr>
32  @contributor Christophe Prud'homme <christophe.prudhomme@epfl.ch>
33  @contributor Mauro Perego <perego.mauro@gmail.com>
34  @maintainer Mauro Perego <perego.mauro@gmail.com>
35 
36  @date 10-11-2004
37  *///@HEADER
38 
39 #ifndef BCHANDLER_H
40 #define BCHANDLER_H 1
41 
42 #include <lifev/core/fem/BCBase.hpp>
43 
44 namespace LifeV
45 {
46 
47 //! BCHandler - class for handling boundary conditions
48 /*!
49  @author Miguel Fernandez
50 
51  Container for @c BCBase classes
52 
53  @c BCHandler is a container of @c BCBase objects.
54  It instantiates the needed @c BCBase objects and provide them with the data needed.
55  As an example, if a @c BCBase object is related with an Essential boundary condition, then the global DOFs IDs associated with that essential boundary conditions will be passed to the object.
56 
57  Boundary conditions are added using the method @c addBC(@c name, @c flag, @c type, ...).
58  @c type is a @c bcType_Type and describes the type of boundary condition (@c Essential, @c Natural, etc.).
59  @c flag is used to determine on which elements the boundary condition should be prescribed.
60 
61  In general @c flag refers to the boundary elements' marker.
62  The only exception are the @c bcType_Type @c EssentialEdges and @c EssentialVertices.
63  In these two cases the flag refers respectively to the Edges' markers and to the Vertices' markers.
64  In general @c EssentialEdges and @c EssentialVertices types are not recommended and they should be used only by advanced users.
65 
66  For this reasons boundary element markers are needed (and they better be specified in the mesh files).
67 
68 
69  The typical way to use the class is to create function handlers:
70 
71  @verbatim
72  BCFunctionBase bcFuncEss( solOnBoundary ), bcFuncNat( ZeroFunction);
73 
74  @endverbatim
75 
76  Then, instantiate a BCHandler object and add boundary conditions (this will create @c BCBase objects).
77 
78  @verbatim
79  BCHandler bcHandler;
80  bcHandler.addBC( "inlet", 10, Essential, Full, bcFuncEss, 3 );
81  bcHandler.addBC( "outlet", 20, Natural, Full, bcFuncNat, 3 );
82  bcHandler.addBC( "wall", 30, Essential, Full, bcFuncEss, 3 );
83  @endverbatim
84 
85  Number 10, 20, 30 refers to the markers on the mesh boundary elements (facets: faces in 3D, edges in 2D).
86  More information about boundary conditions will be found in BCBase.hpp
87 
88  Then, update the boundary conditions, using the function bcUpdate
89  @verbatim
90  bcHandler.bcUpdate(mesh, boundaryFe, dof);
91  @endverbatim
92 
93  This method will looks for the markers in the mesh and will fill the boundary conditions container BCBase, with the appropriate data structures (global DOF id.. coordinates.. ecc)
94 
95  Now all is set to prescribe boundary conditions using one of the functions in bcManager.hpp
96  */
97 
98 
99 
101 {
102 public:
103 
104  //! @name Public Types
105  //@{
106 
109 
111 
112  //@}
113 
114  //! @name Constructor & Destructor
115  //@{
116 
117  //! Empty Constructor
118  BCHandler();
119 
120  //! Copy constructor
121  /*!
122  @warning This is not a copy constructor, since bcUpdate is set to false,
123  as a consequence of the fact that also BCBase "copy" constructor is not
124  actually a copy constructor
125  @param bcHandler BCHandler
126  */
127  BCHandler ( const BCHandler& bcHandler );
128 
129  //! Destructor
130  ~BCHandler();
131 
132  //@}
133 
134 
135  //! @name Operators
136  //@{
137 
138  //! Assignment operator
139  /*!
140  @param bcHandler BCHandler
141  @return Reference to a new BCHandler with the same
142  content of BCHandler bcHandler
143  */
144  BCHandler& operator= ( const BCHandler& bcHandler );
145 
146  //! Extract a BC in the list
147  /*!
148  @param i Position index
149  @return Reference to the BCBase object in M_bcList at position i
150  */
151  BCBase& operator[] ( const ID& );
152 
153  //! Extract a BC in the list, const
154  /*!
155  @param i Position index
156  @return Const reference to the BCBase object in M_bcList at position i
157  */
158  const BCBase& operator[] ( const ID& ) const;
159 
160  //@}
161 
162 
163  //! @name Methods
164  //@{
165 
166  //! Add new BC to the list for Component or Directional mode problems (user defined function case)
167  /*!
168  @param name The name of the boundary condition
169  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
170  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
171  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
172  @param bcFunction The container holding the user defined function involved in this boundary condition
173  @param components storing the list of components involved in this boundary condition
174  */
175  void addBC ( const std::string& name,
176  const bcFlag_Type& flag,
177  const bcType_Type& type,
178  const bcMode_Type& mode,
179  BCFunctionBase& bcFunction,
180  const bcComponentsVec_Type& components );
181 
182 
183  //! Add new BC to the list for Scalar, Tangential or Normal mode problems (user defined function case)
184  /*!
185  @param name The name of the boundary condition
186  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
187  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
188  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
189  @param bcFunction The container holding the user defined function involved in this boundary condition
190  */
191  void addBC ( const std::string& name,
192  const bcFlag_Type& flag,
193  const bcType_Type& type,
194  const bcMode_Type& mode,
195  BCFunctionBase& bcFunction );
196 
197 
198  //! Add new BC to the list for Full mode problems (user defined function case)
199  /*!
200  @param name The name of the boundary condition
201  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
202  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
203  @param mode The boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
204  @param bcFunction The container holding the user defined function involved in this boundary condition
205  @param numberOfComponents The number of components involved in this boundary condition
206  */
207  void addBC ( const std::string& name,
208  const bcFlag_Type& flag,
209  const bcType_Type& type,
210  const bcMode_Type& mode,
211  BCFunctionBase& bcFunction,
212  const UInt& numberOfComponents );
213 
214 
215  //! Add new BC to the list for Component or Directional mode problems (data vector case)
216  /*!
217  @param name The name of the boundary condition
218  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
219  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
220  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
221  @param bcVector The container holding the finite element vector involved in this boundary condition
222  @param components storing the list of components involved in this boundary condition
223  */
224  void addBC ( const std::string& name,
225  const bcFlag_Type& flag,
226  const bcType_Type& type,
227  const bcMode_Type& mode,
228  BCVectorBase& bcVector,
229  const bcComponentsVec_Type& components );
230 
231 
232  //! Add new BC to the list for Scalar, Tangential or Normal mode problems (data vector case)
233  /*!
234  @param name The name of the boundary condition
235  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
236  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
237  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
238  @param bcVector The container holding the finite element vector involved in this boundary condition
239  */
240  void addBC ( const std::string& name,
241  const bcFlag_Type& flag,
242  const bcType_Type& type,
243  const bcMode_Type& mode,
244  BCVectorBase& bcVector );
245 
246 
247  //! Add new BC to the list for Full mode problems (data vector case)
248  /*!
249  @param name The name of the boundary condition
250  @param flag The mesh flag identifying the part of the mesh where the boundary condition applies
251  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
252  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
253  @param bcVector The container holding the finite element vector involved in this boundary condition
254  @param numberOfComponents The number of components involved in this boundary condition
255  */
256  void addBC ( const std::string& name,
257  const bcFlag_Type& flag,
258  const bcType_Type& type,
259  const bcMode_Type& mode,
260  BCVectorBase& bcVector,
261  const UInt& nComp );
262 
263 
264  //! Add new BC to the list for Scalar, Tangential or Normal mode problems (user defined function case, with function depending on U)
265  /*!
266  @param name The name of the boundary condition
267  @param flag The mesh flag identifying the part of the mesh bcBaseIterator the boundary condition applies
268  @param type The boundary condition type: Natural, Robin, Flux, Resistance, Periodic, Essential, EssentialEdges, EssentialVertices
269  @param mode the boundary condition mode: Scalar, Full, Component, Normal, Tangential, Directional
270  @param bcFunctionFEVectorDependent The container holding the user defined function, depending on a FE vector, involved in this boundary condition
271  */
272  void addBC ( const std::string& name,
273  const bcFlag_Type& flag,
274  const bcType_Type& type,
275  const bcMode_Type& mode,
276  BCFunctionUDepBase& bcFunctionFEVectorDependent );
277 
278  //! Add new BC to the list using a BCBase object
279  /*!
280  @param bcBase a BCBase object
281  */
282  void addBC ( const BCBase& bcBase );
283 
284 
285  //! Modify the boundary condition @c name, assigning the function @c bcFunction
286  /*!
287  @param name The name of the boundary condition to be modified
288  @param bcFunction The container holding the user defined function which will replace the existing one
289 
290  */
291  void modifyBC ( std::string const& name, BCFunctionBase const& bcFunction );
292 
293  //! Modify the boundary condition @c assigning the FE vector in @c bcVector
294  /*!
295  @param name The name of the boundary condition to be modified
296  @param bcVector The container holding the user FE vector which will replace the existing one
297  */
298  void modifyBC ( std::string const& name, BCVectorBase const& bcVector );
299 
300  //! Modify the boundary condition @c name, assigning the function in @c bcFunctionFEVectorDependent
301  /*!
302  @param name The name of the boundary condition to be modified
303  @param bcFunctionFEVectorDependent The container holding the user defined function, depending on an FE vector, which will replace the existing one
304  */
305  void modifyBC ( std::string const& name, BCFunctionUDepBase const& bcFunctionFEVectorDependent );
306 
307  //! Modify the boundary condition associated with flag @c aFlag, assigning the function in @c bcFunction
308  /*!
309  @param aFlag The flag associated with the boundary condition to be modified
310  @param bcFunction The container holding the user defined function which will replace the existing one
311  */
312  void modifyBC ( bcFlag_Type const& aFlag, BCFunctionBase const& bcFunction );
313 
314  //! Modify the boundary condition associated with flag @c aFlag, assigning the FE vector in @c bcVector
315  /*!
316  @param aFlag The flag associated with the boundary condition to be modified
317  @param bcVector The container holding the user FE vector which will replace the existing one
318  */
319  void modifyBC ( bcFlag_Type const& aFlag, BCVectorBase const& bcVector );
320 
321  //! Modify the boundary condition associated with flag @c aFlag, assigning the function in @c bcFunctionFEVectorDependent
322  /*!
323  @param aFlag The flag associated with the boundary condition to be modified
324  @param bcFunctionFEVectorDependent The container holding the user defined function, depending on an FE vector, which will replace the existing one
325  */
326  void modifyBC ( bcFlag_Type const& aFlag, BCFunctionUDepBase const& bcFunctionFEVectorDependent );
327 
328  //! Modify the boundary condition associated with flag @c aFlag, assigning the type in @c bcType
329  /*!
330  @param aFlag The flag associated with the boundary condition to be modified
331  @param bcVector The type of b.c. which will replace the existing one
332  */
333  void modifyBC ( bcFlag_Type const& aFlag, bcType_Type const& bcType );
334 
335  //! Update all the boundary conditions
336  /*!
337  This method update the BC classes checking the markers
338  on the boundary.
339  Except for EssentialEdges and EssentialVertices type of boundary conditions,
340  the flags associated with the boundary conditions will be searched among the markers of the boundary element (facets).
341 
342  Then, all the DOFs belonging to a matching boundary element will be associated with the appropriate boundary conditions.
343  It is possible then the same DOF is shared by different boundary conditions.
344  In the case of essential boundary conditions, the largest condition will be prescribed on the shared DOF (largest in the ordering given by the operator< in BCBase.hpp)
345  In particular, if two Essential boundary conditions share the same DOF, it will be prescribed the condition with the largest flag.
346  This behavior is due to the fact that the largest boundary condition is the last to be prescribed.
347 
348  Finally M_bcUpdateDone is set to true, and it is possible to prescribed boundary conditions using functions in BCManage.hpp.
349 
350  @param mesh The mesh
351  @param boundaryFE Current finite element on the boundary
352  @param dof Container of the local to global map of DOF id
353  */
354  template <typename Mesh>
355  void bcUpdate ( Mesh& mesh, CurrentFEManifold& boundaryFE, const DOF& dof );
356 
357  //! Merges the boundary condition bcHandler (with its offset) with the stored one
358  /*!
359  @param bch BCHandler
360  */
361  void merge ( BCHandler& bcHandler );
362 
363  //! Display the content of the variables
364  /*!
365  @param verbose The verbosity (default: true)
366  @param out The ostream output (default: std::cout)
367  */
368  void showMe ( bool verbose = false, std::ostream& out = std::cout ) const;
369 
370  //@}
371 
372 
373  //! @name Set Methods
374  //@{
375 
376  //! Set @c offset in all boundary conditions
377  /*!
378  @param offset The boundary condition offset
379  */
380  void setOffset ( const UInt& offset );
381 
382  //! Set @c offset in boundary conditions @c name
383  /*!
384  @param name The name of the boundary condition
385  @param offset The boundary condition offset
386  */
387  void setOffset ( const std::string& name, Int offset );
388 
389  //@}
390 
391 
392  //! @name Get Methods
393  //@{
394 
395  //! Extract a BC in the list according to its flag
396  /*!
397  @param aFlag The flag associated with the boundary condition
398  @return constant Reference to the boundary condition associated with flag aFlag
399  */
400  BCBase& findBCWithFlag (const bcFlag_Type& aFlag);
401 
402 
403  //! Extract a BC in the list according to its flag (non const)
404  /*!
405  @param aFlag The flag associated with the boundary condition
406  @return constant Reference to the boundary condition associated with flag aFlag
407  */
408  const BCBase& findBCWithFlag (const bcFlag_Type& aFlag) const;
409 
410  //! Get a vector list of BC with specific type. The list contains the bcName_Type of the BC.
411  /*!
412  @param aType The BC type to be inserted in the list
413  */
415 
416 
417  //! Get the number of boundary conditions with type @c aType
418  /*!
419  @param aType The BC type to be counted
420  @return Number of boundary conditions with type aType
421  */
422  UInt numberOfBCWithType ( const bcType_Type& aType ) const;
423 
424 
425  // Get the BC index from the list using its name
426  /*!
427  @param name The name of the boundary condition
428  @return The index of the boundary condition
429  */
430  ID findBCIndexWithName (const bcName_Type& name) const;
431 
432  // Get the BC from the list using its name
433  /*!
434  @param name The name of the boundary condition
435  @return The index of the boundary condition
436  */
437  const BCBase* findBCWithName (const bcName_Type& name) const;
438 
439 
440  // Get the offset of the boundary conditions
441  /*!
442  @return The offset of the boundary conditions
443  */
444  inline UInt offset() const
445  {
446  return M_offset;
447  }
448 
449 
450  //! Iterator of the beginning of the boundary elements list
451  /*!
452  @return The Iterator of the beginning of M_bcList
453  */
455  {
456  return M_bcList.begin();
457  }
459  {
460  return M_bcList.begin();
461  }
462 
463 
464  //! Iterator of the end of the boundary elements list
465  /*!
466  @return The Iterator of the end of M_bcList
467  */
469  {
470  return M_bcList.end();
471  }
473  {
474  return M_bcList.end();
475  }
476 
477 
478  //! Number of the stored boundary conditions
479  /*!
480  @return the number of boundary conditions stored
481  */
482  inline UInt size() const
483  {
484  return M_bcList.size();
485  }
486 
487 
488  //! Determine whether no boundary conditions are stored
489  /*!
490  @return true only if no boundary conditions are stored
491  */
492  inline bool empty() const
493  {
494  return M_bcList.empty();
495  }
496 
497 
498  //! Determine whether bcUpdate has been done before
499  /*!
500  @return true only if bcUpdate has been done before
501  */
502  inline bool bcUpdateDone() const
503  {
504  return M_bcUpdateDone;
505  }
506 
507 
508  //!Determine whether all the stored boundary conditions have EssentialXXX type
509  /*! It throws a @c logic_error exception if state is not consistent with hint.
510  @return true only if the stored boundary conditions are of EssentialXXX type
511  */
512  bool hasOnlyEssential() const;
513 
514  //@}
515 
516 private:
517 
518  //! Find the BC named @c name
519  /*!
520  It throws an @c invalid_argument exception if @c name is not
521  found.
522 
523  @return A pointer to @c BCBase
524  */
525  BCBase* findBC ( const std::string& name );
526 
527 
528  //! Find the BC named @c aFlag
529  /*!
530  It throws an @c invalid_argument exception if @c aFlag is not
531  found.
532 
533  @return A pointer to @c BCBase
534  */
535  BCBase* findBC ( const bcFlag_Type& aFlag);
536 
537  //! Sum the M_offset to boundary conditions offsets
538  void M_sumOffsets();
539 
540  //! true only if the bcUpdate has been done
542 
543  //! vector list holding the stored BCs
545 
546  //! offset
548 
549  //! set of markers which are in the mesh but not in the list
551 
552 };
553 
554 
555 // ===================================================
556 // Template methods implementations
557 // ===================================================
558 template <typename Mesh>
559 void
560 BCHandler::bcUpdate ( Mesh& mesh, CurrentFEManifold& boundaryFE, const DOF& dof )
561 {
562  typedef typename Mesh::elementShape_Type geoShape_Type;
563  typedef typename geoShape_Type::GeoBShape geoBShape_Type;
564 
565  // Some useful local variables
566  UInt nDofPerVert = dof.localDofPattern().nbDofPerVertex(); // number of DOF per vertices
567  UInt nBElemVertices = geoBShape_Type::S_numVertices; // Number of boundary element's vertices
568 
569  UInt nDofPerEdge = dof.localDofPattern().nbDofPerEdge(); // number of DOF per vertices
570  UInt nBElemEdges = geoBShape_Type::S_numEdges; // Number of boundary element's vertices
571 
572  bcFlag_Type marker; //will store the marker of each geometric entity
573  bcFlag_Type elementMarker; //will store the marker of the element
574 
575  // BCbase Iterator
576  bcBaseIterator_Type bcBaseIterator;
577 
578  // Iterators which point to the beginning of EssentialEdges and EssentialVertices conditions
579  bcBaseIterator_Type beginEssential, beginEssVertices, beginEssEdges;
580 
581  // coordinates of DOFs points
582  Real x, y, z;
583 
584  //sets containing markers of boundary elements which have not been found in the boundary conditions' flags
585  std::set<bcFlag_Type> notFoundMarkers;
586 
587  bool marker_found (false);
588 
589  //We set the iterators which points to the beginning of essential types bc.
590  //(Notice that essential bc are positioned at the end of M_bcList, in the order
591  // Essential, EssentialEdges, EssentialVertices)
592 
593  beginEssential = M_bcList.begin();
594  while ( (beginEssential != M_bcList.end() ) && (beginEssential->type() < Essential) )
595  {
596  beginEssential++;
597  }
598 
599  beginEssEdges = beginEssential;
600  while ( (beginEssEdges != M_bcList.end() ) && (beginEssEdges->type() < EssentialEdges) )
601  {
602  beginEssEdges++;
603  }
604 
605  beginEssVertices = beginEssEdges;
606  while ( (beginEssVertices != M_bcList.end() ) && (beginEssVertices->type() < EssentialVertices) )
607  {
608  beginEssVertices++;
609  }
610 
611  // ===================================================
612  // Loop on boundary faces
613  // ===================================================
614  for ( ID iBoundaryElement = 0 ; iBoundaryElement < mesh.numBoundaryFacets(); ++iBoundaryElement )
615  {
616  // ===================================================================================
617  // construction of localToGlobalMapOnBElem (this part should be moved in DOF.hpp)
618  // ===================================================================================
619 
620  boundaryFE.update ( mesh.boundaryFacet ( iBoundaryElement ), UPDATE_ONLY_CELL_NODES ); // updating finite element information
621  elementMarker = mesh.boundaryFacet ( iBoundaryElement ).markerID(); // We keep the element marker
622 
623 
624  //vector containing the local to global map on each element
625  std::vector<ID> localToGlobalMapOnBElem = dof.localToGlobalMapOnBdFacet (iBoundaryElement);
626 
627  // =============================================================
628  // Insertion of boundary conditions defined on boundary Elements
629  // =============================================================
630 
631  //looking for elementMarker in boundary conditions' flags, and updating the boundary conditions data accordingly
632 
633  marker_found = false;
634  bcBaseIterator = M_bcList.begin();
635  while ( ( bcBaseIterator = std::find ( bcBaseIterator, beginEssEdges, elementMarker ) ) != beginEssEdges )
636  {
637  marker_found = true;
638  switch ( bcBaseIterator->type() )
639  {
640  case EssentialVertices:
641  case EssentialEdges:
642  ERROR_MSG ("EssentialVertices and EssentialEdges types should not be prescribed on face labels");
643  break;
644 
645  case Essential:
646  for (ID lDof = 0; lDof < localToGlobalMapOnBElem.size(); lDof++)
647  {
648  ID gDof = localToGlobalMapOnBElem[ lDof]; // global DOF
649 
650  //providing Essential boundary conditions with needed data (global DOF id and their coordinates)
651  if ( bcBaseIterator->isDataAVector() )
652  {
653  bcBaseIterator->addBCIdentifier ( new BCIdentifierBase ( gDof) );
654  }
655  else
656  {
657  // With user defined functions
658  boundaryFE.coorMap ( x, y, z, boundaryFE.refFE().xi ( lDof ), boundaryFE.refFE().eta ( lDof ) );
659  bcBaseIterator->addBCIdentifier ( new BCIdentifierEssential ( gDof, x, y, z ) );
660  }
661  }
662  break;
663 
664  case Natural:
665  //providing Natural boundary conditions with global DOFs on element
666  if ( bcBaseIterator->isDataAVector() )
667  {
668  // With data vector
669  UInt type = bcBaseIterator->pointerToBCVector()->type() ;
670  if ( type == 0 ) // if the BC is a vector which values don't need to be integrated
671  {
672  for (ID lDof = 0; lDof < localToGlobalMapOnBElem.size(); lDof++)
673  {
674  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( localToGlobalMapOnBElem[lDof] ) );
675  }
676  }
677  else if ( type <= 3 ) // FE vector which needed to be integrated on the boundary
678  {
679  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( iBoundaryElement, localToGlobalMapOnBElem ) );
680  }
681  else
682  {
683  ERROR_MSG ( "This BCVector type is not yet implemented" );
684  }
685  }
686  else
687  {
688  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( iBoundaryElement, localToGlobalMapOnBElem) );
689  }
690  break;
691 
692  case Robin:
693  //providing Robin boundary conditions with global DOFs on element
694  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( iBoundaryElement, localToGlobalMapOnBElem ) );
695  break;
696  case Resistance:
697  //providing Resistance boundary conditions with global DOFs on element
698  if ( bcBaseIterator->isDataAVector() )
699  {
700  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( iBoundaryElement, localToGlobalMapOnBElem ) );
701  }
702  break;
703  case Flux:
704  //providing Flux boundary conditions with global DOFs on element
705  bcBaseIterator->addBCIdentifier ( new BCIdentifierNatural ( iBoundaryElement, localToGlobalMapOnBElem ) );
706  break;
707  default:
708  ERROR_MSG ("BC not yet implemented");
709  break;
710  }
711  bcBaseIterator++;
712  }
713 
714  //inserting found and not found markers in respective containers.
715  if (!marker_found)
716  {
717  notFoundMarkers.insert (elementMarker);
718  }
719 
720 
721  // ===================================================
722  // Insertion of EssentialEdges bc
723  // ===================================================
724 
725  //looking for which EssentialEdges are involved in this element.
726  if ( (beginEssEdges != beginEssVertices) && (nDofPerVert || nDofPerEdge) )
727  {
728  ID iAdjacentElem = mesh.boundaryFacet ( iBoundaryElement ).firstAdjacentElementIdentity(); // id of the element adjacent to the face
729  ID iElemBElement = mesh.boundaryFacet ( iBoundaryElement ).firstAdjacentElementPosition(); // local id of the face in its adjacent element
730 
731  //loop on boundary element edges
732  for ( ID iBElemEdge = 0; iBElemEdge < nBElemEdges; ++iBElemEdge )
733  {
734  //index of edge in element
735  ID iElemEdge = geoShape_Type::faceToEdge ( iElemBElement, iBElemEdge ).first;
736 
737  //marker on boundary edge
738  marker = mesh.boundaryEdge ( mesh.localEdgeId ( iAdjacentElem, iElemEdge ) ).markerID(); // edge marker
739 
740  //indices of edge's vertices
741  UInt iEdgeFirstVert = geoBShape_Type::edgeToPoint ( iBElemEdge, 0);
742  UInt iEdgeSecondVert = geoBShape_Type::edgeToPoint ( iBElemEdge, 1);
743 
744  // Finding this marker on the BC list
745  bcBaseIterator = beginEssEdges;
746  while ( ( bcBaseIterator = std::find ( bcBaseIterator, beginEssVertices, marker ) ) != beginEssVertices )
747  {
748  //vector of boundary element DOFs on current edge
749  std::vector<ID> vecEdgeDofs (nDofPerEdge + 2 * nDofPerVert);
750 
751  ID iTotalEdgeDof = 0; //local index of total DOF on current edge
752 
753  //loop on Vertices DOFs
754  for ( ID iVertexDof = 0; iVertexDof < nDofPerVert; ++iVertexDof )
755  {
756  vecEdgeDofs[iTotalEdgeDof++] = iEdgeFirstVert * nDofPerVert + iVertexDof ; // local Dof
757  vecEdgeDofs[iTotalEdgeDof++] = iEdgeSecondVert * nDofPerVert + iVertexDof ;
758  }
759 
760  //loop on Edge DOFs
761  for ( ID iEdgeDof = 0; iEdgeDof < nDofPerEdge; ++iEdgeDof )
762  {
763  vecEdgeDofs[iTotalEdgeDof++] = nDofPerVert * nBElemVertices + iBElemEdge * nDofPerEdge + iEdgeDof ; // local Dof
764  }
765 
766 
767  //loop on total DOFs of current edge
768  for (iTotalEdgeDof = 0; iTotalEdgeDof < vecEdgeDofs.size(); iTotalEdgeDof++)
769  {
770  UInt lDof = vecEdgeDofs[iTotalEdgeDof]; //local DOF on boundary element
771  UInt gDof = localToGlobalMapOnBElem[ lDof ]; // global DOF
772 
773  //providing the boundary conditions with needed data
774  if ( bcBaseIterator->isDataAVector() )
775  {
776  bcBaseIterator->addBCIdentifier ( new BCIdentifierBase ( gDof ) );
777  }
778  else
779  {
780  // With user defined functions
781  boundaryFE.coorMap ( x, y, z, boundaryFE.refFE().xi ( lDof ), boundaryFE.refFE().eta ( lDof ) );
782  bcBaseIterator->addBCIdentifier ( new BCIdentifierEssential ( gDof, x, y, z ) );
783  }
784  }
785  bcBaseIterator++;
786  }
787  }
788  }
789 
790 
791  // ===================================================
792  // Insertion of EssentialVertices bc
793  // ===================================================
794  if ( (beginEssVertices != M_bcList.end() ) && nDofPerVert)
795  {
796  //loop on boundary element vertices
797  for ( ID iBElemVert = 0; iBElemVert < nBElemVertices; ++iBElemVert )
798  {
799  marker = mesh.boundaryFacet ( iBoundaryElement ).point ( iBElemVert ).markerID(); // vertex marker
800 
801  // Finding this marker on the BC list
802  bcBaseIterator = beginEssVertices;
803  while ( ( bcBaseIterator = std::find ( bcBaseIterator, M_bcList.end(), marker ) ) != M_bcList.end() )
804  {
805  for ( ID iVertexDof = 0; iVertexDof < nDofPerVert; ++iVertexDof )
806  {
807  UInt lDof = iBElemVert * nDofPerVert + iVertexDof ; // local Dof
808  UInt gDof = localToGlobalMapOnBElem[lDof]; // global Dof
809 
810  //providing the boundary conditions with needed data
811  if ( bcBaseIterator->isDataAVector() )
812  {
813  bcBaseIterator->addBCIdentifier ( new BCIdentifierBase ( gDof ) );
814  }
815  else
816  {
817  // With user defined functions
818  boundaryFE.coorMap ( x, y, z, boundaryFE.refFE().xi ( lDof ), boundaryFE.refFE().eta ( lDof ) );
819  bcBaseIterator->addBCIdentifier ( new BCIdentifierEssential ( gDof, x, y, z ) );
820  }
821  }
822  bcBaseIterator++;
823  }
824  }
825  }
826  }
827 
828 
829 #ifdef DEBUG
830 
831  if ( notFoundMarkers.size() > 0 )
832  {
833 
834 
835  debugStream (5010) <<
836  "WARNING -- BCHandler::bcUpdate()\n" <<
837  " boundary degrees of freedom with the following markers\n" <<
838  " have no boundary condition set: ";
839  for ( std::set<bcFlag_Type>::iterator it = notFoundMarkers.begin();
840  it != notFoundMarkers.end(); ++it )
841  {
842  debugStream (5010) << *it << " ";
843  }
844  debugStream (5010) << "\n";
845 
846  }
847 #endif
848 
849  // ============================================================================
850  // There is no more identifiers to add to the boundary conditions
851  // We finalize the set of identifiers by transferring it elements to a std::vector
852  // ============================================================================
853  for ( bcBaseIterator = M_bcList.begin(); bcBaseIterator != M_bcList.end(); ++bcBaseIterator )
854  {
855  bcBaseIterator->copyIdSetIntoIdVector();
856  }
857 
858  M_bcUpdateDone = true;
859 } // bcUpdate
860 
861 } // namespace LifeV
862 
863 #endif /* BCHANDLER_H */
const BCBase & operator[](const ID &) const
Extract a BC in the list, const.
Definition: BCHandler.cpp:98
bcBaseIterator_Type begin()
Iterator of the beginning of the boundary elements list.
Definition: BCHandler.hpp:454
BCBase & findBCWithFlag(const bcFlag_Type &aFlag)
Extract a BC in the list according to its flag.
Definition: BCHandler.cpp:304
void addBC(const BCBase &bcBase)
Add new BC to the list using a BCBase object.
Definition: BCHandler.cpp:190
BCFunctionUDepBase - class that holds the function used for prescribing boundary conditions.
Definition: BCFunction.hpp:380
markerID_Type bcFlag_Type
Definition: BCBase.hpp:118
void modifyBC(bcFlag_Type const &aFlag, BCVectorBase const &bcVector)
Modify the boundary condition associated with flag aFlag, assigning the FE vector in bcVector...
Definition: BCHandler.cpp:231
void bcUpdate(Mesh &mesh, CurrentFEManifold &boundaryFE, const DOF &dof)
Update all the boundary conditions.
Definition: BCHandler.hpp:560
std::set< bcFlag_Type > M_notFoundMarkers
set of markers which are in the mesh but not in the list
Definition: BCHandler.hpp:550
A class for a finite element on a manifold.
bcBaseIterator_Type end()
Iterator of the end of the boundary elements list.
Definition: BCHandler.hpp:468
BCHandler - class for handling boundary conditions.
Definition: BCHandler.hpp:100
void modifyBC(bcFlag_Type const &aFlag, bcType_Type const &bcType)
Modify the boundary condition associated with flag aFlag, assigning the type in bcType.
Definition: BCHandler.cpp:247
std::vector< BCBase > M_bcList
vector list holding the stored BCs
Definition: BCHandler.hpp:544
bcMode_Type
Definition: BCBase.hpp:102
UInt numberOfBCWithType(const bcType_Type &aType) const
Get the number of boundary conditions with type aType.
Definition: BCHandler.cpp:346
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
std::vector< BCBase >::const_iterator bcBaseConstIterator_Type
Definition: BCHandler.hpp:108
const UInt & nbDofPerVertex() const
Return the number of degrees of freedom located on the vertices (0D structures)
BCBase & operator[](const ID &)
Extract a BC in the list.
Definition: BCHandler.cpp:92
BCBase * findBC(const bcFlag_Type &aFlag)
Find the BC named aFlag.
Definition: BCHandler.cpp:470
void modifyBC(bcFlag_Type const &aFlag, BCFunctionBase const &bcFunction)
Modify the boundary condition associated with flag aFlag, assigning the function in bcFunction...
Definition: BCHandler.cpp:221
void updateInverseJacobian(const UInt &iQuadPt)
bool hasOnlyEssential() const
Determine whether all the stored boundary conditions have EssentialXXX type.
Definition: BCHandler.cpp:394
std::vector< bcName_Type > findAllBCWithType(const bcType_Type &aType) const
Get a vector list of BC with specific type. The list contains the bcName_Type of the BC...
Definition: BCHandler.cpp:332
void showMe(bool verbose=false, std::ostream &out=std::cout) const
Display the content of the variables.
Definition: BCHandler.cpp:265
const BCBase & findBCWithFlag(const bcFlag_Type &aFlag) const
Extract a BC in the list according to its flag (non const)
Definition: BCHandler.cpp:318
BCFunctionBase - class that holds the function used for prescribing boundary conditions.
Definition: BCFunction.hpp:77
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
std::vector< ID > bcComponentsVec_Type
Definition: BCBase.hpp:120
BCHandler()
Empty Constructor.
Definition: BCHandler.cpp:54
BCVectorBase - class that holds the FE vectors used for prescribing boundary conditions.
Definition: BCVector.hpp:74
void setOffset(const UInt &offset)
Set offset in all boundary conditions.
Definition: BCHandler.cpp:282
uint32_type ID
IDs.
Definition: LifeV.hpp:194
UInt offset() const
Definition: BCHandler.hpp:444
std::vector< BCBase >::iterator bcBaseIterator_Type
Definition: BCHandler.hpp:107
UInt M_offset
offset
Definition: BCHandler.hpp:547
bcBaseConstIterator_Type end() const
Definition: BCHandler.hpp:472
void merge(BCHandler &bcHandler)
Merges the boundary condition bcHandler (with its offset) with the stored one.
Definition: BCHandler.cpp:255
std::string bcName_Type
Definition: BCBase.hpp:116
bcBaseConstIterator_Type begin() const
Definition: BCHandler.hpp:458
double Real
Generic real data.
Definition: LifeV.hpp:175
void M_sumOffsets()
Sum the M_offset to boundary conditions offsets.
Definition: BCHandler.cpp:486
bcType_Type
Definition: BCBase.hpp:88
const DOFLocalPattern & localDofPattern() const
Getter for the localDofPattern.
Definition: DOF.hpp:225
BCHandler(const BCHandler &bcHandler)
Copy constructor.
Definition: BCHandler.cpp:60
BCFunctionBase bcFunction_Type
Definition: BCHandler.hpp:110
bool bcUpdateDone() const
Determine whether bcUpdate has been done before.
Definition: BCHandler.hpp:502
const UInt & nbDofPerEdge() const
Return the number of degrees of freedom located on the edges (1D structures)
~BCHandler()
Destructor.
Definition: BCHandler.cpp:69
void modifyBC(bcFlag_Type const &aFlag, BCFunctionUDepBase const &bcFunctionFEVectorDependent)
Modify the boundary condition associated with flag aFlag, assigning the function in bcFunctionFEVecto...
Definition: BCHandler.cpp:239
UInt size() const
Number of the stored boundary conditions.
Definition: BCHandler.hpp:482
bool M_bcUpdateDone
true only if the bcUpdate has been done
Definition: BCHandler.hpp:541
bool empty() const
Determine whether no boundary conditions are stored.
Definition: BCHandler.hpp:492
std::vector< std::shared_ptr< BCIdentifierBase > > M_idVector
container for id&#39;s when the list is finalized
Definition: BCBase.hpp:647
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
BCHandler & operator=(const BCHandler &bcHandler)
Assignment operator.
Definition: BCHandler.cpp:79
const flag_Type UPDATE_ONLY_CELL_NODES(1)