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

mixedBoundary not writting the correct refGrad values when executed in parallel

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   December 21, 2021, 19:25
Default mixedBoundary not writting the correct refGrad values when executed in parallel
  #1
New Member
 
Join Date: Dec 2021
Posts: 23
Rep Power: 4
MamboJambo is on a distinguished road
Hello to all,


I am new to OF programming, I am using OF2106, and I am trying to build a new mixed boundary condition.


As an example, I have:



Code:
#ifndef trash_H
#define trash_H

#include "mixedFvPatchField.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "PatchFunction1.H"


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

namespace Foam
{

/*---------------------------------------------------------------------------*\
    Class trash Declaration
\*---------------------------------------------------------------------------*/

class trash
:
    public mixedFvPatchField<scalar>
{
    // Private Data


public:

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


    // Constructors

        //- Construct from patch and internal field
        trash
        (
            const fvPatch&,
            const DimensionedField<scalar, volMesh>&
        );

        //- Construct from patch, internal field and dictionary
        trash
        (
            const fvPatch&,
            const DimensionedField<scalar, volMesh>&,
            const dictionary&
        );

        //- Construct by mapping given
        //- trash
        //- onto a new patch
        trash
        (
            const trash&,
            const fvPatch&,
            const DimensionedField<scalar, volMesh>&,
            const fvPatchFieldMapper&
        );

        //- Construct as copy
        trash
        (
            const trash&
        );

        //- Construct and return a clone
        virtual tmp<fvPatchField<scalar>> clone() const
        {
            return tmp<fvPatchField<scalar>>
            (
                new
                trash(*this)
            );
        }

        //- Construct as copy setting internal field reference
        trash
        (
            const trash&,
            const DimensionedField<scalar, volMesh>&
        );

        //- Construct and return a clone setting internal field reference
        virtual tmp<fvPatchField<scalar>> clone
        (
            const DimensionedField<scalar, volMesh>& iF
        ) const
        {
            return tmp<fvPatchField<scalar>>
            (
                new
                trash
                (
                    *this,
                    iF
                )
            );
        }



        // Evaluation

            //- Update the coefficients associated with the patch field
            virtual void updateCoeffs();


        //- Write
        virtual void write(Ostream&) const;
};


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

} // End namespace Foam

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

#endif
and the implementation


Code:
#include "trash.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "gravityMeshObject.H"


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

Foam::trash::trash
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF
)
:
    mixedFvPatchField<scalar>(p, iF)
{
    refValue() = 0.0;
    refGrad() = 0.0;
    valueFraction() = 0.0;
}


Foam::trash::trash
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    mixedFvPatchField<scalar>(p, iF)
{
    refValue() = 0.0;
    refGrad() = 0.0;
    valueFraction() = 0.0;

    if (dict.found("value"))
    {
        fvPatchField<scalar>::operator=
        (
            Field<scalar>("value", dict, p.size())
        );
    }
    else
    {
        fvPatchField<scalar>::operator=(refValue());
    }
}


Foam::trash::trash
(
    const trash& ptf,
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    mixedFvPatchField<scalar>(ptf, p, iF, mapper)
{}


Foam::trash::trash
(
    const trash& tppsf
)
:
    mixedFvPatchField<scalar>(tppsf)
{}


Foam::trash::trash
(
    const trash& tppsf,
    const DimensionedField<scalar, volMesh>& iF
)
:
    mixedFvPatchField<scalar>(tppsf, iF)
{}


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


void Foam::trash::updateCoeffs()
{
    if (updated())
    {
        return;
    }
          
                                         
    this->refGrad() = 2; 
    this->valueFraction() = scalar(0);
    this->refValue() = scalar(0);          


    Info << "New boundary" << endl;

    mixedFvPatchField<scalar>::updateCoeffs();
}


void Foam::trash::write
(
    Ostream& os
) const
{
    mixedFvPatchField<scalar>::write(os);

}


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

namespace Foam
{
    makePatchTypeField
    (
        fvPatchScalarField,
        trash
    );

}
When I run the code in serial the refGrad value of 2 appears in the variable file (T in scalarTransporFoam). However, when I run the code in parallel the refGrad value gets a value of 0. Why is this happening?


Can anyone reproduce this?



Thanks!

Last edited by MamboJambo; December 24, 2021 at 10:28.
MamboJambo is offline   Reply With Quote

 


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
why I cannot get the correct x and y values when using UDF? hotin87 Fluent UDF and Scheme Programming 14 January 24, 2015 14:42
CFD-Post: How to get the correct values ¥yy CFX 1 September 19, 2014 06:09
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Correct way to program a nonlinear cycle to run it in parallel davide_c OpenFOAM Programming & Development 4 March 27, 2012 09:24
Correct values of drag but high values of lift. aamer Main CFD Forum 16 December 16, 2010 04:44


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