LifeV
DOFInterface3Dto2D.cpp
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 Class for connecting the dof of a mesh (3D) and an interface (2D)
30  that lives on the boundary of the mesh.
31 
32  @author Vincent Martin
33  @date 00-02-2003
34 
35  This file contains the class which may be used to update and hold
36  the connections between the dof of a mesh (3D) and an interface (2D)
37  that lives on the boundary of the mesh. The interface is referenced
38  by a flag.
39 
40  @contributor M.A. Fernandez
41  Samuel Quinodoz <samuel.quinodoz@epfl.ch>
42  @mantainer Samuel Quinodoz <samuel.quinodoz@epfl.ch>
43  */
44 
45 
46 #include <lifev/core/fem/DOFInterface3Dto2D.hpp>
47 
48 namespace LifeV
49 {
50 
51 // ===================================================
52 // Helper
53 // ===================================================
54 
55 
56 void RemoveMultiple ( const std::list<ID>& listToTreat, std::list< std::pair<ID, ID> >& finalList )
57 {
58  ID counter = 0;
59  std::list<ID> temporaryList ( listToTreat );
60 
61  //! Sort the list
62  temporaryList.sort();
63 
64  //! initialize the new list
65  std::pair <ID, ID> p0 ( temporaryList.front() , counter );
66  finalList.push_back ( p0 );
67 
68  //! We remove the multiple occurences :
69  for ( std::list<ID>::iterator it = temporaryList.begin() ; it != temporaryList.end() ; ++ it )
70  {
71  if ( ( *it ) != finalList.back().first )
72  {
73  counter ++ ;
74  //! Add to the list the new value
75  std::pair <ID, ID> p ( ( *it ) , counter );
76  finalList.push_back ( p );
77  }
78  }
79 }
80 
81 // ===================================================
82 // Constructors & Destructor
83 // ===================================================
84 
85 DOFInterface3Dto2D::DOFInterface3Dto2D ( const DOFLocalPattern& refFE, const DOF& dof1 ) :
86  M_interfaceFlag ( 0 ), M_refFE1 ( &refFE ), M_dof1 ( &dof1 )
87 {
88  M_finalized = false;
89 }
90 
91 // ===================================================
92 // Methods
93 // ===================================================
94 
95 void
96 DOFInterface3Dto2D::setup ( const DOFLocalPattern& refFE1, const DOF& dof1 )
97 {
98  M_refFE1 = &refFE1;
99  M_dof1 = &dof1;
100 
101  M_finalized = false;
102 }
103 
105 {
106  M_vertexPerFaceList.clear();
107  M_vertexList.clear();
108 }
109 
110 std::ostream& DOFInterface3Dto2D::showMe ( bool verbose, std::ostream& out ) const
111 {
112  out << "------------------------------" << std::endl;
113  out << "myDofInterface reference: " << M_interfaceFlag << std::endl;
114  out << "Number of face connections (M_faceList): " << M_faceList.size() << std::endl;
115  if ( verbose )
116  {
117  unsigned int count ( 0 ), lines ( 10 );
118  out << "\tList of connections between Faces: (global, local)";
119  for ( std::vector< std::pair<ID, ID> >::const_iterator i = M_faceList.begin(); i != M_faceList.end(); ++i )
120  {
121  if ( count++ % lines == 0 )
122  {
123  out << std::endl;
124  }
125  out << "(" << i->first << "," << i->second << ")\t";
126  }
127  out << std::endl;
128  }
129  out << "Number of connections between Vertices (M_vertexList): " << M_vertexList.size() << std::endl;
130  if ( verbose )
131  {
132  unsigned int count ( 0 ), lines ( 10 );
133  out << "\tList of connections between Vertices: (global, local)";
134  for ( std::list< std::pair<ID, ID> >::const_iterator it = M_vertexList.begin(); it != M_vertexList.end(); ++it )
135  {
136  if ( count++ % lines == 0 )
137  {
138  out << std::endl;
139  }
140  out << "(" << it->first << "," << it->second << ")\t";
141  }
142  out << std::endl;
143  }
144  //! print M_locDofMap
145  showMe ( verbose, out );
146 
147  out << "------------------------------" << std::endl;
148  return out;
149 }
150 
151 // ===================================================
152 // Operators
153 // ===================================================
154 
155 
156 ID DOFInterface3Dto2D::operator[] ( const UInt& i ) const
157 {
158  ASSERT_PRE ( M_finalized, "The face List should be finalised before being accessed" );
159  ASSERT_BD ( i < M_faceList.size() );
160  return M_faceList[ i ].first; // M_faceList must be a vector!
161 }
162 
163 
165 {
167  M_refFE1 = dofi.M_refFE1;
168  M_dof1 = dofi.M_dof1;
169  M_faceList = dofi.M_faceList;
170  M_vertexPerFaceList = dofi.M_vertexPerFaceList; // (empty)
171  M_vertexList = dofi.M_vertexList;
172  M_localDofMap = dofi.M_localDofMap;
174 
175  return *this;
176 }
177 
178 
179 // ===================================================
180 // Private Methods
181 // ===================================================
182 
183 ID DOFInterface3Dto2D::vertex3Dto2D ( const ID& idpoint3D ) const
184 {
185  ASSERT_PRE ( M_finalized, "The list of vertices must be finalized before accessing to the interface vertices." );
186  for ( std::list< std::pair<ID, ID> >::const_iterator it = M_vertexList.begin(); it != M_vertexList.end(); ++it )
187  {
188  if ( it->first == idpoint3D )
189  {
190  return it->second;
191  }
192  }
193  ERROR_MSG ( "There is no such 3D index of vertex in the M_vertexList." );
194 
195  return ID();
196 }
197 
198 
199 
200 
201 }
void setup(const DOFLocalPattern &refFE1, const DOF &dof1)
const DOFLocalPattern * M_refFE1
DOFLocalPattern object used in the mesh in which we want to make the computations.
#define ASSERT_BD(X)
Definition: LifeAssert.hpp:114
const DOF * M_dof1
DOF object of the mesh in which we want to make the computations.
void updateInverseJacobian(const UInt &iQuadPt)
ID vertex3Dto2D(const ID &idpoint3D) const
Transforms the 3d index of a vertex into its 2d (interface) index.
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
uint32_type ID
IDs.
Definition: LifeV.hpp:194
ID operator[](const UInt &i) const
Returns the identity of the i-th elements in the (finalised) face list (counting from 0 &#39; a la C&#39;) ...
DOFLocalPattern - A class to store the "couplings" between the basis functions.
std::ostream & showMe(bool verbose=false, std::ostream &out=std::cout) const
output
DOFInterface3Dto2D(const DOFLocalPattern &refFE, const DOF &dof1)
Constructor for interfacing DOF of the same type (DOFLocalPattern)
void RemoveMultiple(const std::list< ID > &listToTreat, std::list< std::pair< ID, ID > > &finalList)
useful function to sort a list and remove multiple numbers.
DOFInterface3Dto2D & operator=(const DOFInterface3Dto2D &dofi)
Assignment operator (we have a vector of DOFInterface3Dto2D)
void clearLists()
removes all unuseful list (all except M_faceList). use it properly!
markerID_Type M_interfaceFlag
reference of the interface
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
bool M_finalized
true if the lists have been updated.