slfmenergyfoam-4.x/BetaGrid/BetaGrid.C
2018-09-15 20:55:34 +09:00

126 lines
3.7 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 "BetaGrid.H"
#include "error.H"
#include "dictionary.H"
#include "SubList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// const scalar Foam::CMC::BetaGrid::staticData();
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CMC::BetaGrid::BetaGrid(const dictionary& dict)
:
etaCut_(dict.lookup("detailedEta")),
nSpacings_(dict.lookup("detailedN")),
etaSpace_(sum(nSpacings_)+3)
{
// Check for input list size
if (etaCut_.size() != nSpacings_.size() + 1)
{
FatalErrorInFunction
<< "Number of grid interval points does not match number of grid sizes"
<< abort(FatalError);
}
// Check for evenness of number of spacings in each interval
forAll (nSpacings_, i)
{
if ((nSpacings_[i] % 2) == 1)
{
FatalErrorInFunction
<< "Number of spacings in intervals should be even"
<< abort(FatalError);
}
}
forAll(nSpacings_, i)
{
const label ns = nSpacings_[i];
const labelList::subList prev(nSpacings_, i);
const label baseI = sum(prev) + 1;
const scalar low = etaCut_[i];
const scalar upp = etaCut_[i+1];
const scalar delta = (upp - low) / scalar(ns);
for (label j = 0; j < ns; j++)
{
etaSpace_[baseI+j] = low + delta * j;
}
}
etaSpace_[0] = 0.0;
etaSpace_[etaSpace_.size()-2] = etaCut_.last();
etaSpace_[etaSpace_.size()-1] = 1.0;
}
Foam::CMC::BetaGrid::BetaGrid(const BetaGrid&)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::CMC::BetaGrid::~BetaGrid()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::CMC::BetaGrid::operator=(const BetaGrid& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorInFunction
<< "Attempted assignment to self"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
// ************************************************************************* //