LifeV
BCInterfaceFunctionSolverDefinedFSI3D.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 the BCInterfaceFunctionSolverDefined class and specializations
30  *
31  * @date 23-04-2009
32  * @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  *
34  * @maintainer Cristiano Malossi <cristiano.malossi@epfl.ch>
35  */
36 
37 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionSolverDefinedFSI3D.hpp>
38 
39 namespace LifeV
40 {
41 
42 // ===================================================
43 // Constructors
44 // ===================================================
45 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::BCInterfaceFunctionSolverDefined() :
46  M_FSIFunction (),
48  M_name (),
49  M_flag (),
50  M_type (),
51  M_mode (),
54  M_robinRHS (),
57 {
58 
59 #ifdef HAVE_LIFEV_DEBUG
60  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::BCInterfaceFunctionSolverDefined()" << "\n";
61 #endif
62 
63 }
64 
65 // ===================================================
66 // Methods
67 // ===================================================
68 void
69 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::exportData ( dataPtr_Type& data )
70 {
71 
72 #ifdef HAVE_LIFEV_DEBUG
73  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::exportData" << "\n";
74 #endif
75 
76  data->setName ( M_name );
77  data->setFlag ( M_flag );
78  data->setType ( M_type );
79  data->setMode ( M_mode );
80  data->setComponentsVector ( M_componentsVector );
81 }
82 
83 void
84 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::updatePhysicalSolverVariables()
85 {
86 
87 #ifdef HAVE_LIFEV_DEBUG
88  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::updatePhysicalSolverVariables" << "\n";
89 #endif
90 
91  switch ( M_FSIFunction )
92  {
93  case RobinWall:
94  {
95  if ( !M_physicalSolver->isSolid() )
96  {
97  return;
98  }
99 
100  // Update the physical solver variables
101  for ( UInt i ( 0 ); i < M_vectorFunctionRobin.size(); ++i )
102  {
103  functionParserSolverPtr_Type castedFunctionSolver = std::dynamic_pointer_cast< functionParserSolver_Type > ( M_vectorFunctionRobin[i] );
104 
105  if ( castedFunctionSolver != 0 )
106  {
107  castedFunctionSolver->updatePhysicalSolverVariables();
108  }
109  }
110 
111  // Set coefficients
112  Int gid;
113  Real x, y, z;
114  Real alpha, beta;
115  Real t ( M_physicalSolver->dataSolid()->dataTime()->time() );
116  Real timeStep ( M_physicalSolver->dataSolid()->dataTime()->timeStep() );
117 
118  Int verticesGlobalNumber ( M_physicalSolver->solidLocalMesh().numGlobalVertices() );
119  for ( UInt i (0) ; i < M_physicalSolver->solidLocalMesh().numVertices() ; ++i )
120  {
121  gid = M_physicalSolver->solidLocalMesh().meshTransformer().pointInitial ( i ).id();
122 
123  x = M_physicalSolver->solidLocalMesh().meshTransformer().pointInitial ( i ).x();
124  y = M_physicalSolver->solidLocalMesh().meshTransformer().pointInitial ( i ).y();
125  z = M_physicalSolver->solidLocalMesh().meshTransformer().pointInitial ( i ).z();
126 
127  alpha = M_vectorFunctionRobin[0]->functionTimeSpace ( t, x, y, z, 0 );
128  beta = M_vectorFunctionRobin[1]->functionTimeSpace ( t, x, y, z, 0 );
129 
130  alpha += M_physicalSolver->solidTimeAdvance()->coefficientFirstDerivative ( 0 ) / timeStep * beta;
131 
132  (*M_robinAlphaCoefficient) [gid] = alpha;
133  (*M_robinBetaCoefficient) [gid] = beta;
134 
135  (*M_robinAlphaCoefficient) [gid + verticesGlobalNumber] = alpha;
136  (*M_robinBetaCoefficient) [gid + verticesGlobalNumber] = beta;
137 
138  (*M_robinAlphaCoefficient) [gid + verticesGlobalNumber * 2] = alpha;
139  (*M_robinBetaCoefficient) [gid + verticesGlobalNumber * 2] = beta;
140  }
141 
142  M_physicalSolver->solidTimeAdvance()->updateRHSFirstDerivative ( timeStep );
143  if ( M_physicalSolver->data().method().compare ("monolithicGE") == 0 || M_physicalSolver->data().method().compare ("monolithicGI") == 0 )
144  {
145  M_robinRHS->subset ( M_physicalSolver->solidTimeAdvance()->rhsContributionFirstDerivative(),
146  std::dynamic_pointer_cast< FSIMonolithic > ( M_physicalSolver )->offset() );
147  }
148  else
149  {
150  *M_robinRHS = M_physicalSolver->solidTimeAdvance()->rhsContributionFirstDerivative();
151  }
152  break;
153  }
154  default:
155  break;
156  }
157 }
158 
159 // ===================================================
160 // Set Methods
161 // ===================================================
162 void
163 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::setData ( const dataPtr_Type& data )
164 {
165 
166 #ifdef HAVE_LIFEV_DEBUG
167  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::setData" << "\n";
168 #endif
169 
170  //Set mapFunction
171  std::map< std::string, FSIFunction > mapFunction;
172  mapFunction["DerFluidLoadToFluid"] = DerFluidLoadToFluid;
173  mapFunction["DerFluidLoadToStructure"] = DerFluidLoadToStructure;
174  mapFunction["DerHarmonicExtensionVelToFluid"] = DerHarmonicExtensionVelToFluid;
175  mapFunction["DerStructureDispToSolid"] = DerStructureDispToSolid;
176  mapFunction["FluidInterfaceDisp"] = FluidInterfaceDisp;
177  mapFunction["FluidLoadToStructure"] = FluidLoadToStructure;
178  mapFunction["HarmonicExtensionVelToFluid"] = HarmonicExtensionVelToFluid;
179  mapFunction["SolidLoadToStructure"] = SolidLoadToStructure;
180  mapFunction["StructureDispToHarmonicExtension"] = StructureDispToHarmonicExtension;
181  mapFunction["StructureDispToSolid"] = StructureDispToSolid;
182  mapFunction["StructureToFluid"] = StructureToFluid;
183  mapFunction["RobinWall"] = RobinWall;
184 
185  // Retrieving the strings
186  M_FSIFunction = mapFunction[ data->baseString() ];
187 
188  M_name = data->name();
189  M_flag = data->flag();
190  M_type = data->type();
191  M_mode = data->mode();
192  M_componentsVector = data->componentsVector();
193 
194  if ( M_FSIFunction == RobinWall )
195  {
196  factory_Type factory;
197  M_vectorFunctionRobin.reserve (2);
198  dataPtr_Type temporaryData ( new data_Type ( *data ) );
199 
200  // Create the mass term function
201  temporaryData->setRobinBaseAlpha();
202  M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
203 
204  // Create the RHS
205  temporaryData->setRobinBaseBeta();
206  M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
207  }
208 }
209 
210 
211 // ===================================================
212 // Get Methods
213 // ===================================================
214 baseContainer_Type
215 BCInterfaceFunctionSolverDefined< BCHandler, FSIOperator >::baseType() const
216 {
217  switch ( M_FSIFunction )
218  {
219  case DerFluidLoadToFluid:
223  case FluidInterfaceDisp:
229  case StructureToFluid:
230 
231  return BASEVectorInterface3D;
232 
233  case RobinWall:
234 
235  return BASEVector3D;
236 
237  default:
238 
239  std::cout << " !!! Error: " << M_FSIFunction << " is not available as a FSIFunction !!!" << std::endl;
240  return BASEDefault;
241  }
242 }
243 
244 } // Namespace LifeV
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
double Real
Generic real data.
Definition: LifeV.hpp:175
void exportData(dataPtr_Type &data)
Copy the stored parameters in the data container.