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

Error compiling solver controlling custom BC

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 16, 2014, 10:18
Default Error compiling solver controlling custom BC
  #1
New Member
 
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14
Gaetano is on a distinguished road
Hello foam-devs.

I have a problem in controlling a custom BC from within the solver (OF 2.1.1).

The BC is a modification of partialSlip: I tried to implement a fixedValue in case valueFraction is 1, that is to have a no-slip condition with a moving wall. Below my modifications (in red).

partialFixedSlipFvPatchField.H:
Code:
template<class Type>
class partialFixedSlipFvPatchField
:
    public transformFvPatchField<Type>
{
    // Private data

        //- Fraction (0-1) of value used for boundary condition
        scalarField valueFraction_;
        Field<Type> refValueWall_;


public:

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

[...]

        // Return defining fields

            virtual scalarField& valueFraction()
            {
                return valueFraction_;
            }

            virtual const scalarField& valueFraction() const
            {
                return valueFraction_;
            }


//---------------------------------------------------
            virtual Field<Type>& refValueWall()
            {
                return refValueWall_;
            }

            virtual const Field<Type>& refValueWall() const
            {
                return refValueWall_;
            }
partialFixedSlipFvPatchField.C:
Code:
template<class Type>
Foam::partialFixedSlipFvPatchField<Type>::partialFixedSlipFvPatchField
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const dictionary& dict
)
:
    transformFvPatchField<Type>(p, iF),
    valueFraction_("valueFraction", dict, p.size()),
    refValueWall_("refValueWall", dict, p.size())
{
    evaluate();
}

[...]

template<class Type>
void Foam::partialFixedSlipFvPatchField<Type>::evaluate
(
    const Pstream::commsTypes
)
{
    if (!this->updated())
    {
        this->updateCoeffs();
    }

    tmp<vectorField> nHat = this->patch().nf();

    Field<Type>::operator=
    (
       valueFraction_ * refValueWall_ +
        (1.0 - valueFraction_)
       *transform(I - sqr(nHat), this->patchInternalField())
    );

    transformFvPatchField<Type>::evaluate();
}

[...]

template<class Type>
void Foam::partialFixedSlipFvPatchField<Type>::write(Ostream& os) const
{
    transformFvPatchField<Type>::write(os);
    valueFraction_.writeEntry("valueFraction", os);
    refValueWall_.writeEntry("refValueWall", os);
}
For the sake of clarity, I'm also attaching the output of the commands:
  • diff -y -W 180 partialFixedSlipFvPatchField.H $FOAM_SRC/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.H
  • diff -y -W 180 partialFixedSlipFvPatchField.C $FOAM_SRC/finiteVolume/fields/fvPatchFields/derived/partialSlip/partialSlipFvPatchField.C

My problem is that I'm not able to assign a value to the field refValueWall:

Code:
    label patchID = mesh.boundaryMesh().findPatchID("wall");
    if(patchID == -1)
    {
        Info << "patch not found" << endl;
        return 0;
    }

    partialFixedSlipFvPatchVectorField& Upatch =
            refCast<partialFixedSlipFvPatchVectorField>
            (
                U.boundaryField()[patchID]
            );

    Upatch.valueFraction() = alpha1.boundaryField()[patchID];
    Upatch.refValueWall() = myField.boundaryField()[patchID];
The problem is in the blue line: I'm able to set Upatch.valueFraction() but not Upatch.refValueWall().

When I try to compile I get this error:


Make/linux64GccDPOpt/myInterFoam.o: In function `Foam::partialFixedSlipFvPatchField<Foam::Vector<d ouble> >& Foam::refCast<Foam::partialFixedSlipFvPatchField<F oam::Vector<double> >, Foam::fvPatchField<Foam::Vector<double> > >(Foam::fvPatchField<Foam::Vector<double> >&)':
myInterFoam.C:(.text._ZN4Foam7refCastINS_28partial FixedSlipFvPatchFieldINS_6VectorIdEEEENS_12fvPatch FieldIS3_EEEERT_RT0_[Foam::partialFixedSlipFvPatchField<Foam::Vector<do uble> >& Foam::refCast<Foam::partialFixedSlipFvPatchField<F oam::Vector<double> >, Foam::fvPatchField<Foam::Vector<double> > >(Foam::fvPatchField<Foam::Vector<double> >&)]+0xdd): undefined reference to `Foam::partialFixedSlipFvPatchField<Foam::Vector<d ouble> >::typeName'
collect2: ld returned 1 exit status


I can't figure out the problem. Does anyone have a clue?

Thanks in advance,
Gaetano
Attached Files
File Type: txt diff_y_partialFixedSlipFvPatchField_C.txt (10.8 KB, 1 views)
File Type: txt diff_y_partialFixedSlipFvPatchField_H.txt (13.7 KB, 1 views)

Last edited by Gaetano; January 16, 2014 at 10:19. Reason: typo
Gaetano is offline   Reply With Quote

Old   January 16, 2014, 11:51
Default
  #2
New Member
 
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14
Gaetano is on a distinguished road
Seems I was wrong; the problem seems to be in:

Code:
    label patchID = mesh.boundaryMesh().findPatchID("wall");
    if(patchID == -1)
    {
        Info << "patch not found" << endl;
        return 0;
    }

    partialFixedSlipFvPatchVectorField& Upatch =
            refCast<partialFixedSlipFvPatchVectorField>
            (
                U.boundaryField()[patchID]
            );

    Upatch.valueFraction() = alpha1.boundaryField()[patchID];
    Upatch.refValueWall() = myField.boundaryField()[patchID];
If I use the partialSlip condition it works like a charm, but I'm not able to use my partialFixedSlip BC.

I'm also trying another path: how about reading a surfaceVectorField calcolated in the main solver from within the BC?

Any suggestion?
Gaetano is offline   Reply With Quote

Old   January 22, 2014, 07:48
Default
  #3
New Member
 
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14
Gaetano is on a distinguished road
Ok, I was trying to reinvent the wheel: mixedFixedValueSlip, in $FOAM_SOLVERS/compressible/rhoCentralFoam/BCs/mixedFixedValueSlip.

I will study its implemention and come back in case of questions.

By the way, here's where I got the clue.
Gaetano 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
Strange residuals of the Density Based Solver Pat84 FLUENT 0 October 22, 2012 16:59
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
Custom derivative method in ODE solver. l_r_mcglashan OpenFOAM 1 January 28, 2011 00:12
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 15:08
Error during Solver cfd guy CFX 4 May 8, 2001 07:04


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