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/)
-   -   dynamicInkJetFvMesh for motion in Y direction (https://www.cfd-online.com/Forums/openfoam-programming-development/146452-dynamicinkjetfvmesh-motion-y-direction.html)

Thangam December 28, 2014 23:20

dynamicInkJetFvMesh for motion in Y direction
 
Hi,

I was just trying to modify the dynamicInkJetFvMesh to have a vertical sinusoidal motion of the mesh. I think it only allows for mesh motion in the x-direction but I want it in Y. I have compiled it successfully but I dont see any mesh movement at all!!
I have attached the code. Dont know where I have gone wrong!

Thanks.

Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    |
    \\  /    A nd          | Copyright (C) 1991-2008 OpenCFD Ltd.
    \\/    M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM 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 2 of the License, or (at your
    option) any later version.

    OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

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

#include "dynamicMyClassFvMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "mathematicalConstants.H"

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

namespace Foam
{
    defineTypeNameAndDebug(dynamicMyClassFvMesh, 0);
    addToRunTimeSelectionTable(dynamicFvMesh, dynamicMyClassFvMesh, IOobject);
}


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

Foam::dynamicMyClassFvMesh::dynamicMyClassFvMesh(const IOobject& io)
:
    dynamicFvMesh(io),
    dynamicMeshCoeffs_
    (
        IOdictionary
        (
            IOobject
            (
                "dynamicMeshDict",
                io.time().constant(),
                *this,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).subDict(typeName + "Coeffs")
    ),
    a_(readScalar(dynamicMeshCoeffs_.lookup("a"))),
    frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
//    refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
    stationaryPoints_
    (
        IOobject
        (
            "points",
            io.time().constant(),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    )
{
    Info<< "Performing a dynamic mesh calculation: " << endl
        << "a: " << a_
        << " frequency: " << frequency_;
//        << " refPlaneX: " << refPlaneX_ << endl;
}

// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

Foam::dynamicMyClassFvMesh::~dynamicMyClassFvMesh()
{}


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

bool Foam::dynamicMyClassFvMesh::update()
{
    scalar scalingFunction =
        0.5*
        (
            ::cos(constant::mathematical::twoPi*frequency_*time().value())
          - 1.0
        );

    Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
        << scalingFunction << endl;

    pointField newPoints = stationaryPoints_;

    newPoints.replace
    (
        vector::Y,
        stationaryPoints_.component(vector::Y)*
        (
            1.0
          + pos
            (
              - (stationaryPoints_.component(vector::Y))
           
            )*a_*scalingFunction
        )
    );

    fvMesh::movePoints(newPoints);

    volVectorField& U =
        const_cast<volVectorField&>(lookupObject<volVectorField>("U"));
    U.correctBoundaryConditions();

    return true;
}


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


Thangam December 30, 2014 01:44

Im just trying to move the bottom surface patch of a cube vertically as a sinusoidal function..im not sure if any other mesh manipulation approach will make it easier..

rahele July 2, 2018 12:19

Hi Thangam,

Did you find any answer to your old question. I'm now dealing with the same problem. I mean finding the best mesh manipulation approach for a cube with moving bottom.

Thanks for your response in advance,
Rahele

Thangam July 8, 2018 21:02

Hi,


I ended up using the dynamicInkJetFvMesh (as this was sufficient in my case) and inorder to move the mesh in the x-direction, I changed my local coordinate system of other parameters. i.e say your top wall of the cube is in '-y' with inlet boundary condition, I changed the inlet to side face and the inlet in '-x'. Then the bottom face would move in 'x'. Hope this helps. I cant really comment on the 'best' mesh manipulation approach as it be will case specific and every moving mesh class has its pros and cons and the resulting solution also depends on several other parameters.


-Thangam.


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