CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Changing velocity with time (https://www.cfd-online.com/Forums/openfoam-programming-development/236209-changing-velocity-time.html)

RichardKelly May 19, 2021 08:43

Changing velocity with time
 
Hi All,



I have a case setup with a moving boat in water. I am trying to create a case to see how the boat will interact with other objects in the water. Right now I can set the velocity of the boat, but am not able to change the velocity at each timestep. I am using the dymanicMeshDict to achieve this. Below is my dict:


Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v2012                                |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "constant";
    object      dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dynamicFvMesh  dynamicMotionSolverFvMesh;

motionSolverLibs (fvMotionSolvers);

motionSolver    solidBody;

cellZone        rotatingZone;

solidBodyMotionFunction  linearMotion;

velocity (.5 0 0);

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



How do I go about changing the velocity in each time step? Will I need to get under the hood to do this? So far I have just been modifying the case dictionary files.

RichardKelly May 19, 2021 10:01

Found this example in tutorials/multiphase/interfoam/ras/floatingobject.



I guess code stream is being used to calculate some values.. wondering if I can do something to calculate the velocity...



Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v2012                                |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dynamicFvMesh      dynamicMotionSolverFvMesh;

motionSolverLibs    (sixDoFRigidBodyMotion);

motionSolver        sixDoFRigidBodyMotion;

sixDoFRigidBodyMotionCoeffs
{
    patches        (floatingObject);
    innerDistance  0.05;
    outerDistance  0.35;

    centreOfMass    (0.5 0.45 0.35);

    // Cuboid dimensions
    Lx              0.3;
    Ly              0.2;
    Lz              0.5;

    // Density of the solid
    rhoSolid        500;

    // Cuboid mass
    mass            #eval{ $rhoSolid*$Lx*$Ly*$Lz };

    // Cuboid moment of inertia about the centre of mass
    momentOfInertia #codeStream
    {
        codeInclude
        #{
            #include "diagTensor.H"
        #};

        code
        #{
            scalar sqrLx = sqr($Lx);
            scalar sqrLy = sqr($Ly);
            scalar sqrLz = sqr($Lz);
            os  <<
                $mass
              *diagTensor(sqrLy + sqrLz, sqrLx + sqrLz, sqrLx + sqrLy)/12.0;
        #};
    };

    report          on;
    accelerationRelaxation 0.7;
    //accelerationDamping 0;

    solver
    {
        type Newmark;
    }

    constraints
    {
        // fixedPoint
        // {
        //    sixDoFRigidBodyMotionConstraint point;
        //    centreOfRotation (0.5 0.45 0.1);
        // }

        fixedLine
        {
            sixDoFRigidBodyMotionConstraint line;
            centreOfRotation (0.5 0.45 0.1);
            direction (0 1 0);
        }

        fixedAxis
        {
            sixDoFRigidBodyMotionConstraint axis;
            axis (0 1 0);
        }
    }
}


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


otaolafr May 19, 2021 11:38

have a look at the tutorial from tobias, can not be better explained and he does a velocity that changes over time if i remember correctly (or a pressure)
https://www.youtube.com/watch?v=cvWaXBnEz1U&t=8s

RichardKelly May 19, 2021 11:41

Thank you for the response! It is very much appreciated. I will watch the vid and post if I have any further questions or solutions.

RichardKelly May 19, 2021 11:54

Quote:

Originally Posted by otaolafr (Post 804186)
have a look at the tutorial from tobias, can not be better explained and he does a velocity that changes over time if i remember correctly (or a pressure)
https://www.youtube.com/watch?v=cvWaXBnEz1U&t=8s


Hey otaolafr, interesting vid, though not exactly what I am looking for... I am looking to change the velocity of the moving mesh, not the velocity of the fluid at a boundary.

otaolafr May 19, 2021 12:37

Quote:

Originally Posted by RichardKelly (Post 804190)
Hey otaolafr, interesting vid, though not exactly what I am looking for... I am looking to change the velocity of the moving mesh, not the velocity of the fluid at a boundary.

sorry I miss read! eventhought it might help you for the programing look at part 13 I think... that is about that

RichardKelly May 19, 2021 12:42

Quote:

Originally Posted by otaolafr (Post 804193)
sorry I miss read! eventhought it might help you for the programing look at part 13 I think... that is about that


Thanks,


Will continue vids you suggested. Also came across this:


https://www.youtube.com/watch?v=3pfCP769C_U


The author also has a paper which I will review to see if they give any information on how they are handling the moving meshes. There is a lot going on in the vid!

Marpole May 20, 2021 12:40

Have you tried tabluated6DoFMotionCoeffs? Something like this link https://www.cfd-online.com/Forums/op...tml#post669711


I haven't tested it myself, but think it can be a solution for you.

RichardKelly May 20, 2021 13:12

Quote:

Originally Posted by Marpole (Post 804286)
Have you tried tabluated6DoFMotionCoeffs? Something like this link https://www.cfd-online.com/Forums/op...tml#post669711


I haven't tested it myself, but think it can be a solution for you.


Thanks Marpole,


I agree this might be better to use tabluated6DoFMotionCoeffs. I am going to play around with that solidBodyMotion solver. I will need to be able to input changes to the vessel at runtime. Still do not know if I can handle this with codestream or if I will have to change the source code. Will play around with that and perhaps upload my case if I can any headway.


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