Esempio n. 1
0
    void ESDIRK::getSourceTerm(
        const bool /*corrector*/,
        const int k,
        const int /*sweep*/,
        const scalar deltaT,
        fsi::vector & rhs,
        fsi::vector & qold
        )
    {
        assert( k <= nbStages - 1 );

        qold = this->qold;

        // Compute the time step from the stage deltaT
        if ( dt < 0 )
        {
            // first time step, first prediction step
            dt = deltaT / A( k, k );
        }

        assert( dt > 0 );

        rhs.setZero();

        // Calculate sum of the stage residuals
        for ( int iStage = 0; iStage < k; iStage++ )
            rhs += A( k, iStage ) * F.row( iStage ).transpose();

        rhs.array() *= dt;

        this->stageIndex = k;
    }
void ImplicitMultiLevelFsiSolver::optimize(
    const fsi::vector & y,
    const fsi::vector & x0,
    fsi::vector & xk
    )
{
    assert( init );

    assert( y.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || y.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( x0.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || x0.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( xk.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || xk.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( x0.rows() == xk.rows() );
    assert( y.rows() == xk.rows() );

    fsi->newMeasurementSeries();

    postProcessing->performPostProcessing( y, x0, xk );
}
Esempio n. 3
0
 void DataStorage::storeFunction(
     const fsi::vector & f,
     int substep
     )
 {
     assert( f.rows() == F.cols() );
     assert( substep <= F.rows() );
     assert( not std::isnan( f.norm() ) );
     F.row( substep ) = f;
 }
Esempio n. 4
0
 void DataStorage::storeSolution(
     const fsi::vector & sol,
     int substep
     )
 {
     assert( sol.rows() == solStages.cols() );
     assert( substep <= solStages.rows() );
     assert( not std::isnan( sol.norm() ) );
     solStages.row( substep ) = sol;
 }
void ImplicitMultiLevelFsiSolver::evaluate(
    const fsi::vector & x,
    fsi::vector & output,
    fsi::vector & R
    )
{
    assert( init );

    assert( x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( output.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || output.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( R.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || R.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( x.rows() == output.rows() );
    assert( x.rows() == R.rows() );

    fsi->evaluate( x, output, R );
}
Esempio n. 6
0
    virtual void optimize(
        const fsi::vector & y,
        const fsi::vector & /*x0*/,
        fsi::vector & xk
        )
    {
        assert( y.rows() == 3 );
        assert( xk.rows() == 2 );

        // Analytical optimum
        xk( 0 ) = (y[2] - y[0]) / 2.0;
        xk( 1 ) = (y[0] + y[1] + y[2]) / 3.0;
    }
Esempio n. 7
0
void SDCFsiSolver::setSolution(
    const fsi::vector & solution,
    const fsi::vector & f
    )
{
    Eigen::Map<const fsi::vector> solFluid( solution.data(), dofFluid );
    Eigen::Map<const fsi::vector> solSolid( solution.data() + dofFluid, dofSolid );

    Eigen::Map<const fsi::vector> fFluid( f.data(), dofFluid );
    Eigen::Map<const fsi::vector> fSolid( f.data() + dofFluid, dofSolid );

    fluid->setSolution( solFluid, fFluid );
    solid->setSolution( solSolid, fSolid );
}
Esempio n. 8
0
    virtual void evaluate(
        const fsi::vector & x,
        fsi::vector & output,
        fsi::vector & R
        )
    {
        assert( x.rows() == 2 );
        assert( R.rows() == 3 );

        fsi::vector t( 3 );
        t << -1, 0, 1;

        R = x( 0 ) * t + x( 1 ) * Eigen::MatrixXd::Ones( 3, 1 );
        output = R;
    }
Esempio n. 9
0
    virtual void evaluate(
        const fsi::vector & x,
        fsi::vector & output,
        fsi::vector & R
        )
    {
        assert( x.rows() == 2 );
        assert( R.rows() == 3 );

        fsi::vector t( 3 );
        t << -1, 0, 1;

        R = x( 0 ) * (x( 1 ) * t.array() + 1.0).pow( 2 );
        output = R;
    }
Esempio n. 10
0
    virtual bool isConvergence(
        const fsi::vector & x,
        const fsi::vector & xprev
        )
    {
        assert( x.rows() == xprev.rows() );

        iter++;

        allConverged_ = false;

        if ( (x - xprev).norm() < tol * x.norm() )
            allConverged_ = true;

        return allConverged_;
    }
Esempio n. 11
0
void SDCFsiSolver::implicitSolve(
    bool corrector,
    const int k,
    const int kold,
    const scalar t,
    const scalar dt,
    const fsi::vector & qold,
    const fsi::vector & rhs,
    fsi::vector & f,
    fsi::vector & result
    )
{
    Eigen::Map<const fsi::vector> qoldFluid( qold.data(), dofFluid );
    Eigen::Map<const fsi::vector> qoldSolid( qold.data() + dofFluid, dofSolid );

    Eigen::Map<const fsi::vector> rhsFluid( rhs.data(), dofFluid );
    Eigen::Map<const fsi::vector> rhsSolid( rhs.data() + dofFluid, dofSolid );

    fluid->prepareImplicitSolve( corrector, k, kold, t, dt, qoldFluid, rhsFluid );
    solid->prepareImplicitSolve( corrector, k, kold, t, dt, qoldSolid, rhsSolid );

    // Perform FSI iterations to solve the coupled problem

    postProcessing->fsi->newMeasurementSeries();

    // Initial solution
    fsi::vector x0;

    if ( corrector )
        x0 = xStages.at( k + 1 );
    else
        x0 = xStages.at( k );

    postProcessing->initStage( k );
    postProcessing->performPostProcessing( x0, postProcessing->fsi->x );
    postProcessing->finalizeStage();

    getSolution( result, f );
    evaluateFunction( k, result, t, f );

    xStages.at( k + 1 ) = postProcessing->fsi->x;

    fluid->finalizeImplicitSolve( k );
    solid->finalizeImplicitSolve( k );
}
Esempio n. 12
0
void SDCFsiSolver::evaluateFunction(
    const int k,
    const fsi::vector & q,
    const scalar t,
    fsi::vector & f
    )
{
    fsi::vector fFluid( dofFluid ), fSolid( dofSolid );

    Eigen::Map<const fsi::vector> qFluid( q.data(), dofFluid );
    Eigen::Map<const fsi::vector> qSolid( q.data() + dofFluid, dofSolid );

    fluid->evaluateFunction( k, qFluid, t, fFluid );
    solid->evaluateFunction( k, qSolid, t, fSolid );

    f.head( dofFluid ) = fFluid;
    f.tail( dofSolid ) = fSolid;
}
Esempio n. 13
0
    void ESDIRK::setFunction(
        const int k,
        const fsi::vector & f,
        const fsi::vector & result
        )
    {
        assert( f.rows() == result.rows() );
        assert( k <= nbStages - 1 );

        if ( F.cols() == 0 )
            F.resize( nbStages, f.rows() );

        if ( solStages.cols() == 0 )
            solStages.resize( nbStages, f.rows() );

        F.row( k ) = f;
        solStages.row( k ) = result;
    }
void TubeFlowLinearizedFluidSolver::solve(
    const fsi::vector & a,
    fsi::vector & p
    )
{
    this->a = a.array() - a0;

    std::cout << "Solve fluid domain" << std::endl;

    // Construct right hand size of linear system

    fsi::vector b( 2 * N ), x( 2 * N );
    b.setZero();

    for ( int i = 1; i < N - 1; i++ )
    {
        // Continuity equation rhs

        b( i ) = dx / dt * ( an( i ) - this->a( i ) );
        b( i ) += 0.5 * u0 * ( this->a( i - 1 ) - this->a( i + 1 ) );

        // Momentum equation rhs

        b( i + N ) = u0 * dx / dt * ( an( i ) - this->a( i ) );
        b( i + N ) += 0.5 * u0 * u0 * ( this->a( i - 1 ) - this->a( i + 1 ) );
        b( i + N ) += a0 * dx / dt * un( i );
    }

    // Boundary conditions

    // Velocity inlet condition
    b( 0 ) = u0 / 10.0 * std::pow( std::sin( M_PI * timeIndex * tau ), 2 );

    // Pressure inlet
    b( N ) = 0;

    // Velocity outlet condition
    b( N - 1 ) = 0;

    // Pressure outlet condition
    b( 2 * N - 1 ) = -cmk * rho * un( N - 1 ) + pn( N - 1 );

    // Solve for x

    x = lu.solve( b );

    // Retrieve solution

    u = x.head( N );
    this->p = x.tail( N );

    // Return pressure p
    p = this->p.array() + p0;

    data.col( 0 ) = p;
}
Esempio n. 15
0
 int operator()(
     const fsi::vector & x,
     fsi::vector & fvec
     ) const
 {
     fsi::vector output( x.rows() );
     model->evaluate( x, output, fvec );
     fvec -= *y;
     return 0;
 }
Esempio n. 16
0
    void ESDIRK::setOldSolution(
        int timeIndex,
        const fsi::vector & result
        )
    {
        assert( timeIndex >= this->timeIndex );

        if ( qold.rows() == result.rows() )
            qold = solStages.bottomRows( 1 ).transpose();
        else
        if ( timeIndex > this->timeIndex )
            qold = result;

        this->timeIndex = timeIndex;
    }
Esempio n. 17
0
void SDCFsiSolver::getSolution(
    fsi::vector & solution,
    fsi::vector & f
    )
{
    assert( dofFluid > 0 );
    assert( dofSolid >= 0 );
    assert( dofFluid + dofSolid == solution.rows() );
    assert( solution.rows() == f.rows() );

    fsi::vector solFluid( dofFluid ), solSolid( dofSolid ), fFluid( dofFluid ), fSolid( dofSolid );
    fluid->getSolution( solFluid, fFluid );
    solid->getSolution( solSolid, fSolid );

    solution.head( dofFluid ) = solFluid;
    solution.tail( dofSolid ) = solSolid;
    f.head( dofFluid ) = fFluid;
    f.tail( dofSolid ) = fSolid;
}
bool ImplicitMultiLevelFsiSolver::isConvergence(
    const fsi::vector & x,
    const fsi::vector & xprev
    )
{
    assert( init );

    assert( x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || x.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( xprev.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        || xprev.rows() == fsi->solidSolver->couplingGridSize * fsi->solid->dim
        + fsi->fluidSolver->couplingGridSize * fsi->fluid->dim );

    assert( x.rows() == xprev.rows() );

    return fsi->isConvergence( x, xprev );
}