CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   FSI solver (https://www.cfd-online.com/Forums/openfoam/103349-fsi-solver.html)

viraj20feb September 14, 2016 00:25

1 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 617786)
Quick answer: Please run the following commands:
Code:

cd $WM_PROJECT_USER_DIR
cd FluidStructureInteraction/src/
./Allwmake > log.make 2>&1
gzip < log.make > log.make.gz

Then please attach the file "log.make.gz" to your next post. I ask this because the PDF file did not have any clear indication of any problem at all.

Hi Mr. Bruno,

Please find the attached file.

wyldckat September 14, 2016 16:11

1 Attachment(s)
Quick answer: The problem was that there were a few steps that failed, where I had written how to download the updated "constitutiveModel" files.
Please follow these steps instead, which hopefully will fix the problem:
  1. Download the attached file "src_fluidStructureInteraction_stressModels_consti tutiveModel.tar.gz".
  2. In the terminal (command line) where you have foam-extend 3.1 ready to be used, please run:
    Code:

    cd $WM_PROJECT_USER_DIR/FluidStructureInteraction

    pwd

  3. The last command above should have told you about a path. Please place the file that you downloaded from here, into that folder (directory).
  4. Then run the following command:
    Code:

    tar -xzf src_fluidStructureInteraction_stressModels_constitutiveModel.tar.gz
  5. Then let's try building the toolbox again, by running:
    Code:

    cd src
    ./Allwmake > log.make 2>&1
    gzip < log.make > log.make.gz

Once it's over, please attach the new "log.make.gz" file once more, to see if everything went well or not.

viraj20feb September 15, 2016 00:33

1 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 617895)
Quick answer: The problem was that there were a few steps that failed, where I had written how to download the updated "constitutiveModel" files.
Please follow these steps instead, which hopefully will fix the problem:
  1. Download the attached file "src_fluidStructureInteraction_stressModels_consti tutiveModel.tar.gz".
  2. In the terminal (command line) where you have foam-extend 3.1 ready to be used, please run:
    Code:

    cd $WM_PROJECT_USER_DIR/FluidStructureInteraction

    pwd

  3. The last command above should have told you about a path. Please place the file that you downloaded from here, into that folder (directory).
  4. Then run the following command:
    Code:

    tar -xzf src_fluidStructureInteraction_stressModels_constitutiveModel.tar.gz
  5. Then let's try building the toolbox again, by running:
    Code:

    cd src
    ./Allwmake > log.make 2>&1
    gzip < log.make > log.make.gz

Once it's over, please attach the new "log.make.gz" file once more, to see if everything went well or not.


Hi wyldckat,

Please find the attached file. There already existed an src folder at this location: cd $WM_PROJECT_USER_DIR/FluidStructureInteraction

from the previous installation. I did exactly what you said.

viraj20feb September 16, 2016 09:06

1 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 617895)
Quick answer: The problem was that there were a few steps that failed, where I had written how to download the updated "constitutiveModel" files.
Please follow these steps instead, which hopefully will fix the problem:
  1. Download the attached file "src_fluidStructureInteraction_stressModels_consti tutiveModel.tar.gz".
  2. In the terminal (command line) where you have foam-extend 3.1 ready to be used, please run:
    Code:

    cd $WM_PROJECT_USER_DIR/FluidStructureInteraction

    pwd

  3. The last command above should have told you about a path. Please place the file that you downloaded from here, into that folder (directory).
  4. Then run the following command:
    Code:

    tar -xzf src_fluidStructureInteraction_stressModels_constitutiveModel.tar.gz
  5. Then let's try building the toolbox again, by running:
    Code:

    cd src
    ./Allwmake > log.make 2>&1
    gzip < log.make > log.make.gz

Once it's over, please attach the new "log.make.gz" file once more, to see if everything went well or not.


Hi wyldckat,

Please find the attached file. I did exactly what you told me

wyldckat September 17, 2016 07:06

Hi viraj20feb,

Sorry for the late reply, but I didn't manage to find enough free time to look into this sooner.

Something strange is going on with your version of foam-extend 3.1. I need more details, namely:
  1. Which exact installation instructions did you follow for installing foam-extend 3.1?
  2. Where and how exactly did you download foam-extend 3.1?
  3. What do the following commands give you?
    Code:

    foam
    git log -1

