39 #ifndef POSTPROCESSINGBOUNDARY_H 40 #define POSTPROCESSINGBOUNDARY_H 1
45 #include <lifev/core/filter/GetPot.hpp> 46 #include <lifev/core/LifeV.hpp> 77 template <
typename MeshType>
78 class PostProcessingBoundary
83 typedef typename MeshType::elementShape_Type elementGeometricShape_Type;
84 typedef typename elementGeometricShape_Type::GeoBShape facetGeometricShape_Type;
85 typedef MeshType mesh_Type;
86 typedef std::shared_ptr<MeshType> meshPtr_Type;
88 typedef DOF* dofPtr_Type;
97 PostProcessingBoundary<MeshType>()
104 PostProcessingBoundary (
const PostProcessingBoundary& )
119 PostProcessingBoundary<MeshType> ( meshPtr_Type mesh,
120 std::vector<currentBdFEPtr_Type > currentBdFEVector,
121 std::vector<dofPtr_Type > dofVector,
127 PostProcessingBoundary<MeshType> ( meshPtr_Type mesh,
128 currentBdFEPtr_Type currentBdFE, dofPtr_Type dof,
137 PostProcessingBoundary<MeshType> ( meshPtr_Type mesh,
138 currentBdFEPtr_Type feBdu, dofPtr_Type dofu,
139 currentBdFEPtr_Type feBdp, dofPtr_Type dofp,
169 template<
typename VectorType >
190 template<
typename VectorType >
219 template<
typename VectorType >
233 template<
typename VectorType >
234 Vector average (
const VectorType& field,
const markerID_Type& flag,
UInt feSpace = 0,
UInt nDim = 1 );
274 template<
typename VectorType>
275 VectorType compute_sstress (
const VectorType& r, UInt ncomp,
bool residual )
const;
289 template<
typename VectorType>
290 VectorType compute_stress (
const VectorType& grad,
const UInt& dim,
const Real& visc )
const;
299 void showDOFIndexMap ( std::ostream& output = std::cout )
const;
301 void showPatchesMeasure ( std::ostream& output = std::cout )
const;
303 void showPatchesNormal ( std::ostream& output = std::cout )
const;
305 void showPatchesPhi ( std::ostream& output = std::cout )
const;
310 const Vector& patchMeasureInFESpace (
const UInt& feSpace = 0 )
const 312 return M_patchMeasureVector[feSpace];
315 const Vector& patchNormalInFESpace (
const UInt& feSpace = 0 )
const 317 return M_patchNormalVector[feSpace];
320 const std::vector< ID >& dofGlobalIdInFESpace (
const UInt& feSpace = 0 )
const 322 return M_dofGlobalIdVector[feSpace];
326 const UInt& numBoundaryDofInFESpace (
const UInt& feSpace = 0 )
const 328 return M_numBoundaryDofVector[feSpace];
340 void computePatchesMeasure();
341 void computePatchesNormal();
342 void computePatchesPhi();
348 std::vector<UInt> M_numBoundaryDofVector;
349 std::vector<UInt> M_numDofPerPeakVector, M_numDofPerRidgeVector, M_numDofPerFacetVector;
350 UInt M_numRidgesPerFacet, M_numFacetPerFacet;
351 UInt M_numPeaksPerElement, M_numRidgesPerElement;
352 std::vector<UInt> M_numPeakDofPerFacetVector, M_numRidgeDofPerFacetVector;
353 std::vector<UInt> M_numTotalDofPerFacetVector;
354 std::vector<UInt> M_numPeakDofPerElement, M_numRidgeDofPerElementVector;
356 std::vector<UInt> M_numTotalDofVector;
358 std::vector<Vector > M_patchMeasureVector;
360 std::vector<Vector > M_patchNormalVector;
362 std::vector<Vector > M_patchIntegratedPhiVector;
365 std::map< markerID_Type, std::list<ID> > M_boundaryMarkerToFacetIdMap;
368 std::vector< std::vector< std::vector<ID> > > M_vectorNumberingPerFacetVector;
370 std::vector< std::vector< ID > > M_dofGlobalIdVector;
373 std::vector<currentBdFEPtr_Type > M_currentBdFEPtrVector;
375 std::vector<dofPtr_Type > M_dofPtrVector;
377 meshPtr_Type M_meshPtr;
379 std::shared_ptr<MapEpetra> M_epetraMapPtr;
388 template <
typename MeshType>
389 PostProcessingBoundary<MeshType>::PostProcessingBoundary ( meshPtr_Type meshPtr,
390 std::vector<currentBdFEPtr_Type > currentBdFEVector,
391 std::vector<dofPtr_Type > dofVector,
393 M_numFESpaces (nvar),
394 M_numBoundaryDofVector (M_numFESpaces),
395 M_numDofPerPeakVector (M_numFESpaces), M_numDofPerRidgeVector (M_numFESpaces), M_numDofPerFacetVector (M_numFESpaces),
396 M_numPeakDofPerFacetVector (M_numFESpaces), M_numRidgeDofPerFacetVector (M_numFESpaces),
397 M_numTotalDofPerFacetVector (M_numFESpaces),
398 M_numPeakDofPerElement (M_numFESpaces), M_numRidgeDofPerElementVector (M_numFESpaces),
399 M_numTotalDofVector (M_numFESpaces),
400 M_patchMeasureVector (M_numFESpaces), M_patchNormalVector (M_numFESpaces),
401 M_patchIntegratedPhiVector (M_numFESpaces),
402 M_vectorNumberingPerFacetVector (M_numFESpaces), M_dofGlobalIdVector (M_numFESpaces),
403 M_currentBdFEPtrVector (currentBdFEVector), M_dofPtrVector (dofVector),
404 M_meshPtr ( meshPtr ), M_epetraMapPtr (
new MapEpetra (epetraMap) ),
405 M_geoDimension (MeshType::S_geoDimensions)
407 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace)
409 M_vectorNumberingPerFacetVector[M_numFESpaces].clear();
410 M_dofGlobalIdVector[iFESpace].clear();
413 M_numRidgesPerFacet = facetGeometricShape_Type::S_numRidges;
414 M_numFacetPerFacet = facetGeometricShape_Type::S_numFacets;
416 M_numPeaksPerElement = elementGeometricShape_Type::S_numPeaks;
417 M_numRidgesPerElement = elementGeometricShape_Type::S_numRidges;
419 M_numBoundaryFacets = M_meshPtr->numBoundaryFacets();
424 computePatchesMeasure();
425 computePatchesNormal();
429 template <
typename MeshType>
430 PostProcessingBoundary<MeshType>::PostProcessingBoundary ( meshPtr_Type mesh,
431 currentBdFEPtr_Type currentBdFE, dofPtr_Type dof,
434 M_numBoundaryDofVector (M_numFESpaces),
435 M_numDofPerPeakVector (M_numFESpaces), M_numDofPerRidgeVector (M_numFESpaces), M_numDofPerFacetVector (M_numFESpaces),
436 M_numPeakDofPerFacetVector (M_numFESpaces), M_numRidgeDofPerFacetVector (M_numFESpaces),
437 M_numTotalDofPerFacetVector (M_numFESpaces),
438 M_numPeakDofPerElement (M_numFESpaces), M_numRidgeDofPerElementVector (M_numFESpaces),
439 M_numTotalDofVector (M_numFESpaces),
440 M_patchMeasureVector (M_numFESpaces), M_patchNormalVector (M_numFESpaces), M_patchIntegratedPhiVector (M_numFESpaces),
441 M_vectorNumberingPerFacetVector (M_numFESpaces), M_dofGlobalIdVector (M_numFESpaces),
442 M_currentBdFEPtrVector (M_numFESpaces), M_dofPtrVector (M_numFESpaces),
443 M_meshPtr ( mesh ), M_epetraMapPtr (
new MapEpetra (epetraMap) ),
444 M_geoDimension (MeshType::S_geoDimensions)
446 M_currentBdFEPtrVector[0] = currentBdFE;
447 M_dofPtrVector[0] = dof;
450 M_numRidgesPerFacet = facetGeometricShape_Type::S_numRidges;
451 M_numFacetPerFacet = facetGeometricShape_Type::S_numFacets;
453 M_numPeaksPerElement = elementGeometricShape_Type::S_numPeaks;
454 M_numRidgesPerElement = elementGeometricShape_Type::S_numRidges;
456 M_numBoundaryFacets = M_meshPtr->numBoundaryFacets();
461 computePatchesMeasure();
462 computePatchesNormal();
466 template <
typename MeshType>
467 PostProcessingBoundary<MeshType>::PostProcessingBoundary ( meshPtr_Type mesh,
468 currentBdFEPtr_Type feBdu, dofPtr_Type dofu,
469 currentBdFEPtr_Type feBdp, dofPtr_Type dofp,
472 M_numBoundaryDofVector (M_numFESpaces),
473 M_numDofPerPeakVector (M_numFESpaces), M_numDofPerRidgeVector (M_numFESpaces), M_numDofPerFacetVector (M_numFESpaces),
474 M_numPeakDofPerFacetVector (M_numFESpaces), M_numRidgeDofPerFacetVector (M_numFESpaces),
475 M_numTotalDofPerFacetVector (M_numFESpaces),
476 M_numPeakDofPerElement (M_numFESpaces), M_numRidgeDofPerElementVector (M_numFESpaces),
477 M_numTotalDofVector (M_numFESpaces),
478 M_patchMeasureVector (M_numFESpaces), M_patchNormalVector (M_numFESpaces), M_patchIntegratedPhiVector (M_numFESpaces),
479 M_vectorNumberingPerFacetVector (M_numFESpaces), M_dofGlobalIdVector (M_numFESpaces),
480 M_currentBdFEPtrVector (M_numFESpaces), M_dofPtrVector (M_numFESpaces),
481 M_meshPtr ( mesh ), M_epetraMapPtr (
new MapEpetra (epetraMap) ),
482 M_geoDimension (MeshType::S_geoDimensions)
484 M_currentBdFEPtrVector[0] = feBdu;
485 M_dofPtrVector[0] = dofu;
486 M_currentBdFEPtrVector[1] = feBdp;
487 M_dofPtrVector[1] = dofp;
490 M_numRidgesPerFacet = facetGeometricShape_Type::S_numRidges;
491 M_numFacetPerFacet = facetGeometricShape_Type::S_numFacets;
493 M_numPeaksPerElement = elementGeometricShape_Type::S_numPeaks;
494 M_numRidgesPerElement = elementGeometricShape_Type::S_numRidges;
496 M_numBoundaryFacets = M_meshPtr->numBoundaryFacets();
501 computePatchesMeasure();
502 computePatchesNormal();
507 template<
typename MeshType>
508 void PostProcessingBoundary<MeshType>::buildVectors()
510 std::vector<ID> boundaryDofGlobalIdVector;
512 UInt iFirstAdjacentElement, iPeakLocalId, iFacetLocalId, iRidgeLocalId;
513 ID dofLocalId, dofGlobalId, dofAuxiliaryId;
514 std::vector<ID> numBoundaryDofVector (M_numFESpaces);
515 std::vector<ID>::iterator dofGlobalIdVectorIterator;
518 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace)
521 numBoundaryDofVector[iFESpace] = 0;
524 M_numDofPerPeakVector[iFESpace] = M_dofPtrVector[iFESpace]->localDofPattern().nbDofPerPeak();
525 M_numDofPerRidgeVector[iFESpace] = M_dofPtrVector[iFESpace]->localDofPattern().nbDofPerRidge();
526 M_numDofPerFacetVector[iFESpace] = M_dofPtrVector[iFESpace]->localDofPattern().nbDofPerFacet();
529 M_numPeakDofPerFacetVector[iFESpace] = M_numDofPerPeakVector[iFESpace] * M_numRidgesPerFacet;
531 M_numRidgeDofPerFacetVector[iFESpace] = M_numDofPerRidgeVector[iFESpace] * M_numFacetPerFacet;
534 M_numTotalDofPerFacetVector[iFESpace] =
535 M_numPeakDofPerFacetVector[iFESpace] + M_numRidgeDofPerFacetVector[iFESpace] + M_numDofPerFacetVector[iFESpace];
537 M_numPeakDofPerElement[iFESpace] = M_numPeaksPerElement * M_numDofPerPeakVector[iFESpace];
539 M_numRidgeDofPerElementVector[iFESpace] = M_numRidgesPerElement * M_numDofPerRidgeVector[iFESpace];
541 M_numTotalDofVector[iFESpace] = M_dofPtrVector[iFESpace]->numTotalDof();
547 for (
ID iboundaryFacet = 0 ; iboundaryFacet < M_numBoundaryFacets; ++iboundaryFacet )
550 iFirstAdjacentElement = M_meshPtr->boundaryFacet ( iboundaryFacet ).firstAdjacentElementIdentity();
551 iFacetLocalId = M_meshPtr->boundaryFacet ( iboundaryFacet ).firstAdjacentElementPosition();
553 boundaryFlag = M_meshPtr->boundaryFacet (iboundaryFacet ).markerID();
554 M_boundaryMarkerToFacetIdMap[boundaryFlag].push_back ( iboundaryFacet );
556 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace)
558 clearVector (boundaryDofGlobalIdVector);
561 boundaryDofGlobalIdVector.resize ( M_numTotalDofPerFacetVector[iFESpace] );
564 M_currentBdFEPtrVector[iFESpace]->update ( M_meshPtr->boundaryFacet ( iboundaryFacet ), UPDATE_W_ROOT_DET_METRIC );
569 if ( M_numDofPerPeakVector[iFESpace] )
573 for (
ID iRidgePerFacet = 0; iRidgePerFacet < M_numRidgesPerFacet; ++iRidgePerFacet )
576 iPeakLocalId = elementGeometricShape_Type::faceToPoint ( iFacetLocalId, iRidgePerFacet );
579 for ( ID localDof = 0; localDof < M_numDofPerPeakVector[iFESpace]; ++localDof )
581 dofLocalId = iRidgePerFacet * M_numDofPerPeakVector[iFESpace] + localDof ;
582 dofGlobalId = M_dofPtrVector[iFESpace]->localToGlobalMap (
583 iFirstAdjacentElement, ( iPeakLocalId ) * M_numDofPerPeakVector[iFESpace] + localDof );
584 dofGlobalIdVectorIterator = find (
585 M_dofGlobalIdVector[iFESpace].begin(), M_dofGlobalIdVector[iFESpace].end(), dofGlobalId );
586 if ( dofGlobalIdVectorIterator == M_dofGlobalIdVector[iFESpace].end() )
589 boundaryDofGlobalIdVector[ dofLocalId ] = numBoundaryDofVector[iFESpace];
590 M_dofGlobalIdVector[iFESpace].push_back ( dofGlobalId );
591 numBoundaryDofVector[iFESpace]++;
596 dofAuxiliaryId = ( ID ) ( ( dofGlobalIdVectorIterator - M_dofGlobalIdVector[iFESpace].begin() ) );
597 boundaryDofGlobalIdVector[ dofLocalId ] = dofAuxiliaryId;
605 if ( M_numDofPerRidgeVector[iFESpace] )
608 for (
ID iFacetPerFacet = 0; iFacetPerFacet < M_numFacetPerFacet; ++iFacetPerFacet )
611 iRidgeLocalId = elementGeometricShape_Type::facetToRidge ( iFacetLocalId, iFacetPerFacet );
613 for ( ID localDof = 0; localDof < M_numDofPerRidgeVector[iFESpace]; ++localDof )
615 dofLocalId = M_numPeakDofPerFacetVector[iFESpace] +
616 iFacetPerFacet * M_numDofPerRidgeVector[iFESpace] + localDof ;
617 dofGlobalId = M_dofPtrVector[iFESpace]->localToGlobalMap (
618 iFirstAdjacentElement, M_numPeakDofPerElement[iFESpace] + iRidgeLocalId *
619 M_numDofPerRidgeVector[iFESpace] + localDof );
620 dofGlobalIdVectorIterator = find (
621 M_dofGlobalIdVector[iFESpace].begin(), M_dofGlobalIdVector[iFESpace].end(), dofGlobalId );
622 if ( dofGlobalIdVectorIterator == M_dofGlobalIdVector[iFESpace].end() )
625 boundaryDofGlobalIdVector[ dofLocalId ] = numBoundaryDofVector[iFESpace];
626 M_dofGlobalIdVector[iFESpace].push_back ( dofGlobalId );
627 numBoundaryDofVector[iFESpace]++;
632 dofAuxiliaryId = ( ID ) ( dofGlobalIdVectorIterator - M_dofGlobalIdVector[iFESpace].begin() );
633 boundaryDofGlobalIdVector[ dofLocalId ] = dofAuxiliaryId;
642 for ( ID localDof = 0; localDof < M_numDofPerFacetVector[iFESpace]; ++localDof )
645 dofLocalId = M_numRidgeDofPerFacetVector[iFESpace] + M_numPeakDofPerFacetVector[iFESpace] + localDof;
646 dofGlobalId = M_dofPtrVector[iFESpace]->localToGlobalMap (
647 iFirstAdjacentElement, M_numRidgeDofPerElementVector[iFESpace] + M_numPeakDofPerElement[iFESpace] +
648 iFacetLocalId * M_numDofPerFacetVector[iFESpace] + localDof );
649 dofGlobalIdVectorIterator = find (
650 M_dofGlobalIdVector[iFESpace].begin(), M_dofGlobalIdVector[iFESpace].end(), dofGlobalId );
651 if ( dofGlobalIdVectorIterator == M_dofGlobalIdVector[iFESpace].end() )
654 boundaryDofGlobalIdVector[ dofLocalId ] = numBoundaryDofVector[iFESpace];
655 M_dofGlobalIdVector[iFESpace].push_back ( dofGlobalId );
656 numBoundaryDofVector[iFESpace]++;
661 dofAuxiliaryId = ( ID ) ( dofGlobalIdVectorIterator - M_dofGlobalIdVector[iFESpace].begin() ) ;
662 boundaryDofGlobalIdVector[ dofLocalId ] = dofAuxiliaryId;
666 M_vectorNumberingPerFacetVector[iFESpace].push_back ( boundaryDofGlobalIdVector );
670 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace)
673 M_numBoundaryDofVector[iFESpace] = M_dofGlobalIdVector[iFESpace].size();
675 M_patchMeasureVector[iFESpace].resize ( M_numBoundaryDofVector[iFESpace] );
676 for ( Vector::iterator it = M_patchMeasureVector[iFESpace].begin(); it < M_patchMeasureVector[iFESpace].end(); it++ )
681 M_patchNormalVector[iFESpace].resize ( M_numBoundaryDofVector[iFESpace] * M_geoDimension );
682 for ( Vector::iterator it = M_patchNormalVector[iFESpace].begin(); it < M_patchNormalVector[iFESpace].end(); it++ )
687 M_patchIntegratedPhiVector[iFESpace].resize ( M_numBoundaryDofVector[iFESpace] );
688 for ( Vector::iterator it = M_patchIntegratedPhiVector[iFESpace].begin();
689 it < M_patchIntegratedPhiVector[iFESpace].end(); it++ )
700 template<
typename MeshType>
705 Real measureScatter (0.0), measure (0.);
707 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
708 typedef std::list<ID>::iterator Iterator;
713 for ( Iterator j = facetList.begin(); j != facetList.end(); ++j )
716 M_currentBdFEPtrVector[0]->update ( M_meshPtr->boundaryFacet ( *j ), UPDATE_W_ROOT_DET_METRIC );
718 measureScatter += M_currentBdFEPtrVector[0]->measure();
723 M_epetraMapPtr->comm().SumAll ( &measureScatter, &measure, 1 );
731 template<
typename VectorType>
736 Real fluxScatter (0.0), flux (0.);
741 UInt dofVectorIndex, dofGlobalId;
744 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
745 typedef std::list<ID>::iterator Iterator;
748 Vector localFieldVector (nDim * M_numTotalDofPerFacetVector[feSpace]);
751 for (Iterator j = facetList.begin(); j != facetList.end(); ++j)
755 M_currentBdFEPtrVector[feSpace]->update (M_meshPtr->boundaryFacet (*j), UPDATE_W_ROOT_DET_METRIC | UPDATE_NORMALS );
759 for (UInt iq = 0; iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq)
764 for (UInt iComponent = 0; iComponent < nDim; ++iComponent)
769 for (ID iDof = 0; iDof < M_numTotalDofPerFacetVector[feSpace]; ++iDof)
773 dofVectorIndex = M_vectorNumberingPerFacetVector[feSpace][ ( UInt ) * j ][ iDof ];
774 dofGlobalId = M_dofGlobalIdVector[feSpace][dofVectorIndex];
776 localFieldVector[iComponent * M_numTotalDofPerFacetVector[feSpace] + iDof] =
777 field[iComponent * M_numTotalDofVector[feSpace] + dofGlobalId];
779 fluxScatter += M_currentBdFEPtrVector[feSpace]->wRootDetMetric (iq)
780 * localFieldVector[iComponent * M_numTotalDofPerFacetVector[feSpace] + iDof]
781 * M_currentBdFEPtrVector[feSpace]->phi (iDof, iq)
782 * M_currentBdFEPtrVector[feSpace]->normal (iComponent, iq);
788 M_epetraMapPtr->comm().SumAll ( &fluxScatter, &flux, 1 );
794 template<
typename VectorType>
795 Real PostProcessingBoundary<MeshType>::kineticNormalStress (
const VectorType& velocity,
const Real& density,
const markerID_Type& flag,
UInt feSpace,
UInt )
798 Real kineticNormalStressScatter (0.0), kineticNormalStress (0.0);
799 Real areaScatter (0.0), area (0.0);
803 Vector faceNormal = normal ( flag );
808 UInt dofVectorIndex, dofGlobalId;
811 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
814 for ( std::list<ID>::iterator j (facetList.begin() ); j != facetList.end(); ++j )
817 M_currentBdFEPtrVector[feSpace]->update ( M_meshPtr->boundaryFacet ( *j ), UPDATE_NORMALS | UPDATE_W_ROOT_DET_METRIC );
820 areaScatter += M_currentBdFEPtrVector[0]->measure();
823 for ( UInt iq (0); iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq )
826 for ( ID iDof (0); iDof < M_numTotalDofPerFacetVector[feSpace]; ++iDof )
829 dofVectorIndex = M_vectorNumberingPerFacetVector[feSpace][ ( UInt ) * j ][ iDof ];
830 dofGlobalId = M_dofGlobalIdVector[feSpace][dofVectorIndex];
832 temp = velocity[0 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[0]
833 + velocity[1 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[1]
834 + velocity[2 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[2];
836 kineticNormalStressScatter += M_currentBdFEPtrVector[feSpace]->wRootDetMetric (iq)
837 * M_currentBdFEPtrVector[feSpace]->phi (Int (iDof), iq)
844 M_epetraMapPtr->comm().SumAll ( &areaScatter, &area, 1 );
845 M_epetraMapPtr->comm().SumAll ( &kineticNormalStressScatter, &kineticNormalStress, 1 );
847 return 0.5 * density * kineticNormalStress / area;
851 template<
typename VectorType>
852 Real PostProcessingBoundary<MeshType>::kineticNormalStressDerivative (
const VectorType& velocity,
const VectorType& velocityDerivative,
858 Real kineticNormalStressScatter (0.0), kineticNormalStress (0.0);
859 Real areaScatter (0.0), area (0.0);
863 Vector faceNormal = normal ( flag );
868 UInt dofVectorIndex, dofGlobalId;
871 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
874 for ( std::list<ID>::iterator j (facetList.begin() ); j != facetList.end(); ++j )
877 M_currentBdFEPtrVector[feSpace]->update ( M_meshPtr->boundaryFacet ( *j ), UPDATE_NORMALS | UPDATE_W_ROOT_DET_METRIC );
880 areaScatter += M_currentBdFEPtrVector[0]->measure();
883 for ( UInt iq (0); iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq )
886 for ( ID iDof (0); iDof < M_numTotalDofPerFacetVector[feSpace]; ++iDof )
889 dofVectorIndex = M_vectorNumberingPerFacetVector[feSpace][ ( UInt ) * j ][ iDof ];
890 dofGlobalId = M_dofGlobalIdVector[feSpace][dofVectorIndex];
893 velocity[0 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[0]
894 + velocity[1 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[1]
895 + velocity[2 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[2]
898 velocityDerivative[0 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[0]
899 + velocityDerivative[1 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[1]
900 + velocityDerivative[2 * M_numTotalDofVector[feSpace] + dofGlobalId] * faceNormal[2]
903 kineticNormalStressScatter += M_currentBdFEPtrVector[feSpace]->wRootDetMetric (iq)
904 * M_currentBdFEPtrVector[feSpace]->phi (Int (iDof), iq)
911 M_epetraMapPtr->comm().SumAll ( &areaScatter, &area, 1 );
912 M_epetraMapPtr->comm().SumAll ( &kineticNormalStressScatter, &kineticNormalStress, 1 );
914 return density * kineticNormalStress / area;
919 template<
typename VectorType>
920 Vector PostProcessingBoundary<MeshType>::average (
const VectorType& field,
const markerID_Type& flag,
UInt feSpace,
UInt nDim )
924 Vector fieldAverageScatter (nDim), fieldAverage (nDim), localField (nDim);
926 for (
UInt iComponent = 0; iComponent < nDim; ++iComponent )
928 fieldAverageScatter[iComponent] = 0.;
929 fieldAverage[iComponent] = 0.;
930 localField[iComponent] = 0.;
934 Real measureScatter (0.), measure;
939 UInt dofVectorIndex, dofGlobalId;
942 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
943 typedef std::list<ID>::iterator Iterator;
946 Vector localFieldVector (M_numTotalDofPerFacetVector[feSpace]);
949 for (Iterator j = facetList.begin(); j != facetList.end(); ++j)
953 for ( UInt iComponent = 0; iComponent < nDim; ++iComponent )
955 localField[iComponent] = 0.;
959 M_currentBdFEPtrVector[feSpace]->update (M_meshPtr->boundaryFacet (*j), UPDATE_W_ROOT_DET_METRIC | UPDATE_NORMALS );
962 for (UInt iComponent = 0; iComponent < nDim; ++iComponent)
967 for (UInt iq = 0; iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq)
972 for (ID iDof = 0; iDof < M_numTotalDofPerFacetVector[feSpace]; ++iDof)
976 dofVectorIndex = M_vectorNumberingPerFacetVector[feSpace][ ( UInt ) * j ][ iDof];
977 dofGlobalId = M_dofGlobalIdVector[feSpace][dofVectorIndex];
980 localFieldVector[iDof] = field[iComponent * M_numTotalDofVector[feSpace] + dofGlobalId];
982 localField[iComponent] += M_currentBdFEPtrVector[feSpace]->wRootDetMetric (iq)
983 * localFieldVector[iDof] * M_currentBdFEPtrVector[feSpace]->phi (Int (iDof), iq);
987 fieldAverageScatter[iComponent] += localField[iComponent];
991 measureScatter += M_currentBdFEPtrVector[feSpace]->measure();
994 M_epetraMapPtr->comm().SumAll ( &measureScatter, &measure, 1 );
997 for (
UInt iComponent (0); iComponent < nDim; ++iComponent )
999 M_epetraMapPtr->comm().SumAll ( &fieldAverageScatter[iComponent], &fieldAverage[iComponent], 1 );
1002 return fieldAverage / measure;
1006 template<
typename MeshType>
1011 Vector normalScatter (3) , normal (3);
1018 normalScatter[0] = 0.0;
1019 normalScatter[1] = 0.0;
1020 normalScatter[2] = 0.0;
1023 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
1024 typedef std::list<ID>::iterator Iterator;
1027 Vector localFieldVector ( nDim * M_numTotalDofPerFacetVector[feSpace] );
1030 for (Iterator j = facetList.begin(); j != facetList.end(); ++j)
1033 M_currentBdFEPtrVector[feSpace]->update ( M_meshPtr->boundaryFacet (*j), UPDATE_W_ROOT_DET_METRIC | UPDATE_NORMALS );
1036 for ( UInt iq (0); iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq )
1039 for ( UInt iComponent (0); iComponent < nDim; ++iComponent )
1042 for (ID iDof (0); iDof < M_numTotalDofPerFacetVector[ feSpace ]; ++iDof)
1044 normalScatter (iComponent) += M_currentBdFEPtrVector[feSpace]->wRootDetMetric ( iq )
1045 * M_currentBdFEPtrVector[feSpace]->phi ( Int (iDof), iq )
1046 * M_currentBdFEPtrVector[feSpace]->normal ( Int (iComponent), iq );
1053 M_epetraMapPtr->comm().SumAll ( &normalScatter (0), &normal (0), 1 );
1054 M_epetraMapPtr->comm().SumAll ( &normalScatter (1), &normal (1), 1 );
1055 M_epetraMapPtr->comm().SumAll ( &normalScatter (2), &normal (2), 1 );
1058 Real nn = std::sqrt ( normal (0) * normal (0) + normal (1) * normal (1) + normal (2) * normal (2) );
1061 if ( std::fabs ( nn ) < 1e-6 )
1063 debugStream ( 5000 ) <<
"Approximate surface normal could not be reliably computed.\n";
1064 debugStream ( 5000 ) <<
"Modulus of the integrated normal vector was: " << nn <<
"\n";
1068 return ( normal / nn );
1072 template<
typename MeshType>
1077 Real areaScatter (0.0), area (0.0);
1078 Vector geometricCenterScatter (3), geometricCenter (3);
1080 geometricCenter[0] = 0.0;
1081 geometricCenter[1] = 0.0;
1082 geometricCenter[2] = 0.0;
1084 geometricCenterScatter[0] = 0.0;
1085 geometricCenterScatter[1] = 0.0;
1086 geometricCenterScatter[2] = 0.0;
1089 std::list<ID> facetList ( M_boundaryMarkerToFacetIdMap[flag] );
1090 typedef std::list<ID>::iterator Iterator;
1093 Vector localFieldVector (nDim * M_numTotalDofPerFacetVector[feSpace]);
1096 for (Iterator j = facetList.begin(); j != facetList.end(); ++j)
1099 M_currentBdFEPtrVector[feSpace]->update (M_meshPtr->boundaryFacet (*j), UPDATE_QUAD_NODES | UPDATE_NORMALS | UPDATE_W_ROOT_DET_METRIC );
1102 areaScatter += M_currentBdFEPtrVector[0]->measure();
1105 for (UInt iq (0); iq < M_currentBdFEPtrVector[feSpace]->nbQuadPt(); ++iq)
1108 for (UInt iComponent (0); iComponent < nDim; ++iComponent)
1111 for (ID iDof (0); iDof < M_numTotalDofPerFacetVector[feSpace]; ++iDof)
1113 geometricCenterScatter (iComponent) += M_currentBdFEPtrVector[feSpace]->wRootDetMetric (iq)
1114 * M_currentBdFEPtrVector[feSpace]->phi (Int (iDof), iq)
1115 * M_currentBdFEPtrVector[feSpace]->quadPt (iq, Int (iComponent) );
1122 M_epetraMapPtr->comm().SumAll ( &geometricCenterScatter (0), &geometricCenter (0), 1 );
1123 M_epetraMapPtr->comm().SumAll ( &geometricCenterScatter (1), &geometricCenter (1), 1 );
1124 M_epetraMapPtr->comm().SumAll ( &geometricCenterScatter (2), &geometricCenter (2), 1 );
1126 M_epetraMapPtr->comm().SumAll ( &areaScatter, &area, 1 );
1129 geometricCenter /= area;
1131 return geometricCenter;
1136 template<
typename MeshType>
1137 void PostProcessingBoundary<MeshType>::computePatchesMeasure()
1139 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1151 for (
ID iboundaryFacet = 0 ; iboundaryFacet < M_numBoundaryFacets; ++iboundaryFacet )
1154 M_currentBdFEPtrVector[iFESpace]->update ( M_meshPtr->boundaryFacet ( iboundaryFacet ), UPDATE_W_ROOT_DET_METRIC );
1156 localMeasure = M_currentBdFEPtrVector[iFESpace]->measure();
1158 for ( ID iDof = 0; iDof < M_numTotalDofPerFacetVector[iFESpace]; ++iDof )
1161 dofVectorIndex = M_vectorNumberingPerFacetVector[iFESpace][ iboundaryFacet ][ iDof];
1162 M_patchMeasureVector[iFESpace][dofVectorIndex] += localMeasure;
1168 template <
typename MeshType>
1169 void PostProcessingBoundary<MeshType>::showPatchesMeasure ( std::ostream& output )
const 1171 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1174 output <<
"\n***** Post Proc: Measure of the patches *****" 1175 <<
"\n\tfor variable " << iFESpace << std::endl;
1178 for ( Vector::const_iterator it = M_patchMeasureVector[iFESpace].begin();
1179 it != M_patchMeasureVector[iFESpace].end(); it++ )
1181 output <<
"Boundary DOF: " << counter
1182 <<
", corresponding to Global DOF: " << M_dofGlobalIdVector[iFESpace][ counter ]
1183 <<
" has patch measure: " << *it << std::endl;
1189 template<
typename MeshType>
1190 void PostProcessingBoundary<MeshType>::showDOFIndexMap ( std::ostream& output )
const 1192 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1194 output <<
"\n***** Data for variable " << iFESpace <<
"*****" << std::endl;
1197 output <<
"\n***** Post Proc: Vector Indexes per Facet *****" << std::endl;
1198 output << M_vectorNumberingPerFacetVector[iFESpace].size() << std::endl;
1199 for ( std::vector<std::vector<ID> >::iterator it1 = M_vectorNumberingPerFacetVector[iFESpace].begin();
1200 it1 < M_vectorNumberingPerFacetVector[iFESpace].end(); it1++ )
1203 output <<
"Boundary Facet " << counter <<
", indexes: " << std::endl;
1204 for ( std::vector<ID>::iterator it2 = it1->begin(); it2 < it1->end(); it2++ )
1206 output << *it2 <<
",";
1208 output << std::endl;
1211 output <<
"***** Post Proc: From Vector Index to Global DOF *****" << std::endl;
1212 output << M_dofGlobalIdVector[iFESpace].size() << std::endl;
1214 for ( std::vector<ID>::iterator it3 = M_dofGlobalIdVector[iFESpace].begin();
1215 it3 < M_dofGlobalIdVector[iFESpace].end(); it3++ )
1217 output <<
"Index :" << it3 - M_dofGlobalIdVector[iFESpace].begin()
1218 <<
", Global DOF: " << *it3 << std::endl;
1229 template<
typename MeshType>
1230 void PostProcessingBoundary<MeshType>::computePatchesNormal()
1232 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1244 for (
ID iboundaryFacet = 0 ; iboundaryFacet < M_numBoundaryFacets; ++iboundaryFacet )
1247 M_currentBdFEPtrVector[iFESpace]->update ( M_meshPtr->boundaryFacet ( iboundaryFacet ), UPDATE_W_ROOT_DET_METRIC | UPDATE_NORMALS );
1250 for (
Int iComponent = 0; iComponent < M_geoDimension; iComponent++ )
1254 for ( UInt iQuadraturePoint = 0; iQuadraturePoint < M_currentBdFEPtrVector[iFESpace]->nbQuadPt();
1255 ++iQuadraturePoint )
1257 sum += M_currentBdFEPtrVector[iFESpace]->normal ( iComponent, iQuadraturePoint ) *
1258 M_currentBdFEPtrVector[iFESpace]->wRootDetMetric ( iQuadraturePoint );
1260 for ( ID iDof = 0; iDof < M_numTotalDofPerFacetVector[iFESpace]; ++iDof )
1263 dofVectorIndex = M_vectorNumberingPerFacetVector[iFESpace][ iboundaryFacet ][ iDof ];
1264 M_patchNormalVector[iFESpace][ iComponent * M_numBoundaryDofVector[iFESpace] + dofVectorIndex ] += sum;
1269 for ( UInt iBoundaryDof = 0; iBoundaryDof < M_numBoundaryDofVector[iFESpace]; ++iBoundaryDof )
1271 Real localMeasure = M_patchMeasureVector[iFESpace][ iBoundaryDof ];
1272 for ( Int icc = 0; icc < M_geoDimension; icc++ )
1274 M_patchNormalVector[iFESpace][ icc * M_numBoundaryDofVector[iFESpace] + iBoundaryDof ] *= 1. / localMeasure;
1281 template <
typename MeshType>
1282 void PostProcessingBoundary<MeshType>::showPatchesNormal ( std::ostream& output )
const 1284 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1287 output <<
"\n***** Post Proc: Normal vector on the patches *****" 1288 <<
"\n\tfor variable " << iFESpace << std::endl;
1292 for ( Vector::const_iterator it = M_patchMeasureVector[iFESpace].begin();
1293 it != M_patchMeasureVector[iFESpace].end(); it++ )
1295 output <<
"Boundary DOF: " << counter
1296 <<
", corresponding to Global DOF: " << M_dofGlobalIdVector[iFESpace][ counter ]
1297 <<
" has patch measure: " << *it << std::endl;
1298 output <<
"and normal components " ;
1299 for ( Int iComponent = 0; iComponent < M_geoDimension; iComponent++ )
1301 M_patchNormalVector[iFESpace][ iComponent * M_numBoundaryDofVector[iFESpace] + counter ] <<
" ";
1303 output << std::endl;
1308 output <<
"End SHOW NORMAL" << std::endl;
1316 template<
typename MeshType>
1317 void PostProcessingBoundary<MeshType>::computePatchesPhi()
1319 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1331 for (
ID iboundaryFacet = 0 ; iboundaryFacet < M_numBoundaryFacets; ++iboundaryFacet )
1334 M_currentBdFEPtrVector[iFESpace]->update ( M_meshPtr->boundaryFacet ( iboundaryFacet ), UPDATE_W_ROOT_DET_METRIC );
1336 for ( ID iDof = 0; iDof < M_numTotalDofPerFacetVector[iFESpace]; ++iDof )
1340 dofVectorIndex = M_vectorNumberingPerFacetVector[iFESpace][ iboundaryFacet ][ iDof ];
1343 for ( UInt iQuadraturePoint = 0; iQuadraturePoint < M_currentBdFEPtrVector[iFESpace]->nbQuadPt();
1344 ++iQuadraturePoint )
1346 sum += M_currentBdFEPtrVector[iFESpace]->phi ( ( Int ) ( iDof), iQuadraturePoint )
1347 * M_currentBdFEPtrVector[iFESpace]->wRootDetMetric ( iQuadraturePoint );
1349 M_patchIntegratedPhiVector[iFESpace][ dofVectorIndex ] += sum;
1356 template <
typename MeshType>
1357 void PostProcessingBoundary<MeshType>::showPatchesPhi ( std::ostream& output )
const 1359 for (
UInt iFESpace = 0; iFESpace < M_numFESpaces; ++iFESpace )
1362 output <<
"\n***** Post Proc: Average phi on the patches *****" 1363 <<
"\n\tfor variable " << iFESpace << std::endl;
1367 for ( Vector::const_iterator it = M_patchMeasureVector[iFESpace].begin();
1368 it != M_patchMeasureVector[iFESpace].end(); it++ )
1370 output <<
"Boundary DOF: " << counter
1371 <<
", corresponding to Global DOF: " << M_dofGlobalIdVector[iFESpace][ counter ]
1372 <<
" has patch measure: " << *it << std::endl;
1373 output <<
"and average phi " << M_patchIntegratedPhiVector[iFESpace][ counter ] << std::endl ;
1377 output <<
"End SHOW PHI" << std::endl;
A class for a finite element on a manifold.
int32_type Int
Generic integer data.
ID markerID_Type
markerID_Type is the type used to store the geometric entity marker IDs
void updateInverseJacobian(const UInt &iQuadPt)
Epetra_Import const & importer()
Getter for the Epetra_Import.
double Real
Generic real data.
const UInt nDimensions(NDIM)
uint32_type UInt
generic unsigned integer (used mainly for addressing)