CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Dynamic Mesh Refinement - Sizes of two fields differ

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 4, 2013, 11:54
Default Dynamic Mesh Refinement - Sizes of two fields differ
  #1
Member
 
Nicklas Linder
Join Date: Jul 2012
Location: Germany
Posts: 35
Rep Power: 14
nlinder is on a distinguished road
Hi Foamers,

I am using (a modified) interDyMFoam solver. After all the meshMovement stuff, or just before "twoPhaseProperties.correct();" is called, I make some calculations. One of them is
Code:
scalarField Ca = mag(mup)*mag(uwall)/sigma;
where
Code:
scalarField mup = mu.boundaryField()[wallPatchID];
and uwall derives from (normalized form of the following Uwall)
Code:
vectorField Uwall = U.boundaryField()[wallPatchID];
.

This works fine without dynamic mesh refinement. When I do the same calculation with dynamic mesh refinement, the size of the fields differ if the mesh is refined. Or more precisely: The size of uwall relates to the refined mesh, mu remains unchanged.

Mu is created in createFields.H as
Code:
    volScalarField mu
    (
        IOobject
        (
            "mu",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT
        ),
        twoPhaseProperties.mu()
    );
Does anyone know how I can tell mu, that the mesh has been refined and it needs to be updated?

Thanks for any hints!

Greetings
Nicklas
nlinder is offline   Reply With Quote

Old   February 8, 2019, 06:56
Default
  #2
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
Hi

I have similar problem
after mesh refinement one of the field is unchanged
Code:
--> FOAM FATAL ERROR: 
index 10240 out of range 0 ... 10239

    From function void Foam::UList<T>::checkIndex(Foam::label) const [with T = double; Foam::label = int]
    in file /home/przemek/OpenFOAM/OpenFOAM-v1612+/src/OpenFOAM/lnInclude/UListI.H at line 106.

FOAM aborting
I found that the reason is the line
Code:
volVectorField gradAlpha(fvc::grad(smoothAlpha_));
smoothAlpha_ is created in the constructor as follows
Code:
Foam::smoothInterfaceProperties::smoothInterfaceProperties
(
    const volScalarField& alpha1,
    const volVectorField& U,
    const IOdictionary& dict
)
:
    transportPropertiesDict_(dict),
    cAlpha_
    (
        readScalar
        (
            alpha1.mesh().solverDict(alpha1.name()).lookup("cAlpha")
        )
    ),
    smoothItr_
        (
            readScalar
            (
                alpha1.mesh().solutionDict().subDict("PIMPLE").lookup("smoothItr")
            )
        ),
    kSmoothItr_
    (
            readScalar
            (
                    alpha1.mesh().solutionDict().subDict("PIMPLE").lookup("kSmoothItr")
            )
    ),
    sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict),
    deltaN_
    (
        "deltaN",
        1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
    ),

    smoothAlpha_(alpha1),
    alpha1_(alpha1),
    U_(U),

    nHatf_
    (
        IOobject
        (
            "nHatf",
            alpha1_.time().timeName(),
            alpha1_.mesh()
        ),
        alpha1_.mesh(),
        dimensionedScalar("nHatf", dimArea, 0.0)
    ),

    K_
    (
        IOobject
        (
            "smoothInterfaceProperties:K",
            alpha1_.time().timeName(),
            alpha1_.mesh()
        ),
        alpha1_.mesh(),
        dimensionedScalar("K", dimless/dimLength, 0.0)
    )
{
    calculateK();
}
and
Code:
class smoothInterfaceProperties
{
    // Private data

        //- Keep a reference to the transportProperties dictionary
        const dictionary& transportPropertiesDict_;

        //- Compression coefficient
        scalar cAlpha_;

        // iteration numbers over smooth function
        scalar smoothItr_;

        // iteration numbers over smooth function for curvature, 0 represent no smooth
        scalar kSmoothItr_;