Best regards,
Bruno

viraj20feb September 19, 2016 00:43

Quote:

Originally Posted by wyldckat (Post 618204)
Hi viraj20feb,

Sorry for the late reply, but I didn't manage to find enough free time to look into this sooner.

Something strange is going on with your version of foam-extend 3.1. I need more details, namely:
  1. Which exact installation instructions did you follow for installing foam-extend 3.1?
  2. Where and how exactly did you download foam-extend 3.1?
  3. What do the following commands give you?
    Code:

    foam
    git log -1

Best regards,
Bruno


Hi Bruno,

Following are the answers of your question:

1. I am working as Research Assistant in a project and foam-extend 3.1 was already installed in the system alloted to me. So I don't know about the installation instructions, sorry! :(
2. Same as 1.
3.
Code:

foam
If I do not source foam -extend 3.1, this command gives me the output :
Code:

foam: command not found
After sourcing, the output is:
Code:

/foam/foam-extend-3.1$
In both the cases, the command
Code:

git log -1
gives the output:
Code:

fatal: Not a git repository (or any of the parent directories): .git
Thanks.

wyldckat September 26, 2016 18:09

Quick answer: My apologies for taking so long to give an answer. Since there aren't enough details about the specific snapshot of foam-extend 3.1, it becomes considerably harder to diagnose which version it is.
Running the following commands might help to diagnose, but it's not 100% guaranteed it will work:
Code:

foam
cat .build

For example, for me, it gives me this:
Code:

3.1-1dd681f6e943

Hgholami March 12, 2019 10:05

Dear Samkhaniani
Did you simulate a non-Newtonian flow with flexible pipe?
I want to simulate non-newtonian fluid with fsiFoam. I was modified icoFsiElasticNonLinULSolidFoam in createField and fluidSolver and was seen correct. But In this Solver I can't do that. Can you favor me? Thanks

nimasam March 13, 2019 11:16

could you please tell me what problems are you dealing with?



Best regards

Hgholami March 14, 2019 08:32

Dear Samkhaniani
I uses fsiFoam as the solver for FSI problem. As you know, this solver has fluidSolver such as icoFluid, PisoFluid and ConsistIcoFluid for solving Newtonian fluid. I want to solve non-Newtonian fluid with fsiFoam.
I modified simply some code of icoFsiElasticNonLinULSolidFoam in createField and fluidSolver to solve now-Newtonian fluid. Only I changed reading nu in solvers. I do that change in this solver but have error. the icoNonFluid.C is
Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | foam-extend: Open Source CFD
  \\    /  O peration    | Version:    4.0
    \\  /    A nd          | Web:        http://www.foam-extend.org
    \\/    M anipulation  | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
    This file is part of foam-extend.

    foam-extend is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    foam-extend is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "icoNonFluid.H"
#include "singlePhaseTransportModel.H"
#include "volFields.H"
#include "fvm.H"
#include "fvc.H"
#include "fvMatrices.H"
#include "addToRunTimeSelectionTable.H"
#include "findRefCell.H"
#include "adjustPhi.H"
#include "fluidSolidInterface.H"
#include "fixedGradientFvPatchFields.H"

#include "EulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "backwardDdtScheme.H"

