LifeV
BCInterfaceFunctionSolverDefinedSolid3D.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/solid/BCInterfaceFunctionSolverDefinedSolid3D.hpp>
38 
39 namespace LifeV
40 {
41 
42 // ===================================================
43 // Constructors
44 // ===================================================
45 BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::BCInterfaceFunctionSolverDefined() :
46  M_solid3DFunction (),
47  M_physicalSolver (),
48  M_name (),
49  M_flag (),
50  M_type (),
51  M_mode (),
52  M_componentsVector (),
53  M_vectorFunctionRobin (),
54  M_robinRHS (),
55  M_robinAlphaCoefficient (),
56  M_robinBetaCoefficient ()
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, StructuralOperator<RegionMesh <LinearTetra> > >::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
85 {
86 
87 #ifdef HAVE_LIFEV_DEBUG
88  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::updatePhysicalSolverVariables" << "\n";
89 #endif
90 
91  switch ( M_solid3DFunction )
92  {
93  case RobinWall:
94  {
95  // Update the physical solver variables
96  for ( UInt i ( 0 ); i < M_vectorFunctionRobin.size(); ++i )
97  {
98  functionParserSolverPtr_Type castedFunctionSolver = std::dynamic_pointer_cast< functionParserSolver_Type > ( M_vectorFunctionRobin[i] );
99 
100  if ( castedFunctionSolver != 0 )
101  {
102  castedFunctionSolver->updatePhysicalSolverVariables();
103  }
104  }
105 
106  // Set coefficients
107  Int gid;
108  Real x, y, z;
109  Real alpha, beta;
110  Real t ( M_physicalSolver->data()->dataTime()->time() );
111  Real timeStep ( M_physicalSolver->data()->dataTime()->timeStep() );
112 
113  Int verticesGlobalNumber ( M_physicalSolver->dispFESpace().mesh()->numGlobalVertices() );
114  for ( UInt i (0) ; i < M_physicalSolver->dispFESpace().mesh()->numVertices() ; ++i )
115  {
116  gid = M_physicalSolver->dispFESpace().mesh()->meshTransformer().pointInitial ( i ).id();
117 
118  x = M_physicalSolver->dispFESpace().mesh()->meshTransformer().pointInitial ( i ).x();
119  y = M_physicalSolver->dispFESpace().mesh()->meshTransformer().pointInitial ( i ).y();
120  z = M_physicalSolver->dispFESpace().mesh()->meshTransformer().pointInitial ( i ).z();
121 
122  alpha = M_vectorFunctionRobin[0]->functionTimeSpace ( t, x, y, z, 0 );
123  beta = M_vectorFunctionRobin[1]->functionTimeSpace ( t, x, y, z, 0 );
124 
125  alpha += M_physicalSolver->timeAdvancePtr()->coefficientFirstDerivative ( 0 ) / timeStep * beta;
126 
127  (*M_robinAlphaCoefficient) [gid] = alpha;
128  (*M_robinBetaCoefficient) [gid] = beta;
129 
130  (*M_robinAlphaCoefficient) [gid + verticesGlobalNumber] = alpha;
131  (*M_robinBetaCoefficient) [gid + verticesGlobalNumber] = beta;
132 
133  (*M_robinAlphaCoefficient) [gid + verticesGlobalNumber * 2] = alpha;
134  (*M_robinBetaCoefficient) [gid + verticesGlobalNumber * 2] = beta;
135  }
136 
137  M_physicalSolver->timeAdvancePtr()->updateRHSFirstDerivative ( timeStep );
138  *M_robinRHS = M_physicalSolver->timeAdvancePtr()->rhsContributionFirstDerivative();
139  break;
140  }
141  default:
142  break;
143  }
144 }
145 
146 // ===================================================
147 // Set Methods
148 // ===================================================
149 void
151 {
152 
153 #ifdef HAVE_LIFEV_DEBUG
154  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::setData" << "\n";
155 #endif
156 
157  //Set mapFunction
158  std::map< std::string, Solid3DFunction > mapFunction;
159  mapFunction["RobinWall"] = RobinWall;
160 
161  // Retrieving the strings
162  M_solid3DFunction = mapFunction[ data->baseString() ];
163 
164  M_name = data->name();
165  M_flag = data->flag();
166  M_type = data->type();
167  M_mode = data->mode();
168  M_componentsVector = data->componentsVector();
169 
170  if ( M_solid3DFunction == RobinWall )
171  {
172  factory_Type factory;
173  M_vectorFunctionRobin.reserve (2);
174  dataPtr_Type temporaryData ( new data_Type ( *data ) );
175 
176  // Create the mass term function
177  temporaryData->setRobinBaseAlpha();
178  M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
179 
180  // Create the RHS
181  temporaryData->setRobinBaseBeta();
182  M_vectorFunctionRobin.push_back ( factory.createFunctionParser ( temporaryData ) );
183  }
184 }
185 
186 
187 
188 // ===================================================
189 // Get Methods
190 // ===================================================
191 baseContainer_Type
192 BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::baseType() const
193 {
194  switch ( M_solid3DFunction )
195  {
196  case RobinWall:
197 
198  return BASEVector3D;
199 
200  default:
201 
202  std::cout << " !!! Error: " << M_solid3DFunction << " is not available as a Solid3DFunction !!!" << std::endl;
203  return BASEDefault;
204  }
205 }
206 
207 
208 
209 // ===================================================
210 // Private Methods
211 // ===================================================
212 void
213 BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::checkFunction ( BCVectorInterface& /*base*/ )
214 {
215  switch ( M_solid3DFunction )
216  {
217  default:
218 
219  std::cout << " !!! Error: " << M_solid3DFunction << " is not available as a BCVectorInterface !!!" << std::endl;
220 
221  break;
222  }
223 }
224 
225 void
226 BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::checkFunction ( BCVector& base )
227 {
228  switch ( M_solid3DFunction )
229  {
230  case RobinWall:
231 
232 #ifdef HAVE_LIFEV_DEBUG
233  debugStream ( 5025 ) << "BCInterfaceFunctionSolverDefined::checkFunction RobinWall" << "\n";
234 #endif
235 
236  // Define the vectors
237  M_robinRHS.reset ( new physicalSolver_Type::vector_Type ( M_physicalSolver->dispFESpace().map(), Repeated, Zero ) );
238  M_robinAlphaCoefficient.reset ( new physicalSolver_Type::vector_Type ( M_physicalSolver->dispFESpace().map(), Repeated, Zero ) );
239  M_robinBetaCoefficient.reset ( new physicalSolver_Type::vector_Type ( M_physicalSolver->dispFESpace().map(), Repeated, Zero ) );
240 
241  // Set the vectors (still empty)
242  base.setRhsVector ( *M_robinRHS, M_physicalSolver->dispFESpace().dof().numTotalDof(), 0 );
243  base.setRobinCoeffVector ( *M_robinAlphaCoefficient );
244  base.setBetaCoeffVector ( *M_robinBetaCoefficient );
245 
246  // Set the physical solver in the Robin functions for alpha and beta
247  for ( UInt i ( 0 ); i < M_vectorFunctionRobin.size(); ++i )
248  {
249  functionParserSolverPtr_Type castedFunctionSolver = std::dynamic_pointer_cast< functionParserSolver_Type > ( M_vectorFunctionRobin[i] );
250 
251  if ( castedFunctionSolver != 0 )
252  {
253  castedFunctionSolver->setPhysicalSolver ( M_physicalSolver );
254  }
255  }
256 
257  break;
258 
259  default:
260 
261  std::cout << " !!! Error: " << M_solid3DFunction << " is not available as a BCVector !!!" << std::endl;
262 
263  break;
264  }
265 }
266 
267 void
268 BCInterfaceFunctionSolverDefined< BCHandler, StructuralOperator<RegionMesh <LinearTetra> > >::checkFunction ( BCFunctionBase& /*base*/ )
269 {
270  switch ( M_solid3DFunction )
271  {
272  default:
273 
274  std::cout << " !!! Error: " << M_solid3DFunction << " is not available as a BCFunction !!!" << std::endl;
275 
276  return;
277  }
278 }
279 
280 } // Namespace LifeV
void setData(const std::shared_ptr< BCInterfaceData > &data)