/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | www.openfoam.com
     \\/     M anipulation  |
-------------------------------------------------------------------------------
    Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "thermalShellModel.H"
#include "faMesh.H"
#include "fvMesh.H"
#include "fvPatchFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace regionModels
{

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

defineTypeNameAndDebug(thermalShellModel, 0);

defineRunTimeSelectionTable(thermalShellModel, dictionary);

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

bool thermalShellModel::read(const dictionary& dict)
{
    if (regionFaModel::read(dict))
    {
        return true;
    }

    return false;
}


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

thermalShellModel::thermalShellModel
(
    const word& modelType,
    const fvPatch& p,
    const dictionary& dict
)
:
    regionFaModel(p, "thermalShell", modelType, dict, true),
    TName_(dict.get<word>("T")),
    Tp_(p.boundaryMesh().mesh().lookupObject<volScalarField>(TName_)),
    T_
    (
        IOobject
        (
            "Ts_" + regionName_,
            p.boundaryMesh().mesh().time().timeName(),
            p.boundaryMesh().mesh(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        regionMesh()
    ),
    faOptions_(Foam::fa::options::New(p))
{
    if (!faOptions_.optionList::size())
    {
        Info << "No finite area options present" << endl;
    }
}


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

void thermalShellModel::preEvolveRegion()
{}


const Foam::volScalarField& thermalShellModel::Tp() const
{
    return Tp_;
}


const Foam::areaScalarField& thermalShellModel::T() const
{
    return T_;
}


Foam::fa::options& thermalShellModel::faOptions()
{
     return faOptions_;
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace regionModels
} // End namespace Foam

// ************************************************************************* //