#include "elasticSlipWallVelocityFvPatchVectorField.H"
#include "elasticWallVelocityFvPatchVectorField.H"
#include "elasticWallPressureFvPatchScalarField.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace fluidSolvers
{

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(icoNonFluid, 0);
addToRunTimeSelectionTable(fluidSolver, icoNonFluid, dictionary);


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

icoNonFluid::icoNonFluid(const fvMesh& mesh)
:
    fluidSolver(this->typeName, mesh),
    U_
    (
        IOobject
        (
            "U",
            runTime().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),
    p_
    (
        IOobject
        (
            "p",
            runTime().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),

    gradp_(fvc::grad(p_)),
    gradU_(fvc::grad(U_)),

    phi_
    (
        IOobject
        (
            "phi",
            runTime().timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        fvc::interpolate(U_) & mesh.Sf()
    ),
    singlePhaseTransportModel fluid(U, phi); //the new code
    transportProperties_
    (
        IOobject
        (
            "transportProperties",
            runTime().constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
//    nu_(transportProperties_.lookup("nu")),
    rho_( transportProperties.lookup("rho"))

{}

// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

const volVectorField& icoNonFluid::U() const
{
    return U_;
}


const volScalarField& icoNonFluid::p() const
{
    return p_;
}


const volScalarField& icoNonFluid::nu() const
{
    return nu_;
}

//- Patch viscous force (N/m2)
tmp<vectorField> icoNonFluid::patchViscousForce(const label patchID) const
{
    tmp<vectorField> tvF
    (
        new vectorField(mesh().boundary()[patchID].size(), vector::zero)
    );

    tvF() = rho_.value()*nu().value()*U().boundaryField()[patchID].snGrad();

    vectorField n = mesh().boundary()[patchID].nf();
    tvF() -= n*(n&tvF());

    return tvF;
}

//- Patch pressure force (N/m2)
tmp<scalarField> icoNonFluid::patchPressureForce(const label patchID) const
{
    tmp<scalarField> tpF
    (
        new scalarField(mesh().boundary()[patchID].size(), 0)
    );

    tpF() = rho_.value()*p().boundaryField()[patchID];

    return tpF;
}

//- Patch viscous force (N/m2)
tmp<vectorField> icoNonFluid::faceZoneViscousForce
(
    const label zoneID,
    const label patchID
) const
{
    vectorField pVF = patchViscousForce(patchID);

    tmp<vectorField> tvF
    (
        new vectorField(mesh().faceZones()[zoneID].size(), vector::zero)
    );
    vectorField& vF = tvF();

    const label patchStart =
        mesh().boundaryMesh()[patchID].start();

    forAll(pVF, i)
    {
        vF[mesh().faceZones()[zoneID].whichFace(patchStart + i)] =
            pVF[i];
    }

    // Parallel data exchange: collect pressure field on all processors
    reduce(vF, sumOp<vectorField>());


    return tvF;
}

//- Patch pressure force (N/m2)
tmp<scalarField> icoNonFluid::faceZonePressureForce
(
    const label zoneID,
    const label patchID
) const
{
    scalarField pPF = patchPressureForce(patchID);

    tmp<scalarField> tpF
    (
        new scalarField(mesh().faceZones()[zoneID].size(), 0)
    );
    scalarField& pF = tpF();

    const label patchStart =
        mesh().boundaryMesh()[patchID].start();

    forAll(pPF, i)
    {
        pF[mesh().faceZones()[zoneID].whichFace(patchStart + i)] =
            pPF[i];
    }

    // Parallel data exchange: collect pressure field on all processors
    reduce(pF, sumOp<scalarField>());

    return tpF;
}

tmp<scalarField> icoNonFluid::faceZoneMuEff
(
    const label zoneID,
    const label patchID
) const
{
    tmp<scalarField> tMuEff
    (
        new scalarField
        (
            mesh().faceZones()[zoneID].size(),
            rho_.value()*nu_.value()
        )
    );

    return tMuEff;
}

void icoNonFluid::evolve()
{
    Info << "Evolving fluid solver: " << this->type() << endl;

    const fvMesh& mesh = fluidSolver::mesh();

    int nCorr(readInt(fluidProperties().lookup("nCorrectors")));

    int nNonOrthCorr =
        readInt(fluidProperties().lookup("nNonOrthogonalCorrectors"));

    int nOuterCorr =
        readInt(fluidProperties().lookup("nOuterCorrectors"));

    // Prepare for the pressure solution
    label pRefCell = 0;
    scalar pRefValue = 0.0;
    setRefCell(p_, fluidProperties(), pRefCell, pRefValue);

    for (int oCorr = 0; oCorr < nOuterCorr; oCorr++)
    {
        if(mesh.moving())
        {
            // Make the fluxes relative
            phi_ -= fvc::meshPhi(U_);
        }

        // CourantNo
        {
          scalar CoNum = 0.0;
          scalar meanCoNum = 0.0;
          scalar velMag = 0.0;

          if (mesh.nInternalFaces())
          {
              surfaceScalarField SfUfbyDelta =
                  mesh.surfaceInterpolation::deltaCoeffs()*mag(phi_);

              CoNum = max(SfUfbyDelta/mesh.magSf())
                .value()*runTime().deltaT().value();

              meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
                .value()*runTime().deltaT().value();

              velMag = max(mag(phi_)/mesh.magSf()).value();
          }

          Info<< "Courant Number mean: " << meanCoNum
              << " max: " << CoNum
              << " velocity magnitude: " << velMag << endl;
        }

        fvVectorMatrix UEqn
        (
            fvm::ddt(U_)
          + fvm::div(phi_, U_)
          - fvm::laplacian(nu_, U_)
        );

        solve(UEqn == -gradp_);   

        // --- PISO loop

        volScalarField rAU = 1.0/UEqn.A();
        surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));

        for (int corr=0; corr<nCorr; corr++)
        {
            U_ = rAU*UEqn.H();
            phi_ = (fvc::interpolate(U_) & mesh.Sf());
//            + fvc::ddtPhiCorr(rUA, U_, phi_);

#          include "updateRobinFsiInterface.H"

            adjustPhi(phi_, U_, p_);

            for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
            {
                fvScalarMatrix pEqn
                (
                    fvm::laplacian
                    (
                        rAUf, p_, "laplacian((1|A(U)),p)"
                    )
                == fvc::div(phi_)
                  // fvm::laplacian(rAUf, p_) == fvc::div(phi_)
                );

                pEqn.setReference(pRefCell, pRefValue);
                pEqn.solve();

                gradp_ = fvc::grad(p_);

                if (nonOrth == nNonOrthCorr)
                {
                    phi_ -= pEqn.flux();
                }
            }

            // Continuity error
            {
                volScalarField contErr = fvc::div(phi_);

                scalar sumLocalContErr = runTime().deltaT().value()*
                    mag(contErr)().weightedAverage(mesh.V()).value();

                scalar globalContErr = runTime().deltaT().value()*
                    contErr.weightedAverage(mesh.V()).value();

                Info<< "time step continuity errors : sum local = "
                    << sumLocalContErr << ", global = "
                    << globalContErr << endl;
            }

            U_ -= rAU*gradp_;
            U_.correctBoundaryConditions();

            gradU_ = fvc::grad(U_);
        }
    }
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace fluidSolvers
} // End namespace Foam

// ************************************************************************* //

and the icoNonFluid.H is
Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | foam-extend: Open Source CFD
  \\    /  O peration    | Version:    4.0
    \\  /    A nd          | Web:        http://www.foam-extend.org
    \\/    M anipulation  | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
    This file is part of foam-extend.

    foam-extend is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    foam-extend is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.

Class
    icoNonFluid

Description
    icoFoam fluid solver

Author
    Hrvoje Jasak, Wikki Ltd.  All rights reserved. modified

SourceFiles
    icoNonFluid.C

\*---------------------------------------------------------------------------*/

#ifndef icoNonFluid_H
#define icoNonFluid_H

#include "fluidSolver.H"
#include "volFields.H"
#include "surfaceFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace fluidSolvers
{

/*---------------------------------------------------------------------------*\
                        Class icoNonFluid Declaration
\*---------------------------------------------------------------------------*/

class icoNonFluid
:
    public fluidSolver
{
    // Private data

        //- Velocity field
        volVectorField U_;

        //- Pressure field
        volScalarField p_;


      //- viscousity field
        volScalarField nu_;

        //- Pressure gradient
        volVectorField gradp_;

        //- Velocity gradient
        volTensorField gradU_;

        //- Flux field
        surfaceScalarField phi_;

        // Transport properties dictionary
        IOdictionary transportProperties_;

        //- Density
        dimensionedScalar rho_;


//        //-
//        scalarField nGradUn_;

    // Private Member Functions

        //- Disallow default bitwise copy construct
        icoNonFluid(const icoNonFluid&);

        //- Disallow default bitwise assignment
        void operator=(const icoNonFluid&);


public:

    //- Runtime type information
    TypeName("icoNonFluid");

    // Constructors

        //- Construct from components
        icoNonFluid(const fvMesh& mesh);

//        //- Construct from components
//        icoNonFluid
//        (
//            const word& type,
//            const fvMesh& mesh
//        );

    // Destructor

        virtual ~icoNonFluid()
        {}


    // Member Functions

        // Access

            //- Return velocity field
            virtual const volVectorField& U() const;

            //- Return velocity field
            volVectorField& U()
            {
                return U_;
            }

            //- Return pressure field
            virtual const volScalarField& p() const;

            //- Return pressure field
            volScalarField& p()
            {
                return p_;
            }

            // return viscousity field
            virtual const volScalarField& nu() const;
            //- Return viscousity field
            volScalarField& nu()
            {
                return nu_;
            }
            //- Return pressure gradient
            volVectorField& gradp()
            {
                return gradp_;
            }

            //- Return pressure gradient
            volTensorField& gradU()
            {
                return gradU_;
            }
            //- Return flux field
            surfaceScalarField& phi()
            {
                return phi_;
            }

            //- Density
            const dimensionedScalar& rho()
            {
                return rho_;
            }

            //- Patch viscous force (N/m2)
            virtual tmp<vectorField> patchViscousForce
            (
                const label patchID
            ) const;

            //- Patch pressure force (N/m2)
            virtual tmp<scalarField> patchPressureForce
            (
                const label patchID
            ) const;

            //- Patch viscous force (N/m2)
            virtual tmp<vectorField> faceZoneViscousForce
            (
                const label zoneID,
                const label patchID
            ) const;

            //- Patch pressure force (N/m2)
            virtual tmp<scalarField> faceZonePressureForce
            (
                const label zoneID,
                const label patchID
            ) const;

            //- Face zone effective dynamic viscosity
            virtual tmp<scalarField> faceZoneMuEff
            (
                const label zoneID,
                const label patchID
            ) const;

        // Edit

            //- Evolve the fluid solver
            virtual void evolve();
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace fluidSolvers
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //


Hgholami March 14, 2019 08:36

first error is from "singlePhaseTransportModel fluid(U, phi);" type is not direct base of "icoNonFluid"

nimasam March 14, 2019 13:00

no need to write new solver, use pisoFlow as your fluid solver, then you can use non-Newtonian fluid

Hgholami March 16, 2019 23:31

Dear Samkhaniani
Thanks for your comment. I used the pisoFluid, and worked with non-Newtonian fluid. But the problem have diverging. I will try to change fvscheme for the converging. thanks again

Hgholami March 20, 2019 23:31

Dear Samkhaniani
I changed fvscheme to converge the solution, but still I unsuccessful.
I also modify the icoFluid to add add nu() as non-Newtonian fluid in that.
the problem is in here "part of icoFluid"
Quote:

tmp<scalarField> icoNonFluid::faceZoneMuEff
(
const label zoneID,
const label patchID
) const
{

tmp<scalarField> tMuEff
(
new scalarField
(
mesh().faceZones()[zoneID].size(),
rho_.value()*nu_.value() //Here
)
);

return tMuEff;
}
void icoNonFluid::evolve()
I want to change "nu_.value" with
Quote:

fluid_.nu().boundaryField()[patchID]
I add non-Newtonian fluid as fluid_(U_, phi_), then to call that I used fluid_nu.
the compiler give this error.
Quote:

fluidSolvers/icoNonFluid/icoNonFluid.C: In member function ‘virtual Foam::tmp<Foam::Field<double> > Foam::fluidSolvers::icoNonFluid::faceZoneMuEff(Foa m::label, Foam::label) const’:
fluidSolvers/icoNonFluid/icoNonFluid.C:285:9: error: no matching function for call to ‘Foam::Field<double>::Field(Foam::label, Foam::tmp<Foam::Field<double> >)’
)
^
Do you know what is the problem?
Thanks

nimasam March 26, 2019 09:16

it seems that you used the wrong constructor to make your object!
maybe you need to do something like this (im not sure :D )

Code:

tmp<scalarField> icoNonFluid::faceZoneMuEff
(
    const label zoneID,
    const label patchID
) const
{
 
    tmp<scalarField> tMuEff
      (
        new scalarField
        (
            mesh().faceZones()[zoneID].size(),
            rho_.value()  //Here
        )
    );

tMuff=tMuff*fluid_.nu().boundaryField()[patchID];
    return tMuEff;
}
void icoNonFluid::evolve()



All times are GMT -4. The time now is 17:17.