mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// subsetMesh tool definition
|
||||
|
||||
description "Creates a region of the mesh based on parameter specified in subsetMeshDict";
|
||||
|
||||
subsetMeshDict
|
||||
{
|
||||
type dictionary;
|
||||
description "subsetMesh control dictionary";
|
||||
dictionaryPath "system";
|
||||
|
||||
entries
|
||||
{
|
||||
arguments
|
||||
{
|
||||
type rootCaseArguments;
|
||||
entries
|
||||
{
|
||||
include "$FOAMX_CONFIG/entries/arguments/patch.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
points
|
||||
{
|
||||
type list;
|
||||
description "list of point labels";
|
||||
elementType label;
|
||||
}
|
||||
|
||||
faces
|
||||
{
|
||||
type list;
|
||||
description "list of face labels";
|
||||
elementType block;
|
||||
}
|
||||
|
||||
cells
|
||||
{
|
||||
type list;
|
||||
description "list of cell labels";
|
||||
elementType edge;
|
||||
}
|
||||
|
||||
include "$FOAMX_CONFIG/entries/Switch/addCellNeighbours.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,4 @@
|
||||
subsetMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/subsetMesh
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools
|
||||
288
applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
Normal file
288
applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C
Normal file
@ -0,0 +1,288 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Selects a section of mesh based on a cellSet.
|
||||
|
||||
The utility sub-sets the mesh to choose only a part of interest. Check
|
||||
the setSet/cellSet utilities to see how to select cells based on various.
|
||||
|
||||
The mesh will subset all points, faces and cells needed to make a sub-mesh
|
||||
but will not preserve attached boundary types.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvMeshSubset.H"
|
||||
#include "argList.H"
|
||||
#include "cellSet.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "volFields.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetVolFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
PtrList<GeometricField<Type, fvPatchField, volMesh> >& subFields
|
||||
)
|
||||
{
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
GeometricField<Type, fvPatchField, volMesh> volField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
baseMesh.time().timeName(),
|
||||
baseMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
baseMesh
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(volField));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetSurfaceFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& subFields
|
||||
)
|
||||
{
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh> volField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
baseMesh.time().timeName(),
|
||||
baseMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
baseMesh
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(volField));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::validArgs.append("set");
|
||||
argList::validOptions.insert("patch", "patch name");
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
word setName(args.additionalArgs()[0]);
|
||||
|
||||
|
||||
Info<< "Reading cell set from " << setName << endl << endl;
|
||||
|
||||
// Create mesh subsetting engine
|
||||
fvMeshSubset subsetter(mesh);
|
||||
|
||||
label patchI = -1;
|
||||
|
||||
if (args.options().found("patch"))
|
||||
{
|
||||
word patchName(args.options()["patch"]);
|
||||
|
||||
patchI = mesh.boundaryMesh().findPatchID(patchName);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
FatalErrorIn(args.executable()) << "Illegal patch " << patchName
|
||||
<< nl << "Valid patches are " << mesh.boundaryMesh().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "Adding exposed internal faces to patch " << patchName << endl
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Adding exposed internal faces to a patch called"
|
||||
<< " \"oldInternalFaces\" (created if nessecary)" << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
cellSet currentSet(mesh, setName);
|
||||
|
||||
subsetter.setLargeCellSubset(currentSet, patchI, true);
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
// Read vol fields and subset.
|
||||
|
||||
wordList scalarNames(objects.names(volScalarField::typeName));
|
||||
PtrList<volScalarField> scalarFlds(scalarNames.size());
|
||||
subsetVolFields(subsetter, scalarNames, scalarFlds);
|
||||
|
||||
wordList vectorNames(objects.names(volVectorField::typeName));
|
||||
PtrList<volVectorField> vectorFlds(vectorNames.size());
|
||||
subsetVolFields(subsetter, vectorNames, vectorFlds);
|
||||
|
||||
wordList sphericalTensorNames
|
||||
(
|
||||
objects.names(volSphericalTensorField::typeName)
|
||||
);
|
||||
PtrList<volSphericalTensorField> sphericalTensorFlds
|
||||
(
|
||||
sphericalTensorNames.size()
|
||||
);
|
||||
subsetVolFields(subsetter, sphericalTensorNames, sphericalTensorFlds);
|
||||
|
||||
wordList symmTensorNames(objects.names(volSymmTensorField::typeName));
|
||||
PtrList<volSymmTensorField> symmTensorFlds(symmTensorNames.size());
|
||||
subsetVolFields(subsetter, symmTensorNames, symmTensorFlds);
|
||||
|
||||
wordList tensorNames(objects.names(volTensorField::typeName));
|
||||
PtrList<volTensorField> tensorFlds(tensorNames.size());
|
||||
subsetVolFields(subsetter, tensorNames, tensorFlds);
|
||||
|
||||
// Read surface fields and subset.
|
||||
|
||||
wordList surfScalarNames(objects.names(surfaceScalarField::typeName));
|
||||
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size());
|
||||
subsetSurfaceFields(subsetter, surfScalarNames, surfScalarFlds);
|
||||
|
||||
wordList surfVectorNames(objects.names(surfaceVectorField::typeName));
|
||||
PtrList<surfaceVectorField> surfVectorFlds(surfVectorNames.size());
|
||||
subsetSurfaceFields(subsetter, surfVectorNames, surfVectorFlds);
|
||||
|
||||
wordList surfSphericalTensorNames
|
||||
(
|
||||
objects.names(surfaceSphericalTensorField::typeName)
|
||||
);
|
||||
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
||||
(
|
||||
surfSphericalTensorNames.size()
|
||||
);
|
||||
subsetSurfaceFields
|
||||
(
|
||||
subsetter,
|
||||
surfSphericalTensorNames,
|
||||
surfSphericalTensorFlds
|
||||
);
|
||||
|
||||
wordList surfSymmTensorNames
|
||||
(
|
||||
objects.names(surfaceSymmTensorField::typeName)
|
||||
);
|
||||
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
||||
(
|
||||
surfSymmTensorNames.size()
|
||||
);
|
||||
subsetSurfaceFields(subsetter, surfSymmTensorNames, surfSymmTensorFlds);
|
||||
|
||||
wordList surfTensorNames(objects.names(surfaceTensorField::typeName));
|
||||
PtrList<surfaceTensorField> surfTensorFlds(surfTensorNames.size());
|
||||
subsetSurfaceFields(subsetter, surfTensorNames, surfTensorFlds);
|
||||
|
||||
|
||||
|
||||
runTime++;
|
||||
|
||||
Info<< "Writing subsetted mesh and fields to time " << runTime.value()
|
||||
<< endl;
|
||||
subsetter.subMesh().write();
|
||||
|
||||
|
||||
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||
forAll(scalarFlds, i)
|
||||
{
|
||||
scalarFlds[i].rename(scalarNames[i]);
|
||||
|
||||
scalarFlds[i].write();
|
||||
}
|
||||
forAll(vectorFlds, i)
|
||||
{
|
||||
vectorFlds[i].rename(vectorNames[i]);
|
||||
|
||||
vectorFlds[i].write();
|
||||
}
|
||||
forAll(tensorFlds, i)
|
||||
{
|
||||
tensorFlds[i].rename(tensorNames[i]);
|
||||
|
||||
tensorFlds[i].write();
|
||||
}
|
||||
|
||||
// Surface ones.
|
||||
forAll(surfScalarFlds, i)
|
||||
{
|
||||
surfScalarFlds[i].rename(surfScalarNames[i]);
|
||||
|
||||
surfScalarFlds[i].write();
|
||||
}
|
||||
forAll(surfVectorFlds, i)
|
||||
{
|
||||
surfVectorFlds[i].rename(surfVectorNames[i]);
|
||||
|
||||
surfVectorFlds[i].write();
|
||||
}
|
||||
forAll(surfTensorNames, i)
|
||||
{
|
||||
surfTensorFlds[i].rename(surfTensorNames[i]);
|
||||
|
||||
surfTensorFlds[i].write();
|
||||
}
|
||||
|
||||
Info << nl << "End" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user