View Issue Details

IDProjectCategoryView StatusLast Update
0001670OpenFOAMBugpublic2015-04-27 12:02
Reportertniemi Assigned Tohenry  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Summary0001670: Lagrangian LocalInteraction, protection against user stupidity
DescriptionAt the moment the LocalInteraction model checks that interaction type is specified for all wall patches, but it does not check the other types of patches, such as inlets or outlets. If a particle hits an unspecified patch, it will just disappear and nothing is written to the log. This can lead to hard to find errors if user forgets to specify interaction for all patches.

I have attached a modified patchInteractionDataList.C, which checks that interaction is specified for all non coupled patches and throws an error if not. Alternatively, if throwing an error is too restrictive for some use cases, maybe at least a warning could be given if some patches are unspecified?
TagsNo tags attached.

Activities

tniemi

2015-04-23 13:47

reporter  

patchInteractionDataList.C (3,847 bytes)   
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "patchInteractionDataList.H"
#include "stringListOps.H"
#include "wallPolyPatch.H"

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

Foam::patchInteractionDataList::patchInteractionDataList()
:
    List<patchInteractionData>(),
    patchGroupIDs_()
{}


Foam::patchInteractionDataList::patchInteractionDataList
(
    const polyMesh& mesh,
    const dictionary& dict
)
:
    List<patchInteractionData>(dict.lookup("patches")),
    patchGroupIDs_(this->size())
{
    const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
    const wordList allPatchNames = bMesh.names();

    const List<patchInteractionData>& items = *this;
    forAllReverse(items, i)
    {
        const word& patchName = items[i].patchName();
        labelList patchIDs = findStrings(patchName, allPatchNames);

        if (patchIDs.empty())
        {
            WarningIn
            (
                "Foam::patchInteractionDataList::patchInteractionDataList"
                "("
                    "const polyMesh&, "
                    "const dictionary&"
                ")"
            )   << "Cannot find any patch names matching " << patchName
                << endl;
        }

        patchGroupIDs_[i].transfer(patchIDs);
    }

    // check that all patches are specified
    DynamicList<word> badPatches;
    forAll(bMesh, patchI)
    {
        const polyPatch& pp = bMesh[patchI];
        if (!pp.coupled() && applyToPatch(pp.index()) < 0)
        {
            badPatches.append(pp.name());
        }
    }

    if (badPatches.size() > 0)
    {
        FatalErrorIn
        (
            "Foam::patchInteractionDataList::patchInteractionDataList"
            "("
                "const polyMesh&, "
                "const dictionary&"
            ")"
        )    << "All patches must be specified when employing local patch "
            << "interaction. Please specify data for patches:" << nl
            << badPatches << nl << exit(FatalError);
    }
}


Foam::patchInteractionDataList::patchInteractionDataList
(
    const patchInteractionDataList& pidl
)
:
    List<patchInteractionData>(pidl),
    patchGroupIDs_(pidl.patchGroupIDs_)
{}


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

Foam::label Foam::patchInteractionDataList::applyToPatch(const label id) const
{
    forAll(patchGroupIDs_, groupI)
    {
        const labelList& patchIDs = patchGroupIDs_[groupI];
        forAll(patchIDs, patchI)
        {
            if (patchIDs[patchI] == id)
            {
                return groupI;
            }
        }
    }

    return -1;
}


// ************************************************************************* //
patchInteractionDataList.C (3,847 bytes)   

henry

2015-04-27 12:02

manager   ~0004662

I agree the current default behavior can cause confusion. I have applied the change you suggest and if it proves irritating we can change it to a warning rather than an error.

Resolved by commit 105f106f30097286624d11c4bb7cbe884261a5f3

Issue History

Date Modified Username Field Change
2015-04-23 13:47 tniemi New Issue
2015-04-23 13:47 tniemi File Added: patchInteractionDataList.C
2015-04-27 12:02 henry Note Added: 0004662
2015-04-27 12:02 henry Status new => resolved
2015-04-27 12:02 henry Resolution open => fixed
2015-04-27 12:02 henry Assigned To => henry