|
[Sponsors] |
January 16, 2014, 10:18 |
Error compiling solver controlling custom BC
|
#1 |
New Member
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14 |
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_; } 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); }
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]; 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 Last edited by Gaetano; January 16, 2014 at 10:19. Reason: typo |
|
January 16, 2014, 11:51 |
|
#2 |
New Member
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14 |
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]; I'm also trying another path: how about reading a surfaceVectorField calcolated in the main solver from within the BC? Any suggestion? |
|
January 22, 2014, 07:48 |
|
#3 |
New Member
Gaetano
Join Date: Jul 2012
Posts: 18
Rep Power: 14 |
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. |
|
|
|
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 |