Merge remote-tracking branch 'origin/master' into feature/procAgglom

This commit is contained in:
mattijs
2013-05-08 12:52:45 +01:00
31 changed files with 1682 additions and 224 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,7 +54,7 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
{ {
if (patchNames_[patchI] == pName) if (patchNames_[patchI] == pName)
{ {
if (patchTypes_[patchI] == pType) if (word(patchDicts_[patchI]["type"]) == pType)
{ {
// Found name and types match // Found name and types match
return patchI; return patchI;
@ -68,7 +68,11 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
} }
// Patch not found. Append to the list // Patch not found. Append to the list
patchTypes_.append(pType); {
OStringStream os;
p.write(os);
patchDicts_.append(dictionary(IStringStream(os.str())()));
}
if (nameFound) if (nameFound)
{ {
@ -121,20 +125,22 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
: :
polyMesh(io), polyMesh(io),
meshMod_(*this), meshMod_(*this),
patchTypes_(2*boundaryMesh().size()),
patchNames_(2*boundaryMesh().size()), patchNames_(2*boundaryMesh().size()),
patchDicts_(2*boundaryMesh().size()),
pointZoneNames_(), pointZoneNames_(),
faceZoneNames_(), faceZoneNames_(),
cellZoneNames_() cellZoneNames_()
{ {
// Insert the original patches into the list // Insert the original patches into the list
wordList curPatchTypes = boundaryMesh().types();
wordList curPatchNames = boundaryMesh().names(); wordList curPatchNames = boundaryMesh().names();
forAll(curPatchTypes, patchI) forAll(boundaryMesh(), patchI)
{ {
patchTypes_.append(curPatchTypes[patchI]); patchNames_.append(boundaryMesh()[patchI].name());
patchNames_.append(curPatchNames[patchI]);
OStringStream os;
boundaryMesh()[patchI].write(os);
patchDicts_.append(dictionary(IStringStream(os.str())()));
} }
// Insert point, face and cell zones into the list // Insert point, face and cell zones into the list
@ -379,7 +385,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
void Foam::mergePolyMesh::merge() void Foam::mergePolyMesh::merge()
{ {
Info<< "patch names: " << patchNames_ << nl Info<< "patch names: " << patchNames_ << nl
<< "patch types: " << patchTypes_ << nl << "patch dicts: " << patchDicts_ << nl
<< "point zone names: " << pointZoneNames_ << nl << "point zone names: " << pointZoneNames_ << nl
<< "face zone names: " << faceZoneNames_ << nl << "face zone names: " << faceZoneNames_ << nl
<< "cell zone names: " << cellZoneNames_ << endl; << "cell zone names: " << cellZoneNames_ << endl;
@ -409,14 +415,16 @@ void Foam::mergePolyMesh::merge()
for (; patchI < patchNames_.size(); patchI++) for (; patchI < patchNames_.size(); patchI++)
{ {
// Add a patch // Add a patch
dictionary dict(patchDicts_[patchI]);
dict.set("nFaces", 0);
dict.set("startFace", endOfLastPatch);
newPatches[patchI] = newPatches[patchI] =
( (
polyPatch::New polyPatch::New
( (
patchTypes_[patchI],
patchNames_[patchI], patchNames_[patchI],
0, dict,
endOfLastPatch,
patchI, patchI,
oldPatches oldPatches
).ptr() ).ptr()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,12 +58,12 @@ class mergePolyMesh
//- Topological change to accumulated all mesh changes //- Topological change to accumulated all mesh changes
polyTopoChange meshMod_; polyTopoChange meshMod_;
//- Patch types
DynamicList<word> patchTypes_;
//- Patch names //- Patch names
DynamicList<word> patchNames_; DynamicList<word> patchNames_;
//- Patch dictionaries
DynamicList<dictionary> patchDicts_;
//- Point zone names //- Point zone names
DynamicList<word> pointZoneNames_; DynamicList<word> pointZoneNames_;

View File

@ -0,0 +1,4 @@
mapLagrangian.C
mapFields.C
EXE = $(FOAM_APPBIN)/mapFieldsNew

View File

@ -0,0 +1,13 @@
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lsampling \
-lmeshTools \
-llagrangian \
-lfiniteVolume \
-lgenericPatchFields

View File

@ -0,0 +1,184 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
InNamespace
Foam
Description
Gets the indices of (source)particles that have been appended to the
target cloud and maps the lagrangian fields accordingly.
\*---------------------------------------------------------------------------*/
#ifndef MapLagrangianFields_H
#define MapLagrangianFields_H
#include "cloud.H"
#include "GeometricField.H"
#include "meshToMeshNew.H"
#include "IOobjectList.H"
#include "CompactIOField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Gets the indices of (source)particles that have been appended to the
// target cloud and maps the lagrangian fields accordingly.
template<class Type>
void MapLagrangianFields
(
const string& cloudName,
const IOobjectList& objects,
const polyMesh& meshTarget,
const labelList& addParticles
)
{
{
IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
forAllIter(IOobjectList, fields, fieldIter)
{
const word& fieldName = fieldIter()->name();
Info<< " mapping lagrangian field " << fieldName << endl;
// Read field (does not need mesh)
IOField<Type> fieldSource(*fieldIter());
// Map
IOField<Type> fieldTarget
(
IOobject
(
fieldName,
meshTarget.time().timeName(),
cloud::prefix/cloudName,
meshTarget,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
addParticles.size()
);
forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
// Write field
fieldTarget.write();
}
}
{
IOobjectList fieldFields =
objects.lookupClass(IOField<Field<Type> >::typeName);
forAllIter(IOobjectList, fieldFields, fieldIter)
{
const word& fieldName = fieldIter()->name();
Info<< " mapping lagrangian fieldField " << fieldName << endl;
// Read field (does not need mesh)
IOField<Field<Type> > fieldSource(*fieldIter());
// Map - use CompactIOField to automatically write in
// compact form for binary format.
CompactIOField<Field<Type>, Type> fieldTarget
(
IOobject
(
fieldName,
meshTarget.time().timeName(),
cloud::prefix/cloudName,
meshTarget,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
addParticles.size()
);
forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
// Write field
fieldTarget.write();
}
}
{
IOobjectList fieldFields =
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
forAllIter(IOobjectList, fieldFields, fieldIter)
{
Info<< " mapping lagrangian fieldField "
<< fieldIter()->name() << endl;
// Read field (does not need mesh)
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
// Map
CompactIOField<Field<Type>, Type> fieldTarget
(
IOobject
(
fieldIter()->name(),
meshTarget.time().timeName(),
cloud::prefix/cloudName,
meshTarget,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
addParticles.size()
);
forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
// Write field
fieldTarget.write();
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
\*---------------------------------------------------------------------------*/
#ifndef MapMeshes_H
#define MapMeshes_H
#include "MapVolFields.H"
#include "mapLagrangian.H"
#include "UnMapped.H"
#include "pointMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<template<class> class CombineOp>
void MapMesh
(
const meshToMeshNew& interp,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
{
const polyMesh& meshSource = interp.srcRegion();
// Search for list of objects for this time
IOobjectList objects(meshSource, meshSource.time().timeName());
// Map volFields
// ~~~~~~~~~~~~~
MapVolFields<scalar>
(
objects,
selectedFields,
interp,
CombineOp<scalar>()
);
MapVolFields<vector>
(
objects,
selectedFields,
interp,
CombineOp<vector>()
);
MapVolFields<sphericalTensor>
(
objects,
selectedFields,
interp,
CombineOp<sphericalTensor>()
);
MapVolFields<symmTensor>
(
objects,
selectedFields,
interp,
CombineOp<symmTensor>()
);
MapVolFields<tensor>
(
objects,
selectedFields,
interp,
CombineOp<tensor>()
);
}
{
const polyMesh& meshTarget = interp.tgtRegion();
// Search for list of target objects for this time
IOobjectList objects(meshTarget, meshTarget.time().timeName());
// Mark surfaceFields as unmapped
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UnMapped<surfaceScalarField>(objects);
UnMapped<surfaceVectorField>(objects);
UnMapped<surfaceSphericalTensorField>(objects);
UnMapped<surfaceSymmTensorField>(objects);
UnMapped<surfaceTensorField>(objects);
// Mark pointFields as unmapped
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UnMapped<pointScalarField>(objects);
UnMapped<pointVectorField>(objects);
UnMapped<pointSphericalTensorField>(objects);
UnMapped<pointSymmTensorField>(objects);
UnMapped<pointTensorField>(objects);
}
if (!noLagrangian)
{
mapLagrangian(interp);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
\*---------------------------------------------------------------------------*/
#ifndef MapConsistentVolFields_H
#define MapConsistentVolFields_H
#include "GeometricField.H"
#include "meshToMeshNew.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type, class CombineOp>
void MapVolFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields,
const meshToMeshNew& interp,
const CombineOp& cop
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& meshSource = static_cast<const fvMesh&>(interp.srcRegion());
const fvMesh& meshTarget = static_cast<const fvMesh&>(interp.tgtRegion());
IOobjectList fields = objects.lookupClass(fieldType::typeName);
forAllIter(IOobjectList, fields, fieldIter)
{
const word& fieldName = fieldIter()->name();
if (selectedFields.empty() || selectedFields.found(fieldName))
{
Info<< " interpolating " << fieldName << endl;
const fieldType fieldSource(*fieldIter(), meshSource);
IOobject targetIO
(
fieldName,
meshTarget.time().timeName(),
meshTarget,
IOobject::MUST_READ
);
if (targetIO.headerOk())
{
fieldType fieldTarget(targetIO, meshTarget);
interp.mapSrcToTgt(fieldSource, cop, fieldTarget);
fieldTarget.write();
}
else
{
targetIO.readOpt() = IOobject::NO_READ;
tmp<fieldType>
tfieldTarget(interp.mapSrcToTgt(fieldSource, cop));
fieldType fieldTarget(targetIO, tfieldTarget);
fieldTarget.write();
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
\*---------------------------------------------------------------------------*/
#ifndef UnMapped_H
#define UnMapped_H
#include "IOobjectList.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
void UnMapped(const IOobjectList& objects)
{
IOobjectList fields = objects.lookupClass(Type::typeName);
forAllConstIter(IOobjectList, fields, fieldIter)
{
mvBak(fieldIter()->objectPath(), "unmapped");
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,11 @@
Info<< "\nCreate databases as time" << endl;
HashTable<string> srcOptions(args.options());
srcOptions.erase("case");
srcOptions.insert("case", fileName(rootDirSource/caseDirSource));
argList argsSrc(args, srcOptions, false, false, false);
Time runTimeSource(Time::controlDictName, argsSrc);
Time runTimeTarget(Time::controlDictName, args);

View File

@ -0,0 +1,343 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
Application
mapFields
Description
Maps volume fields from one mesh to another, reading and
interpolating all fields present in the time directory of both cases.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "meshToMeshNew.H"
#include "processorPolyPatch.H"
#include "MapMeshes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMeshNew::interpolationMethod& mapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Consistently creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMeshNew interp(meshSource, meshTarget, mapMethod);
if (subtract)
{
MapMesh<minusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
else
{
MapMesh<plusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
}
void mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const meshToMeshNew::interpolationMethod& mapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMeshNew interp
(
meshSource,
meshTarget,
mapMethod,
patchMap,
cuttingPatches
);
if (subtract)
{
MapMesh<minusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
else
{
MapMesh<plusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
}
wordList addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
)
{
// Add the processor patches to the cutting list
HashSet<word> cuttingPatchTable;
forAll(cuttingPatches, i)
{
cuttingPatchTable.insert(cuttingPatches[i]);
}
const polyBoundaryMesh& pbm = meshTarget.boundaryMesh();
forAll(pbm, patchI)
{
if (isA<processorPolyPatch>(pbm[patchI]))
{
const word& patchName = pbm[patchI].name();
cuttingPatchTable.insert(patchName);
}
}
return cuttingPatchTable.toc();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"map volume fields from one mesh to another"
);
argList::validArgs.append("sourceCase");
argList::addOption
(
"sourceTime",
"scalar|'latestTime'",
"specify the source time"
);
argList::addOption
(
"sourceRegion",
"word",
"specify the source region"
);
argList::addOption
(
"targetRegion",
"word",
"specify the target region"
);
argList::addBoolOption
(
"consistent",
"source and target geometry and boundary conditions identical"
);
argList::addOption
(
"mapMethod",
"word",
"specify the mapping method"
);
argList::addBoolOption
(
"subtract",
"subtract mapped source from target"
);
argList::addOption
(
"fields",
"list",
"specify a list of fields to be mapped. Eg, '(U T p)' - "
"regular expressions not currently supported"
);
argList::addBoolOption
(
"noLagrangian",
"skip mapping lagrangian positions and fields"
);
argList args(argc, argv);
fileName rootDirTarget(args.rootPath());
fileName caseDirTarget(args.globalCaseName());
const fileName casePath = args[1];
const fileName rootDirSource = casePath.path();
const fileName caseDirSource = casePath.name();
Info<< "Source: " << rootDirSource << " " << caseDirSource << endl;
word sourceRegion = fvMesh::defaultRegion;
if (args.optionFound("sourceRegion"))
{
sourceRegion = args["sourceRegion"];
Info<< "Source region: " << sourceRegion << endl;
}
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl;
word targetRegion = fvMesh::defaultRegion;
if (args.optionFound("targetRegion"))
{
targetRegion = args["targetRegion"];
Info<< "Target region: " << targetRegion << endl;
}
const bool consistent = args.optionFound("consistent");
meshToMeshNew::interpolationMethod mapMethod =
meshToMeshNew::imCellVolumeWeight;
if (args.optionFound("mapMethod"))
{
mapMethod = meshToMeshNew::interpolationMethodNames_[args["mapMethod"]];
Info<< "Mapping method: "
<< meshToMeshNew::interpolationMethodNames_[mapMethod] << endl;
}
const bool subtract = args.optionFound("subtract");
if (subtract)
{
Info<< "Subtracting mapped source field from target" << endl;
}
HashSet<word> selectedFields;
if (args.optionFound("fields"))
{
args.optionLookup("fields")() >> selectedFields;
}
const bool noLagrangian = args.optionFound("noLagrangian");
#include "createTimes.H"
HashTable<word> patchMap;
wordList cuttingPatches;
if (!consistent)
{
IOdictionary mapFieldsDict
(
IOobject
(
"mapFieldsDict",
runTimeTarget.system(),
runTimeTarget,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
mapFieldsDict.lookup("patchMap") >> patchMap;
mapFieldsDict.lookup("cuttingPatches") >> cuttingPatches;
}
#include "setTimeIndex.H"
Info<< "\nCreate meshes\n" << endl;
fvMesh meshSource
(
IOobject
(
sourceRegion,
runTimeSource.timeName(),
runTimeSource
)
);
fvMesh meshTarget
(
IOobject
(
targetRegion,
runTimeTarget.timeName(),
runTimeTarget
)
);
Info<< "Source mesh size: " << meshSource.nCells() << tab
<< "Target mesh size: " << meshTarget.nCells() << nl << endl;
if (consistent)
{
mapConsistentMesh
(
meshSource,
meshTarget,
mapMethod,
subtract,
selectedFields,
noLagrangian
);
}
else
{
mapSubMesh
(
meshSource,
meshTarget,
patchMap,
addProcessorPatches(meshTarget, cuttingPatches),
mapMethod,
subtract,
selectedFields,
noLagrangian
);
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object mapFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// List of pairs of source/target patches for mapping
patchMap
(
lid movingWall
);
// List of target patches cutting the source domain (these need to be
// handled specially e.g. interpolated from internal values)
cuttingPatches
(
fixedWalls
);
// ************************************************************************* //

View File

@ -0,0 +1,303 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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 "MapLagrangianFields.H"
#include "passiveParticleCloud.H"
#include "meshSearch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
static const scalar perturbFactor = 1e-6;
// Special version of findCell that generates a cell guaranteed to be
// compatible with tracking.
static label findCell(const Cloud<passiveParticle>& cloud, const point& pt)
{
label cellI = -1;
label tetFaceI = -1;
label tetPtI = -1;
const polyMesh& mesh = cloud.pMesh();
mesh.findCellFacePt(pt, cellI, tetFaceI, tetPtI);
if (cellI >= 0)
{
return cellI;
}
else
{
// See if particle on face by finding nearest face and shifting
// particle.
meshSearch meshSearcher
(
mesh,
polyMesh::FACEPLANES // no decomposition needed
);
label faceI = meshSearcher.findNearestBoundaryFace(pt);
if (faceI >= 0)
{
const point& cc = mesh.cellCentres()[mesh.faceOwner()[faceI]];
const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
mesh.findCellFacePt(perturbPt, cellI, tetFaceI, tetPtI);
return cellI;
}
}
return -1;
}
void mapLagrangian(const meshToMeshNew& interp)
{
// Determine which particles are in meshTarget
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const polyMesh& meshSource = interp.srcRegion();
const polyMesh& meshTarget = interp.tgtRegion();
const labelListList& sourceToTarget = interp.srcToTgtCellAddr();
const pointField& targetCc = meshTarget.cellCentres();
fileNameList cloudDirs
(
readDir
(
meshSource.time().timePath()/cloud::prefix,
fileName::DIRECTORY
)
);
forAll(cloudDirs, cloudI)
{
// Search for list of lagrangian objects for this time
IOobjectList objects
(
meshSource,
meshSource.time().timeName(),
cloud::prefix/cloudDirs[cloudI]
);
IOobject* positionsPtr = objects.lookup(word("positions"));
if (positionsPtr)
{
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl;
// Read positions & cell
passiveParticleCloud sourceParcels
(
meshSource,
cloudDirs[cloudI],
false
);
Info<< " read " << sourceParcels.size()
<< " parcels from source mesh." << endl;
// Construct empty target cloud
passiveParticleCloud targetParcels
(
meshTarget,
cloudDirs[cloudI],
IDLList<passiveParticle>()
);
particle::TrackingData<passiveParticleCloud> td(targetParcels);
label sourceParticleI = 0;
// Indices of source particles that get added to targetParcels
DynamicList<label> addParticles(sourceParcels.size());
// Unmapped particles
labelHashSet unmappedSource(sourceParcels.size());
// Initial: track from fine-mesh cell centre to particle position
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This requires there to be no boundary in the way.
forAllConstIter(Cloud<passiveParticle>, sourceParcels, iter)
{
bool foundCell = false;
// Assume that cell from read parcel is the correct one...
if (iter().cell() >= 0)
{
const labelList& targetCells =
sourceToTarget[iter().cell()];
// Particle probably in one of the targetcells. Try
// all by tracking from their cell centre to the parcel
// position.
forAll(targetCells, i)
{
// Track from its cellcentre to position to make sure.
autoPtr<passiveParticle> newPtr
(
new passiveParticle
(
meshTarget,
targetCc[targetCells[i]],
targetCells[i]
)
);
passiveParticle& newP = newPtr();
label faceI = newP.track(iter().position(), td);
if (faceI < 0 && newP.cell() >= 0)
{
// Hit position.
foundCell = true;
addParticles.append(sourceParticleI);
targetParcels.addParticle(newPtr.ptr());
break;
}
}
}
if (!foundCell)
{
// Store for closer analysis
unmappedSource.insert(sourceParticleI);
}
sourceParticleI++;
}
Info<< " after meshToMesh addressing found "
<< targetParcels.size()
<< " parcels in target mesh." << endl;
// Do closer inspection for unmapped particles
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (unmappedSource.size())
{
sourceParticleI = 0;
forAllIter(Cloud<passiveParticle>, sourceParcels, iter)
{
if (unmappedSource.found(sourceParticleI))
{
label targetCell =
findCell(targetParcels, iter().position());
if (targetCell >= 0)
{
unmappedSource.erase(sourceParticleI);
addParticles.append(sourceParticleI);
iter().cell() = targetCell;
targetParcels.addParticle
(
sourceParcels.remove(&iter())
);
}
}
sourceParticleI++;
}
}
addParticles.shrink();
Info<< " after additional mesh searching found "
<< targetParcels.size() << " parcels in target mesh." << endl;
if (addParticles.size())
{
IOPosition<passiveParticleCloud>(targetParcels).write();
// addParticles now contains the indices of the sourceMesh
// particles that were appended to the target mesh.
// Map lagrangian fields
// ~~~~~~~~~~~~~~~~~~~~~
MapLagrangianFields<label>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
MapLagrangianFields<scalar>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
MapLagrangianFields<vector>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
MapLagrangianFields<sphericalTensor>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
MapLagrangianFields<symmTensor>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
MapLagrangianFields<tensor>
(
cloudDirs[cloudI],
objects,
meshTarget,
addParticles
);
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 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/>.
InNamespace
Foam
Description
Maps lagrangian positions and fields
SourceFiles
mapLagrangian.C
\*---------------------------------------------------------------------------*/
#ifndef mapLagrangian_H
#define mapLagrangian_H
#include "meshToMeshNew.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Maps lagrangian positions and fields
void mapLagrangian(const meshToMeshNew& interp);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,33 @@
{
instantList sourceTimes = runTimeSource.times();
label sourceTimeIndex = runTimeSource.timeIndex();
if (args.optionFound("sourceTime"))
{
if (args["sourceTime"] == "latestTime")
{
sourceTimeIndex = sourceTimes.size() - 1;
}
else
{
sourceTimeIndex = Time::findClosestTimeIndex
(
sourceTimes,
args.optionRead<scalar>("sourceTime")
);
}
}
else
{
sourceTimeIndex = Time::findClosestTimeIndex
(
sourceTimes,
runTimeTarget.time().value()
);
}
runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex);
Info<< "\nSource time: " << runTimeSource.value()
<< "\nTarget time: " << runTimeTarget.value()
<< endl;
}

View File

@ -373,7 +373,8 @@ Foam::argList::argList
int& argc, int& argc,
char**& argv, char**& argv,
bool checkArgs, bool checkArgs,
bool checkOpts bool checkOpts,
const bool initialise
) )
: :
args_(argc), args_(argc),
@ -405,12 +406,12 @@ Foam::argList::argList
// Check arguments and options, we already have argv[0] // Check arguments and options, we already have argv[0]
int nArgs = 1; int nArgs = 1;
string argListString = args_[0]; argListStr_ = args_[0];
for (int argI = 1; argI < args_.size(); ++argI) for (int argI = 1; argI < args_.size(); ++argI)
{ {
argListString += ' '; argListStr_ += ' ';
argListString += args_[argI]; argListStr_ += args_[argI];
if (args_[argI][0] == '-') if (args_[argI][0] == '-')
{ {
@ -438,8 +439,8 @@ Foam::argList::argList
FatalError.exit(); FatalError.exit();
} }
argListString += ' '; argListStr_ += ' ';
argListString += args_[argI]; argListStr_ += args_[argI];
options_.insert(optionName, args_[argI]); options_.insert(optionName, args_[argI]);
} }
else else
@ -459,6 +460,39 @@ Foam::argList::argList
args_.setSize(nArgs); args_.setSize(nArgs);
parse(checkArgs, checkOpts, initialise);
}
Foam::argList::argList
(
const argList& args,
const HashTable<string>& options,
bool checkArgs,
bool checkOpts,
bool initialise
)
:
args_(args.args_),
options_(options),
executable_(args.executable_),
rootPath_(args.rootPath_),
globalCase_(args.globalCase_),
case_(args.case_),
argListStr_(args.argListStr_),
parRunControl_(args.parRunControl_)
{
parse(checkArgs, checkOpts, initialise);
}
void Foam::argList::parse
(
bool checkArgs,
bool checkOpts,
bool initialise
)
{
// Help/documentation options: // Help/documentation options:
// -help print the usage // -help print the usage
// -doc display application documentation in browser // -doc display application documentation in browser
@ -495,6 +529,8 @@ Foam::argList::argList
} }
if (initialise)
{
string dateString = clock::date(); string dateString = clock::date();
string timeString = clock::clockTime(); string timeString = clock::clockTime();
@ -503,7 +539,7 @@ Foam::argList::argList
{ {
IOobject::writeBanner(Info, true) IOobject::writeBanner(Info, true)
<< "Build : " << Foam::FOAMbuild << nl << "Build : " << Foam::FOAMbuild << nl
<< "Exec : " << argListString.c_str() << nl << "Exec : " << argListStr_.c_str() << nl
<< "Date : " << dateString.c_str() << nl << "Date : " << dateString.c_str() << nl
<< "Time : " << timeString.c_str() << nl << "Time : " << timeString.c_str() << nl
<< "Host : " << hostName() << nl << "Host : " << hostName() << nl
@ -515,7 +551,7 @@ Foam::argList::argList
jobInfo.add("userName", userName()); jobInfo.add("userName", userName());
jobInfo.add("foamVersion", word(FOAMversion)); jobInfo.add("foamVersion", word(FOAMversion));
jobInfo.add("code", executable_); jobInfo.add("code", executable_);
jobInfo.add("argList", argListString); jobInfo.add("argList", argListStr_);
jobInfo.add("currentDir", cwd()); jobInfo.add("currentDir", cwd());
jobInfo.add("PPID", ppid()); jobInfo.add("PPID", ppid());
jobInfo.add("PGID", pgid()); jobInfo.add("PGID", pgid());
@ -530,7 +566,7 @@ Foam::argList::argList
} }
jobInfo.add("foamBuild", build); jobInfo.add("foamBuild", build);
} }
}
// Case is a single processor run unless it is running parallel // Case is a single processor run unless it is running parallel
int nProcs = 1; int nProcs = 1;
@ -781,6 +817,8 @@ Foam::argList::argList
} }
} }
if (initialise)
{
jobInfo.add("root", rootPath_); jobInfo.add("root", rootPath_);
jobInfo.add("case", globalCase_); jobInfo.add("case", globalCase_);
jobInfo.add("nProcs", nProcs); jobInfo.add("nProcs", nProcs);
@ -818,7 +856,8 @@ Foam::argList::argList
} }
else else
{ {
Info<< "Disallowing user-supplied system call operations" << endl; Info<< "Disallowing user-supplied system call operations"
<< endl;
} }
} }
@ -828,6 +867,7 @@ Foam::argList::argList
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
} }
} }
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,7 +41,7 @@ Description
\par Default command-line options \par Default command-line options
\param -case \<dir\> \n \param -case \<dir\> \n
select an case directory instead of the current working directory select a case directory instead of the current working directory
\param -parallel \n \param -parallel \n
specify case as a parallel job specify case as a parallel job
\param -doc \n \param -doc \n
@ -69,6 +69,7 @@ Note
SourceFiles SourceFiles
argList.C argList.C
argListI.H
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -111,6 +112,7 @@ class argList
fileName rootPath_; fileName rootPath_;
fileName globalCase_; fileName globalCase_;
fileName case_; fileName case_;
string argListStr_;
ParRunControl parRunControl_; ParRunControl parRunControl_;
@ -187,7 +189,18 @@ public:
int& argc, int& argc,
char**& argv, char**& argv,
bool checkArgs = true, bool checkArgs = true,
bool checkOpts=true bool checkOpts = true,
bool initialise = true
);
//- Construct copy with new options
argList
(
const argList& args,
const HashTable<string>& options,
bool checkArgs = true,
bool checkOpts = true,
bool initialise = true
); );
@ -197,6 +210,15 @@ public:
// Member functions // Member functions
//- Parse
void parse
(
bool checkArgs,
bool checkOpts,
bool initialise
);
// Access // Access
//- Name of executable without the path //- Name of executable without the path
@ -211,12 +233,18 @@ public:
//- Return case name //- Return case name
inline const fileName& globalCaseName() const; inline const fileName& globalCaseName() const;
//- Return parRunControl
inline const ParRunControl& parRunControl() const;
//- Return the path to the caseName //- Return the path to the caseName
inline fileName path() const; inline fileName path() const;
//- Return arguments //- Return arguments
inline const stringList& args() const; inline const stringList& args() const;
//- Return non-const access to arguments
inline stringList& args();
//- Return the argument corresponding to index. //- Return the argument corresponding to index.
inline const string& arg(const label index) const; inline const string& arg(const label index) const;
@ -240,6 +268,9 @@ public:
//- Return options //- Return options
inline const Foam::HashTable<string>& options() const; inline const Foam::HashTable<string>& options() const;
//- Return non-const access to options
inline Foam::HashTable<string>& options();
//- Return the argument string associated with the named option //- Return the argument string associated with the named option
inline const string& option(const word& opt) const; inline const string& option(const word& opt) const;
@ -295,6 +326,7 @@ public:
// \sa option() // \sa option()
inline const string& operator[](const word& opt) const; inline const string& operator[](const word& opt) const;
// Edit // Edit
//- Add to a bool option to validOptions with usage information //- Add to a bool option to validOptions with usage information

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,6 +51,12 @@ inline const Foam::fileName& Foam::argList::globalCaseName() const
} }
inline const Foam::ParRunControl& Foam::argList::parRunControl() const
{
return parRunControl_;
}
inline Foam::fileName Foam::argList::path() const inline Foam::fileName Foam::argList::path() const
{ {
return rootPath()/caseName(); return rootPath()/caseName();
@ -63,6 +69,12 @@ inline const Foam::stringList& Foam::argList::args() const
} }
inline Foam::stringList& Foam::argList::args()
{
return args_;
}
inline const Foam::string& Foam::argList::arg(const label index) const inline const Foam::string& Foam::argList::arg(const label index) const
{ {
return args_[index]; return args_[index];
@ -81,6 +93,12 @@ inline const Foam::HashTable<Foam::string>& Foam::argList::options() const
} }
inline Foam::HashTable<Foam::string>& Foam::argList::options()
{
return options_;
}
inline const Foam::string& Foam::argList::option(const word& opt) const inline const Foam::string& Foam::argList::option(const word& opt) const
{ {
return options_[opt]; return options_[opt];

View File

@ -190,12 +190,13 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
wghtSum.setSize(wght.size()); wghtSum.setSize(wght.size());
forAll(wght, faceI) forAll(wght, faceI)
{ {
scalar s = sum(wght[faceI]); scalarList& w = wght[faceI];
scalar s = sum(w);
scalar t = s/patchAreas[faceI]; scalar t = s/patchAreas[faceI];
forAll(addr[faceI], i) forAll(w, i)
{ {
wght[faceI][i] /= s; w[i] /= s;
} }
wghtSum[faceI] = t; wghtSum[faceI] = t;

View File

@ -268,7 +268,7 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
) const ) const
{ {
const labelList& nbrFaces = patch.faceFaces()[faceI]; const labelList& nbrFaces = patch.faceFaces()[faceI];
const pointField& tgtPoints = patch.points(); const pointField& points = patch.points();
// filter out faces already visited from src face neighbours // filter out faces already visited from src face neighbours
forAll(nbrFaces, i) forAll(nbrFaces, i)
@ -298,14 +298,13 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
if (valid) if (valid)
{ {
const face& myn = patch[faceI]; const face& f = patch[faceI];
const face& nbrn = patch[nbrFaceI]; const face& nbrF = patch[nbrFaceI];
const vector& nbrNormal = nbrn.normal(tgtPoints); const vector& n = f.normal(points);
const vector& mynNormal = myn.normal(tgtPoints); const vector& nbrN = nbrF.normal(points);
scalar cosI = mag(nbrN & n);
scalar cosI = nbrNormal & mynNormal; if (cosI < Foam::cos(degToRad(89.0)))
if (cosI > Foam::cos(degToRad(89.0)))
{ {
faceIDs.append(nbrFaceI); faceIDs.append(nbrFaceI);
} }

View File

@ -67,7 +67,7 @@ bool Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::processSourceFace
visitedFaces.append(tgtFaceI); visitedFaces.append(tgtFaceI);
scalar area = interArea(srcFaceI, tgtFaceI); scalar area = interArea(srcFaceI, tgtFaceI);
// store when intersection area > 0 // store when intersection fractional area > tolerance
if (area/this->srcMagSf_[srcFaceI] > faceAreaIntersect::tolerance()) if (area/this->srcMagSf_[srcFaceI] > faceAreaIntersect::tolerance())
{ {
srcAddr[srcFaceI].append(tgtFaceI); srcAddr[srcFaceI].append(tgtFaceI);
@ -227,12 +227,9 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea
const face& tgt = this->tgtPatch_[tgtFaceI]; const face& tgt = this->tgtPatch_[tgtFaceI];
// quick reject if either face has zero area // quick reject if either face has zero area
// Note: do not used stored face areas for target patch // Note: do not use stored face areas for target patch
const scalar tgtMag = tgt.mag(tgtPoints); const scalar tgtMag = tgt.mag(tgtPoints);
if if ((this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL))
(
(this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL)
)
{ {
return 0.0; return 0.0;
} }

View File

@ -38,6 +38,16 @@ namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::directMethod::intersect
(
const label srcCellI,
const label tgtCellI
) const
{
return tgt_.pointInCell(src_.cellCentres()[srcCellI], tgtCellI);
}
bool Foam::directMethod::findInitialSeeds bool Foam::directMethod::findInitialSeeds
( (
const labelList& srcCellIDs, const labelList& srcCellIDs,

View File

@ -56,9 +56,16 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Return the true if cells intersect
virtual bool intersect
(
const label srcCellI,
const label tgtCellI
) const;
//- Find indices of overlapping cells in src and tgt meshes - returns //- Find indices of overlapping cells in src and tgt meshes - returns
// true if found a matching pair // true if found a matching pair
bool findInitialSeeds virtual bool findInitialSeeds
( (
const labelList& srcCellIDs, const labelList& srcCellIDs,
const boolList& mapFlag, const boolList& mapFlag,
@ -68,7 +75,7 @@ protected:
) const; ) const;
//- Calculate the mesh-to-mesh addressing and weights //- Calculate the mesh-to-mesh addressing and weights
void calculateAddressing virtual void calculateAddressing
( (
labelListList& srcToTgtCellAddr, labelListList& srcToTgtCellAddr,
scalarListList& srcToTgtCellWght, scalarListList& srcToTgtCellWght,
@ -82,7 +89,7 @@ protected:
); );
//- Append to list of src mesh seed indices //- Append to list of src mesh seed indices
void appendToDirectSeeds virtual void appendToDirectSeeds
( (
boolList& mapFlag, boolList& mapFlag,
labelList& srcTgtSeed, labelList& srcTgtSeed,

View File

@ -58,7 +58,7 @@ protected:
//- Find indices of overlapping cells in src and tgt meshes - returns //- Find indices of overlapping cells in src and tgt meshes - returns
// true if found a matching pair // true if found a matching pair
bool findInitialSeeds virtual bool findInitialSeeds
( (
const labelList& srcCellIDs, const labelList& srcCellIDs,
const boolList& mapFlag, const boolList& mapFlag,
@ -68,7 +68,7 @@ protected:
) const; ) const;
//- Calculate the mesh-to-mesh addressing and weights //- Calculate the mesh-to-mesh addressing and weights
void calculateAddressing virtual void calculateAddressing
( (
labelListList& srcToTgtCellAddr, labelListList& srcToTgtCellAddr,
scalarListList& srcToTgtCellWght, scalarListList& srcToTgtCellWght,
@ -82,7 +82,7 @@ protected:
); );
//- Find the nearest cell on mesh2 for cell1 on mesh1 //- Find the nearest cell on mesh2 for cell1 on mesh1
void findNearestCell virtual void findNearestCell
( (
const polyMesh& mesh1, const polyMesh& mesh1,
const polyMesh& mesh2, const polyMesh& mesh2,
@ -91,7 +91,7 @@ protected:
) const; ) const;
//- Set the next cells for the marching front algorithm //- Set the next cells for the marching front algorithm
void setNextNearestCells virtual void setNextNearestCells
( (
label& startSeedI, label& startSeedI,
label& srcCellI, label& srcCellI,
@ -101,7 +101,7 @@ protected:
) const; ) const;
//- Find a source cell mapped to target cell tgtCellI //- Find a source cell mapped to target cell tgtCellI
label findMappedSrcCell virtual label findMappedSrcCell
( (
const label tgtCellI, const label tgtCellI,
const List<DynamicList<label> >& tgtToSrc const List<DynamicList<label> >& tgtToSrc

View File

@ -72,13 +72,21 @@ protected:
labelList maskCells() const; labelList maskCells() const;
//- Return the true if cells intersect //- Return the true if cells intersect
bool intersect(const label srcCellI, const label tgtCellI) const; virtual bool intersect
(
const label srcCellI,
const label tgtCellI
) const;
//- Return the intersection volume between two cells //- Return the intersection volume between two cells
scalar interVol(const label srcCellI, const label tgtCellI) const; virtual scalar interVol
(
const label srcCellI,
const label tgtCellI
) const;
//- Append target cell neihgbour cells to cellIDs list //- Append target cell neihgbour cells to cellIDs list
void appendNbrCells virtual void appendNbrCells
( (
const label tgtCellI, const label tgtCellI,
const polyMesh& mesh, const polyMesh& mesh,
@ -86,7 +94,7 @@ protected:
DynamicList<label>& nbrTgtCellIDs DynamicList<label>& nbrTgtCellIDs
) const; ) const;
bool initialise virtual bool initialise
( (
labelListList& srcToTgtAddr, labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght, scalarListList& srcToTgtWght,

View File

@ -93,7 +93,6 @@ Foam::labelList Foam::meshToMeshNew::maskCells
void Foam::meshToMeshNew::normaliseWeights void Foam::meshToMeshNew::normaliseWeights
( (
const word& descriptor, const word& descriptor,
const scalarField& cellVolumes,
const labelListList& addr, const labelListList& addr,
scalarListList& wght scalarListList& wght
) const ) const
@ -102,27 +101,18 @@ void Foam::meshToMeshNew::normaliseWeights
if (nCell > 0) if (nCell > 0)
{ {
scalar minW = GREAT;
scalar maxW = -GREAT;
forAll(wght, cellI) forAll(wght, cellI)
{ {
scalarList& w = wght[cellI]; scalarList& w = wght[cellI];
scalar s = sum(w); scalar s = sum(w);
scalar Vc = cellVolumes[cellI];
forAll(w, i) forAll(w, i)
{ {
w[i] /= Vc; // note: normalise by s instead of cell volume since
// 1-to-1 methods duplicate contributions in parallel
w[i] /= s;
} }
minW = min(minW, s/Vc);
maxW = max(maxW, s/Vc);
} }
Info<< " " << descriptor << " weights min/max = "
<< returnReduce(minW, minOp<scalar>()) << ", "
<< returnReduce(maxW, maxOp<scalar>()) << endl;
} }
} }
@ -303,7 +293,6 @@ void Foam::meshToMeshNew::calculate()
normaliseWeights normaliseWeights
( (
"source", "source",
srcRegion_.cellVolumes(),
srcToTgtCellAddr_, srcToTgtCellAddr_,
srcToTgtCellWght_ srcToTgtCellWght_
); );
@ -311,7 +300,6 @@ void Foam::meshToMeshNew::calculate()
normaliseWeights normaliseWeights
( (
"target", "target",
tgtRegion_.cellVolumes(),
tgtToSrcCellAddr_, tgtToSrcCellAddr_,
tgtToSrcCellWght_ tgtToSrcCellWght_
); );
@ -337,7 +325,6 @@ void Foam::meshToMeshNew::calculate()
normaliseWeights normaliseWeights
( (
"source", "source",
srcRegion_.cellVolumes(),
srcToTgtCellAddr_, srcToTgtCellAddr_,
srcToTgtCellWght_ srcToTgtCellWght_
); );
@ -345,7 +332,6 @@ void Foam::meshToMeshNew::calculate()
normaliseWeights normaliseWeights
( (
"target", "target",
tgtRegion_.cellVolumes(),
tgtToSrcCellAddr_, tgtToSrcCellAddr_,
tgtToSrcCellWght_ tgtToSrcCellWght_
); );
@ -461,6 +447,7 @@ Foam::meshToMeshNew::meshToMeshNew
srcPatchID_(), srcPatchID_(),
tgtPatchID_(), tgtPatchID_(),
patchAMIs_(), patchAMIs_(),
cuttingPatches_(),
srcToTgtCellAddr_(), srcToTgtCellAddr_(),
tgtToSrcCellAddr_(), tgtToSrcCellAddr_(),
srcToTgtCellWght_(), srcToTgtCellWght_(),
@ -476,7 +463,22 @@ Foam::meshToMeshNew::meshToMeshNew
const polyBoundaryMesh& srcBM = src.boundaryMesh(); const polyBoundaryMesh& srcBM = src.boundaryMesh();
const polyBoundaryMesh& tgtBM = tgt.boundaryMesh(); const polyBoundaryMesh& tgtBM = tgt.boundaryMesh();
if (srcBM.size() != tgtBM.size()) DynamicList<label> srcPatchID(src.boundaryMesh().size());
DynamicList<label> tgtPatchID(tgt.boundaryMesh().size());
forAll(srcBM, patchI)
{
const polyPatch& pp = srcBM[patchI];
if (!polyPatch::constraintType(pp.type()))
{
srcPatchID.append(pp.index());
label tgtPatchI = tgt.boundaryMesh().findPatchID(pp.name());
if (tgtPatchI != -1)
{
tgtPatchID.append(tgtPatchI);
}
else
{ {
FatalErrorIn FatalErrorIn
( (
@ -484,26 +486,19 @@ Foam::meshToMeshNew::meshToMeshNew
"(" "("
"const polyMesh&, " "const polyMesh&, "
"const polyMesh&, " "const polyMesh&, "
"const interpolationMethod&" "const interpolationMethod&, "
"bool"
")" ")"
) << "Source and target meshes are dissimiar:" << nl ) << "Source patch " << pp.name()
<< " Source patches: " << srcBM.size() << nl << " not found in target mesh. "
<< " Target patches: " << tgtBM.size() << exit(FatalError); << "Available target patches are " << tgtBM.names()
<< exit(FatalError);
} }
DynamicList<label> patchID(src.boundaryMesh().size());
forAll(srcBM, patchI)
{
const polyPatch& pp = srcBM[patchI];
if (!polyPatch::constraintType(pp.type()))
{
patchID.append(pp.index());
} }
} }
srcPatchID_.transfer(patchID); srcPatchID_.transfer(srcPatchID);
tgtPatchID_ = srcPatchID_; tgtPatchID_.transfer(tgtPatchID);
} }
// calculate volume addressing and weights // calculate volume addressing and weights
@ -519,7 +514,8 @@ Foam::meshToMeshNew::meshToMeshNew
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const interpolationMethod& method, const interpolationMethod& method,
const HashTable<word>& patchMap const HashTable<word>& patchMap,
const wordList& cuttingPatches
) )
: :
srcRegion_(src), srcRegion_(src),
@ -527,6 +523,7 @@ Foam::meshToMeshNew::meshToMeshNew
srcPatchID_(), srcPatchID_(),
tgtPatchID_(), tgtPatchID_(),
patchAMIs_(), patchAMIs_(),
cuttingPatches_(),
srcToTgtCellAddr_(), srcToTgtCellAddr_(),
tgtToSrcCellAddr_(), tgtToSrcCellAddr_(),
srcToTgtCellWght_(), srcToTgtCellWght_(),
@ -559,6 +556,14 @@ Foam::meshToMeshNew::meshToMeshNew
// calculate patch addressing and weights // calculate patch addressing and weights
(void)patchAMIs(); (void)patchAMIs();
// set IDs of cutting patches on target mesh
cuttingPatches_.setSize(cuttingPatches.size());
forAll(cuttingPatches_, i)
{
const word& patchName = cuttingPatches[i];
cuttingPatches_[i] = tgt.boundaryMesh().findPatchID(patchName);
}
} }

View File

@ -94,6 +94,9 @@ private:
//- List of AMIs between source and target patches //- List of AMIs between source and target patches
mutable PtrList<AMIPatchToPatchInterpolation> patchAMIs_; mutable PtrList<AMIPatchToPatchInterpolation> patchAMIs_;
//- Cutting patches whose values are set using a zero-gradient condition
List<label> cuttingPatches_;
//- Source to target cell addressing //- Source to target cell addressing
labelListList srcToTgtCellAddr_; labelListList srcToTgtCellAddr_;
@ -136,7 +139,6 @@ private:
void normaliseWeights void normaliseWeights
( (
const word& descriptor, const word& descriptor,
const scalarField& cellVolumes,
const labelListList& addr, const labelListList& addr,
scalarListList& wght scalarListList& wght
) const; ) const;
@ -242,7 +244,8 @@ public:
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const interpolationMethod& method, const interpolationMethod& method,
const HashTable<word>& patchMap const HashTable<word>& patchMap,
const wordList& cuttingPatches
); );

View File

@ -336,9 +336,6 @@ void Foam::meshToMeshNew::mapSrcToTgt
GeometricField<Type, fvPatchField, volMesh>& result GeometricField<Type, fvPatchField, volMesh>& result
) const ) const
{ {
// clear any previously stored values
mapSrcToTgt(field, cop, result.internalField()); mapSrcToTgt(field, cop, result.internalField());
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs(); const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
@ -360,6 +357,13 @@ void Foam::meshToMeshNew::mapSrcToTgt
tgtField tgtField
); );
} }
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
pf == pf.patchInternalField();
}
} }
@ -466,6 +470,13 @@ void Foam::meshToMeshNew::mapTgtToSrc
srcField srcField
); );
} }
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
pf == pf.patchInternalField();
}
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,8 +52,12 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
// Print patch names as comment // Print patch names as comment
forAll(myPatches, patchI) forAll(myPatches, patchI)
{ {
os << "# " << patchI << " " const surfacePatch& patch = myPatches[patchI];
<< myPatches[patchI].name() << nl;
if (patch.size() > 0)
{
os << "# " << patchI << " " << patch.name() << nl;
}
} }
os << "#" << nl; os << "#" << nl;
@ -77,14 +81,17 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
forAll(myPatches, patchI) forAll(myPatches, patchI)
{ {
// Print all faces belonging to this patch const surfacePatch& patch = myPatches[patchI];
os << "g " << myPatches[patchI].name() << nl; // Print all faces belonging to this patch
if (patch.size() > 0)
{
os << "g " << patch.name() << nl;
for for
( (
label patchFaceI = 0; label patchFaceI = 0;
patchFaceI < myPatches[patchI].size(); patchFaceI < patch.size();
patchFaceI++ patchFaceI++
) )
{ {
@ -99,6 +106,7 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
} }
} }
} }
}
else else
{ {
// Get patch (=compact region) per face // Get patch (=compact region) per face

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,6 +43,8 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
// Print all faces belonging to this region // Print all faces belonging to this region
const surfacePatch& patch = myPatches[patchI]; const surfacePatch& patch = myPatches[patchI];
if (patch.size() > 0)
{
os << "solid " << patch.name() << endl; os << "solid " << patch.name() << endl;
for for
@ -78,6 +80,7 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
os << "endsolid " << patch.name() << endl; os << "endsolid " << patch.name() << endl;
} }
} }
}
void Foam::triSurface::writeSTLBINARY(std::ostream& os) const void Foam::triSurface::writeSTLBINARY(std::ostream& os) const

View File

@ -51,6 +51,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(true), baffleActivated_(true),
thickness_(p.size()), thickness_(p.size()),
Qs_(p.size()), Qs_(p.size()),
solidDict_(),
solidPtr_(NULL) solidPtr_(NULL)
{} {}
@ -70,6 +71,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
@ -88,6 +90,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(readBool(dict.lookup("baffleActivated"))), baffleActivated_(readBool(dict.lookup("baffleActivated"))),
thickness_(scalarField("thickness", dict, p.size())), thickness_(scalarField("thickness", dict, p.size())),
Qs_(scalarField("Qs", dict, p.size())), Qs_(scalarField("Qs", dict, p.size())),
solidDict_(dict),
solidPtr_(new solidType(dict)) solidPtr_(new solidType(dict))
{ {
if (!isA<mappedPatchBase>(this->patch().patch())) if (!isA<mappedPatchBase>(this->patch().patch()))
@ -141,6 +144,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
@ -158,12 +162,28 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class solidType>
const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solidPtr() const
{
if (!solidPtr_.empty())
{
return solidPtr_();
}
else
{
solidPtr_.reset(new solidType(solidDict_));
return solidPtr_();
}
}
template<class solidType> template<class solidType>
void thermalBaffle1DFvPatchScalarField<solidType>::autoMap void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
( (
@ -171,6 +191,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
) )
{ {
mixedFvPatchScalarField::autoMap(m); mixedFvPatchScalarField::autoMap(m);
thickness_.autoMap(m);
Qs_.autoMap(m);
} }
template<class solidType> template<class solidType>
@ -181,6 +203,12 @@ void thermalBaffle1DFvPatchScalarField<solidType>::rmap
) )
{ {
mixedFvPatchScalarField::rmap(ptf, addr); mixedFvPatchScalarField::rmap(ptf, addr);
const thermalBaffle1DFvPatchScalarField& tiptf =
refCast<const thermalBaffle1DFvPatchScalarField>(ptf);
thickness_.rmap(tiptf.thickness_, addr);
Qs_.rmap(tiptf.Qs_, addr);
} }
@ -264,7 +292,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
forAll(KDeltaw, i) forAll(KDeltaw, i)
{ {
KDeltaw[i] = KDeltaw[i] =
solidPtr_().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i]; solidPtr().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i];
} }
const scalarField q const scalarField q
@ -338,8 +366,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
} }
template<class solidType> template<class solidType>
void thermalBaffle1DFvPatchScalarField<solidType>:: void thermalBaffle1DFvPatchScalarField<solidType>:: write(Ostream& os) const
write(Ostream& os) const
{ {
mixedFvPatchScalarField::write(os); mixedFvPatchScalarField::write(os);
os.writeKeyword("TName") os.writeKeyword("TName")
@ -348,7 +375,7 @@ write(Ostream& os) const
os.writeKeyword("baffleActivated") os.writeKeyword("baffleActivated")
<< baffleActivated_ << token::END_STATEMENT << nl; << baffleActivated_ << token::END_STATEMENT << nl;
Qs_.writeEntry("Qs", os); Qs_.writeEntry("Qs", os);
solidPtr_->write(os); solidPtr().write(os);
} }

View File

@ -70,8 +70,17 @@ class thermalBaffle1DFvPatchScalarField
//- Superficial heat source [W/m2] //- Superficial heat source [W/m2]
scalarField Qs_; scalarField Qs_;
// Solid thermo //- Solid dictionary
autoPtr<solidType> solidPtr_; dictionary solidDict_;
//- Solid thermo
mutable autoPtr<solidType> solidPtr_;
// Private members
//- Return non const solid thermo autoMap
const solidType& solidPtr() const;
public: public:
@ -144,6 +153,7 @@ public:
// Member functions // Member functions
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object //- Map (and resize as needed) from self given a mapping object
@ -160,6 +170,8 @@ public:
); );
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();