2017-08-21 07:26 BST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002643OpenFOAM[All Projects] Bugpublic2017-07-31 21:06
Reporterprojectionist 
Assigned Towill 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformLinuxOSUbuntuOS Version14.04
Product Versiondev 
Target VersionFixed in Version 
Summary0002643: Wrong parameters passed to constructor of KinematicParcel by the constructor of CollidingParcel
DescriptionThe signature of the "Construct from components" constructor in KinematicParcel.H features a misleading parameter name (torque0). This alone does not make it a bug, since the signature only cares about data types. However, "U0" would be the proper name. In the file KinematicParcelI.H, where said constructor is implemented, the correct name "U0" is used.

The malicious parameter name of KinematicParcel's constructor, probably, made its way into the constructors of templates which call KinematicParcel's constructor, e.g. the "Construct from components" constructor of CollidingParcel. The first item in this constructor's initialisation list is a call to the constructor of its template parameter (in this case KinematicParcel). There, "torque0" is passed instead of "U0". This is where the bug comes in.
Since the compiler expects a vector, and both "U0" and "torque0" are vectors, the compiler is not able to detect to error, since syntactically, there is none.
Steps To ReproduceOpenFOAM versions I have checked:

OpenFOAM-dev: commit 254ff361e67c9de773f80a9adc90e1f1c7398432
OpenFOAM-4.0
Additional Information// File: KinematicParcel.H
//- Construct from components
        inline KinematicParcel
        (
            const polyMesh& mesh,
            const barycentric& coordinates,
            const label celli,
            const label tetFacei,
            const label tetPti,
            const label typeId,
            const scalar nParticle0,
            const scalar d0,
            const scalar dTarget0,
            const vector& torque0,
            const constantProperties& constProps
        );

// File: KinematicParcelI.H
template<class ParcelType>
inline Foam::KinematicParcel<ParcelType>::KinematicParcel
(
    const polyMesh& owner,
    const barycentric& coordinates,
    const label celli,
    const label tetFacei,
    const label tetPti,
    const label typeId,
    const scalar nParticle0,
    const scalar d0,
    const scalar dTarget0,
    const vector& U0,
    const constantProperties& constProps
)
:
    ParcelType(owner, coordinates, celli, tetFacei, tetPti),
    active_(true),
    typeId_(typeId),
    nParticle_(nParticle0),
    d_(d0),
    dTarget_(dTarget0),
    U_(U0),
    rho_(constProps.rho0()),
    age_(0.0),
    tTurb_(0.0),
    UTurb_(Zero),
    rhoc_(0.0),
    Uc_(Zero),
    muc_(0.0)
{}


// File: CollidingParcelI.H
template<class ParcelType>
inline Foam::CollidingParcel<ParcelType>::CollidingParcel
(
    const polyMesh& owner,
    const barycentric& coordinates,
    const label celli,
    const label tetFacei,
    const label tetPti,
    const label typeId,
    const scalar nParticle0,
    const scalar d0,
    const scalar dTarget0,
    const vector& U0,
    const vector& f0,
    const vector& angularMomentum0,
    const vector& torque0,
    const typename ParcelType::constantProperties& constProps
)
:
    ParcelType
    (
        owner,
        coordinates,
        celli,
        tetFacei,
        tetPti,
        typeId,
        nParticle0,
        d0,
        dTarget0,
        torque0,
        constProps
    ),
    f_(f0),
    angularMomentum_(angularMomentum0),
    torque_(torque0),
    collisionRecords_()
{}
TagsLagrangian
Attached Files

-Relationships
+Relationships

-Notes

~0008488

will (manager)

Thanks for the report

Fixed in dev by commit 934d48e30147f1033a9fd101e7936093645be6e7

Fixed in 5.x by commit bfda106526f37d41830d69c2877031f87c7a2625
+Notes

-Issue History
Date Modified Username Field Change
2017-07-31 16:34 projectionist New Issue
2017-07-31 16:34 projectionist Tag Attached: Lagrangian
2017-07-31 21:06 will Assigned To => will
2017-07-31 21:06 will Status new => resolved
2017-07-31 21:06 will Resolution open => fixed
2017-07-31 21:06 will Note Added: 0008488
+Issue History