LifeV
OneDFSIBCHandler.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 containing a class for the boundary conditions handling of the 1D model.
30  *
31  * @version 1.0
32  * @date 01-28-2006
33  * @author Lucia Mirabella <lucia@mathcs.emory.edu>
34  * @author Tiziano Passerini <tiziano@mathcs.emory.edu>
35  *
36  * @version 2.0
37  * @date 20-04-2010
38  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
39  *
40  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
41  */
42 
43 #include <lifev/one_d_fsi/fem/OneDFSIBCHandler.hpp>
44 
45 namespace LifeV
46 {
47 
48 // ===================================================
49 // Constructors & Destructor
50 // ===================================================
52  M_boundary (),
53  M_boundarySet (),
55 {
56 
57 #ifdef HAVE_LIFEV_DEBUG
58  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::OneDFSIModel_BCHandler] Creating OneDFSIModel_BC classes.\n";
59 #endif
60 
61  M_boundary[ OneDFSI::left ].reset ( new bc_Type ( OneDFSI::left ) );
62  M_boundary[ OneDFSI::right ].reset ( new bc_Type ( OneDFSI::right ) );
63 
64  M_boundarySet[ OneDFSI::left ].insert ( std::make_pair ( OneDFSI::first, false ) );
65  M_boundarySet[ OneDFSI::left ].insert ( std::make_pair ( OneDFSI::second, false ) );
66  M_boundarySet[ OneDFSI::right ].insert ( std::make_pair ( OneDFSI::first, false ) );
67  M_boundarySet[ OneDFSI::right ].insert ( std::make_pair ( OneDFSI::second, false ) );
68 }
69 
71  M_boundary (),
74 {
75  M_boundary[ OneDFSI::left ].reset ( new bc_Type ( *bcHandler.M_boundary.find ( OneDFSI::left )->second ) );
76  M_boundary[ OneDFSI::right ].reset ( new bc_Type ( *bcHandler.M_boundary.find ( OneDFSI::right )->second ) );
77 
78  for ( std::vector < bcFunctionSolverDefinedPtr_Type >::const_iterator i = bcHandler.M_defaultFunctions.begin();
79  i != bcHandler.M_defaultFunctions.end() ; ++i )
80  {
81  bcFunctionSolverDefinedPtr_Type BCDefaultFunction ( new bcFunctionSolverDefined_Type ( *i->get() ) );
82  M_defaultFunctions.push_back ( BCDefaultFunction );
83  }
84 
85  // NOTE: The copy constructor is not working correctly. All the members of the class are true copy, but
86  // the BCFunctions inside M_boundary are still pointing to the original M_defaultFunction, instead
87  // of to the copy (which remain unused!). This is because the link between M_boundary and M_defaultFunction
88  // is provided by std::bind and, for now, we have no solution for this.
89  std::cerr << "!!! WARNING: COPY CONSTRUCTOR DOES NOT CREATE A TRUE COPY !!!" << std::endl;
90  std::exit ( EXIT_FAILURE );
91 }
92 
93 // ===================================================
94 // Methods
95 // ===================================================
96 void
97 OneDFSIBCHandler::applyBC ( const Real& time, const Real& timeStep, const solution_Type& solution,
98  const fluxPtr_Type& fluxPtr, vectorPtrContainer_Type& rhs )
99 {
100  M_boundary[ OneDFSI::left ]->applyBC ( time, timeStep, solution, fluxPtr, rhs );
101  M_boundary[ OneDFSI::right ]->applyBC ( time, timeStep, solution, fluxPtr, rhs );
102 }
103 
104 void
105 OneDFSIBCHandler::applyViscoelasticBC ( const fluxPtr_Type& fluxPtr, matrix_Type& matrix, vector_Type& rhs )
106 {
107  M_boundary[ OneDFSI::left ]->applyViscoelasticBC ( fluxPtr, matrix, rhs );
108  M_boundary[ OneDFSI::right ]->applyViscoelasticBC ( fluxPtr, matrix, rhs );
109 }
110 
111 // ===================================================
112 // Set Methods
113 // ===================================================
114 void
115 OneDFSIBCHandler::setBC ( const bcSide_Type& bcSide, const bcLine_Type& bcLine,
116  const bcType_Type& bcType, const bcFunction_Type& bcFunction )
117 {
118  M_boundarySet[bcSide][bcLine] = true;
119  M_boundary[bcSide]->setType ( bcLine, bcType );
120  M_boundary[bcSide]->setBCFunction ( bcLine, bcFunction );
121 
122 #ifdef HAVE_LIFEV_DEBUG
123  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::setBC] imposing function at "
124  << bcSide << " boundary (" << bcLine << " bcLine), variable " << bcType << ".\n";
125 #endif
126 }
127 
128 void
130 {
131 #ifdef HAVE_LIFEV_DEBUG
132  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::OneDFSIModel_BCHandler] Set Default BC ... \n";
133 #endif
134 
135  if ( !M_boundarySet[ OneDFSI::left ][OneDFSI::first] )
136  {
137  //bcFunctionSolverDefinedPtr_Type bcFunction( new OneDFSIFunctionSolverDefined( OneDFSI::OneD_left, OneDFSI::OneD_W1 ) );
138  bcFunctionSolverDefinedPtr_Type bcDefaultFunction ( new OneDFSIFunctionSolverDefinedRiemann ( OneDFSI::left, OneDFSI::W1 ) );
139  M_defaultFunctions.push_back ( bcDefaultFunction );
140 
141  //bcFunctionPtr_Type bcFunction( new bcFunction_Type() );
142  bcFunction_Type bcFunction;
143  bcFunction.setFunction ( std::bind ( &OneDFSIFunctionSolverDefinedRiemann::operator(),
144  dynamic_cast<OneDFSIFunctionSolverDefinedRiemann*> ( & ( *M_defaultFunctions.back() ) ), std::placeholders::_1, std::placeholders::_2 ) );
145 
146 #ifdef HAVE_LIFEV_DEBUG
147  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::setDefaultBC] left-first-W1 Invoking setBC.\n";
148 #endif
150  }
151 
152  if ( !M_boundarySet[ OneDFSI::left ][OneDFSI::second] )
153  {
154  //bcFunctionPtr_Type bcFunction( new OneDFSIFunctionSolverDefinedCompatibility( OneDFSI::OneD_left, OneDFSI::OneD_W2 ) );
155  bcFunctionSolverDefinedPtr_Type bcDefaultFunction ( new OneDFSIFunctionSolverDefinedCompatibility ( OneDFSI::left, OneDFSI::W2 ) );
156  M_defaultFunctions.push_back ( bcDefaultFunction );
157 
158  //bcFunctionPtr_Type bcFunction ( new bcFunction_Type() );
159  bcFunction_Type bcFunction;
160  bcFunction.setFunction ( std::bind ( &OneDFSIFunctionSolverDefinedCompatibility::operator(),
161  dynamic_cast<OneDFSIFunctionSolverDefinedCompatibility*> ( & ( *M_defaultFunctions.back() ) ), std::placeholders::_1, std::placeholders::_2 ) );
162 
163 #ifdef HAVE_LIFEV_DEBUG
164  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::setDefaultBC] left-second-W2 Invoking setBC.\n";
165 #endif
167  }
168 
169  if ( !M_boundarySet[ OneDFSI::right ][ OneDFSI::first ] )
170  {
171  //bcFunctionPtr_Type bcFunction( new OneDFSIFunctionSolverDefinedRiemann( OneDFSI::OneD_right, OneDFSI::OneD_W2 ) );
172  bcFunctionSolverDefinedPtr_Type bcDefaultFunction ( new OneDFSIFunctionSolverDefinedRiemann ( OneDFSI::right, OneDFSI::W2 ) );
173  M_defaultFunctions.push_back ( bcDefaultFunction );
174 
175  //bcFunctionPtr_Type bcFunction ( new bcFunction_Type() );
176  bcFunction_Type bcFunction;
177  bcFunction.setFunction ( std::bind ( &OneDFSIFunctionSolverDefinedRiemann::operator(),
178  dynamic_cast<OneDFSIFunctionSolverDefinedRiemann*> ( & ( *M_defaultFunctions.back() ) ), std::placeholders::_1, std::placeholders::_2 ) );
179 
180 #ifdef HAVE_LIFEV_DEBUG
181  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::setDefaultBC] right-first-W2 Invoking setBC.\n";
182 #endif
184  }
185 
186  if ( !M_boundarySet[ OneDFSI::right ][ OneDFSI::second ] )
187  {
188  //bcFunctionPtr_Type bcFunction( new OneDFSIFunctionSolverDefinedCompatibility( OneDFSI::OneD_right, OneDFSI::OneD_W1 ) );
189  bcFunctionSolverDefinedPtr_Type bcDefaultFunction ( new OneDFSIFunctionSolverDefinedCompatibility ( OneDFSI::right, OneDFSI::W1 ) );
190  M_defaultFunctions.push_back ( bcDefaultFunction );
191 
192  //bcFunctionPtr_Type bcFunction ( new bcFunction_Type() );
193  bcFunction_Type bcFunction;
194  bcFunction.setFunction ( std::bind ( &OneDFSIFunctionSolverDefinedCompatibility::operator(),
195  dynamic_cast<OneDFSIFunctionSolverDefinedCompatibility*> ( & ( *M_defaultFunctions.back() ) ), std::placeholders::_1, std::placeholders::_2 ) );
196 
197 #ifdef HAVE_LIFEV_DEBUG
198  debugStream ( 6311 ) << "[OneDFSIModel_BCHandler::setDefaultBC] right-second-W1 Invoking setBC.\n";
199 #endif
201  }
202 }
203 
204 void
205 OneDFSIBCHandler::setFluxSource ( const fluxPtr_Type& fluxPtr, const sourcePtr_Type& sourcePtr )
206 {
207  for ( std::vector < bcFunctionSolverDefinedPtr_Type >::const_iterator i = M_defaultFunctions.begin() ; i < M_defaultFunctions.end() ; ++i )
208  {
209  ( *i )->setFluxSource ( fluxPtr, sourcePtr );
210  }
211 }
212 
213 void
214 OneDFSIBCHandler::setSolution ( const solutionPtr_Type& solution )
215 {
216  for ( std::vector < bcFunctionSolverDefinedPtr_Type >::const_iterator i = M_defaultFunctions.begin() ; i < M_defaultFunctions.end() ; ++i )
217  {
218  ( *i )->setSolution ( solution );
219  }
220 }
221 
222 }
OneDFSIBCHandler(const OneDFSIBCHandler &bcHandler)
Copy constructor.
void setBC(const bcSide_Type &bcSide, const bcLine_Type &bcLine, const bcType_Type &bcType, const bcFunction_Type &bcFunction)
Set a boundary condition.
void updateInverseJacobian(const UInt &iQuadPt)
void setFluxSource(const fluxPtr_Type &fluxPtr, const sourcePtr_Type &sourcePtr)
Set the flux and the source classes for the problem.
void applyBC(const Real &time, const Real &timeStep, const solution_Type &solution, const fluxPtr_Type &fluxPtr, vectorPtrContainer_Type &rhs)
Apply boundary conditions to the rhs of the Taylor-Galerkin problem.
OneDFSIBCHandler - Class featuring methods to handle boundary conditions.
double Real
Generic real data.
Definition: LifeV.hpp:175
OneDFSIBCHandler()
Empty Constructor.
void setSolution(const solutionPtr_Type &solutionPtr)
Set the solution of the problem.
void setDefaultBC()
Set the default boundary conditions.
void applyViscoelasticBC(const fluxPtr_Type &fluxPtr, matrix_Type &matrix, vector_Type &rhs)
Apply boundary conditions to the rhs of the viscoelastic problem.