// =================================================== // Inline conversion methods // =================================================== inline Real OneDFSIPhysics::fromPToA( const Real& P, const Real& timeStep, const UInt& iNode, const bool& elasticExternalNodes ) const { if ( !M_dataPtr->viscoelasticWall() || ( ( iNode == 0 || iNode == M_dataPtr->numberOfNodes() - 1 ) && elasticExternalNodes ) ) return ( M_dataPtr->area0( iNode ) * OneDFSI::pow20( ( P - externalPressure() ) / M_dataPtr->beta0( iNode ) + 1, 1 / M_dataPtr->beta1( iNode ) ) ); else { // Newton method to solve the non linear equation Real tolerance(1e-6); Real maxIT(100); UInt i(0); Real A( M_dataPtr->area0( iNode ) ); Real newtonUpdate(0); for ( ; i < maxIT ; ++i ) { if ( std::abs( pressure( A, timeStep, iNode, elasticExternalNodes ) - P ) < tolerance ) break; newtonUpdate = ( pressure( A, timeStep, iNode, elasticExternalNodes ) - P ) / dPdA( A, timeStep, iNode, elasticExternalNodes ); if ( A - newtonUpdate <= 0 ) A /= 2.0; // Bisection else A -= newtonUpdate; // Newton } if ( i == maxIT ) { std::cout << "!!! Warning: conversion fromPToA below tolerance !!! " << std::endl; std::cout << "Tolerance: " << tolerance << "; Residual: " << std::abs( pressure( A, timeStep, iNode, elasticExternalNodes ) - P ) << std::endl; } return A; } }
inline Real OneDFSIPhysics::viscoelasticPressure( const Real& A, const Real& timeStep, const UInt& iNode, const bool& elasticExternalNodes ) const { if ( !M_dataPtr->viscoelasticWall() || ( ( iNode == 0 || iNode == M_dataPtr->numberOfNodes() - 1 ) && elasticExternalNodes ) ) return 0; else return M_dataPtr->viscoelasticCoefficient( iNode ) / ( A * std::sqrt( A ) ) * dAdt( A, timeStep, iNode ); }
inline Real OneDFSIPhysics::dAdP( const Real& P, const Real& timeStep, const UInt& iNode, const bool& elasticExternalNodes ) const { if ( !M_dataPtr->viscoelasticWall() || ( ( iNode == 0 || iNode == M_dataPtr->numberOfNodes() - 1 ) && elasticExternalNodes ) ) { return M_dataPtr->area0( iNode ) / ( M_dataPtr->beta0( iNode ) * M_dataPtr->beta1( iNode ) ) * OneDFSI::pow10( 1 + ( P - externalPressure() ) / M_dataPtr->beta0( iNode ), 1 / M_dataPtr->beta1( iNode ) - 1 ); } else { // Finite difference approach return ( fromPToA( P + M_dataPtr->jacobianPerturbationStress(), timeStep, iNode, elasticExternalNodes ) - fromPToA( P, timeStep, iNode, elasticExternalNodes ) ) / M_dataPtr->jacobianPerturbationStress(); } }