diff --git a/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.C b/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.C
new file mode 100644
index 0000000000..25de86d62f
--- /dev/null
+++ b/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.C
@@ -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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "SetPatchFields.H"
+
+// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
+
+template
+void Foam::SetPatchFields
+(
+ PtrList& fields,
+ const label patchI,
+ const typename GeoField::value_type& initVal
+)
+{
+ forAll(fields, i)
+ {
+ typename GeoField::PatchFieldType& pfld =
+ fields[i].boundaryField()[patchI];
+ pfld == initVal;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.H b/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.H
new file mode 100644
index 0000000000..1dcb1e346a
--- /dev/null
+++ b/applications/utilities/mesh/manipulation/createBaffles/SetPatchFields.H
@@ -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 .
+
+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
+void SetPatchFields
+(
+ PtrList& fields,
+ const label patchI,
+ const typename GeoField::value_type& initVal
+);
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+# include "SetPatchFields.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
index f01c2cd602..a94dc42144 100644
--- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
+++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C
@@ -43,6 +43,8 @@ Description
#include "volFields.H"
#include "surfaceFields.H"
#include "ZoneIDs.H"
+#include "fvMeshMapper.H"
+#include "SetPatchFields.H"
using namespace Foam;
@@ -241,45 +243,39 @@ int main(int argc, char *argv[])
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields.
- if (args.optionFound("updateFields"))
- {
- Info<< "Reading geometric fields" << nl << endl;
- PtrList vsFlds;
- ReadFields(mesh, objects, vsFlds);
+ Info<< "Reading geometric fields" << nl << endl;
+ PtrList vsFlds;
+ ReadFields(mesh, objects, vsFlds);
- PtrList vvFlds;
- ReadFields(mesh, objects, vvFlds);
+ PtrList vvFlds;
+ ReadFields(mesh, objects, vvFlds);
- PtrList vstFlds;
- ReadFields(mesh, objects, vstFlds);
+ PtrList vstFlds;
+ ReadFields(mesh, objects, vstFlds);
- PtrList vsymtFlds;
- ReadFields(mesh, objects, vsymtFlds);
+ PtrList vsymtFlds;
+ ReadFields(mesh, objects, vsymtFlds);
- PtrList vtFlds;
- ReadFields(mesh, objects, vtFlds);
+ PtrList vtFlds;
+ ReadFields(mesh, objects, vtFlds);
- // Read surface fields.
+ // Read surface fields.
- PtrList ssFlds;
- ReadFields(mesh, objects, ssFlds);
+ PtrList ssFlds;
+ ReadFields(mesh, objects, ssFlds);
- PtrList svFlds;
- ReadFields(mesh, objects, svFlds);
+ PtrList svFlds;
+ ReadFields(mesh, objects, svFlds);
- PtrList sstFlds;
- ReadFields(mesh, objects, sstFlds);
+ PtrList sstFlds;
+ ReadFields(mesh, objects, sstFlds);
- PtrList ssymtFlds;
- ReadFields(mesh, objects, ssymtFlds);
+ PtrList ssymtFlds;
+ ReadFields(mesh, objects, ssymtFlds);
+
+ PtrList stFlds;
+ ReadFields(mesh, objects, stFlds);
- PtrList stFlds;
- ReadFields(mesh, objects, stFlds);
- }
- else
- {
- Info<< "Not updating geometric fields" << nl << endl;
- }
// Mesh change container
polyTopoChange meshMod(mesh);
@@ -484,6 +480,58 @@ int main(int argc, char *argv[])
// Update fields
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::zero);
+ SetPatchFields(vvFlds, patchI, pTraits::zero);
+ SetPatchFields(vstFlds, patchI, pTraits::zero);
+ SetPatchFields(vsymtFlds, patchI, pTraits::zero);
+ SetPatchFields(vtFlds, patchI, pTraits::zero);
+
+ SetPatchFields(ssFlds, patchI, pTraits::zero);
+ SetPatchFields(svFlds, patchI, pTraits::zero);
+ SetPatchFields(sstFlds, patchI, pTraits::zero);
+ SetPatchFields(ssymtFlds, patchI, pTraits::zero);
+ SetPatchFields(stFlds, patchI, pTraits::zero);
+ }
+ }
+ forAll(newSlavePatches, i)
+ {
+ label patchI = newSlavePatches[i];
+ const fvPatchMapper& pm = mapper.boundaryMap()[patchI];
+ if (pm.sizeBeforeMapping() == 0)
+ {
+ SetPatchFields(vsFlds, patchI, pTraits::zero);
+ SetPatchFields(vvFlds, patchI, pTraits::zero);
+ SetPatchFields(vstFlds, patchI, pTraits::zero);
+ SetPatchFields(vsymtFlds, patchI, pTraits::zero);
+ SetPatchFields(vtFlds, patchI, pTraits::zero);
+
+ SetPatchFields(ssFlds, patchI, pTraits::zero);
+ SetPatchFields(svFlds, patchI, pTraits::zero);
+ SetPatchFields(sstFlds, patchI, pTraits::zero);
+ SetPatchFields(ssymtFlds, patchI, pTraits::zero);
+ SetPatchFields(stFlds, patchI, pTraits::zero);
+ }
+ }
+ }
+
// Move mesh (since morphing might not do this)
if (map().hasMotionPoints())
{