        //- Surface tension
        dimensionedScalar sigma_;


        //- Stabilisation for normalisation of the interface normal
        const dimensionedScalar deltaN_;
        volScalarField smoothAlpha_;

        const volScalarField& alpha1_;
        const volVectorField& U_;
        surfaceScalarField nHatf_;
        volScalarField K_;


    // Private Member Functions

        //- Disallow default bitwise copy construct and assignment
        smoothInterfaceProperties(const smoothInterfaceProperties&);
        void operator=(const smoothInterfaceProperties&);

        //- Correction for the boundary condition on the unit normal nHat on
        //  walls to produce the correct contact dynamic angle
        //  calculated from the component of U parallel to the wall
        void correctContactAngle
        (
            surfaceVectorField::Boundary& nHat,
            surfaceVectorField::Boundary& gradAlphaf
        ) const;

        //- Re-calculate the interface curvature
        void calculateK();


public:

    //- Conversion factor for degrees into radians
    static const scalar convertToRad;


    // Constructors

        //- Construct from volume fraction field gamma and IOdictionary
        smoothInterfaceProperties
        (
            const volScalarField& alpha1,
            const volVectorField& U,
            const IOdictionary&
        );


    // Member Functions

        scalar cAlpha() const
        {
            return cAlpha_;
        }

        const dimensionedScalar& deltaN() const
        {
            return deltaN_;
        }

        const surfaceScalarField& nHatf() const
        {
            return nHatf_;
        }

        const volScalarField& K() const
        {
            return K_;
        }

        const volScalarField& smoothAlpha() const
        {
            return smoothAlpha_;
        }

        const dimensionedScalar& sigma() const
        {
            return sigma_;
        }

        tmp<volScalarField> sigmaK() const
        {
            return sigma_*K_;
        }

        tmp<surfaceScalarField> surfaceTensionForce() const;

        //- Indicator of the proximity of the interface
        //  Field values are 1 near and 0 away for the interface.
        tmp<volScalarField> nearInterface() const;

        void correct()
        {
            calculateK();
        }

        //- Read transportProperties dictionary
        bool read();
};
When I change the problematic line into
Code:
volVectorField gradAlpha(fvc::grad(alpha1_));
everything goes well. But I need the version
Code:
volVectorField gradAlpha(fvc::grad(smoothAlpha_));
Can anybody explain why the line with alpha1_ works and smoothAlpha_ does not?
__________________
best regards
pblasiak

Last edited by gaza; February 8, 2019 at 11:23.
gaza is offline   Reply With Quote

Old   February 8, 2019, 07:54
Default
  #3
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
I checked the size of smoothAlpha_ and it is updated
so what is wrong?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 8, 2019, 08:57
Default
  #4
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
I do not understand the difference between smoothAlpha_ and alpha1_
why with alpha1_ works and with smoothAlpha_ does not?
__________________
best regards
pblasiak

Last edited by gaza; February 8, 2019 at 12:05.
gaza is offline   Reply With Quote

Old   February 9, 2019, 08:08
Default
  #5
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
OK I found solution

I had to change constructor
I do not know why the previous version did not work
Code:
...

     alpha1_(alpha1),

    smoothAlpha_
    (
        IOobject
        (
            "smoothAlpha",
            alpha1_.time().timeName(),
            alpha1_.mesh(),
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        alpha1_.mesh(),
        dimensionedScalar("smoothAlpha", dimless, 0.0)
    ),
...
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Dynamic mesh, interDymFoam : refinement on 2 fields tek_cfd OpenFOAM Pre-Processing 1 May 30, 2013 04:07
How to know mesh size after dynamic refinement tayo OpenFOAM 16 May 22, 2013 14:39
[snappyHexMesh] Adding layers goes wrong with SnappyHexMesh Elise OpenFOAM Meshing & Mesh Conversion 1 April 22, 2013 03:32
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43


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