mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fvMeshTools: utility functions for fvPatch, fvMesh
This commit is contained in:
@ -81,6 +81,8 @@ fvMeshDistribute/fvMeshDistribute.C
|
||||
polyMeshAdder/faceCoupleInfo.C
|
||||
polyMeshAdder/polyMeshAdder.C
|
||||
|
||||
fvMeshTools/fvMeshTools.C
|
||||
|
||||
motionSmoother/motionSmoother.C
|
||||
motionSmoother/motionSmootherCheck.C
|
||||
motionSmoother/polyMeshGeometry/polyMeshGeometry.C
|
||||
|
||||
351
src/dynamicMesh/fvMeshTools/fvMeshTools.C
Normal file
351
src/dynamicMesh/fvMeshTools/fvMeshTools.C
Normal file
@ -0,0 +1,351 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "fvMeshTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Adds patch if not yet there. Returns patchID.
|
||||
Foam::label Foam::fvMeshTools::addPatch
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const polyPatch& patch,
|
||||
const dictionary& patchFieldDict,
|
||||
const word& defaultPatchFieldType,
|
||||
const bool validBoundary
|
||||
)
|
||||
{
|
||||
polyBoundaryMesh& polyPatches =
|
||||
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
|
||||
|
||||
label patchI = polyPatches.findPatchID(patch.name());
|
||||
if (patchI != -1)
|
||||
{
|
||||
// Already there
|
||||
return patchI;
|
||||
}
|
||||
|
||||
|
||||
label insertPatchI = polyPatches.size();
|
||||
label startFaceI = mesh.nFaces();
|
||||
|
||||
forAll(polyPatches, patchI)
|
||||
{
|
||||
const polyPatch& pp = polyPatches[patchI];
|
||||
|
||||
if (isA<processorPolyPatch>(pp))
|
||||
{
|
||||
insertPatchI = patchI;
|
||||
startFaceI = pp.start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Below is all quite a hack. Feel free to change once there is a better
|
||||
// mechanism to insert and reorder patches.
|
||||
|
||||
// Clear local fields and e.g. polyMesh parallelInfo.
|
||||
mesh.clearOut();
|
||||
|
||||
label sz = polyPatches.size();
|
||||
|
||||
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary());
|
||||
|
||||
// Add polyPatch at the end
|
||||
polyPatches.setSize(sz+1);
|
||||
polyPatches.set
|
||||
(
|
||||
sz,
|
||||
patch.clone
|
||||
(
|
||||
polyPatches,
|
||||
insertPatchI, //index
|
||||
0, //size
|
||||
startFaceI //start
|
||||
)
|
||||
);
|
||||
fvPatches.setSize(sz+1);
|
||||
fvPatches.set
|
||||
(
|
||||
sz,
|
||||
fvPatch::New
|
||||
(
|
||||
polyPatches[sz], // point to newly added polyPatch
|
||||
mesh.boundary()
|
||||
)
|
||||
);
|
||||
|
||||
addPatchFields<volScalarField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<scalar>::zero
|
||||
);
|
||||
addPatchFields<volVectorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<vector>::zero
|
||||
);
|
||||
addPatchFields<volSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<sphericalTensor>::zero
|
||||
);
|
||||
addPatchFields<volSymmTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<symmTensor>::zero
|
||||
);
|
||||
addPatchFields<volTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<tensor>::zero
|
||||
);
|
||||
|
||||
// Surface fields
|
||||
|
||||
addPatchFields<surfaceScalarField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<scalar>::zero
|
||||
);
|
||||
addPatchFields<surfaceVectorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<vector>::zero
|
||||
);
|
||||
addPatchFields<surfaceSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<sphericalTensor>::zero
|
||||
);
|
||||
addPatchFields<surfaceSymmTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<symmTensor>::zero
|
||||
);
|
||||
addPatchFields<surfaceTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchFieldDict,
|
||||
defaultPatchFieldType,
|
||||
pTraits<tensor>::zero
|
||||
);
|
||||
|
||||
// Create reordering list
|
||||
// patches before insert position stay as is
|
||||
labelList oldToNew(sz+1);
|
||||
for (label i = 0; i < insertPatchI; i++)
|
||||
{
|
||||
oldToNew[i] = i;
|
||||
}
|
||||
// patches after insert position move one up
|
||||
for (label i = insertPatchI; i < sz; i++)
|
||||
{
|
||||
oldToNew[i] = i+1;
|
||||
}
|
||||
// appended patch gets moved to insert position
|
||||
oldToNew[sz] = insertPatchI;
|
||||
|
||||
// Shuffle into place
|
||||
polyPatches.reorder(oldToNew, validBoundary);
|
||||
fvPatches.reorder(oldToNew);
|
||||
|
||||
reorderPatchFields<volScalarField>(mesh, oldToNew);
|
||||
reorderPatchFields<volVectorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volSphericalTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volSymmTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceScalarField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceVectorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceSphericalTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceSymmTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceTensorField>(mesh, oldToNew);
|
||||
|
||||
return insertPatchI;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvMeshTools::setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const dictionary& patchFieldDict
|
||||
)
|
||||
{
|
||||
setPatchFields<volScalarField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<volVectorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<volSphericalTensorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<volSymmTensorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<volTensorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<surfaceScalarField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<surfaceVectorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<surfaceSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchI,
|
||||
patchFieldDict
|
||||
);
|
||||
setPatchFields<surfaceSymmTensorField>(mesh, patchI, patchFieldDict);
|
||||
setPatchFields<surfaceTensorField>(mesh, patchI, patchFieldDict);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvMeshTools::zeroPatchFields(fvMesh& mesh, const label patchI)
|
||||
{
|
||||
setPatchFields<volScalarField>(mesh, patchI, pTraits<scalar>::zero);
|
||||
setPatchFields<volVectorField>(mesh, patchI, pTraits<vector>::zero);
|
||||
setPatchFields<volSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchI,
|
||||
pTraits<sphericalTensor>::zero
|
||||
);
|
||||
setPatchFields<volSymmTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchI,
|
||||
pTraits<symmTensor>::zero
|
||||
);
|
||||
setPatchFields<volTensorField>(mesh, patchI, pTraits<tensor>::zero);
|
||||
setPatchFields<surfaceScalarField>(mesh, patchI, pTraits<scalar>::zero);
|
||||
setPatchFields<surfaceVectorField>(mesh, patchI, pTraits<vector>::zero);
|
||||
setPatchFields<surfaceSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchI,
|
||||
pTraits<sphericalTensor>::zero
|
||||
);
|
||||
setPatchFields<surfaceSymmTensorField>
|
||||
(
|
||||
mesh,
|
||||
patchI,
|
||||
pTraits<symmTensor>::zero
|
||||
);
|
||||
setPatchFields<surfaceTensorField>(mesh, patchI, pTraits<tensor>::zero);
|
||||
}
|
||||
|
||||
|
||||
// Deletes last patch
|
||||
void Foam::fvMeshTools::trimPatches(fvMesh& mesh, const label nPatches)
|
||||
{
|
||||
// Clear local fields and e.g. polyMesh globalMeshData.
|
||||
mesh.clearOut();
|
||||
|
||||
polyBoundaryMesh& polyPatches =
|
||||
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
|
||||
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary());
|
||||
|
||||
if (polyPatches.empty())
|
||||
{
|
||||
FatalErrorIn("fvMeshTools::trimPatches(fvMesh&, const label)")
|
||||
<< "No patches in mesh"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
label nFaces = 0;
|
||||
for (label patchI = nPatches; patchI < polyPatches.size(); patchI++)
|
||||
{
|
||||
nFaces += polyPatches[patchI].size();
|
||||
}
|
||||
reduce(nFaces, sumOp<label>());
|
||||
|
||||
if (nFaces)
|
||||
{
|
||||
FatalErrorIn("fvMeshTools::trimPatches(fvMesh&, const label)")
|
||||
<< "There are still " << nFaces
|
||||
<< " faces in " << polyPatches.size()-nPatches
|
||||
<< " patches to be deleted" << abort(FatalError);
|
||||
}
|
||||
|
||||
// Remove actual patches
|
||||
polyPatches.setSize(nPatches);
|
||||
fvPatches.setSize(nPatches);
|
||||
|
||||
trimPatchFields<volScalarField>(mesh, nPatches);
|
||||
trimPatchFields<volVectorField>(mesh, nPatches);
|
||||
trimPatchFields<volSphericalTensorField>(mesh, nPatches);
|
||||
trimPatchFields<volSymmTensorField>(mesh, nPatches);
|
||||
trimPatchFields<volTensorField>(mesh, nPatches);
|
||||
|
||||
trimPatchFields<surfaceScalarField>(mesh, nPatches);
|
||||
trimPatchFields<surfaceVectorField>(mesh, nPatches);
|
||||
trimPatchFields<surfaceSphericalTensorField>(mesh, nPatches);
|
||||
trimPatchFields<surfaceSymmTensorField>(mesh, nPatches);
|
||||
trimPatchFields<surfaceTensorField>(mesh, nPatches);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fvMeshTools::reorderPatches
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const labelList& oldToNew,
|
||||
const label nNewPatches,
|
||||
const bool validBoundary
|
||||
)
|
||||
{
|
||||
polyBoundaryMesh& polyPatches =
|
||||
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
|
||||
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary());
|
||||
|
||||
// Shuffle into place
|
||||
polyPatches.reorder(oldToNew, validBoundary);
|
||||
fvPatches.reorder(oldToNew);
|
||||
|
||||
reorderPatchFields<volScalarField>(mesh, oldToNew);
|
||||
reorderPatchFields<volVectorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volSphericalTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volSymmTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<volTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceScalarField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceVectorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceSphericalTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceSymmTensorField>(mesh, oldToNew);
|
||||
reorderPatchFields<surfaceTensorField>(mesh, oldToNew);
|
||||
|
||||
// Remove last.
|
||||
trimPatches(mesh, nNewPatches);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
142
src/dynamicMesh/fvMeshTools/fvMeshTools.H
Normal file
142
src/dynamicMesh/fvMeshTools/fvMeshTools.H
Normal file
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Class
|
||||
Foam::fvMeshTools
|
||||
|
||||
Description
|
||||
A collection of tools for operating on an fvMesh.
|
||||
|
||||
SourceFiles
|
||||
fvMeshTools.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fvMeshTools_H
|
||||
#define fvMeshTools_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
//#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fvMeshTools Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fvMeshTools
|
||||
{
|
||||
template<class GeoField>
|
||||
static void addPatchFields
|
||||
(
|
||||
fvMesh&,
|
||||
const dictionary& patchFieldDict,
|
||||
const word& defaultPatchFieldType,
|
||||
const typename GeoField::value_type& defaultPatchValue
|
||||
);
|
||||
|
||||
//- Set patchFields according to dictionary
|
||||
template<class GeoField>
|
||||
static void setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const dictionary& patchFieldDict
|
||||
);
|
||||
|
||||
//- Set patchFields to value
|
||||
template<class GeoField>
|
||||
static void setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const typename GeoField::value_type& value
|
||||
);
|
||||
|
||||
// Remove last patch fields
|
||||
template<class GeoField>
|
||||
static void trimPatchFields(fvMesh&, const label nPatches);
|
||||
|
||||
template<class GeoField>
|
||||
static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
|
||||
|
||||
// Remove trialing patches
|
||||
static void trimPatches(fvMesh&, const label nPatches);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Add patch. Supply per field the new patchField per field as a
|
||||
// subdictionary or a default type. If validBoundary call is parallel
|
||||
// synced and all add the same patch with same settings
|
||||
static label addPatch
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const polyPatch& patch,
|
||||
const dictionary& patchFieldDict,
|
||||
const word& defaultPatchFieldType,
|
||||
const bool validBoundary
|
||||
);
|
||||
|
||||
//- Change patchField on registered fields according to dictionary
|
||||
static void setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const dictionary& patchFieldDict
|
||||
);
|
||||
|
||||
//- Change patchField to zero on registered fields
|
||||
static void zeroPatchFields(fvMesh& mesh, const label patchI);
|
||||
|
||||
// -Reorder and remove trailing patches. If validBoundary call is parallel
|
||||
// synced and all add the same patch with same settings
|
||||
static void reorderPatches
|
||||
(
|
||||
fvMesh&,
|
||||
const labelList& oldToNew,
|
||||
const label nPatches,
|
||||
const bool validBoundary
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "fvMeshToolsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
208
src/dynamicMesh/fvMeshTools/fvMeshToolsTemplates.C
Normal file
208
src/dynamicMesh/fvMeshTools/fvMeshToolsTemplates.C
Normal file
@ -0,0 +1,208 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "fvMeshTools.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshTools::addPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const dictionary& patchFieldDict,
|
||||
const word& defaultPatchFieldType,
|
||||
const typename GeoField::value_type& defaultPatchValue
|
||||
)
|
||||
{
|
||||
HashTable<const GeoField*> flds
|
||||
(
|
||||
mesh.objectRegistry::lookupClass<GeoField>()
|
||||
);
|
||||
|
||||
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
|
||||
{
|
||||
const GeoField& fld = *iter();
|
||||
|
||||
typename GeoField::GeometricBoundaryField& bfld =
|
||||
const_cast<typename GeoField::GeometricBoundaryField&>
|
||||
(
|
||||
fld.boundaryField()
|
||||
);
|
||||
|
||||
label sz = bfld.size();
|
||||
bfld.setSize(sz+1);
|
||||
|
||||
if (patchFieldDict.found(fld.name()))
|
||||
{
|
||||
bfld.set
|
||||
(
|
||||
sz,
|
||||
GeoField::PatchFieldType::New
|
||||
(
|
||||
mesh.boundary()[sz],
|
||||
fld.dimensionedInternalField(),
|
||||
patchFieldDict.subDict(fld.name())
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
bfld.set
|
||||
(
|
||||
sz,
|
||||
GeoField::PatchFieldType::New
|
||||
(
|
||||
defaultPatchFieldType,
|
||||
mesh.boundary()[sz],
|
||||
fld.dimensionedInternalField()
|
||||
)
|
||||
);
|
||||
bfld[sz] == defaultPatchValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshTools::setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const dictionary& patchFieldDict
|
||||
)
|
||||
{
|
||||
HashTable<const GeoField*> flds
|
||||
(
|
||||
mesh.objectRegistry::lookupClass<GeoField>()
|
||||
);
|
||||
|
||||
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
|
||||
{
|
||||
const GeoField& fld = *iter();
|
||||
|
||||
typename GeoField::GeometricBoundaryField& bfld =
|
||||
const_cast<typename GeoField::GeometricBoundaryField&>
|
||||
(
|
||||
fld.boundaryField()
|
||||
);
|
||||
|
||||
if (patchFieldDict.found(fld.name()))
|
||||
{
|
||||
bfld.set
|
||||
(
|
||||
patchI,
|
||||
GeoField::PatchFieldType::New
|
||||
(
|
||||
mesh.boundary()[patchI],
|
||||
fld.dimensionedInternalField(),
|
||||
patchFieldDict.subDict(fld.name())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshTools::setPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const label patchI,
|
||||
const typename GeoField::value_type& value
|
||||
)
|
||||
{
|
||||
HashTable<const GeoField*> flds
|
||||
(
|
||||
mesh.objectRegistry::lookupClass<GeoField>()
|
||||
);
|
||||
|
||||
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
|
||||
{
|
||||
const GeoField& fld = *iter();
|
||||
|
||||
typename GeoField::GeometricBoundaryField& bfld =
|
||||
const_cast<typename GeoField::GeometricBoundaryField&>
|
||||
(
|
||||
fld.boundaryField()
|
||||
);
|
||||
|
||||
bfld[patchI] == value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove last patch field
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshTools::trimPatchFields(fvMesh& mesh, const label nPatches)
|
||||
{
|
||||
HashTable<const GeoField*> flds
|
||||
(
|
||||
mesh.objectRegistry::lookupClass<GeoField>()
|
||||
);
|
||||
|
||||
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
|
||||
{
|
||||
const GeoField& fld = *iter();
|
||||
|
||||
const_cast<typename GeoField::GeometricBoundaryField&>
|
||||
(
|
||||
fld.boundaryField()
|
||||
).setSize(nPatches);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reorder patch field
|
||||
template<class GeoField>
|
||||
void Foam::fvMeshTools::reorderPatchFields
|
||||
(
|
||||
fvMesh& mesh,
|
||||
const labelList& oldToNew
|
||||
)
|
||||
{
|
||||
HashTable<const GeoField*> flds
|
||||
(
|
||||
mesh.objectRegistry::lookupClass<GeoField>()
|
||||
);
|
||||
|
||||
forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
|
||||
{
|
||||
const GeoField& fld = *iter();
|
||||
|
||||
typename GeoField::GeometricBoundaryField& bfld =
|
||||
const_cast<typename GeoField::GeometricBoundaryField&>
|
||||
(
|
||||
fld.boundaryField()
|
||||
);
|
||||
bfld.reorder(oldToNew);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user