mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: DMDModel: move nComponents function to an upper level
This commit is contained in:
committed by
Andrew Heather
parent
44ba2d868d
commit
e3d8b36c63
@ -65,9 +65,31 @@ void Foam::functionObjects::DMD::snapshot()
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::functionObjects::DMD::nComponents(const word& fieldName) const
|
||||
{
|
||||
label nComps = 0;
|
||||
bool processed = false;
|
||||
processed = processed || nComponents<scalar>(fieldName, nComps);
|
||||
processed = processed || nComponents<vector>(fieldName, nComps);
|
||||
processed = processed || nComponents<sphericalTensor>(fieldName, nComps);
|
||||
processed = processed || nComponents<symmTensor>(fieldName, nComps);
|
||||
processed = processed || nComponents<tensor>(fieldName, nComps);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown type of input field during initialisation: "
|
||||
<< fieldName << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return nComps;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::DMD::initialise()
|
||||
{
|
||||
const label nComps = DMDModelPtr_->nComponents(fieldName_);
|
||||
const label nComps = nComponents(fieldName_);
|
||||
|
||||
if (patch_.empty())
|
||||
{
|
||||
|
||||
@ -217,6 +217,16 @@ class DMD
|
||||
bool getSnapshotField();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return number of components of the base type of a given field
|
||||
label nComponents(const word& fieldName) const;
|
||||
|
||||
//- Get the number of components of the base type of a given field
|
||||
template<class Type>
|
||||
bool nComponents(const word& fieldName, label& nComps) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
@ -51,28 +51,4 @@ Foam::DMDModel::DMDModel
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::DMDModel::nComponents(const word& fieldName) const
|
||||
{
|
||||
label nComps = 0;
|
||||
bool processed = false;
|
||||
processed = processed || nComponents<scalar>(fieldName, nComps);
|
||||
processed = processed || nComponents<vector>(fieldName, nComps);
|
||||
processed = processed || nComponents<sphericalTensor>(fieldName, nComps);
|
||||
processed = processed || nComponents<symmTensor>(fieldName, nComps);
|
||||
processed = processed || nComponents<tensor>(fieldName, nComps);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< " # Unknown type of input field during initialisation = "
|
||||
<< fieldName << " #" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return nComps;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -169,16 +169,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return number of components of the base type of a given field
|
||||
label nComponents(const word& fieldName) const;
|
||||
|
||||
//- Get the number of components of the base type of a given field
|
||||
template<class Type>
|
||||
bool nComponents(const word& fieldName, label& nComps) const;
|
||||
|
||||
|
||||
// IO
|
||||
|
||||
//- Read model settings
|
||||
@ -192,12 +182,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DMDModelTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 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 "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::DMDModel::nComponents(const word& fieldName, label& nComps) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (mesh_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
nComps = pTraits<typename VolFieldType::value_type>::nComponents;
|
||||
return true;
|
||||
}
|
||||
else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
nComps = pTraits<typename SurfaceFieldType::value_type>::nComponents;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -109,4 +109,29 @@ bool Foam::functionObjects::DMD::getSnapshotField()
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::DMD::nComponents
|
||||
(
|
||||
const word& fieldName,
|
||||
label& nComps
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (mesh_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
nComps = pTraits<typename VolFieldType::value_type>::nComponents;
|
||||
return true;
|
||||
}
|
||||
else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
nComps = pTraits<typename SurfaceFieldType::value_type>::nComponents;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user