genericFields: Library reorganisation and reduce duplication

This commit is contained in:
Will Bainbridge
2023-08-24 16:37:23 +01:00
parent ba416ac909
commit 0433bd3e00
71 changed files with 920 additions and 1601 deletions

View File

@ -3,7 +3,6 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatches \ -lgenericPatches \

View File

@ -3,10 +3,8 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lgenericPatches \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -7,4 +7,4 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-ldynamicMesh \ -ldynamicMesh \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -4,7 +4,6 @@ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \

View File

@ -11,5 +11,5 @@ EXE_LIBS = \
-lsurfMesh \ -lsurfMesh \
-lmeshTools \ -lmeshTools \
-ldynamicMesh \ -ldynamicMesh \
-lgenericPatchFields \ -lgenericFvFields \
-lextrudeModel -lextrudeModel

View File

@ -8,7 +8,7 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfileFormats \ -lfileFormats \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-lmeshTools \ -lmeshTools \
-ldynamicMesh \ -ldynamicMesh \
-lextrudeModel -lextrudeModel

View File

@ -10,7 +10,7 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-ldecompositionMethods \ -ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \ -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \
-lmeshTools \ -lmeshTools \

View File

@ -8,4 +8,4 @@ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -7,4 +7,4 @@ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lgenericPatchFields -lgenericFvFields

View File

@ -2,7 +2,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude -I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-ltriSurface \ -ltriSurface \
-lgenericPatches \ -lgenericPatches \

View File

@ -5,6 +5,6 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-lmeshTools \ -lmeshTools \
-ldynamicMesh -ldynamicMesh

View File

@ -5,6 +5,6 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools -lmeshTools

View File

@ -11,7 +11,7 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-ldynamicMesh \ -ldynamicMesh \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-lrenumberMethods \ -lrenumberMethods \
$(LINK_FLAGS) \ $(LINK_FLAGS) \
-ldecompositionMethods \ -ldecompositionMethods \

View File

@ -2,6 +2,6 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume -lfiniteVolume

View File

@ -5,6 +5,6 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools -lmeshTools

View File

@ -7,4 +7,4 @@ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -5,4 +5,4 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lgenericPatchFields -lgenericFvFields

View File

@ -5,4 +5,4 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -6,5 +6,5 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian -llagrangian

View File

