36 #ifndef INTEGRATE_VECTOR_VOLUMEID_HPP 37 #define INTEGRATE_VECTOR_VOLUMEID_HPP 39 #include <lifev/core/LifeV.hpp> 41 #include <lifev/core/fem/QuadratureRule.hpp> 42 #include <lifev/core/mesh/RegionMesh.hpp> 43 #include <lifev/eta/fem/ETCurrentFE.hpp> 44 #include <lifev/eta/fem/MeshGeometricMap.hpp> 45 #include <lifev/eta/fem/QRAdapterBase.hpp> 47 #include <lifev/eta/expression/ExpressionToEvaluation.hpp> 49 #include <lifev/eta/array/ETVectorElemental.hpp> 51 #include <boost/shared_ptr.hpp> 58 namespace ExpressionAssembly
70 template <
typename MeshType,
71 typename TestSpaceType,
72 typename ExpressionType,
73 typename QRAdapterType >
74 class IntegrateVectorVolumeID
82 typedef typename ExpressionToEvaluation < ExpressionType,
83 TestSpaceType::field_dim,
85 3 >::evaluation_Type evaluation_Type;
87 typedef typename MeshType::element_Type element_Type;
90 typedef std::shared_ptr<std::vector<element_Type*> > vectorVolumesPtr_Type;
91 typedef std::shared_ptr<std::vector<UInt> > vectorIndexesPtr_Type;
100 IntegrateVectorVolumeID (
const vectorVolumesPtr_Type volumeList,
101 const vectorIndexesPtr_Type indexList,
102 const QRAdapterType& qrAdapter,
103 const std::shared_ptr<TestSpaceType>& testSpace,
104 const ExpressionType& expression);
107 IntegrateVectorVolumeID (
const IntegrateVectorVolumeID < MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator);
110 ~IntegrateVectorVolumeID();
119 template <
typename Vector>
120 inline void operator>> (Vector& vector)
126 template <
typename Vector>
127 inline void operator>> (std::shared_ptr<Vector> vector)
139 void check (std::ostream& out = std::cout);
149 template <
typename Vector>
150 void addTo (Vector& vec);
160 IntegrateVectorVolumeID();
165 vectorVolumesPtr_Type M_volumeList;
166 vectorIndexesPtr_Type M_indexList;
169 QRAdapterType M_qrAdapter;
172 std::shared_ptr<TestSpaceType> M_testSpace;
175 evaluation_Type M_evaluation;
177 ETCurrentFE<3, 1>* M_globalCFE_std;
178 ETCurrentFE<3, 1>* M_globalCFE_adapted;
180 ETCurrentFE<3, TestSpaceType::field_dim>* M_testCFE_std;
181 ETCurrentFE<3, TestSpaceType::field_dim>* M_testCFE_adapted;
183 ETVectorElemental M_elementalVector;
195 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
196 IntegrateVectorVolumeID < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
197 IntegrateVectorVolumeID (
const vectorVolumesPtr_Type volumeList,
198 const vectorIndexesPtr_Type indexList,
199 const QRAdapterType& qrAdapter,
200 const std::shared_ptr<TestSpaceType>& testSpace,
201 const ExpressionType& expression)
202 : M_volumeList ( volumeList ),
203 M_indexList ( indexList ),
204 M_qrAdapter (qrAdapter),
205 M_testSpace (testSpace),
206 M_evaluation (expression),
208 M_globalCFE_std (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() ) ),
209 M_globalCFE_adapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() ) ),
211 M_testCFE_std (
new ETCurrentFE<3, TestSpaceType::field_dim> (testSpace->refFE(), testSpace->geoMap(), qrAdapter.standardQR() ) ),
212 M_testCFE_adapted (
new ETCurrentFE<3, TestSpaceType::field_dim> (testSpace->refFE(), testSpace->geoMap(), qrAdapter.standardQR() ) ),
214 M_elementalVector (TestSpaceType::field_dim * testSpace->refFE().nbDof() )
216 M_evaluation.setQuadrature (qrAdapter.standardQR() );
217 M_evaluation.setGlobalCFE (M_globalCFE_std);
218 M_evaluation.setTestCFE (M_testCFE_std);
222 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
223 IntegrateVectorVolumeID <MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
224 IntegrateVectorVolumeID (
const IntegrateVectorVolumeID <MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator)
225 : M_volumeList (integrator.M_volumeList),
226 M_indexList (integrator.M_indexList),
227 M_qrAdapter (integrator.M_qrAdapter),
228 M_testSpace (integrator.M_testSpace),
229 M_evaluation (integrator.M_evaluation),
231 M_globalCFE_std (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() ) ),
232 M_globalCFE_adapted (
new ETCurrentFE<3, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() ) ),
234 M_testCFE_std (
new ETCurrentFE<3, TestSpaceType::field_dim> (M_testSpace->refFE(), M_testSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
235 M_testCFE_adapted (
new ETCurrentFE<3, TestSpaceType::field_dim> (M_testSpace->refFE(), M_testSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
237 M_elementalVector (integrator.M_elementalVector)
239 M_evaluation.setQuadrature (integrator.M_qrAdapter.standardQR() );
240 M_evaluation.setGlobalCFE (M_globalCFE_std);
241 M_evaluation.setTestCFE (M_testCFE_std);
245 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
246 IntegrateVectorVolumeID < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
247 ~IntegrateVectorVolumeID()
249 delete M_globalCFE_std;
250 delete M_globalCFE_adapted;
251 delete M_testCFE_std;
252 delete M_testCFE_adapted;
259 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
261 IntegrateVectorVolumeID <MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
262 check (std::ostream& out)
264 out <<
" Checking the integration : " << std::endl;
265 M_evaluation.display (out);
267 out <<
" Elemental vector : " << std::endl;
268 M_elementalVector.showMe (out);
272 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
273 template <
typename Vector>
275 IntegrateVectorVolumeID <MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
279 bool isPreviousAdapted (
true);
282 UInt nbElements ( (*M_volumeList).size() );
283 UInt nbIndexes ( (*M_indexList).size() );
285 ASSERT ( nbElements == nbIndexes,
"The number of indexes is different from the number of volumes!!!");
287 UInt nbQuadPt_std (M_qrAdapter.standardQR().nbQuadPt() );
288 UInt nbTestDof (M_testSpace->refFE().nbDof() );
290 for (UInt iElement (0); iElement < nbElements; ++iElement)
293 M_elementalVector.zero();
296 M_qrAdapter.update ( (*M_indexList) [iElement] );
299 if (M_qrAdapter.isAdaptedElement() )
302 M_evaluation.setQuadrature ( M_qrAdapter.adaptedQR() );
303 M_globalCFE_adapted -> setQuadratureRule ( M_qrAdapter.adaptedQR() );
304 M_testCFE_adapted -> setQuadratureRule ( M_qrAdapter.adaptedQR() );
307 M_evaluation.setGlobalCFE ( M_globalCFE_adapted );
308 M_evaluation.setTestCFE ( M_testCFE_adapted );
311 M_evaluation.update ( (*M_indexList) [iElement] );
314 M_globalCFE_adapted->update (* ( (*M_volumeList) [iElement]), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
315 M_testCFE_adapted->update (* ( (*M_volumeList) [iElement]), evaluation_Type::S_testUpdateFlag);
319 for (UInt iblock (0); iblock < TestSpaceType::field_dim; ++iblock)
322 for (UInt i (0); i < nbTestDof; ++i)
324 M_elementalVector.setRowIndex
325 (i + iblock * nbTestDof,
326 M_testSpace->dof().localToGlobalMap ( (*M_indexList) [iElement], i) + iblock * M_testSpace->dof().numTotalDof() );
330 for (UInt iQuadPt (0); iQuadPt < M_qrAdapter.adaptedQR().nbQuadPt(); ++iQuadPt)
332 for (UInt i (0); i < nbTestDof; ++i)
334 M_elementalVector.element (i + iblock * nbTestDof) +=
335 M_evaluation.value_qi (iQuadPt, i + iblock * nbTestDof)
336 * M_globalCFE_adapted->wDet (iQuadPt);
343 isPreviousAdapted =
true;
349 if (isPreviousAdapted)
351 M_evaluation.setQuadrature ( M_qrAdapter.standardQR() );
352 M_evaluation.setGlobalCFE ( M_globalCFE_std );
353 M_evaluation.setTestCFE ( M_testCFE_std );
355 isPreviousAdapted =
false;
360 M_globalCFE_std->update (* ( (*M_volumeList) [iElement]), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
361 M_testCFE_std->update (* ( (*M_volumeList) [iElement]), evaluation_Type::S_testUpdateFlag);
364 M_evaluation.update ( (*M_indexList) [iElement] );
367 for (UInt iblock (0); iblock < TestSpaceType::field_dim; ++iblock)
370 for (UInt i (0); i < nbTestDof; ++i)
372 M_elementalVector.setRowIndex
373 (i + iblock * nbTestDof,
374 M_testSpace->dof().localToGlobalMap ( (*M_indexList) [iElement], i) + iblock * M_testSpace->dof().numTotalDof() );
378 for (UInt iQuadPt (0); iQuadPt < nbQuadPt_std; ++iQuadPt)
380 for (UInt i (0); i < nbTestDof; ++i)
382 M_elementalVector.element (i + iblock * nbTestDof) +=
383 M_evaluation.value_qi (iQuadPt, i + iblock * nbTestDof) *
384 M_globalCFE_std->wDet (iQuadPt);
391 M_elementalVector.pushToGlobal (vec);