ENH: createBaffles : set added patch faces to value 0

This commit is contained in:
mattijs
2010-10-13 18:12:51 +01:00
parent 8cabfbb7d1
commit b7a4b9a7bf
3 changed files with 190 additions and 29 deletions

View File

@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ 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 "SetPatchFields.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class GeoField>
void Foam::SetPatchFields
(
PtrList<GeoField>& fields,
const label patchI,
const typename GeoField::value_type& initVal
)
{
forAll(fields, i)
{
typename GeoField::PatchFieldType& pfld =
fields[i].boundaryField()[patchI];
pfld == initVal;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ 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/>.
Global
Foam::SetPatchFields
Description
Helper routine to initialise a patch field to a constant value
SourceFiles
SetPatchFields.C
\*---------------------------------------------------------------------------*/
#ifndef SetPatchFields_H
#define SetPatchFields_H
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Helper routine to read fields
template<class GeoField>
void SetPatchFields
(
PtrList<GeoField>& fields,
const label patchI,
const typename GeoField::value_type& initVal
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "SetPatchFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -43,6 +43,8 @@ Description
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "ZoneIDs.H" #include "ZoneIDs.H"
#include "fvMeshMapper.H"
#include "SetPatchFields.H"
using namespace Foam; using namespace Foam;
@ -241,45 +243,39 @@ int main(int argc, char *argv[])
IOobjectList objects(mesh, runTime.timeName()); IOobjectList objects(mesh, runTime.timeName());
// Read vol fields. // Read vol fields.
if (args.optionFound("updateFields")) Info<< "Reading geometric fields" << nl << endl;
{ PtrList<volScalarField> vsFlds;
Info<< "Reading geometric fields" << nl << endl; ReadFields(mesh, objects, vsFlds);
PtrList<volScalarField> vsFlds;
ReadFields(mesh, objects, vsFlds);
PtrList<volVectorField> vvFlds; PtrList<volVectorField> vvFlds;
ReadFields(mesh, objects, vvFlds); ReadFields(mesh, objects, vvFlds);
PtrList<volSphericalTensorField> vstFlds; PtrList<volSphericalTensorField> vstFlds;
ReadFields(mesh, objects, vstFlds); ReadFields(mesh, objects, vstFlds);
PtrList<volSymmTensorField> vsymtFlds; PtrList<volSymmTensorField> vsymtFlds;
ReadFields(mesh, objects, vsymtFlds); ReadFields(mesh, objects, vsymtFlds);
PtrList<volTensorField> vtFlds; PtrList<volTensorField> vtFlds;
ReadFields(mesh, objects, vtFlds); ReadFields(mesh, objects, vtFlds);
// Read surface fields. // Read surface fields.
PtrList<surfaceScalarField> ssFlds; PtrList<surfaceScalarField> ssFlds;
ReadFields(mesh, objects, ssFlds); ReadFields(mesh, objects, ssFlds);
PtrList<surfaceVectorField> svFlds; PtrList<surfaceVectorField> svFlds;
ReadFields(mesh, objects, svFlds); ReadFields(mesh, objects, svFlds);
PtrList<surfaceSphericalTensorField> sstFlds; PtrList<surfaceSphericalTensorField> sstFlds;
ReadFields(mesh, objects, sstFlds); ReadFields(mesh, objects, sstFlds);
PtrList<surfaceSymmTensorField> ssymtFlds; PtrList<surfaceSymmTensorField> ssymtFlds;
ReadFields(mesh, objects, ssymtFlds); ReadFields(mesh, objects, ssymtFlds);
PtrList<surfaceTensorField> stFlds;
ReadFields(mesh, objects, stFlds);
PtrList<surfaceTensorField> stFlds;
ReadFields(mesh, objects, stFlds);
}
else
{
Info<< "Not updating geometric fields" << nl << endl;
}
// Mesh change container // Mesh change container
polyTopoChange meshMod(mesh); polyTopoChange meshMod(mesh);
@ -484,6 +480,58 @@ int main(int argc, char *argv[])
// Update fields // Update fields
mesh.updateMesh(map); mesh.updateMesh(map);
// Correct boundary faces mapped-out-of-nothing.
{
fvMeshMapper mapper(mesh, map);
bool hasWarned = false;
forAll(newMasterPatches, i)
{
label patchI = newMasterPatches[i];
const fvPatchMapper& pm = mapper.boundaryMap()[patchI];
if (pm.sizeBeforeMapping() == 0)
{
if (!hasWarned)
{
hasWarned = true;
WarningIn(args.executable())
<< "Setting field on boundary faces to zero." << endl
<< "You might have to edit these fields." << endl;
}
SetPatchFields(vsFlds, patchI, pTraits<scalar>::zero);
SetPatchFields(vvFlds, patchI, pTraits<vector>::zero);
SetPatchFields(vstFlds, patchI, pTraits<sphericalTensor>::zero);
SetPatchFields(vsymtFlds, patchI, pTraits<symmTensor>::zero);
SetPatchFields(vtFlds, patchI, pTraits<tensor>::zero);
SetPatchFields(ssFlds, patchI, pTraits<scalar>::zero);
SetPatchFields(svFlds, patchI, pTraits<vector>::zero);
SetPatchFields(sstFlds, patchI, pTraits<sphericalTensor>::zero);
SetPatchFields(ssymtFlds, patchI, pTraits<symmTensor>::zero);
SetPatchFields(stFlds, patchI, pTraits<tensor>::zero);
}
}
forAll(newSlavePatches, i)
{
label patchI = newSlavePatches[i];
const fvPatchMapper& pm = mapper.boundaryMap()[patchI];
if (pm.sizeBeforeMapping() == 0)
{
SetPatchFields(vsFlds, patchI, pTraits<scalar>::zero);
SetPatchFields(vvFlds, patchI, pTraits<vector>::zero);
SetPatchFields(vstFlds, patchI, pTraits<sphericalTensor>::zero);
SetPatchFields(vsymtFlds, patchI, pTraits<symmTensor>::zero);
SetPatchFields(vtFlds, patchI, pTraits<tensor>::zero);
SetPatchFields(ssFlds, patchI, pTraits<scalar>::zero);
SetPatchFields(svFlds, patchI, pTraits<vector>::zero);
SetPatchFields(sstFlds, patchI, pTraits<sphericalTensor>::zero);
SetPatchFields(ssymtFlds, patchI, pTraits<symmTensor>::zero);
SetPatchFields(stFlds, patchI, pTraits<tensor>::zero);
}
}
}
// Move mesh (since morphing might not do this) // Move mesh (since morphing might not do this)
if (map().hasMotionPoints()) if (map().hasMotionPoints())
{ {