40 #ifndef HARMONICEXTENSIONSOLVER_H_ 41 #define HARMONICEXTENSIONSOLVER_H_ 43 #include <lifev/core/LifeV.hpp> 44 #include <lifev/core/fem/DOF.hpp> 45 #include <lifev/core/array/MatrixElemental.hpp> 46 #include <lifev/core/fem/AssemblyElemental.hpp> 47 #include <lifev/core/fem/Assembly.hpp> 48 #include <lifev/core/fem/BCManage.hpp> 49 #include <lifev/core/fem/FESpace.hpp> 69 template <
typename Mesh,
70 typename SolverType = LifeV::SolverAztecOO >
71 class HarmonicExtensionSolver
78 typedef SolverType solver_Type;
79 typedef std::shared_ptr<solver_Type> solverPtr_Type;
81 typedef typename solver_Type::matrix_type matrix_Type;
82 typedef typename solver_Type::matrix_ptrtype matrixPtr_Type;
83 typedef typename solver_Type::vector_type vector_Type;
84 typedef typename solver_Type::vector_ptrtype vectorPtr_Type;
87 typedef SolverType solver_type;
89 typedef typename solver_type::matrix_type matrix_type;
90 typedef typename solver_type::vector_type vector_type;
104 HarmonicExtensionSolver (
FESpace<Mesh, MapEpetra>& mmFESpace,
105 std::shared_ptr<Epetra_Comm> comm);
114 HarmonicExtensionSolver (
FESpace<Mesh, MapEpetra>& mmFESpace,
115 std::shared_ptr<Epetra_Comm> comm,
121 virtual ~HarmonicExtensionSolver() {};
132 void setUp (
const GetPot& dataFile );
138 void iterate (BCHandler& BCh);
141 bool isLeader()
const 143 return comm().MyPID() == 0;
147 void resetPrec (
bool reset =
true)
151 M_linearSolver->precReset();
162 void addSystemMatrixTo (matrixPtr_Type matr)
const 172 void applyBoundaryConditions (vector_Type& rhs, BCHandler& BCh);
174 void computeMatrix();
175 void updateDispDiff();
182 vector_Type
const& disp()
const 191 MapEpetra
const& getMap()
const 196 FESpace<Mesh, MapEpetra>
const& mFESpace()
const 201 const std::shared_ptr<Epetra_Comm>& comm()
const 203 return M_displayer.comm();
214 MapEpetra M_localMap;
217 matrixPtr_Type M_matrHE;
219 Displayer M_displayer;
224 MatrixElemental M_elmat;
227 vectorPtr_Type M_disp;
230 vectorPtr_Type M_secondRHS;
233 solverPtr_Type M_linearSolver;
246 template <
typename Mesh,
typename SolverType>
247 HarmonicExtensionSolver<Mesh, SolverType>::
248 HarmonicExtensionSolver (
FESpace<Mesh, MapEpetra>& mmFESpace,
249 std::shared_ptr<Epetra_Comm> comm ) :
250 M_FESpace ( mmFESpace ),
251 M_localMap ( M_FESpace.map() ),
252 M_matrHE (
new matrix_Type (M_localMap ) ),
253 M_displayer ( comm ),
254 M_me ( comm->MyPID() ),
255 M_verbose ( M_me == 0 ),
256 M_elmat ( M_FESpace.fe().nbFEDof(), nDimensions, nDimensions ),
265 template <
typename Mesh,
typename SolverType>
266 HarmonicExtensionSolver<Mesh, SolverType>::
267 HarmonicExtensionSolver (
FESpace<Mesh, MapEpetra>& mmFESpace,
268 std::shared_ptr<Epetra_Comm> comm ,
271 M_FESpace ( mmFESpace ),
272 M_localMap ( localMap),
273 M_matrHE (
new matrix_Type (M_localMap ) ),
274 M_displayer ( comm ),
275 M_me ( comm->MyPID() ),
276 M_verbose ( M_me == 0 ),
277 M_elmat ( M_FESpace.fe().nbFEDof(), nDimensions, nDimensions ),
290 template <
typename Mesh,
typename SolverType>
291 void HarmonicExtensionSolver<Mesh, SolverType>::setUp (
const GetPot& dataFile )
293 M_linearSolver.reset (
new solver_Type (M_displayer.comm() ) );
294 M_linearSolver->setDataFromGetPot ( dataFile,
"mesh_motion/solver" );
295 M_linearSolver->setupPreconditioner (dataFile,
"mesh_motion/prec");
297 M_diffusion = dataFile
("mesh_motion/diffusion", 1.0
);
300 M_linearSolver->setMatrix ( *M_matrHE );
301 M_secondRHS.reset (
new vector_Type (M_FESpace.map() ) );
302 M_disp.reset (
new vector_Type (M_FESpace.map() ) );
306 template <
typename Mesh,
typename SolverType>
308 HarmonicExtensionSolver<Mesh, SolverType>::iterate ( BCHandler& BCh )
313 M_displayer.leaderPrint (
" HE- Applying boundary conditions ... ");
317 applyBoundaryConditions (*M_secondRHS, BCh);
320 M_displayer.leaderPrintMax (
"done in " , chrono.diff() );
323 M_linearSolver->solveSystem ( *M_secondRHS, *M_disp, M_matrHE );
326 template <
typename Mesh,
typename SolverType>
328 HarmonicExtensionSolver<Mesh, SolverType>::applyBoundaryConditions (vector_Type& rhs, BCHandler& BCh)
334 if ( ! BCh.bcUpdateDone() )
337 BCh.bcUpdate ( *M_FESpace.mesh(), M_FESpace.feBd(), M_FESpace.dof() );
342 BCh.setOffset (M_offset);
346 bcManageRhs (rhs, *M_FESpace.mesh(), M_FESpace.dof(), BCh, M_FESpace.feBd(), 1., 0.0);
349 bcManageMatrix ( *M_matrHE, *M_FESpace.mesh(), M_FESpace.dof(), BCh, M_FESpace.feBd(), 1.0, 0. );
352 template <
typename Mesh,
typename SolverType>
353 void HarmonicExtensionSolver<Mesh, SolverType>::computeMatrix( )
357 M_displayer.leaderPrint (
" HE- Computing constant matrices ... ");
359 M_matrHE.reset (
new matrix_Type (M_localMap ) );
361 UInt totalDof = M_FESpace.dof().numTotalDof();
363 for (
UInt i = 0; i < M_FESpace.mesh()->numVolumes(); ++i )
366 M_FESpace.fe().updateFirstDerivQuadPt ( M_FESpace.mesh()->volumeList ( i ) );
368 AssemblyElemental::stiff ( M_diffusion, M_elmat, M_FESpace.fe(), 0, 0, 3 );
370 for (
UInt j = 0; j < M_FESpace.fieldDim(); ++j )
372 assembleMatrix ( *M_matrHE, M_elmat, M_FESpace.fe(), M_FESpace.dof(), j, j, j * totalDof + M_offset, j * totalDof + M_offset );
376 M_matrHE->globalAssemble();
379 M_displayer.leaderPrintMax (
"done in " , chrono.diff() );
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
double operator()(const char *VarName, const double &Default) const
FESpace - Short description here please!
double Real
Generic real data.
uint32_type UInt
generic unsigned integer (used mainly for addressing)