36 #ifndef COMPUTE_FINESCALEVELOCITY_ELEMENT_HPP 37 #define COMPUTE_FINESCALEVELOCITY_ELEMENT_HPP 39 #include <lifev/core/LifeV.hpp> 41 #include <lifev/core/fem/QuadratureRule.hpp> 42 #include <lifev/eta/fem/ETCurrentFE.hpp> 43 #include <lifev/eta/fem/MeshGeometricMap.hpp> 44 #include <lifev/eta/fem/QRAdapterBase.hpp> 46 #include <lifev/eta/expression/ExpressionToEvaluation.hpp> 47 #include <lifev/eta/expression/EvaluationPhiI.hpp> 49 #include <lifev/eta/array/ETVectorElemental.hpp> 57 namespace ExpressionAssembly
65 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
66 class ComputeFineScaleVelocity
74 typedef typename ExpressionToEvaluation < ExpressionType,
75 TestSpaceType::field_dim,
77 MeshType::S_geoDimensions >::evaluation_Type evaluation_Type;
86 ComputeFineScaleVelocity (
const std::shared_ptr<MeshType>& mesh,
87 const QRAdapterType& qrAdapter,
88 const std::shared_ptr<TestSpaceType>& testSpace,
89 const ExpressionType& expression,
90 const UInt offset = 0);
93 ComputeFineScaleVelocity (
const IntegrateVectorElement < MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator);
96 ~ComputeFineScaleVelocity();
105 template <
typename VectorType>
106 inline void operator>> (VectorType& vector)
117 void check (std::ostream& out = std::cout);
127 template <
typename VectorType>
128 void compute (VectorType& vec);
138 ComputeFineScaleVelocity();
143 std::shared_ptr<MeshType> M_mesh;
146 QRAdapterType M_qrAdapter;
149 std::shared_ptr<TestSpaceType> M_testSpace;
152 evaluation_Type M_evaluation;
154 ETCurrentFE<MeshType::S_geoDimensions, 1>* M_globalCFE_std;
155 ETCurrentFE<MeshType::S_geoDimensions, 1>* M_globalCFE_adapted;
157 ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim>* M_testCFE_std;
158 ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim>* M_testCFE_adapted;
160 ETVectorElemental M_elementalVector;
175 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
176 ComputeFineScaleVelocity < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
177 ComputeFineScaleVelocity (
const std::shared_ptr<MeshType>& mesh,
178 const QRAdapterType& qrAdapter,
179 const std::shared_ptr<TestSpaceType>& testSpace,
180 const ExpressionType& expression,
183 M_qrAdapter (qrAdapter),
184 M_testSpace (testSpace),
185 M_evaluation (expression),
187 M_testCFE_std (
new ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim> (testSpace->refFE(), testSpace->geoMap(), qrAdapter.standardQR() ) ),
188 M_testCFE_adapted (
new ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim> (testSpace->refFE(), testSpace->geoMap(), qrAdapter.standardQR() ) ),
190 M_elementalVector (TestSpaceType::field_dim * testSpace->refFE().nbDof() ),
194 switch (MeshType::geoShape_Type::BasRefSha::S_shape)
197 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
198 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
201 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
202 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
205 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
206 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
209 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
210 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
213 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
214 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), qrAdapter.standardQR() );
217 ERROR_MSG (
"Unrecognized element shape");
219 M_evaluation.setQuadrature ( qrAdapter.standardQR() );
221 M_evaluation.setGlobalCFE (M_globalCFE_std);
222 M_evaluation.setTestCFE (M_testCFE_std);
226 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
227 ComputeFineScaleVelocity < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
228 ComputeFineScaleVelocity (
const IntegrateVectorElement < MeshType, TestSpaceType, ExpressionType, QRAdapterType>& integrator)
229 : M_mesh (integrator.M_mesh),
230 M_qrAdapter (integrator.M_qrAdapter),
231 M_testSpace (integrator.M_testSpace),
232 M_evaluation (integrator.M_evaluation),
234 M_testCFE_std (
new ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim> (M_testSpace->refFE(), M_testSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
235 M_testCFE_adapted (
new ETCurrentFE<TestSpaceType::space_dim, TestSpaceType::field_dim> (M_testSpace->refFE(), M_testSpace->geoMap(), integrator.M_qrAdapter.standardQR() ) ),
237 M_elementalVector (integrator.M_elementalVector),
238 M_offset (integrator.M_offset)
240 switch (MeshType::geoShape_Type::BasRefSha::S_shape)
243 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
244 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feSegP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
247 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
248 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTriaP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
251 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
252 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feQuadQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
255 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
256 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feTetraP0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
259 M_globalCFE_std =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
260 M_globalCFE_adapted =
new ETCurrentFE<MeshType::S_geoDimensions, 1> (feHexaQ0, geometricMapFromMesh<MeshType>(), integrator.M_qrAdapter.standardQR() );
263 ERROR_MSG (
"Unrecognized element shape");
265 M_evaluation.setQuadrature (integrator.M_qrAdapter.standardQR() );
266 M_evaluation.setGlobalCFE (M_globalCFE_std);
267 M_evaluation.setTestCFE (M_testCFE_std);
271 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
272 ComputeFineScaleVelocity < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
273 ~ComputeFineScaleVelocity()
275 delete M_globalCFE_std;
276 delete M_globalCFE_adapted;
277 delete M_testCFE_std;
278 delete M_testCFE_adapted;
285 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
287 ComputeFineScaleVelocity < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
288 check (std::ostream& out)
290 out <<
" Checking the integration : " << std::endl;
291 M_evaluation.display (out);
293 out <<
" Elemental vector : " << std::endl;
294 M_elementalVector.showMe (out);
298 template <
typename MeshType,
typename TestSpaceType,
typename ExpressionType,
typename QRAdapterType>
299 template <
typename VectorType>
301 ComputeFineScaleVelocity < MeshType, TestSpaceType, ExpressionType, QRAdapterType>::
302 compute (VectorType& vec)
304 UInt nbElements (M_mesh->numElements() );
305 UInt nbQuadPt_std (M_qrAdapter.standardQR().nbQuadPt() );
306 UInt nbTestDof (M_testSpace->refFE().nbDof() );
309 bool isPreviousAdapted (
true);
311 VectorSmall<3> elementalVelocities;
313 for (UInt iElement (0); iElement < nbElements; ++iElement)
317 M_qrAdapter.update (iElement);
320 if (isPreviousAdapted)
322 M_evaluation.setQuadrature ( M_qrAdapter.standardQR() );
323 M_evaluation.setGlobalCFE ( M_globalCFE_std );
324 M_evaluation.setTestCFE ( M_testCFE_std );
326 isPreviousAdapted =
false;
330 M_globalCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_globalUpdateFlag | ET_UPDATE_WDET);
331 M_testCFE_std->update (M_mesh->element (iElement), evaluation_Type::S_testUpdateFlag);
334 M_evaluation.update (iElement);
336 elementalVelocities = M_evaluation.value_qi (0, 0);
338 for (UInt i (0); i < 3; ++i)
340 vec[M_mesh->element(iElement).id() + i * M_mesh->numGlobalElements() ] = elementalVelocities(i);
341 elementalVelocities(i) = 0.0;