@ -1,9 +1,9 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/genericPatchFields/lnInclude \ -I$(LIB_SRC)/generic/genericFields/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools -lmeshTools

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "patchSummaryTemplates.H" #include "patchSummaryTemplates.H"
#include "genericPatchField.H" #include "genericFieldBase.H"
#include "IOmanip.H" #include "IOmanip.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -32,9 +32,9 @@ License
template<class PatchField> template<class PatchField>
Foam::word Foam::patchFieldType(const PatchField& pf) Foam::word Foam::patchFieldType(const PatchField& pf)
{ {
if (isA<genericPatchField>(pf)) if (isA<genericFieldBase>(pf))
{ {
return refCast<const genericPatchField>(pf).actualTypeName(); return refCast<const genericFieldBase>(pf).actualTypeName();
} }
else else
{ {

View File

@ -11,4 +11,4 @@ EXE_LIBS = \
-lparallel \ -lparallel \
-ldecompositionMethods \ -ldecompositionMethods \
-llagrangian \ -llagrangian \
-lgenericPatchFields -lgenericFvFields

View File

@ -9,4 +9,4 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-lparallel \ -lparallel \
-llagrangian \ -llagrangian \
-lgenericPatchFields -lgenericFvFields

View File

@ -6,7 +6,7 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-ldecompositionMethods \ -ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \ -L$(FOAM_LIBBIN)/dummy -lscotchDecomp -lptscotchDecomp \
-lmeshTools \ -lmeshTools \

View File

@ -3,6 +3,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools -lmeshTools

View File

@ -8,5 +8,5 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lsampling \ -lsampling \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian -llagrangian

View File

@ -8,5 +8,5 @@ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-llagrangian \ -llagrangian \
-lmeshTools \ -lmeshTools \
-lgenericPatchFields \ -lgenericFvFields \
-lconversion -lconversion

View File

@ -8,5 +8,5 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian -llagrangian

View File

@ -5,9 +5,8 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-llagrangian \ -llagrangian \
-ldynamicMesh \ -ldynamicMesh \
-lgenericPatchFields \ -lgenericFvFields \
-L$(FOAM_EXT_LIBBIN) -ltecio -L$(FOAM_EXT_LIBBIN) -ltecio

View File

@ -10,5 +10,5 @@ EXE_LIBS = \
-lfoamToVTK \ -lfoamToVTK \
-ldynamicMesh \ -ldynamicMesh \
-llagrangian \ -llagrangian \
-lgenericPatchFields \ -lgenericFvFields \
-lfileFormats -lfileFormats

View File

@ -8,5 +8,5 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-llagrangian \ -llagrangian \
-lgenericPatchFields \ -lgenericFvFields \
-lfileFormats -lfileFormats

View File

@ -3,6 +3,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools -lmeshTools

View File

@ -3,4 +3,4 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -15,7 +15,7 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian \ -llagrangian \
-L$(FOAM_LIBBIN) \ -L$(FOAM_LIBBIN) \
$(GLIBS) $(GLIBS)

View File

@ -8,6 +8,6 @@ LIB_LIBS = \
-lOpenFOAM \ -lOpenFOAM \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian \ -llagrangian \
$(PROJECT_LIBS) $(PROJECT_LIBS)

View File

@ -10,5 +10,5 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-lfileFormats \ -lfileFormats \
-lsampling \ -lsampling \
-lgenericPatchFields \ -lgenericFvFields \
-llagrangian -llagrangian

View File

@ -9,7 +9,7 @@ EXE_LIBS = \
-lmomentumTransportModels \ -lmomentumTransportModels \
-lincompressibleMomentumTransportModels \ -lincompressibleMomentumTransportModels \
-lphysicalProperties \ -lphysicalProperties \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-lfvModels -lfvModels

View File

@ -3,6 +3,6 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lgenericPatchFields \ -lgenericFvFields \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools -lmeshTools

View File

@ -9,4 +9,4 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-llagrangian \ -llagrangian \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -7,4 +7,4 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-llagrangian \ -llagrangian \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields

View File

@ -4,5 +4,5 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields \ -lgenericFvFields \
-lmeshTools -lmeshTools

View File

@ -29,7 +29,6 @@ wmake $targetType OpenFOAM
wmake $targetType fileFormats wmake $targetType fileFormats
wmake $targetType surfMesh wmake $targetType surfMesh
wmake $targetType triSurface wmake $targetType triSurface
wmake $targetType genericPatches
wmake $targetType meshTools wmake $targetType meshTools
# Decomposition methods needed by dummyThirdParty # Decomposition methods needed by dummyThirdParty
@ -38,7 +37,8 @@ dummyThirdParty/Allwmake $targetType $*
wmake $targetType finiteVolume wmake $targetType finiteVolume
wmake $targetType lagrangian/basic wmake $targetType lagrangian/basic
wmake $targetType genericPatchFields
generic/Allwmake $targetType $*
wmake $targetType mesh/extrudeModel wmake $targetType mesh/extrudeModel
wmake $targetType dynamicMesh wmake $targetType dynamicMesh

12
src/generic/Allwmake Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
wmake $targetType genericPatches
wmake $targetType genericFields
wmake $targetType genericFvPatches
wmake $targetType genericFvFields
#------------------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
genericFieldBase/genericFieldBase.C
genericPointPatchField/genericPointPatchFields.C
LIB = $(FOAM_LIBBIN)/libgenericFields

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/generic/genericPatches/lnInclude
LIB_LIBS = \
-lgenericPatches

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,13 +23,32 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "genericPatchField.H" #include "genericFieldBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(genericPatchField, 0); defineTypeNameAndDebug(genericFieldBase, 0);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::genericFieldBase::genericFieldBase()
{}
Foam::genericFieldBase::genericFieldBase(const word& actualTypeName)
:
actualTypeName_(actualTypeName)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::genericFieldBase::~genericFieldBase()
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,17 +22,19 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::genericPatchField Foam::genericFieldBase
Description Description
Base class for generic field types. Facilitates down-casting so that the
actual type can be queried.
SourceFiles SourceFiles
genericPatchField.C genericFieldBase.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef genericPatchField_H #ifndef genericFieldBase_H
#define genericPatchField_H #define genericFieldBase_H
#include "typeInfo.H" #include "typeInfo.H"
@ -42,15 +44,17 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class genericFvPatch Declaration Class genericFieldBase Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class genericPatchField class genericFieldBase
{ {
// Private Data // Private Data
//- Actual field type name
word actualTypeName_; word actualTypeName_;
public: public:
//- Runtime type information //- Runtime type information
@ -59,24 +63,21 @@ public:
// Constructors // Constructors
genericPatchField() //- Construct null
{} genericFieldBase();
genericPatchField(const word& atn) //- Construct from actual type name
: genericFieldBase(const word& actualTypeName);
actualTypeName_(atn)
{}
//- Destructor //- Destructor
virtual ~genericPatchField() virtual ~genericFieldBase();
{}
// Member Functions // Member Functions
//- Return the actual type name //- Return the actual type name
word actualTypeName() const inline const word& actualTypeName() const
{ {
return actualTypeName_; return actualTypeName_;
} }

View File

@ -0,0 +1,275 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 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 "genericPointPatchField.H"
#include "pointPatchFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict
)
:
genericFieldBase(dict.lookup("type")),
calculatedPointPatchField<Type>(p, iF, dict),
dict_(dict)
{
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type")
{
if
(
iter().isStream()
&& iter().stream().size()
)
{
ITstream& is = iter().stream();
// Read first token
token firstToken(is);
if
(
firstToken.isWord()
&& firstToken.wordToken() == "nonuniform"
)
{
token fieldToken(is);
if (!fieldToken.isCompound())
{
if
(
fieldToken.isLabel()
&& fieldToken.labelToken() == 0
)
{
scalarFields_.insert
(
iter().keyword(),
new scalarField(0)
);
}
else
{
FatalIOErrorInFunction(dict)
<< "\n token following 'nonuniform' "
"is not a compound"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
#define ReadTypeField(Type, nullArg) \
else if \
( \
fieldToken.compoundToken().type() \
== token::Compound<List<Type>>::typeName \
) \
{ \
Field<Type>* fPtr = new Field<Type>; \
fPtr->transfer \
( \
dynamicCast<token::Compound<List<Type>>> \
( \
fieldToken.transferCompoundToken(is) \
) \
); \
\
if (fPtr->size() != this->size()) \
{ \
FatalIOErrorInFunction(dict) \
<< "\n size of field " \
<< iter().keyword() \
<< " (" << fPtr->size() << ')' \
<< " is not the same size as the patch (" \
<< this->size() << ')' \
<< "\n on patch " \
<< this->patch().name() \
<< " of field " \
<< this->internalField().name() \
<< " in file " \
<< this->internalField().objectPath() \
<< exit(FatalIOError); \
} \
\
Type##Fields_.insert(iter().keyword(), fPtr); \
}
FOR_ALL_FIELD_TYPES(ReadTypeField)
#undef ReadTypeField
}
}
}
}
}
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const genericPointPatchField<Type>& ptf,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
genericFieldBase(ptf),
calculatedPointPatchField<Type>(ptf, p, iF, mapper),
dict_(ptf.dict_)
{
#define MapTypeFields(Type, nullArg) \
forAllConstIter(HashPtrTable<Field<Type>>, ptf.Type##Fields_, iter) \
{ \
Type##Fields_.insert \
( \
iter.key(), \
mapper(*iter()).ptr() \
); \
}
FOR_ALL_FIELD_TYPES(MapTypeFields);
#undef MapTypeFields
}
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const genericPointPatchField<Type>& ptf,
const DimensionedField<Type, pointMesh>& iF
)
:
genericFieldBase(ptf),
calculatedPointPatchField<Type>(ptf, iF),
dict_(ptf.dict_),
scalarFields_(ptf.scalarFields_),
vectorFields_(ptf.vectorFields_),
sphericalTensorFields_(ptf.sphericalTensorFields_),
symmTensorFields_(ptf.symmTensorFields_),
tensorFields_(ptf.tensorFields_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::genericPointPatchField<Type>::map
(
const pointPatchField<Type>& ptf,
const pointPatchFieldMapper& mapper
)
{
const genericPointPatchField<Type>& dptf =
refCast<const genericPointPatchField<Type>>(ptf);
#define MapTypeFields(Type, nullArg) \
forAllIter(HashPtrTable<Field<Type>>, Type##Fields_, iter) \
{ \
HashPtrTable<Field<Type>>::const_iterator dptfIter = \
dptf.Type##Fields_.find(iter.key()); \
\
if (dptfIter != dptf.Type##Fields_.end()) \
{ \
mapper(*iter(), *dptfIter()); \
} \
}
FOR_ALL_FIELD_TYPES(MapTypeFields);
#undef MapTypeFields
}
template<class Type>
void Foam::genericPointPatchField<Type>::reset
(
const pointPatchField<Type>& ptf
)
{
const genericPointPatchField<Type>& dptf =
refCast<const genericPointPatchField<Type>>(ptf);
#define ResetTypeFields(Type, nullArg) \
forAllIter(HashPtrTable<Field<Type>>, Type##Fields_, iter) \
{ \
HashPtrTable<Field<Type>>::const_iterator dptfIter = \
dptf.Type##Fields_.find(iter.key()); \
\
if (dptfIter != dptf.Type##Fields_.end()) \
{ \
iter()->reset(*dptfIter()); \
} \
}
FOR_ALL_FIELD_TYPES(ResetTypeFields);
#undef ResetTypeFields
}
template<class Type>
void Foam::genericPointPatchField<Type>::write(Ostream& os) const
{
writeEntry(os, "type", actualTypeName());
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type")
{
if
(
iter().isStream()
&& iter().stream().size()
&& iter().stream()[0].isWord()
&& iter().stream()[0].wordToken() == "nonuniform"
)
{
#define WriteTypeFieldEntry(Type, nullArg) \
else if (Type##Fields_.found(iter().keyword())) \
{ \
writeEntry \
( \
os, \
iter().keyword(), \
*Type##Fields_.find(iter().keyword())() \
); \
}
if (false) {} FOR_ALL_FIELD_TYPES(WriteTypeFieldEntry)
#undef WriteTypeFieldEntry
}
else
{
iter().write(os);
}
}
}
}
// ************************************************************************* //

View File

@ -25,8 +25,13 @@ Class
Foam::genericPointPatchField Foam::genericPointPatchField
Description Description
A generic version of calculatedPointPatchField, useful as a fallback for This boundary condition provides a generic version of the \c calculated
handling unknown patch types. condition, useful as a fallback for handling unknown patch types when
post-processing or running mesh manipulation utilities. Not generally
applicable as a user-specified condition.
See also
Foam::calculatedPointPatchField
SourceFiles SourceFiles
genericPointPatchField.C genericPointPatchField.C
@ -36,7 +41,7 @@ SourceFiles
#ifndef genericPointPatchField_H #ifndef genericPointPatchField_H
#define genericPointPatchField_H #define genericPointPatchField_H
#include "genericPatchField.H" #include "genericFieldBase.H"
#include "calculatedPointPatchField.H" #include "calculatedPointPatchField.H"
#include "HashPtrTable.H" #include "HashPtrTable.H"
@ -52,18 +57,19 @@ namespace Foam
template<class Type> template<class Type>
class genericPointPatchField class genericPointPatchField
: :
public genericPatchField, public genericFieldBase,
public calculatedPointPatchField<Type> public calculatedPointPatchField<Type>
{ {
// Private Data // Private Data
//- Patch field dictionary
dictionary dict_; dictionary dict_;
HashPtrTable<scalarField> scalarFields_; //- Fields
HashPtrTable<vectorField> vectorFields_; #define DeclareTypeFields(Type, nullArg) \
HashPtrTable<sphericalTensorField> sphericalTensorFields_; HashPtrTable<Field<Type>> Type##Fields_;
HashPtrTable<symmTensorField> symmTensorFields_; FOR_ALL_FIELD_TYPES(DeclareTypeFields);
HashPtrTable<tensorField> tensorFields_; #undef DeclareTypeFields
public: public:

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -0,0 +1,3 @@
genericFvPatchField/genericFvPatchFields.C
LIB = $(FOAM_LIBBIN)/libgenericFvFields

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/generic/genericPatches/lnInclude \
-I$(LIB_SRC)/generic/genericFields/lnInclude \
-I$(LIB_SRC)/generic/genericFvPatches/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \
-lgenericPatches \
-lgenericFields \
-lgenericFvPatches \
-lfiniteVolume

View File

@ -0,0 +1,481 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 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 "genericFvPatchField.H"
#include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
bool insertUniformTypeField
(
const scalarList& components,
const word& keyword,
const label size,
HashPtrTable<Field<Type>>& typeFields
)
{
if (components.size() != Type::nComponents)
{
return false;
}
Type t;
forAll(t, i)
{
t[i] = components[i];
}
typeFields.insert(keyword, new Field<Type>(size, t));
return true;
}
template<>
bool insertUniformTypeField
(
const scalarList& components,
const word& keyword,
const label size,
HashPtrTable<Field<scalar>>& typeFields
)
{
return false;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
genericFieldBase(dict.lookup("type")),
calculatedFvPatchField<Type>(p, iF, dict),
dict_(dict)
{
if (!dict.found("value"))
{
FatalIOErrorInFunction(dict)
<< "\n Cannot find 'value' entry"
<< " on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< nl
<< " which is required to set the"
" values of the generic patch field." << nl
<< " (Actual type " << actualTypeName() << ")" << nl
<< "\n Please add the 'value' entry to the write function "
"of the user-defined boundary-condition\n"
<< exit(FatalIOError);
}
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type" && iter().keyword() != "value")
{
if
(
iter().isStream()
&& iter().stream().size()
)
{
ITstream& is = iter().stream();
// Read first token
token firstToken(is);
if
(
firstToken.isWord()
&& firstToken.wordToken() == "nonuniform"
)
{
token fieldToken(is);
if (!fieldToken.isCompound())
{
if
(
fieldToken.isLabel()
&& fieldToken.labelToken() == 0
)
{
scalarFields_.insert
(
iter().keyword(),
new scalarField(0)
);
}
else
{
FatalIOErrorInFunction(dict)
<< "\n token following 'nonuniform' "
"is not a compound"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
#define ReadTypeField(Type, nullArg) \
else if \
( \
fieldToken.compoundToken().type() \
== token::Compound<List<Type>>::typeName \
) \
{ \
Field<Type>* fPtr = new Field<Type>; \
fPtr->transfer \
( \
dynamicCast<token::Compound<List<Type>>> \
( \
fieldToken.transferCompoundToken(is) \
) \
); \
\
if (fPtr->size() != this->size()) \
{ \
FatalIOErrorInFunction(dict) \
<< "\n size of field " \
<< iter().keyword() \
<< " (" << fPtr->size() << ')' \
<< " is not the same size as the patch (" \
<< this->size() << ')' \
<< "\n on patch " \
<< this->patch().name() \
<< " of field " \
<< this->internalField().name() \
<< " in file " \
<< this->internalField().objectPath() \
<< exit(FatalIOError); \
} \
\
Type##Fields_.insert(iter().keyword(), fPtr); \
}
FOR_ALL_FIELD_TYPES(ReadTypeField)
#undef ReadTypeField
else
{
FatalIOErrorInFunction(dict)
<< "\n compound " << fieldToken.compoundToken()
<< " not supported"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
else if
(
firstToken.isWord()
&& firstToken.wordToken() == "uniform"
)
{
token fieldToken(is);
if (!fieldToken.isPunctuation())
{
scalarFields_.insert
(
iter().keyword(),
new scalarField
(
this->size(),
fieldToken.number()
)
);
}
else
{
// Read as a scalarList
is.putBack(fieldToken);
scalarList l(is);
#define InsertUniformTypeField(Type, nullArg) \
|| insertUniformTypeField \
( \
l, \
iter().keyword(), \
this->size(), \
Type##Fields_ \
)
if (!(0 FOR_ALL_FIELD_TYPES(InsertUniformTypeField)))
{
FatalIOErrorInFunction(dict)
<< "\n unrecognised native type " << l
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
#undef InsertUniformTypeField
}
}
}
}
}
}
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const genericFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
genericFieldBase(ptf),
calculatedFvPatchField<Type>(ptf, p, iF, mapper),
dict_(ptf.dict_)
{
#define MapTypeFields(Type, nullArg) \
forAllConstIter(HashPtrTable<Field<Type>>, ptf.Type##Fields_, iter) \
{ \
Type##Fields_.insert \
( \
iter.key(), \
mapper(*iter()).ptr() \
); \
}
FOR_ALL_FIELD_TYPES(MapTypeFields);
#undef MapTypeFields
}
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const genericFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
genericFieldBase(ptf),
calculatedFvPatchField<Type>(ptf, iF),
dict_(ptf.dict_),
scalarFields_(ptf.scalarFields_),
vectorFields_(ptf.vectorFields_),
sphericalTensorFields_(ptf.sphericalTensorFields_),
symmTensorFields_(ptf.symmTensorFields_),
tensorFields_(ptf.tensorFields_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::genericFvPatchField<Type>::map
(
const fvPatchField<Type>& ptf,
const fvPatchFieldMapper& mapper
)
{
calculatedFvPatchField<Type>::map(ptf, mapper);
const genericFvPatchField<Type>& dptf =
refCast<const genericFvPatchField<Type>>(ptf);
#define MapTypeFields(Type, nullArg) \
forAllIter(HashPtrTable<Field<Type>>, Type##Fields_, iter) \
{ \
HashPtrTable<Field<Type>>::const_iterator dptfIter = \
dptf.Type##Fields_.find(iter.key()); \
\
if (dptfIter != dptf.Type##Fields_.end()) \
{ \
mapper(*iter(), *dptfIter()); \
} \
}
FOR_ALL_FIELD_TYPES(MapTypeFields);
#undef MapTypeFields
}
template<class Type>
void Foam::genericFvPatchField<Type>::reset
(
const fvPatchField<Type>& ptf
)
{
calculatedFvPatchField<Type>::reset(ptf);
const genericFvPatchField<Type>& dptf =
refCast<const genericFvPatchField<Type>>(ptf);
#define ResetTypeFields(Type, nullArg) \
forAllIter(HashPtrTable<Field<Type>>, Type##Fields_, iter) \
{ \
HashPtrTable<Field<Type>>::const_iterator dptfIter = \
dptf.Type##Fields_.find(iter.key()); \
\
if (dptfIter != dptf.Type##Fields_.end()) \
{ \
iter()->reset(*dptfIter()); \
} \
}
FOR_ALL_FIELD_TYPES(ResetTypeFields);
#undef ResetTypeFields
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::valueInternalCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::valueBoundaryCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::gradientInternalCoeffs() const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::gradientBoundaryCoeffs() const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
void Foam::genericFvPatchField<Type>::write(Ostream& os) const
{
writeEntry(os, "type", actualTypeName());
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type" && iter().keyword() != "value")
{
if
(
iter().isStream()
&& iter().stream().size()
&& iter().stream()[0].isWord()
&& iter().stream()[0].wordToken() == "nonuniform"
)
{
#define WriteTypeFieldEntry(Type, nullArg) \
else if (Type##Fields_.found(iter().keyword())) \
{ \
writeEntry \
( \
os, \
iter().keyword(), \
*Type##Fields_.find(iter().keyword())() \
); \
}
if (false) {} FOR_ALL_FIELD_TYPES(WriteTypeFieldEntry)
#undef WriteTypeFieldEntry
}
else
{
iter().write(os);
}
}
}
writeEntry(os, "value", *this);
}
// ************************************************************************* //

View File

@ -26,8 +26,9 @@ Class
Description Description
This boundary condition provides a generic version of the \c calculated This boundary condition provides a generic version of the \c calculated
condition, useful as a fallback for handling unknown patch types. Not condition, useful as a fallback for handling unknown patch types when
generally applicable as a user-specified condition. post-processing or running mesh manipulation utilities. Not generally
applicable as a user-specified condition.
See also See also
Foam::calculatedFvPatchField Foam::calculatedFvPatchField
@ -40,7 +41,7 @@ SourceFiles
#ifndef genericFvPatchField_H #ifndef genericFvPatchField_H
#define genericFvPatchField_H #define genericFvPatchField_H
#include "genericPatchField.H" #include "genericFieldBase.H"
#include "calculatedFvPatchField.H" #include "calculatedFvPatchField.H"
#include "HashPtrTable.H" #include "HashPtrTable.H"
@ -56,18 +57,19 @@ namespace Foam
template<class Type> template<class Type>
class genericFvPatchField class genericFvPatchField
: :
public genericPatchField, public genericFieldBase,
public calculatedFvPatchField<Type> public calculatedFvPatchField<Type>
{ {
// Private Data // Private Data
//- Patch field dictionary
dictionary dict_; dictionary dict_;
HashPtrTable<scalarField> scalarFields_; //- Fields
HashPtrTable<vectorField> vectorFields_; #define DeclareTypeFields(Type, nullArg) \
HashPtrTable<sphericalTensorField> sphericalTensorFields_; HashPtrTable<Field<Type>> Type##Fields_;
HashPtrTable<symmTensorField> symmTensorFields_; FOR_ALL_FIELD_TYPES(DeclareTypeFields);
HashPtrTable<tensorField> tensorFields_; #undef DeclareTypeFields
public: public:

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -0,0 +1,3 @@
genericFvPatch/genericFvPatch.C
LIB = $(FOAM_LIBBIN)/libgenericFvPatches

View File

@ -1,5 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/genericPatches/lnInclude \ -I$(LIB_SRC)/generic/genericPatches/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \ LIB_LIBS = \

View File

@ -25,7 +25,8 @@ Class
Foam::genericFvPatch Foam::genericFvPatch
Description Description
FV variant of the genericPolyPatch. Substitute for unknown patches. Used for post-processing when only
basic fvPatch info is needed.
SourceFiles SourceFiles
genericFvPatch.C genericFvPatch.C

View File

@ -25,8 +25,8 @@ Class
Foam::genericPointPatch Foam::genericPointPatch
Description Description
Substitute for unknown patches. Used for postprocessing when only Substitute for unknown patches. Used for post-processing when only
basic polyPatch info is needed. basic pointPatch info is needed.
SourceFiles SourceFiles
genericPointPatch.C genericPointPatch.C

View File

@ -26,7 +26,7 @@ License
#include "genericPolyPatch.H" #include "genericPolyPatch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
@ -37,7 +37,7 @@ namespace Foam
} }
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::genericPolyPatch::genericPolyPatch Foam::genericPolyPatch::genericPolyPatch
( (

View File

@ -25,13 +25,9 @@ Class
Foam::genericPolyPatch Foam::genericPolyPatch
Description Description
Substitute for unknown patches. Used for postprocessing when only Substitute for unknown patches. Used for post-processing when only
basic polyPatch info is needed. basic polyPatch info is needed.
Note:
Storage is not optimal. It stores all face centres and cells on all
processors to keep the addressing calculation simple.
SourceFiles SourceFiles
genericPolyPatch.C genericPolyPatch.C
@ -57,9 +53,13 @@ class genericPolyPatch
{ {
// Private Data // Private Data
//- Actual patch type name
word actualTypeName_; word actualTypeName_;
//- Patch dictionary
dictionary dict_; dictionary dict_;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -1,6 +0,0 @@
genericFvPatch/genericFvPatch.C
genericPatchField/genericPatchField.C
genericFvPatchField/genericFvPatchFields.C
genericPointPatchField/genericPointPatchFields.C
LIB = $(FOAM_LIBBIN)/libgenericPatchFields

View File

@ -1,840 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 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 "genericFvPatchField.H"
#include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
genericPatchField(dict.lookup("type")),
calculatedFvPatchField<Type>(p, iF, dict),
dict_(dict)
{
if (!dict.found("value"))
{
FatalIOErrorInFunction
(
dict
) << "\n Cannot find 'value' entry"
<< " on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< nl
<< " which is required to set the"
" values of the generic patch field." << nl
<< " (Actual type " << actualTypeName() << ")" << nl
<< "\n Please add the 'value' entry to the write function "
"of the user-defined boundary-condition\n"
<< exit(FatalIOError);
}
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type" && iter().keyword() != "value")
{
if
(
iter().isStream()
&& iter().stream().size()
)
{
ITstream& is = iter().stream();
// Read first token
token firstToken(is);
if
(
firstToken.isWord()
&& firstToken.wordToken() == "nonuniform"
)
{
token fieldToken(is);
if (!fieldToken.isCompound())
{
if
(
fieldToken.isLabel()
&& fieldToken.labelToken() == 0
)
{
scalarFields_.insert
(
iter().keyword(),
new scalarField(0)
);
}
else
{
FatalIOErrorInFunction
(
dict
) << "\n token following 'nonuniform' "
"is not a compound"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<scalar>>::typeName
)
{
scalarField* fPtr = new scalarField;
fPtr->transfer
(
dynamicCast<token::Compound<List<scalar>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
scalarFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<vector>>::typeName
)
{
vectorField* fPtr = new vectorField;
fPtr->transfer
(
dynamicCast<token::Compound<List<vector>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
vectorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<sphericalTensor>>::typeName
)
{
sphericalTensorField* fPtr = new sphericalTensorField;
fPtr->transfer
(
dynamicCast
<
token::Compound<List<sphericalTensor>>
>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
sphericalTensorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<symmTensor>>::typeName
)
{
symmTensorField* fPtr = new symmTensorField;
fPtr->transfer
(
dynamicCast
<
token::Compound<List<symmTensor>>
>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
symmTensorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<tensor>>::typeName
)
{
tensorField* fPtr = new tensorField;
fPtr->transfer
(
dynamicCast<token::Compound<List<tensor>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
tensorFields_.insert(iter().keyword(), fPtr);
}
else
{
FatalIOErrorInFunction
(
dict
) << "\n compound " << fieldToken.compoundToken()
<< " not supported"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
else if
(
firstToken.isWord()
&& firstToken.wordToken() == "uniform"
)
{
token fieldToken(is);
if (!fieldToken.isPunctuation())
{
scalarFields_.insert
(
iter().keyword(),
new scalarField
(
this->size(),
fieldToken.number()
)
);
}
else
{
// Read as scalarList.
is.putBack(fieldToken);
scalarList l(is);
if (l.size() == vector::nComponents)
{
vector vs(l[0], l[1], l[2]);
vectorFields_.insert
(
iter().keyword(),
new vectorField(this->size(), vs)
);
}
else if (l.size() == sphericalTensor::nComponents)
{
sphericalTensor vs(l[0]);
sphericalTensorFields_.insert
(
iter().keyword(),
new sphericalTensorField(this->size(), vs)
);
}
else if (l.size() == symmTensor::nComponents)
{
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
symmTensorFields_.insert
(
iter().keyword(),
new symmTensorField(this->size(), vs)
);
}
else if (l.size() == tensor::nComponents)
{
tensor vs
(
l[0], l[1], l[2],
l[3], l[4], l[5],
l[6], l[7], l[8]
);
tensorFields_.insert
(
iter().keyword(),
new tensorField(this->size(), vs)
);
}
else
{
FatalIOErrorInFunction
(
dict
) << "\n unrecognised native type " << l
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
}
}
}
}
}
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const genericFvPatchField<Type>& ptf,
const fvPatch& p,
const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
genericPatchField(ptf),
calculatedFvPatchField<Type>(ptf, p, iF, mapper),
dict_(ptf.dict_)
{
forAllConstIter
(
HashPtrTable<scalarField>,
ptf.scalarFields_,
iter
)
{
scalarFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<vectorField>,
ptf.vectorFields_,
iter
)
{
vectorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<sphericalTensorField>,
ptf.sphericalTensorFields_,
iter
)
{
sphericalTensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<symmTensorField>,
ptf.symmTensorFields_,
iter
)
{
symmTensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<tensorField>,
ptf.tensorFields_,
iter
)
{
tensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
}
template<class Type>
Foam::genericFvPatchField<Type>::genericFvPatchField
(
const genericFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF
)
:
genericPatchField(ptf),
calculatedFvPatchField<Type>(ptf, iF),
dict_(ptf.dict_),
scalarFields_(ptf.scalarFields_),
vectorFields_(ptf.vectorFields_),
sphericalTensorFields_(ptf.sphericalTensorFields_),
symmTensorFields_(ptf.symmTensorFields_),
tensorFields_(ptf.tensorFields_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::genericFvPatchField<Type>::map
(
const fvPatchField<Type>& ptf,
const fvPatchFieldMapper& mapper
)
{
calculatedFvPatchField<Type>::map(ptf, mapper);
const genericFvPatchField<Type>& dptf =
refCast<const genericFvPatchField<Type>>(ptf);
forAllIter
(
HashPtrTable<scalarField>,
scalarFields_,
iter
)
{
HashPtrTable<scalarField>::const_iterator dptfIter =
dptf.scalarFields_.find(iter.key());
if (dptfIter != dptf.scalarFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<vectorField>,
vectorFields_,
iter
)
{
HashPtrTable<vectorField>::const_iterator dptfIter =
dptf.vectorFields_.find(iter.key());
if (dptfIter != dptf.vectorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<sphericalTensorField>,
sphericalTensorFields_,
iter
)
{
HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
dptf.sphericalTensorFields_.find(iter.key());
if (dptfIter != dptf.sphericalTensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<symmTensorField>,
symmTensorFields_,
iter
)
{
HashPtrTable<symmTensorField>::const_iterator dptfIter =
dptf.symmTensorFields_.find(iter.key());
if (dptfIter != dptf.symmTensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<tensorField>,
tensorFields_,
iter
)
{
HashPtrTable<tensorField>::const_iterator dptfIter =
dptf.tensorFields_.find(iter.key());
if (dptfIter != dptf.tensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
}
template<class Type>
void Foam::genericFvPatchField<Type>::reset
(
const fvPatchField<Type>& ptf
)
{
calculatedFvPatchField<Type>::reset(ptf);
const genericFvPatchField<Type>& dptf =
refCast<const genericFvPatchField<Type>>(ptf);
forAllIter
(
HashPtrTable<scalarField>,
scalarFields_,
iter
)
{
HashPtrTable<scalarField>::const_iterator dptfIter =
dptf.scalarFields_.find(iter.key());
if (dptfIter != dptf.scalarFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<vectorField>,
vectorFields_,
iter
)
{
HashPtrTable<vectorField>::const_iterator dptfIter =
dptf.vectorFields_.find(iter.key());
if (dptfIter != dptf.vectorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<sphericalTensorField>,
sphericalTensorFields_,
iter
)
{
HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
dptf.sphericalTensorFields_.find(iter.key());
if (dptfIter != dptf.sphericalTensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<symmTensorField>,
symmTensorFields_,
iter
)
{
HashPtrTable<symmTensorField>::const_iterator dptfIter =
dptf.symmTensorFields_.find(iter.key());
if (dptfIter != dptf.symmTensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<tensorField>,
tensorFields_,
iter
)
{
HashPtrTable<tensorField>::const_iterator dptfIter =
dptf.tensorFields_.find(iter.key());
if (dptfIter != dptf.tensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::valueInternalCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::valueBoundaryCoeffs
(
const tmp<scalarField>&
) const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::gradientInternalCoeffs() const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::genericFvPatchField<Type>::gradientBoundaryCoeffs() const
{
FatalErrorInFunction
<< "cannot be called for a genericFvPatchField"
" (actual type " << actualTypeName() << ")"
<< "\n on patch " << this->patch().name()
<< " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath()
<< "\n You are probably trying to solve for a field with a "
"generic boundary condition."
<< abort(FatalError);
return *this;
}
template<class Type>
void Foam::genericFvPatchField<Type>::write(Ostream& os) const
{
writeEntry(os, "type", actualTypeName());
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type" && iter().keyword() != "value")
{
if
(
iter().isStream()
&& iter().stream().size()
&& iter().stream()[0].isWord()
&& iter().stream()[0].wordToken() == "nonuniform"
)
{
if (scalarFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*scalarFields_.find(iter().keyword())()
);
}
else if (vectorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*vectorFields_.find(iter().keyword())()
);
}
else if (sphericalTensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*sphericalTensorFields_.find(iter().keyword())()
);
}
else if (symmTensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*symmTensorFields_.find(iter().keyword())()
);
}
else if (tensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*tensorFields_.find(iter().keyword())()
);
}
}
else
{
iter().write(os);
}
}
}
writeEntry(os, "value", *this);
}
// ************************************************************************* //

View File

@ -1,652 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 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 "genericPointPatchField.H"
#include "pointPatchFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict
)
:
genericPatchField(dict.lookup("type")),
calculatedPointPatchField<Type>(p, iF, dict),
dict_(dict)
{
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type")
{
if
(
iter().isStream()
&& iter().stream().size()
)
{
ITstream& is = iter().stream();
// Read first token
token firstToken(is);
if
(
firstToken.isWord()
&& firstToken.wordToken() == "nonuniform"
)
{
token fieldToken(is);
if (!fieldToken.isCompound())
{
if
(
fieldToken.isLabel()
&& fieldToken.labelToken() == 0
)
{
scalarFields_.insert
(
iter().keyword(),
new scalarField(0)
);
}
else
{
FatalIOErrorInFunction
(
dict
) << "\n token following 'nonuniform' "
"is not a compound"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<scalar>>::typeName
)
{
scalarField* fPtr = new scalarField;
fPtr->transfer
(
dynamicCast<token::Compound<List<scalar>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
scalarFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<vector>>::typeName
)
{
vectorField* fPtr = new vectorField;
fPtr->transfer
(
dynamicCast<token::Compound<List<vector>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
vectorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<sphericalTensor>>::typeName
)
{
sphericalTensorField* fPtr = new sphericalTensorField;
fPtr->transfer
(
dynamicCast
<
token::Compound<List<sphericalTensor>>
>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
sphericalTensorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<symmTensor>>::typeName
)
{
symmTensorField* fPtr = new symmTensorField;
fPtr->transfer
(
dynamicCast
<
token::Compound<List<symmTensor>>
>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
symmTensorFields_.insert(iter().keyword(), fPtr);
}
else if
(
fieldToken.compoundToken().type()
== token::Compound<List<tensor>>::typeName
)
{
tensorField* fPtr = new tensorField;
fPtr->transfer
(
dynamicCast<token::Compound<List<tensor>>>
(
fieldToken.transferCompoundToken(is)
)
);
if (fPtr->size() != this->size())
{
FatalIOErrorInFunction
(
dict
) << "\n size of field " << iter().keyword()
<< " (" << fPtr->size() << ')'
<< " is not the same size as the patch ("
<< this->size() << ')'
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
tensorFields_.insert(iter().keyword(), fPtr);
}
else
{
FatalIOErrorInFunction
(
dict
) << "\n compound " << fieldToken.compoundToken()
<< " not supported"
<< "\n on patch " << this->patch().name()
<< " of field "
<< this->internalField().name()
<< " in file "
<< this->internalField().objectPath()
<< exit(FatalIOError);
}
}
}
}
}
}
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const genericPointPatchField<Type>& ptf,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
genericPatchField(ptf),
calculatedPointPatchField<Type>(ptf, p, iF, mapper),
dict_(ptf.dict_)
{
forAllConstIter
(
HashPtrTable<scalarField>,
ptf.scalarFields_,
iter
)
{
scalarFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<vectorField>,
ptf.vectorFields_,
iter
)
{
vectorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<sphericalTensorField>,
ptf.sphericalTensorFields_,
iter
)
{
sphericalTensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<symmTensorField>,
ptf.symmTensorFields_,
iter
)
{
symmTensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
forAllConstIter
(
HashPtrTable<tensorField>,
ptf.tensorFields_,
iter
)
{
tensorFields_.insert
(
iter.key(),
mapper(*iter()).ptr()
);
}
}
template<class Type>
Foam::genericPointPatchField<Type>::genericPointPatchField
(
const genericPointPatchField<Type>& ptf,
const DimensionedField<Type, pointMesh>& iF
)
:
genericPatchField(ptf),
calculatedPointPatchField<Type>(ptf, iF),
dict_(ptf.dict_),
scalarFields_(ptf.scalarFields_),
vectorFields_(ptf.vectorFields_),
sphericalTensorFields_(ptf.sphericalTensorFields_),
symmTensorFields_(ptf.symmTensorFields_),
tensorFields_(ptf.tensorFields_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::genericPointPatchField<Type>::map
(
const pointPatchField<Type>& ptf,
const pointPatchFieldMapper& mapper
)
{
const genericPointPatchField<Type>& dptf =
refCast<const genericPointPatchField<Type>>(ptf);
forAllIter
(
HashPtrTable<scalarField>,
scalarFields_,
iter
)
{
HashPtrTable<scalarField>::const_iterator dptfIter =
dptf.scalarFields_.find(iter.key());
if (dptfIter != scalarFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<vectorField>,
vectorFields_,
iter
)
{
HashPtrTable<vectorField>::const_iterator dptfIter =
dptf.vectorFields_.find(iter.key());
if (dptfIter != vectorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<sphericalTensorField>,
sphericalTensorFields_,
iter
)
{
HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
dptf.sphericalTensorFields_.find(iter.key());
if (dptfIter != sphericalTensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<symmTensorField>,
symmTensorFields_,
iter
)
{
HashPtrTable<symmTensorField>::const_iterator dptfIter =
dptf.symmTensorFields_.find(iter.key());
if (dptfIter != symmTensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
forAllIter
(
HashPtrTable<tensorField>,
tensorFields_,
iter
)
{
HashPtrTable<tensorField>::const_iterator dptfIter =
dptf.tensorFields_.find(iter.key());
if (dptfIter != tensorFields_.end())
{
mapper(*iter(), *dptfIter());
}
}
}
template<class Type>
void Foam::genericPointPatchField<Type>::reset
(
const pointPatchField<Type>& ptf
)
{
const genericPointPatchField<Type>& dptf =
refCast<const genericPointPatchField<Type>>(ptf);
forAllIter
(
HashPtrTable<scalarField>,
scalarFields_,
iter
)
{
HashPtrTable<scalarField>::const_iterator dptfIter =
dptf.scalarFields_.find(iter.key());
if (dptfIter != scalarFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<vectorField>,
vectorFields_,
iter
)
{
HashPtrTable<vectorField>::const_iterator dptfIter =
dptf.vectorFields_.find(iter.key());
if (dptfIter != vectorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<sphericalTensorField>,
sphericalTensorFields_,
iter
)
{
HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
dptf.sphericalTensorFields_.find(iter.key());
if (dptfIter != sphericalTensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<symmTensorField>,
symmTensorFields_,
iter
)
{
HashPtrTable<symmTensorField>::const_iterator dptfIter =
dptf.symmTensorFields_.find(iter.key());
if (dptfIter != symmTensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
forAllIter
(
HashPtrTable<tensorField>,
tensorFields_,
iter
)
{
HashPtrTable<tensorField>::const_iterator dptfIter =
dptf.tensorFields_.find(iter.key());
if (dptfIter != tensorFields_.end())
{
iter()->reset(*dptfIter());
}
}
}
template<class Type>
void Foam::genericPointPatchField<Type>::write(Ostream& os) const
{
writeEntry(os, "type", actualTypeName());
forAllConstIter(dictionary, dict_, iter)
{
if (iter().keyword() != "type")
{
if
(
iter().isStream()
&& iter().stream().size()
&& iter().stream()[0].isWord()
&& iter().stream()[0].wordToken() == "nonuniform"
)
{
if (scalarFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*scalarFields_.find(iter().keyword())()
);
}
else if (vectorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*vectorFields_.find(iter().keyword())()
);
}
else if (sphericalTensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*sphericalTensorFields_.find(iter().keyword())()
);
}
else if (symmTensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*symmTensorFields_.find(iter().keyword())()
);
}
else if (tensorFields_.found(iter().keyword()))
{
writeEntry
(
os,
iter().keyword(),
*tensorFields_.find(iter().keyword())()
);
}
}
else
{
iter().write(os);
}
}
}
}
// ************************************************************************* //

View File

@ -8,4 +8,4 @@ EXE_LIBS = \
-ldynamicMesh \ -ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lfiniteVolume \ -lfiniteVolume \
-lgenericPatchFields -lgenericFvFields