Skip to content
Snippets Groups Projects
surfZoneIdentifier.C 3.92 KiB
Newer Older
  • Learn to ignore specific revisions
  • Mark Olesen's avatar
    Mark Olesen committed
    /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     |
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
        \\  /    A nd           | www.openfoam.com
    
         \\/     M anipulation  |
    -------------------------------------------------------------------------------
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
        Copyright (C) 2011 OpenFOAM Foundation
    
        Copyright (C) 2016-2021 OpenCFD Ltd.
    
    Mark Olesen's avatar
    Mark Olesen committed
    -------------------------------------------------------------------------------
    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.
    
    Mark Olesen's avatar
    Mark Olesen committed
    
        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/>.
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    \*---------------------------------------------------------------------------*/
    
    
    #include "surfZoneIdentifier.H"
    
    Mark Olesen's avatar
    Mark Olesen committed
    #include "dictionary.H"
    
    // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    
    
    Foam::surfZoneIdentifier::surfZoneIdentifier()
    
    Mark Olesen's avatar
    Mark Olesen committed
    :
    
        surfZoneIdentifier(0)
    
    Foam::surfZoneIdentifier::surfZoneIdentifier(const label index)
    
    :
        name_(),
        index_(index),
        geometricType_()
    
    Mark Olesen's avatar
    Mark Olesen committed
    {}
    
    
    
    Foam::surfZoneIdentifier::surfZoneIdentifier
    (
        const word& name,
        const label index
    )
    :
        name_(name),
        index_(index),
        geometricType_()
    {}
    
    
    
    Foam::surfZoneIdentifier::surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    (
        const word& name,
        const label index,
        const word& geometricType
    )
    :
        name_(name),
    
        index_(index),
    
    Mark Olesen's avatar
    Mark Olesen committed
        geometricType_(geometricType)
    {}
    
    
    
    Foam::surfZoneIdentifier::surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    (
        const word& name,
        const dictionary& dict,
        const label index
    )
    :
        name_(name),
    
        index_(index),
        geometricType_()
    
    Mark Olesen's avatar
    Mark Olesen committed
    {
        dict.readIfPresent("geometricType", geometricType_);
    }
    
    
    
    Foam::surfZoneIdentifier::surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    (
    
        const surfZoneIdentifier& ident,
    
    Mark Olesen's avatar
    Mark Olesen committed
        const label index
    )
    :
    
        name_(ident.name_),
    
        index_(index),
    
        geometricType_(ident.geometricType_)
    
    Mark Olesen's avatar
    Mark Olesen committed
    {}
    
    
    Andrew Heather's avatar
    Andrew Heather committed
    
    
    Mark Olesen's avatar
    Mark Olesen committed
    // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
    
    
    void Foam::surfZoneIdentifier::write(Ostream& os) const
    
    Mark Olesen's avatar
    Mark Olesen committed
    {
    
        if (!geometricType_.empty())
    
    Mark Olesen's avatar
    Mark Olesen committed
        {
    
            os.writeEntry("geometricType", geometricType_);
    
    // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
    bool Foam::operator==
    (
        const surfZoneIdentifier& a,
        const surfZoneIdentifier& b
    )
    
        return
        (
            (a.index() == b.index())
         && (a.name()  == b.name())
         && (a.geometricType() == b.geometricType())
        );
    
    bool Foam::operator!=
    (
        const surfZoneIdentifier& a,
        const surfZoneIdentifier& b
    )
    
    // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
    Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
    {
    
        // Also read "" for empty words
        obj.name() = word::validate(token(is).stringToken());
        obj.geometricType() = word::validate(token(is).stringToken());
    
    Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
    
    Mark Olesen's avatar
    Mark Olesen committed
    {
    
        // Force unconditional line-breaks on list output.
        // We otherwise risk extremely unreadable entries
        os << nl;
    
        // Empty words are double-quoted so they are treated as 'string'
    
        // and not simply lost
    
    
        os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE;
        os.writeQuoted(obj.geometricType(), obj.geometricType().empty());
    
    
    Mark Olesen's avatar
    Mark Olesen committed
        return os;
    }
    
    
    Andrew Heather's avatar
    Andrew Heather committed
    
    
    Mark Olesen's avatar
    Mark Olesen committed
    // ************************************************************************* //