38 #ifndef MultiscaleModelFSI3D_H 39 #define MultiscaleModelFSI3D_H 1
54 #define FSI_WITH_BOUNDARYAREA 57 #define FSI_WITH_STRESSOUTPUT 59 #include <lifev/core/filter/ExporterEnsight.hpp> 61 #include <lifev/core/filter/ExporterHDF5.hpp> 64 #include <lifev/core/algorithm/NonLinearRichardson.hpp> 66 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionParserFSI3D.hpp> 67 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionParserSolverFSI3D.hpp> 68 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionSolverDefinedFSI3D.hpp> 69 #include <lifev/bc_interface/3D/function/fsi/BCInterfaceFunctionUserDefinedFSI3D.hpp> 70 #include <lifev/bc_interface/3D/bc/BCInterface3D.hpp> 72 #include <lifev/fsi/solver/FSIMonolithic.hpp> 73 #include <lifev/fsi/solver/FSIMonolithicGE.hpp> 74 #include <lifev/fsi/solver/FSIMonolithicGI.hpp> 76 #include <lifev/fsi/solver/MonolithicBlockMatrix.hpp> 77 #include <lifev/fsi/solver/MonolithicBlockMatrixRN.hpp> 78 #include <lifev/fsi/solver/MonolithicBlockComposedDN.hpp> 79 #include <lifev/fsi/solver/MonolithicBlockComposedNN.hpp> 80 #include <lifev/fsi/solver/MonolithicBlockComposedDNND.hpp> 83 #include <lifev/structure/solver/WallTensionEstimator.hpp> 84 #include <lifev/structure/solver/WallTensionEstimatorData.hpp> 87 #include <lifev/multiscale/models/MultiscaleModel.hpp> 88 #include <lifev/multiscale/framework/MultiscaleInterface.hpp> 95 #ifndef FSI_WITH_EXTERNALPRESSURE 97 class FSI3DBoundaryStressFunction;
100 #ifndef FSI_WITHOUT_VELOCITYPROFILE 102 class FSI3DBoundaryFlowRateFunction;
107 class FSI3DBoundaryAreaFunction;
119 class MultiscaleModelFSI3D:
public virtual multiscaleModel_Type,
120 public virtual MultiscaleInterface
127 typedef FSIMonolithic FSIOperator_Type;
128 typedef std::shared_ptr< FSIOperator_Type> FSIOperatorPtr_Type;
130 typedef FSIOperator::data_Type data_Type;
131 typedef FSIOperator::dataPtr_Type dataPtr_Type;
133 typedef FSIOperator::mesh_Type mesh_Type;
135 typedef FSIOperator::fluid_Type fluid_Type;
136 typedef FSIOperator::solid_Type solid_Type;
138 typedef FSIOperator::vector_Type vector_Type;
139 typedef FSIOperator::vectorPtr_Type vectorPtr_Type;
141 typedef Exporter< mesh_Type > IOFile_Type;
142 typedef std::shared_ptr< IOFile_Type > IOFilePtr_Type;
143 typedef ExporterData< mesh_Type > IOData_Type;
145 typedef ExporterEnsight< mesh_Type > ensightIOFile_Type;
147 typedef ExporterHDF5< mesh_Type > hdf5IOFile_Type;
150 typedef BCHandler bc_Type;
151 typedef std::shared_ptr< bc_Type > bcPtr_Type;
152 typedef BCInterface3D< bc_Type, FSIOperator > bcInterface_Type;
153 typedef std::shared_ptr< bcInterface_Type > bcInterfacePtr_Type;
155 #ifndef FSI_WITH_EXTERNALPRESSURE 156 typedef FSI3DBoundaryStressFunction boundaryStressFunction_Type;
157 typedef std::shared_ptr< boundaryStressFunction_Type > boundaryStressFunctionPtr_Type;
158 typedef std::vector< boundaryStressFunctionPtr_Type > boundaryStressFunctionContainer_Type;
161 #ifndef FSI_WITHOUT_VELOCITYPROFILE 165 enum FSI3DBoundaryFlowRate_Type
172 typedef std::vector< FSI3DBoundaryFlowRate_Type > boundaryFlowRateTypeContainer_Type;
174 typedef std::map< multiscaleID_Type, FSI3DBoundaryFlowRate_Type > boundaryFlowRateMap_Type;
176 typedef FSI3DBoundaryFlowRateFunction boundaryFlowRateFunction_Type;
177 typedef std::shared_ptr< boundaryFlowRateFunction_Type > boundaryFlowRateFunctionPtr_Type;
178 typedef std::vector< boundaryFlowRateFunctionPtr_Type > boundaryFlowRateFunctionsContainer_Type;
179 typedef boundaryFlowRateFunctionsContainer_Type::iterator boundaryFlowRateFunctionsContainerIterator_Type;
183 typedef FSI3DBoundaryAreaFunction boundaryAreaFunction_Type;
184 typedef std::shared_ptr< boundaryAreaFunction_Type > boundaryAreaFunctionPtr_Type;
185 typedef std::vector< boundaryAreaFunctionPtr_Type > boundaryAreaFunctionsContainer_Type;
186 typedef boundaryAreaFunctionsContainer_Type::iterator boundaryAreaFunctionsContainerIterator_Type;
190 typedef WallTensionEstimator< mesh_Type > wallTensionEstimator_Type;
191 typedef std::shared_ptr< wallTensionEstimator_Type > wallTensionEstimatorPtr_Type;
201 explicit MultiscaleModelFSI3D();
204 virtual ~MultiscaleModelFSI3D() {}
216 void setupData (
const std::string& fileName );
231 void updateSolution();
244 Real checkSolution()
const;
257 void imposeBoundaryFlowRate (
const multiscaleID_Type& boundaryID,
const function_Type& function );
264 void imposeBoundaryMeanNormalStress (
const multiscaleID_Type& boundaryID,
const function_Type& function );
273 void imposeBoundaryMeanTotalNormalStress (
const multiscaleID_Type& ,
const function_Type& )
275 multiscaleErrorCheck ( ModelInterface,
"Invalid interface [MeanTotalNormalStress] for model type [" + enum2String ( M_type, multiscaleModelsMap ) +
"]", M_comm->MyPID() == 0 );
285 void imposeBoundaryArea (
const multiscaleID_Type& boundaryID,
const function_Type& function );
292 Real boundaryFlowRate (
const multiscaleID_Type& boundaryID )
const 294 return M_FSIoperator->fluid().flux ( boundaryFlag ( boundaryID ), *M_stateVariable );
302 Real boundaryMeanNormalStress (
const multiscaleID_Type& boundaryID )
const;
309 Real boundaryMeanTotalNormalStress (
const multiscaleID_Type& boundaryID )
const;
316 Real boundaryArea (
const multiscaleID_Type& boundaryID )
const 318 return M_FSIoperator->fluid().area ( boundaryFlag ( boundaryID ) );
327 Real boundaryDeltaFlowRate (
const multiscaleID_Type& boundaryID,
bool& solveLinearSystem );
335 Real boundaryDeltaMeanNormalStress (
const multiscaleID_Type& boundaryID,
bool& solveLinearSystem );
344 Real boundaryDeltaMeanTotalNormalStress (
const multiscaleID_Type& boundaryID,
bool& solveLinearSystem );
354 Real boundaryDeltaArea (
const multiscaleID_Type& ,
bool& )
369 bc_Type& bcHandlerFluid()
371 return *M_fluidBC->handler();
378 bc_Type& bcHandlerSolid()
380 return *M_solidBC->handler();
387 bcInterface_Type& bcInterface()
396 Real boundaryDensity()
const 398 return M_FSIoperator->dataFluid()->density();
405 Real boundaryViscosity()
const 407 return M_FSIoperator->dataFluid()->viscosity();
415 Real boundaryPressure (
const multiscaleID_Type& boundaryID )
const;
422 Real boundaryTotalPressure (
const multiscaleID_Type& boundaryID )
const;
428 Real externalPressure()
const;
434 const dataPtr_Type& data()
const 443 const FSIOperatorPtr_Type& solver()
const 445 return M_FSIoperator;
455 MultiscaleModelFSI3D (
const MultiscaleModelFSI3D& model );
457 MultiscaleModelFSI3D& operator= (
const MultiscaleModelFSI3D& model );
472 void setupGlobalData (
const std::string& fileName );
475 void initializeSolution();
477 void setupCommunicator();
479 void setupBC (
const std::string& fileName );
482 void setupExporter ( IOFilePtr_Type& exporter,
const GetPot& dataFile,
const std::string& label =
"" );
483 void setupImporter ( IOFilePtr_Type& exporter,
const GetPot& dataFile,
const std::string& label =
"" );
485 void setExporterFluid (
const IOFilePtr_Type& exporter );
486 void setExporterSolid (
const IOFilePtr_Type& exporter );
488 void exportFluidSolution();
489 void exportSolidSolution();
492 void setupLinearModel();
495 void updateLinearModel();
498 void solveLinearModel (
bool& solveLinearSystem );
501 void imposePerturbation();
504 void resetPerturbation();
506 Real bcFunctionDeltaZero (
const Real& ,
const Real& ,
const Real& ,
const Real& ,
const UInt& )
510 Real bcFunctionDeltaOne (
const Real& ,
const Real& ,
const Real& ,
const Real& ,
const UInt& )
518 FSIOperatorPtr_Type M_FSIoperator;
524 IOFilePtr_Type M_exporterFluid;
525 IOFilePtr_Type M_exporterSolid;
528 IOFilePtr_Type M_importerFluid;
529 IOFilePtr_Type M_importerSolid;
531 #ifndef FSI_WITH_EXTERNALPRESSURE 533 boundaryStressFunctionContainer_Type M_boundaryStressFunctions;
536 Real M_externalPressureScalar;
539 #ifndef FSI_WITHOUT_VELOCITYPROFILE 541 boundaryFlowRateFunctionsContainer_Type M_boundaryFlowRateFunctions;
544 boundaryFlowRateTypeContainer_Type M_boundaryFlowRateType;
549 boundaryAreaFunctionsContainer_Type M_boundaryAreaFunctions;
552 multiscaleIDContainer_Type M_boundaryFlagsArea;
553 std::vector<
bool > M_boundaryFlagsAreaPerturbed;
557 wallTensionEstimatorPtr_Type M_wallTensionEstimator;
561 vectorPtr_Type M_fluidVelocity;
562 vectorPtr_Type M_fluidPressure;
563 vectorPtr_Type M_fluidDisplacement;
564 vectorPtr_Type M_solidVelocity;
565 vectorPtr_Type M_solidDisplacement;
568 vectorPtr_Type M_solidStressXX;
569 vectorPtr_Type M_solidStressXY;
570 vectorPtr_Type M_solidStressXZ;
571 vectorPtr_Type M_solidStressYY;
572 vectorPtr_Type M_solidStressYZ;
573 vectorPtr_Type M_solidStressZZ;
574 vectorPtr_Type M_solidStressVonMises;
577 vectorPtr_Type M_stateVariable;
579 UInt M_nonLinearRichardsonIteration;
582 bcInterfacePtr_Type M_fluidBC;
583 bcInterfacePtr_Type M_solidBC;
584 bcInterfacePtr_Type M_harmonicExtensionBC;
587 bcPtr_Type M_linearFluidBC;
588 bcPtr_Type M_linearSolidBC;
589 vectorPtr_Type M_linearRHS;
590 vectorPtr_Type M_linearSolution;
595 #ifndef FSI_WITH_EXTERNALPRESSURE 604 class FSI3DBoundaryStressFunction
611 typedef MultiscaleInterface::function_Type function_Type;
620 explicit FSI3DBoundaryStressFunction() : M_function(), M_delta() {}
623 virtual ~FSI3DBoundaryStressFunction() {}
635 Real function (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const UInt& id )
637 return M_function ( t, x, y, z, id ) + M_delta;
650 void setDelta (
const Real& delta )
659 void setFunction (
const function_Type& function )
661 M_function = function;
671 FSI3DBoundaryStressFunction (
const FSI3DBoundaryStressFunction& boundaryFunction );
673 FSI3DBoundaryStressFunction& operator= (
const FSI3DBoundaryStressFunction& boundaryFunction );
677 function_Type M_function;
685 #ifndef FSI_WITHOUT_VELOCITYPROFILE 695 class FSI3DBoundaryFlowRateFunction
702 typedef MultiscaleInterface::function_Type function_Type;
704 typedef MultiscaleModelFSI3D::FSI3DBoundaryFlowRate_Type FSI3DBoundaryFlowRate_Type;
713 explicit FSI3DBoundaryFlowRateFunction() :
717 M_boundaryFlowRateType (),
724 virtual ~FSI3DBoundaryFlowRateFunction()
739 void updateParameters()
742 M_area = M_FSI3D->solver()->fluid().area ( M_fluidFlag );
745 switch ( M_boundaryFlowRateType )
747 case MultiscaleModelFSI3D::Strong:
750 useNormalDirectionFlow ( M_FSI3D->bcHandlerFluid().findBCWithFlag ( M_fluidFlag ) );
754 case MultiscaleModelFSI3D::Semiweak:
758 M_flowRateIsZero = ( std::abs ( M_function ( M_FSI3D->data()->dataFluid()->dataTime()->time(), 0.0, 0.0, 0.0, 0 ) ) < 1e-8 );
761 if ( M_flowRateIsZero )
764 M_FSI3D->bcHandlerFluid().modifyBC ( M_fluidFlag, Essential );
773 M_FSI3D->bcHandlerFluid().modifyBC ( M_fluidFlag, Flux );
778 case MultiscaleModelFSI3D::Weak:
780 std::cerr <<
"!!! ERROR: in case Weak option has been selected, this class should not be instantiated at all !!!" << std::endl;
797 Real function (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const UInt& id )
805 if ( M_boundaryFlowRateType == MultiscaleModelFSI3D::Semiweak && M_flowRateIsZero )
810 Real flowRate = M_function ( t, x, y, z, id );
811 Real meanVelocity = flowRate / M_area;
813 return meanVelocity * M_n[id];
826 void setModel ( MultiscaleModelFSI3D* modelFSI3D )
828 M_FSI3D = modelFSI3D;
835 void setFluidFlag (
const multiscaleID_Type& flag )
844 void setNormal (
const std::array< Real, 3 >& normal )
853 void setFunction (
const function_Type& function )
855 M_function = function;
862 void setBoundaryFlowRateType (
const FSI3DBoundaryFlowRate_Type& boundaryFlowRateType )
864 M_boundaryFlowRateType = boundaryFlowRateType;
877 const multiscaleID_Type& fluidFlag()
const 886 const FSI3DBoundaryFlowRate_Type& boundaryFlowRateType()
const 888 return M_boundaryFlowRateType;
899 FSI3DBoundaryFlowRateFunction (
const FSI3DBoundaryFlowRateFunction& boundaryFunction );
901 FSI3DBoundaryFlowRateFunction& operator= (
const FSI3DBoundaryFlowRateFunction& boundaryFunction );
909 void useNormalDirectionFlow (
const BCBase& boundaryID )
912 PostProcessingBoundary<MultiscaleModelFSI3D::mesh_Type> normalExtraction ( M_FSI3D->solver()->uFESpacePtr()->mesh(),
913 & (M_FSI3D->solver()->uFESpacePtr()->feBd() ),
914 & (M_FSI3D->solver()->uFESpacePtr()->dof() ),
915 M_FSI3D->solver()->uFESpacePtr()->map() );
917 Vector approxNormal = normalExtraction.normal ( boundaryID.flag() );
920 M_n[0] = approxNormal[0];
921 M_n[1] = approxNormal[1];
922 M_n[2] = approxNormal[2];
927 MultiscaleModelFSI3D* M_FSI3D;
928 function_Type M_function;
929 multiscaleID_Type M_fluidFlag;
930 FSI3DBoundaryFlowRate_Type M_boundaryFlowRateType;
931 std::array< Real, 3 > M_n;
933 bool M_flowRateIsZero;
949 class FSI3DBoundaryAreaFunction
956 typedef MultiscaleInterface::function_Type function_Type;
965 explicit FSI3DBoundaryAreaFunction() :
969 M_geometricCenter (),
977 virtual ~FSI3DBoundaryAreaFunction()
992 Real function (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const UInt& id )
994 return displacement ( std::sqrt ( M_function ( t, x, y, z, id ) / M_referenceArea ) - 1, x , y, z, id );
1001 Real functionLinear (
const Real& ,
const Real& x,
const Real& y,
const Real& z,
const UInt& id )
1003 return displacement ( std::sqrt ( 1. / M_referenceArea ) - 1, x , y, z, id );
1010 M_referenceArea = M_FSI3D->solver()->fluid().area ( M_fluidFlag );
1013 Vector normal = M_FSI3D->solver()->fluid().normal ( M_fluidFlag );
1023 Vector geometricCenter = M_FSI3D->solver()->fluid().geometricCenter ( M_fluidFlag );
1025 M_geometricCenter[0] = geometricCenter[0];
1026 M_geometricCenter[1] = geometricCenter[1];
1027 M_geometricCenter[2] = geometricCenter[2];
1036 if ( M_FSI3D->communicator()->MyPID() == 0 )
1038 std::cout <<
"Fluid flag = " << M_fluidFlag << std::endl
1039 <<
"Reference area = " << M_referenceArea << std::endl
1040 <<
"Geometric center = " << M_geometricCenter[0] <<
" " << M_geometricCenter[1] <<
" " << M_geometricCenter[2] << std::endl
1041 <<
"Normal = " << M_n[0] <<
" " << M_n[1] <<
" " << M_n[2] << std::endl
1042 <<
"Tangent 1 = " << M_t1[0] <<
" " << M_t1[1] <<
" " << M_t1[2] << std::endl
1043 <<
"Tangent 2 = " << M_t2[0] <<
" " << M_t2[1] <<
" " << M_t2[2] << std::endl << std::endl;
1057 void setModel (
const MultiscaleModelFSI3D* modelFSI3D )
1059 M_FSI3D = modelFSI3D;
1066 void setFluidFlag (
const multiscaleID_Type& flag )
1075 void setReferenceArea (
const Real& referenceArea )
1077 M_referenceArea = referenceArea;
1084 void setGeometricCenter (
const std::array< Real, 3 >& geometricCenter )
1086 M_geometricCenter = geometricCenter;
1093 void setNormal (
const std::array< Real, 3 >& normal )
1103 void setFunction (
const function_Type& function )
1105 M_function = function;
1117 const multiscaleID_Type& fluidFlag()
const 1129 FSI3DBoundaryAreaFunction (
const FSI3DBoundaryAreaFunction& boundaryFunction );
1131 FSI3DBoundaryAreaFunction& operator= (
const FSI3DBoundaryAreaFunction& boundaryFunction );
1143 Real module = std::sqrt ( M_n[0] * M_n[0] + M_n[1] * M_n[1] + M_n[2] * M_n[2] );
1144 M_n[0] = M_n[0] / module;
1145 M_n[1] = M_n[1] / module;
1146 M_n[2] = M_n[2] / module;
1149 M_t1[0] = M_n[1] * M_n[1] - M_n[0] * M_n[2];
1150 M_t1[1] = M_n[2] * M_n[2] - M_n[0] * M_n[1];
1151 M_t1[2] = M_n[0] * M_n[0] - M_n[1] * M_n[2];
1154 M_t2[0] = M_n[1] * M_t1[2] - M_n[2] * M_t1[1];
1155 M_t2[1] = M_n[2] * M_t1[0] - M_n[0] * M_t1[2];
1156 M_t2[2] = M_n[0] * M_t1[1] - M_n[1] * M_t1[0];
1168 Real displacement (
const Real& scaleFactor,
const Real& x,
const Real& y,
const Real& z,
const UInt& id )
1171 std::array< Real, 3 > rhs;
1173 rhs[1] = scaleFactor * ( ( x - M_geometricCenter[0] ) * M_t1[0] + ( y - M_geometricCenter[1] ) * M_t1[1] + ( z - M_geometricCenter[2] ) * M_t1[2] );
1174 rhs[2] = scaleFactor * ( ( x - M_geometricCenter[0] ) * M_t2[0] + ( y - M_geometricCenter[1] ) * M_t2[1] + ( z - M_geometricCenter[2] ) * M_t2[2] );
1177 Real determinant = M_n[0] * ( M_t1[1] * M_t2[2] - M_t1[2] * M_t2[1] )
1178 + M_n[1] * ( M_t1[2] * M_t2[0] - M_t1[0] * M_t2[2] )
1179 + M_n[2] * ( M_t1[0] * M_t2[1] - M_t1[1] * M_t2[0] );
1183 return - ( rhs[0] * ( M_t1[2] * M_t2[1] - M_t1[1] * M_t2[2] )
1184 + rhs[1] * ( M_n[1] * M_t2[2] - M_n[2] * M_t2[1] )
1185 + rhs[2] * ( M_n[2] * M_t1[1] - M_n[1] * M_t1[2] ) ) / determinant;
1188 return ( rhs[0] * ( M_t1[2] * M_t2[0] - M_t1[0] * M_t2[2] )
1189 + rhs[1] * ( M_n[0] * M_t2[2] - M_n[2] * M_t2[0] )
1190 + rhs[2] * ( M_n[2] * M_t1[0] - M_n[0] * M_t1[2] ) ) / determinant;
1193 return - ( rhs[0] * ( M_t1[1] * M_t2[0] - M_t1[0] * M_t2[1] )
1194 + rhs[1] * ( M_n[0] * M_t2[1] - M_n[1] * M_t2[0] )
1195 + rhs[2] * ( M_n[1] * M_t1[0] - M_n[0] * M_t1[1] ) ) / determinant;
1206 const MultiscaleModelFSI3D* M_FSI3D;
1207 multiscaleID_Type M_fluidFlag;
1208 Real M_referenceArea;
1209 std::array< Real, 3 > M_geometricCenter;
1210 std::array< Real, 3 > M_n;
1211 std::array< Real, 3 > M_t1;
1212 std::array< Real, 3 > M_t2;
1213 function_Type M_function;
1221 inline multiscaleModel_Type* createMultiscaleModelFSI3D()
1223 return new MultiscaleModelFSI3D();
#define FSI_WITH_BOUNDARYAREA
#define FSI_WITH_STRESSOUTPUT