LifeV
BCVector.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 File contains classes to holds the FE vectors used for prescribing boundary conditions
30 
31  @author Miguel Fernandez <miguel.fernandez@inria.fr>
32  @author Christophe Prud'homme <christophe.prudhomme@epfl.ch>
33  @author Vincent Martin <vincent.martin@inria.fr>
34  @contributor Mauro Perego <perego.mauro@gmail.com>
35  @maintainer Mauro Perego <perego.mauro@gmail.com>
36 
37  */
38 
39 
40 #include <lifev/core/fem/BCVector.hpp>
41 namespace LifeV
42 {
43 // ===================================
44 // Implementation for BCVectorBase
45 // ===================================
46 
47 
48 
49 // ===================================
50 // Constructors
51 //====================================
52 
53 
55  :
57  M_resistanceCoeff ( 0.0 ),
58  M_betaCoeff (1.0),
60  M_isBetaCoeffAVector ( false ),
61  M_type ( 0 ),
62  M_finalized ( false )
63 {}
64 
65 
66 BCVectorBase::BCVectorBase ( const vector_Type& rightHandSideVector , const UInt numberOfTotalDof, UInt type )
67  :
68  M_rightHandSideVectorPtr ( &rightHandSideVector ),
69  M_numberOfTotalDof ( numberOfTotalDof ),
71  M_resistanceCoeff ( 0.0 ),
72  M_betaCoeff (1.0),
74  M_isBetaCoeffAVector ( false ),
75  M_type ( type ),
76  M_finalized ( false )
77 {}
78 
79 BCVectorBase::BCVectorBase ( BCVectorBase const& bcVectorBase ) :
85  M_resistanceCoeff ( bcVectorBase.M_resistanceCoeff ),
86  M_betaCoeff ( bcVectorBase.M_betaCoeff ),
89  M_type ( bcVectorBase.M_type ),
90  M_finalized ( bcVectorBase.M_finalized )
91 {
92 
93 }
94 
95 // ===================================
96 // Operators
97 //====================================
98 
99 
101 BCVectorBase::operator= ( BCVectorBase const& bcVectorBase )
102 {
103  if ( this != &bcVectorBase )
104  {
112  M_betaCoeff = bcVectorBase.M_betaCoeff;
113  M_type = bcVectorBase.M_type;
116  M_finalized = bcVectorBase.M_finalized;
117  }
118  return *this;
119 }
120 
121 
122 Real
123 BCVectorBase::operator() ( const ID& globalDofId, const ID& component ) const
124 {
125  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
127 }
128 
129 
130 // ===================================
131 // Methods
132 //====================================
133 
134 Real
135 BCVectorBase::robinCoeffVector ( const ID& globalDofId, const ID& component ) const
136 {
137  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
139 }
140 
141 
142 Real
143 BCVectorBase::betaCoeffVector ( const ID& globalDofId, const ID& component ) const
144 {
145 
146 
147  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
148 
150 }
151 
152 
153 // ===================================
154 // Set Methods
155 //====================================
156 
157 void
158 BCVectorBase::setRhsVector ( const vector_Type& rightHandSideVector , UInt numberOfTotalDof, UInt type )
159 {
160  M_rightHandSideVectorPtr = &rightHandSideVector ;
161  M_numberOfTotalDof = numberOfTotalDof;
162  M_type = type;
163  M_finalized = true;
164 }
165 
166 void
167 BCVectorBase::setRobinCoeffVector ( const vector_Type& robinBoundaryMassCoeffVector )
168 {
170  M_robinBoundaryMassCoeffVectorPtr = &robinBoundaryMassCoeffVector;
171 }
172 
173 void
174 BCVectorBase::setBetaCoeffVector ( const vector_Type& betaCoeffVector )
175 {
176  M_isBetaCoeffAVector = true;
177  M_betaCoeffVectorPtr = &betaCoeffVector;
178 }
179 
180 
181 // ===================================
182 // Implementation for BCVector
183 // ===================================
184 
185 
186 
187 // ===================================
188 // Constructors
189 //====================================
190 
191 
192 BCVector::BCVector ( const vector_Type& rightHandSideVector, UInt const numberOfTotalDof, UInt type )
193  :
194  BCVectorBase ( rightHandSideVector, numberOfTotalDof, type )
195 {
196  M_finalized = true;
197 }
198 
199 
200 BCVector::BCVector ( const BCVector& bcVector ) :
201  BCVectorBase ( bcVector ) {}
202 
203 
204 // ===================================
205 // Operators
206 //====================================
207 
208 
209 //! Assignment operator for BCVector
210 BCVector&
211 BCVector::operator= ( const BCVector& bcVector )
212 {
213  if ( this != &bcVector )
214  {
216  }
217 
218  return *this;
219 }
220 
221 // ===================================
222 // Methods
223 //====================================
224 
225 
226 std::ostream&
227 BCVector::showMe ( bool /* verbose */, std::ostream& out ) const
228 {
229  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
230  out << "+++++++++++++++++++++++++++++++" << std::endl;
231  out << "BC Vector Interface: " << std::endl;
232  out << "number of interface vector DOF : " << this->nbTotalDOF() << std::endl;
233  out << "==>Interface DOF :\n";
234  out << "+++++++++++++++++++++++++++++++" << std::endl;
235  return out;
236 }
237 
238 
239 
240 
241 
244 {
245  return new BCVector ( ( BCVector const& ) *__bc );
246 }
247 
248 
249 // ====================================
250 // Implementation for BCVectorInterface
251 // ====================================
252 
253 
254 // ===================================
255 // Constructors
256 //====================================
257 
258 
259 BCVectorInterface::BCVectorInterface ( const VectorEpetra& rightHandSideVector, UInt numberOfTotalDof,
260  const dofInterfacePtr_Type& interfaceDofPtr, UInt type )
261  :
262  BCVectorBase ( rightHandSideVector, numberOfTotalDof, type ),
263  M_interfaceDofPtr ( interfaceDofPtr )
264 {
265  M_finalized = true;
266 }
267 
268 
270  BCVectorBase ( bcVectorInterface ),
271  M_interfaceDofPtr ( bcVectorInterface.M_interfaceDofPtr ) {}
272 
273 
274 // ===================================
275 // Operators
276 //====================================
277 
279 BCVectorInterface::operator= ( const BCVectorInterface& bcVectorInterface )
280 {
281  if ( this != &bcVectorInterface )
282  {
283  bcVectorBase_Type::operator= ( bcVectorInterface );
284  M_interfaceDofPtr = bcVectorInterface.M_interfaceDofPtr;
285  }
286 
287  return *this;
288 }
289 
290 
291 Real
292 BCVectorInterface::operator() ( const ID& globalDofId, const ID& component ) const
293 {
294  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
295  return ( *M_rightHandSideVectorPtr ) ( component * M_numberOfTotalDof + M_interfaceDofPtr->getInterfaceDof ( globalDofId ) );
296 }
297 
298 // ===================================
299 // methods
300 //====================================
301 
302 void BCVectorInterface::setup ( const vector_Type& rightHandSideVector, UInt numberOfTotalDof, const dofInterfacePtr_Type& interfaceDofPtr, UInt type )
303 {
304  M_rightHandSideVectorPtr = &rightHandSideVector;
305  M_numberOfTotalDof = numberOfTotalDof;
307  M_resistanceCoeff = 0.0;
308  M_betaCoeff = 1.0;
309  M_type = type;
310  M_interfaceDofPtr = interfaceDofPtr;
312  M_isBetaCoeffAVector = false;
313  M_finalized = true;
314 }
315 
316 
317 void
318 BCVectorInterface::setRhsVector ( const vector_Type& rightHandSideVector, UInt numberOfTotalDof, const dofInterfacePtr_Type& interfaceDofPtr, UInt type )
319 {
320  ASSERT_PRE ( !this->isFinalized(), "BC Vector cannot be set twice." );
321 
322  bcVectorBase_Type::setRhsVector ( rightHandSideVector, numberOfTotalDof, type );
323 
324  M_interfaceDofPtr = interfaceDofPtr;
325 
326 }
327 
328 
329 Real
330 BCVectorInterface::robinCoeffVector ( const ID& globalDofId, const ID& component ) const
331 {
332  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
333  return ( *M_robinBoundaryMassCoeffVectorPtr ) ( component * M_numberOfTotalDof + M_interfaceDofPtr->getInterfaceDof ( globalDofId ) );
334 }
335 
336 
337 Real
338 BCVectorInterface::betaCoeffVector ( const ID& globalDofId, const ID& component ) const
339 {
340  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
341  return ( *M_betaCoeffVectorPtr ) ( component * M_numberOfTotalDof + M_interfaceDofPtr->getInterfaceDof ( globalDofId ) );
342 }
343 
344 
345 std::ostream&
346 BCVectorInterface::showMe ( bool verbose, std::ostream& out ) const
347 {
348  ASSERT_PRE ( this->isFinalized(), "BC Vector should be finalized before being accessed." );
349  out << "+++++++++++++++++++++++++++++++" << std::endl;
350  out << "BC Vector Interface: " << std::endl;
351  out << "number of interface vector DOF : " << M_numberOfTotalDof << std::endl;
352  out << "==>Interface DOF :\n";
353  M_interfaceDofPtr->showMe ( verbose, out ); // no showMe(..) in Miguel's DofInterface
354  out << "+++++++++++++++++++++++++++++++" << std::endl;
355  return out;
356 }
357 
359 createBCVectorInterface ( BCVectorBase const* bcVectorBase )
360 {
361  return new BCVectorInterface ( ( BCVectorInterface const& ) * bcVectorBase );
362 }
363 
364 
365 }
VectorEpetra - The Epetra Vector format Wrapper.
BCVectorBase * createBCVector(BCVectorBase const *__bc)
Definition: BCVector.cpp:243
std::ostream & showMe(bool verbose=false, std::ostream &out=std::cout) const
showMe
Definition: BCVector.cpp:346
virtual Real robinCoeffVector(const ID &globalDofId, const ID &component) const
Return the value of the selected component of the boundary mass coefficient vector at position dofID...
Definition: BCVector.cpp:135
vectorConstPtr_Type M_robinBoundaryMassCoeffVectorPtr
The pointer to FE Vector holding the robin boundary Mass coefficients.
Definition: BCVector.hpp:313
BCVector(const vector_Type &rightHandSideVector, UInt const numberOfTotalDof, UInt type=0)
Constructor.
Definition: BCVector.cpp:192
Real M_betaCoeff
Coefficient for the beta coefficient.
Definition: BCVector.hpp:327
dofInterfacePtr_Type M_interfaceDofPtr
DOFInterface object holding the connections between the interface dofs.
Definition: BCVector.hpp:614
bool M_finalized
true when the BCVector is updated
Definition: BCVector.hpp:339
BCVectorBase bcVectorBase_Type
Definition: BCVector.hpp:485
Real operator()(const ID &globalDofId, const ID &component) const
Return the value of the selected component of rightHandSideVector at position globalDofID.
Definition: BCVector.cpp:292
std::ostream & showMe(bool verbose=false, std::ostream &out=std::cout) const
showMe
Definition: BCVector.cpp:227
bool M_isRobinBdMassCoeffAVector
boolean determining whether the boundary mass coefficient is a FE Vector
Definition: BCVector.hpp:330
void setup(const vector_Type &rightHandSideVector, UInt numberOfTotalDof, const dofInterfacePtr_Type &interfaceDofPtr, UInt type=0)
setup after default constructor
Definition: BCVector.cpp:302
Real M_resistanceCoeff
Coefficient for Resistance coefficient.
Definition: BCVector.hpp:323
UInt M_type
Type of boundary condition; see the BCBase class description.
Definition: BCVector.hpp:336
void updateInverseJacobian(const UInt &iQuadPt)
BCVector & operator=(const BCVector &bcVector)
Assignment operator for BCVector.
Definition: BCVector.cpp:211
vectorConstPtr_Type M_rightHandSideVectorPtr
The pointer to FE vector for the right hand side part of the equation.
Definition: BCVector.hpp:310
Real betaCoeffVector(const ID &globalDofId, const ID &component) const
Return the value of the selected component of the beta coefficient vector at position dofID...
Definition: BCVector.cpp:338
VectorEpetra vector_Type
Definition: BCVector.hpp:81
BCVectorBase - class that holds the FE vectors used for prescribing boundary conditions.
Definition: BCVector.hpp:74
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
uint32_type ID
IDs.
Definition: LifeV.hpp:194
BCVectorInterface(const BCVectorInterface &bcVectorInterface)
Copy Constructor.
Definition: BCVector.cpp:269
virtual BCVectorBase & operator=(BCVectorBase const &)
Assignment operator.
Definition: BCVector.cpp:101
BCVectorInterface & operator=(const BCVectorInterface &bcVectorInterface)
Assignment operator for BCVectorInterface.
Definition: BCVector.cpp:279
BCVectorInterface - class that holds the FE vectors used for prescribing boundary conditions on Inter...
Definition: BCVector.hpp:475
BCVectorBase(const BCVectorBase &bcVectorBase)
Copy Constructor.
Definition: BCVector.cpp:79
void setRhsVector(const vector_Type &rightHandSideVector, UInt numberOfTotalDof, const dofInterfacePtr_Type &interfaceDofPtr, UInt type=0)
set the BC vector (after default construction)
Definition: BCVector.cpp:318
vectorConstPtr_Type M_betaCoeffVectorPtr
Definition: BCVector.hpp:314
BCVectorInterface(const vector_Type &rightHandSideVector, UInt numberOfTotalDof, const dofInterfacePtr_Type &interfaceDofPtr, UInt type=0)
Constructor.
Definition: BCVector.cpp:259
BCVectorBase()
Empty Constructor.
Definition: BCVector.cpp:54
void setRhsVector(const vector_Type &righHandSideVector, UInt numberOfTotalDOF, UInt type=0)
set the right hand side FE vector
Definition: BCVector.cpp:158
BCVectorBase bcVectorBase_Type
super class
Definition: BCVector.hpp:389
void setRobinCoeffVector(const vector_Type &robinBoundaryMassCoeffVector)
set the boundary mass coefficient FE vector for Robin boundary conditions
Definition: BCVector.cpp:167
Real M_robinBoundaryMassCoeff
Coefficient for boundary mass term in Robin conditions.
Definition: BCVector.hpp:320
virtual Real operator()(const ID &globalDofId, const ID &component) const
Return the value of the selected component of rightHandSideVector at position globalDofID.
Definition: BCVector.cpp:123
double Real
Generic real data.
Definition: LifeV.hpp:175
Real robinCoeffVector(const ID &globalDofId, const ID &component) const
Return the value of the selected component of the boundary mass coefficient vector at position dofID...
Definition: BCVector.cpp:330
BCVectorBase(const vector_Type &rightHandSideVector, const UInt numberOfTotalDof, UInt type=0)
Constructor.
Definition: BCVector.cpp:66
void setBetaCoeffVector(const vector_Type &betaCoeffVector)
set the beta coefficient FE vector
Definition: BCVector.cpp:174
BCVectorBase * createBCVectorInterface(BCVectorBase const *bcVectorBase)
Definition: BCVector.cpp:359
std::shared_ptr< DOFInterface > dofInterfacePtr_Type
Definition: BCVector.hpp:486
BCVector - class that holds the FE vectors used for prescribing boundary conditions.
Definition: BCVector.hpp:381
UInt M_numberOfTotalDof
Number of total dof in the vector of data.
Definition: BCVector.hpp:317
bool M_isBetaCoeffAVector
boolean determining whether the boundary mass coefficient is a FE Vector
Definition: BCVector.hpp:333
virtual Real betaCoeffVector(const ID &globalDofId, const ID &component) const
Return the value of the selected component of the beta coefficient vector at position dofID...
Definition: BCVector.cpp:143
const data_type & operator()(const UInt row) const
Access operators.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
BCVector(const BCVector &bcVector)
Definition: BCVector.cpp:200