mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge remote-tracking branch 'origin/master' into feature/procAgglom
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,7 +54,7 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
|
||||
{
|
||||
if (patchNames_[patchI] == pName)
|
||||
{
|
||||
if (patchTypes_[patchI] == pType)
|
||||
if (word(patchDicts_[patchI]["type"]) == pType)
|
||||
{
|
||||
// Found name and types match
|
||||
return patchI;
|
||||
@ -68,7 +68,11 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
|
||||
}
|
||||
|
||||
// Patch not found. Append to the list
|
||||
patchTypes_.append(pType);
|
||||
{
|
||||
OStringStream os;
|
||||
p.write(os);
|
||||
patchDicts_.append(dictionary(IStringStream(os.str())()));
|
||||
}
|
||||
|
||||
if (nameFound)
|
||||
{
|
||||
@ -121,20 +125,22 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
|
||||
:
|
||||
polyMesh(io),
|
||||
meshMod_(*this),
|
||||
patchTypes_(2*boundaryMesh().size()),
|
||||
patchNames_(2*boundaryMesh().size()),
|
||||
patchDicts_(2*boundaryMesh().size()),
|
||||
pointZoneNames_(),
|
||||
faceZoneNames_(),
|
||||
cellZoneNames_()
|
||||
{
|
||||
// Insert the original patches into the list
|
||||
wordList curPatchTypes = boundaryMesh().types();
|
||||
wordList curPatchNames = boundaryMesh().names();
|
||||
|
||||
forAll(curPatchTypes, patchI)
|
||||
forAll(boundaryMesh(), patchI)
|
||||
{
|
||||
patchTypes_.append(curPatchTypes[patchI]);
|
||||
patchNames_.append(curPatchNames[patchI]);
|
||||
patchNames_.append(boundaryMesh()[patchI].name());
|
||||
|
||||
OStringStream os;
|
||||
boundaryMesh()[patchI].write(os);
|
||||
patchDicts_.append(dictionary(IStringStream(os.str())()));
|
||||
}
|
||||
|
||||
// Insert point, face and cell zones into the list
|
||||
@ -379,7 +385,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
|
||||
void Foam::mergePolyMesh::merge()
|
||||
{
|
||||
Info<< "patch names: " << patchNames_ << nl
|
||||
<< "patch types: " << patchTypes_ << nl
|
||||
<< "patch dicts: " << patchDicts_ << nl
|
||||
<< "point zone names: " << pointZoneNames_ << nl
|
||||
<< "face zone names: " << faceZoneNames_ << nl
|
||||
<< "cell zone names: " << cellZoneNames_ << endl;
|
||||
@ -409,14 +415,16 @@ void Foam::mergePolyMesh::merge()
|
||||
for (; patchI < patchNames_.size(); patchI++)
|
||||
{
|
||||
// Add a patch
|
||||
dictionary dict(patchDicts_[patchI]);
|
||||
dict.set("nFaces", 0);
|
||||
dict.set("startFace", endOfLastPatch);
|
||||
|
||||
newPatches[patchI] =
|
||||
(
|
||||
polyPatch::New
|
||||
(
|
||||
patchTypes_[patchI],
|
||||
patchNames_[patchI],
|
||||
0,
|
||||
endOfLastPatch,
|
||||
dict,
|
||||
patchI,
|
||||
oldPatches
|
||||
).ptr()
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,12 +58,12 @@ class mergePolyMesh
|
||||
//- Topological change to accumulated all mesh changes
|
||||
polyTopoChange meshMod_;
|
||||
|
||||
//- Patch types
|
||||
DynamicList<word> patchTypes_;
|
||||
|
||||
//- Patch names
|
||||
DynamicList<word> patchNames_;
|
||||
|
||||
//- Patch dictionaries
|
||||
DynamicList<dictionary> patchDicts_;
|
||||
|
||||
//- Point zone names
|
||||
DynamicList<word> pointZoneNames_;
|
||||
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
mapLagrangian.C
|
||||
mapFields.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/mapFieldsNew
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
131
applications/utilities/preProcessing/mapFieldsNew/MapMeshes.H
Normal file
131
applications/utilities/preProcessing/mapFieldsNew/MapMeshes.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
104
applications/utilities/preProcessing/mapFieldsNew/MapVolFields.H
Normal file
104
applications/utilities/preProcessing/mapFieldsNew/MapVolFields.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
57
applications/utilities/preProcessing/mapFieldsNew/UnMapped.H
Normal file
57
applications/utilities/preProcessing/mapFieldsNew/UnMapped.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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);
|
||||
343
applications/utilities/preProcessing/mapFieldsNew/mapFields.C
Normal file
343
applications/utilities/preProcessing/mapFieldsNew/mapFields.C
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
@ -373,7 +373,8 @@ Foam::argList::argList
|
||||
int& argc,
|
||||
char**& argv,
|
||||
bool checkArgs,
|
||||
bool checkOpts
|
||||
bool checkOpts,
|
||||
const bool initialise
|
||||
)
|
||||
:
|
||||
args_(argc),
|
||||
@ -405,12 +406,12 @@ Foam::argList::argList
|
||||
|
||||
// Check arguments and options, we already have argv[0]
|
||||
int nArgs = 1;
|
||||
string argListString = args_[0];
|
||||
argListStr_ = args_[0];
|
||||
|
||||
for (int argI = 1; argI < args_.size(); ++argI)
|
||||
{
|
||||
argListString += ' ';
|
||||
argListString += args_[argI];
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argI];
|
||||
|
||||
if (args_[argI][0] == '-')
|
||||
{
|
||||
@ -438,8 +439,8 @@ Foam::argList::argList
|
||||
FatalError.exit();
|
||||
}
|
||||
|
||||
argListString += ' ';
|
||||
argListString += args_[argI];
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argI];
|
||||
options_.insert(optionName, args_[argI]);
|
||||
}
|
||||
else
|
||||
@ -459,6 +460,39 @@ Foam::argList::argList
|
||||
|
||||
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 print the usage
|
||||
// -doc display application documentation in browser
|
||||
@ -495,6 +529,8 @@ Foam::argList::argList
|
||||
}
|
||||
|
||||
|
||||
if (initialise)
|
||||
{
|
||||
string dateString = clock::date();
|
||||
string timeString = clock::clockTime();
|
||||
|
||||
@ -503,7 +539,7 @@ Foam::argList::argList
|
||||
{
|
||||
IOobject::writeBanner(Info, true)
|
||||
<< "Build : " << Foam::FOAMbuild << nl
|
||||
<< "Exec : " << argListString.c_str() << nl
|
||||
<< "Exec : " << argListStr_.c_str() << nl
|
||||
<< "Date : " << dateString.c_str() << nl
|
||||
<< "Time : " << timeString.c_str() << nl
|
||||
<< "Host : " << hostName() << nl
|
||||
@ -515,7 +551,7 @@ Foam::argList::argList
|
||||
jobInfo.add("userName", userName());
|
||||
jobInfo.add("foamVersion", word(FOAMversion));
|
||||
jobInfo.add("code", executable_);
|
||||
jobInfo.add("argList", argListString);
|
||||
jobInfo.add("argList", argListStr_);
|
||||
jobInfo.add("currentDir", cwd());
|
||||
jobInfo.add("PPID", ppid());
|
||||
jobInfo.add("PGID", pgid());
|
||||
@ -530,7 +566,7 @@ Foam::argList::argList
|
||||
}
|
||||
jobInfo.add("foamBuild", build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Case is a single processor run unless it is running parallel
|
||||
int nProcs = 1;
|
||||
@ -781,6 +817,8 @@ Foam::argList::argList
|
||||
}
|
||||
}
|
||||
|
||||
if (initialise)
|
||||
{
|
||||
jobInfo.add("root", rootPath_);
|
||||
jobInfo.add("case", globalCase_);
|
||||
jobInfo.add("nProcs", nProcs);
|
||||
@ -818,7 +856,8 @@ Foam::argList::argList
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -41,7 +41,7 @@ Description
|
||||
|
||||
\par Default command-line options
|
||||
\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
|
||||
specify case as a parallel job
|
||||
\param -doc \n
|
||||
@ -69,6 +69,7 @@ Note
|
||||
|
||||
SourceFiles
|
||||
argList.C
|
||||
argListI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -111,6 +112,7 @@ class argList
|
||||
fileName rootPath_;
|
||||
fileName globalCase_;
|
||||
fileName case_;
|
||||
string argListStr_;
|
||||
|
||||
ParRunControl parRunControl_;
|
||||
|
||||
@ -187,7 +189,18 @@ public:
|
||||
int& argc,
|
||||
char**& argv,
|
||||
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
|
||||
|
||||
//- Parse
|
||||
void parse
|
||||
(
|
||||
bool checkArgs,
|
||||
bool checkOpts,
|
||||
bool initialise
|
||||
);
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Name of executable without the path
|
||||
@ -211,12 +233,18 @@ public:
|
||||
//- Return case name
|
||||
inline const fileName& globalCaseName() const;
|
||||
|
||||
//- Return parRunControl
|
||||
inline const ParRunControl& parRunControl() const;
|
||||
|
||||
//- Return the path to the caseName
|
||||
inline fileName path() const;
|
||||
|
||||
//- Return arguments
|
||||
inline const stringList& args() const;
|
||||
|
||||
//- Return non-const access to arguments
|
||||
inline stringList& args();
|
||||
|
||||
//- Return the argument corresponding to index.
|
||||
inline const string& arg(const label index) const;
|
||||
|
||||
@ -240,6 +268,9 @@ public:
|
||||
//- Return options
|
||||
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
|
||||
inline const string& option(const word& opt) const;
|
||||
|
||||
@ -295,6 +326,7 @@ public:
|
||||
// \sa option()
|
||||
inline const string& operator[](const word& opt) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Add to a bool option to validOptions with usage information
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return options_[opt];
|
||||
|
||||
@ -190,12 +190,13 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
|
||||
wghtSum.setSize(wght.size());
|
||||
forAll(wght, faceI)
|
||||
{
|
||||
scalar s = sum(wght[faceI]);
|
||||
scalarList& w = wght[faceI];
|
||||
scalar s = sum(w);
|
||||
scalar t = s/patchAreas[faceI];
|
||||
|
||||
forAll(addr[faceI], i)
|
||||
forAll(w, i)
|
||||
{
|
||||
wght[faceI][i] /= s;
|
||||
w[i] /= s;
|
||||
}
|
||||
|
||||
wghtSum[faceI] = t;
|
||||
|
||||
@ -268,7 +268,7 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
|
||||
) const
|
||||
{
|
||||
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
|
||||
forAll(nbrFaces, i)
|
||||
@ -298,14 +298,13 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::appendNbrFaces
|
||||
|
||||
if (valid)
|
||||
{
|
||||
const face& myn = patch[faceI];
|
||||
const face& nbrn = patch[nbrFaceI];
|
||||
const vector& nbrNormal = nbrn.normal(tgtPoints);
|
||||
const vector& mynNormal = myn.normal(tgtPoints);
|
||||
const face& f = patch[faceI];
|
||||
const face& nbrF = patch[nbrFaceI];
|
||||
const vector& n = f.normal(points);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ bool Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::processSourceFace
|
||||
visitedFaces.append(tgtFaceI);
|
||||
scalar area = interArea(srcFaceI, tgtFaceI);
|
||||
|
||||
// store when intersection area > 0
|
||||
// store when intersection fractional area > tolerance
|
||||
if (area/this->srcMagSf_[srcFaceI] > faceAreaIntersect::tolerance())
|
||||
{
|
||||
srcAddr[srcFaceI].append(tgtFaceI);
|
||||
@ -227,12 +227,9 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea
|
||||
const face& tgt = this->tgtPatch_[tgtFaceI];
|
||||
|
||||
// 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);
|
||||
if
|
||||
(
|
||||
(this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL)
|
||||
)
|
||||
if ((this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL))
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -38,6 +38,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * 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
|
||||
(
|
||||
const labelList& srcCellIDs,
|
||||
|
||||
@ -56,9 +56,16 @@ protected:
|
||||
|
||||
// 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
|
||||
// true if found a matching pair
|
||||
bool findInitialSeeds
|
||||
virtual bool findInitialSeeds
|
||||
(
|
||||
const labelList& srcCellIDs,
|
||||
const boolList& mapFlag,
|
||||
@ -68,7 +75,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Calculate the mesh-to-mesh addressing and weights
|
||||
void calculateAddressing
|
||||
virtual void calculateAddressing
|
||||
(
|
||||
labelListList& srcToTgtCellAddr,
|
||||
scalarListList& srcToTgtCellWght,
|
||||
@ -82,7 +89,7 @@ protected:
|
||||
);
|
||||
|
||||
//- Append to list of src mesh seed indices
|
||||
void appendToDirectSeeds
|
||||
virtual void appendToDirectSeeds
|
||||
(
|
||||
boolList& mapFlag,
|
||||
labelList& srcTgtSeed,
|
||||
|
||||
@ -58,7 +58,7 @@ protected:
|
||||
|
||||
//- Find indices of overlapping cells in src and tgt meshes - returns
|
||||
// true if found a matching pair
|
||||
bool findInitialSeeds
|
||||
virtual bool findInitialSeeds
|
||||
(
|
||||
const labelList& srcCellIDs,
|
||||
const boolList& mapFlag,
|
||||
@ -68,7 +68,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Calculate the mesh-to-mesh addressing and weights
|
||||
void calculateAddressing
|
||||
virtual void calculateAddressing
|
||||
(
|
||||
labelListList& srcToTgtCellAddr,
|
||||
scalarListList& srcToTgtCellWght,
|
||||
@ -82,7 +82,7 @@ protected:
|
||||
);
|
||||
|
||||
//- Find the nearest cell on mesh2 for cell1 on mesh1
|
||||
void findNearestCell
|
||||
virtual void findNearestCell
|
||||
(
|
||||
const polyMesh& mesh1,
|
||||
const polyMesh& mesh2,
|
||||
@ -91,7 +91,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Set the next cells for the marching front algorithm
|
||||
void setNextNearestCells
|
||||
virtual void setNextNearestCells
|
||||
(
|
||||
label& startSeedI,
|
||||
label& srcCellI,
|
||||
@ -101,7 +101,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Find a source cell mapped to target cell tgtCellI
|
||||
label findMappedSrcCell
|
||||
virtual label findMappedSrcCell
|
||||
(
|
||||
const label tgtCellI,
|
||||
const List<DynamicList<label> >& tgtToSrc
|
||||
|
||||
@ -72,13 +72,21 @@ protected:
|
||||
labelList maskCells() const;
|
||||
|
||||
//- 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
|
||||
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
|
||||
void appendNbrCells
|
||||
virtual void appendNbrCells
|
||||
(
|
||||
const label tgtCellI,
|
||||
const polyMesh& mesh,
|
||||
@ -86,7 +94,7 @@ protected:
|
||||
DynamicList<label>& nbrTgtCellIDs
|
||||
) const;
|
||||
|
||||
bool initialise
|
||||
virtual bool initialise
|
||||
(
|
||||
labelListList& srcToTgtAddr,
|
||||
scalarListList& srcToTgtWght,
|
||||
|
||||
@ -93,7 +93,6 @@ Foam::labelList Foam::meshToMeshNew::maskCells
|
||||
void Foam::meshToMeshNew::normaliseWeights
|
||||
(
|
||||
const word& descriptor,
|
||||
const scalarField& cellVolumes,
|
||||
const labelListList& addr,
|
||||
scalarListList& wght
|
||||
) const
|
||||
@ -102,27 +101,18 @@ void Foam::meshToMeshNew::normaliseWeights
|
||||
|
||||
if (nCell > 0)
|
||||
{
|
||||
scalar minW = GREAT;
|
||||
scalar maxW = -GREAT;
|
||||
|
||||
forAll(wght, cellI)
|
||||
{
|
||||
scalarList& w = wght[cellI];
|
||||
scalar s = sum(w);
|
||||
scalar Vc = cellVolumes[cellI];
|
||||
|
||||
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
|
||||
(
|
||||
"source",
|
||||
srcRegion_.cellVolumes(),
|
||||
srcToTgtCellAddr_,
|
||||
srcToTgtCellWght_
|
||||
);
|
||||
@ -311,7 +300,6 @@ void Foam::meshToMeshNew::calculate()
|
||||
normaliseWeights
|
||||
(
|
||||
"target",
|
||||
tgtRegion_.cellVolumes(),
|
||||
tgtToSrcCellAddr_,
|
||||
tgtToSrcCellWght_
|
||||
);
|
||||
@ -337,7 +325,6 @@ void Foam::meshToMeshNew::calculate()
|
||||
normaliseWeights
|
||||
(
|
||||
"source",
|
||||
srcRegion_.cellVolumes(),
|
||||
srcToTgtCellAddr_,
|
||||
srcToTgtCellWght_
|
||||
);
|
||||
@ -345,7 +332,6 @@ void Foam::meshToMeshNew::calculate()
|
||||
normaliseWeights
|
||||
(
|
||||
"target",
|
||||
tgtRegion_.cellVolumes(),
|
||||
tgtToSrcCellAddr_,
|
||||
tgtToSrcCellWght_
|
||||
);
|
||||
@ -461,6 +447,7 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
srcPatchID_(),
|
||||
tgtPatchID_(),
|
||||
patchAMIs_(),
|
||||
cuttingPatches_(),
|
||||
srcToTgtCellAddr_(),
|
||||
tgtToSrcCellAddr_(),
|
||||
srcToTgtCellWght_(),
|
||||
@ -476,7 +463,22 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
const polyBoundaryMesh& srcBM = src.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
|
||||
(
|
||||
@ -484,26 +486,19 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
"("
|
||||
"const polyMesh&, "
|
||||
"const polyMesh&, "
|
||||
"const interpolationMethod&"
|
||||
"const interpolationMethod&, "
|
||||
"bool"
|
||||
")"
|
||||
) << "Source and target meshes are dissimiar:" << nl
|
||||
<< " Source patches: " << srcBM.size() << nl
|
||||
<< " Target patches: " << tgtBM.size() << exit(FatalError);
|
||||
) << "Source patch " << pp.name()
|
||||
<< " not found in target mesh. "
|
||||
<< "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);
|
||||
tgtPatchID_ = srcPatchID_;
|
||||
srcPatchID_.transfer(srcPatchID);
|
||||
tgtPatchID_.transfer(tgtPatchID);
|
||||
}
|
||||
|
||||
// calculate volume addressing and weights
|
||||
@ -519,7 +514,8 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt,
|
||||
const interpolationMethod& method,
|
||||
const HashTable<word>& patchMap
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches
|
||||
)
|
||||
:
|
||||
srcRegion_(src),
|
||||
@ -527,6 +523,7 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
srcPatchID_(),
|
||||
tgtPatchID_(),
|
||||
patchAMIs_(),
|
||||
cuttingPatches_(),
|
||||
srcToTgtCellAddr_(),
|
||||
tgtToSrcCellAddr_(),
|
||||
srcToTgtCellWght_(),
|
||||
@ -559,6 +556,14 @@ Foam::meshToMeshNew::meshToMeshNew
|
||||
|
||||
// calculate patch addressing and weights
|
||||
(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -94,6 +94,9 @@ private:
|
||||
//- List of AMIs between source and target patches
|
||||
mutable PtrList<AMIPatchToPatchInterpolation> patchAMIs_;
|
||||
|
||||
//- Cutting patches whose values are set using a zero-gradient condition
|
||||
List<label> cuttingPatches_;
|
||||
|
||||
//- Source to target cell addressing
|
||||
labelListList srcToTgtCellAddr_;
|
||||
|
||||
@ -136,7 +139,6 @@ private:
|
||||
void normaliseWeights
|
||||
(
|
||||
const word& descriptor,
|
||||
const scalarField& cellVolumes,
|
||||
const labelListList& addr,
|
||||
scalarListList& wght
|
||||
) const;
|
||||
@ -242,7 +244,8 @@ public:
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt,
|
||||
const interpolationMethod& method,
|
||||
const HashTable<word>& patchMap
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -336,9 +336,6 @@ void Foam::meshToMeshNew::mapSrcToTgt
|
||||
GeometricField<Type, fvPatchField, volMesh>& result
|
||||
) const
|
||||
{
|
||||
// clear any previously stored values
|
||||
|
||||
|
||||
mapSrcToTgt(field, cop, result.internalField());
|
||||
|
||||
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
|
||||
@ -360,6 +357,13 @@ void Foam::meshToMeshNew::mapSrcToTgt
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
forAll(cuttingPatches_, i)
|
||||
{
|
||||
label patchI = cuttingPatches_[i];
|
||||
fvPatchField<Type>& pf = result.boundaryField()[patchI];
|
||||
pf == pf.patchInternalField();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -52,8 +52,12 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
|
||||
// Print patch names as comment
|
||||
forAll(myPatches, patchI)
|
||||
{
|
||||
os << "# " << patchI << " "
|
||||
<< myPatches[patchI].name() << nl;
|
||||
const surfacePatch& patch = myPatches[patchI];
|
||||
|
||||
if (patch.size() > 0)
|
||||
{
|
||||
os << "# " << patchI << " " << patch.name() << nl;
|
||||
}
|
||||
}
|
||||
os << "#" << nl;
|
||||
|
||||
@ -77,14 +81,17 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
|
||||
|
||||
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
|
||||
(
|
||||
label patchFaceI = 0;
|
||||
patchFaceI < myPatches[patchI].size();
|
||||
patchFaceI < patch.size();
|
||||
patchFaceI++
|
||||
)
|
||||
{
|
||||
@ -99,6 +106,7 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get patch (=compact region) per face
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,6 +43,8 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
|
||||
// Print all faces belonging to this region
|
||||
const surfacePatch& patch = myPatches[patchI];
|
||||
|
||||
if (patch.size() > 0)
|
||||
{
|
||||
os << "solid " << patch.name() << endl;
|
||||
|
||||
for
|
||||
@ -78,6 +80,7 @@ void Foam::triSurface::writeSTLASCII(Ostream& os) const
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::triSurface::writeSTLBINARY(std::ostream& os) const
|
||||
|
||||
@ -51,6 +51,7 @@ thermalBaffle1DFvPatchScalarField
|
||||
baffleActivated_(true),
|
||||
thickness_(p.size()),
|
||||
Qs_(p.size()),
|
||||
solidDict_(),
|
||||
solidPtr_(NULL)
|
||||
{}
|
||||
|
||||
@ -70,6 +71,7 @@ thermalBaffle1DFvPatchScalarField
|
||||
baffleActivated_(ptf.baffleActivated_),
|
||||
thickness_(ptf.thickness_),
|
||||
Qs_(ptf.Qs_),
|
||||
solidDict_(ptf.solidDict_),
|
||||
solidPtr_(ptf.solidPtr_)
|
||||
{}
|
||||
|
||||
@ -88,6 +90,7 @@ thermalBaffle1DFvPatchScalarField
|
||||
baffleActivated_(readBool(dict.lookup("baffleActivated"))),
|
||||
thickness_(scalarField("thickness", dict, p.size())),
|
||||
Qs_(scalarField("Qs", dict, p.size())),
|
||||
solidDict_(dict),
|
||||
solidPtr_(new solidType(dict))
|
||||
{
|
||||
if (!isA<mappedPatchBase>(this->patch().patch()))
|
||||
@ -141,6 +144,7 @@ thermalBaffle1DFvPatchScalarField
|
||||
baffleActivated_(ptf.baffleActivated_),
|
||||
thickness_(ptf.thickness_),
|
||||
Qs_(ptf.Qs_),
|
||||
solidDict_(ptf.solidDict_),
|
||||
solidPtr_(ptf.solidPtr_)
|
||||
{}
|
||||
|
||||
@ -158,12 +162,28 @@ thermalBaffle1DFvPatchScalarField
|
||||
baffleActivated_(ptf.baffleActivated_),
|
||||
thickness_(ptf.thickness_),
|
||||
Qs_(ptf.Qs_),
|
||||
solidDict_(ptf.solidDict_),
|
||||
solidPtr_(ptf.solidPtr_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * 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>
|
||||
void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
|
||||
(
|
||||
@ -171,6 +191,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
|
||||
)
|
||||
{
|
||||
mixedFvPatchScalarField::autoMap(m);
|
||||
thickness_.autoMap(m);
|
||||
Qs_.autoMap(m);
|
||||
}
|
||||
|
||||
template<class solidType>
|
||||
@ -181,6 +203,12 @@ void thermalBaffle1DFvPatchScalarField<solidType>::rmap
|
||||
)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
@ -338,8 +366,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
|
||||
}
|
||||
|
||||
template<class solidType>
|
||||
void thermalBaffle1DFvPatchScalarField<solidType>::
|
||||
write(Ostream& os) const
|
||||
void thermalBaffle1DFvPatchScalarField<solidType>:: write(Ostream& os) const
|
||||
{
|
||||
mixedFvPatchScalarField::write(os);
|
||||
os.writeKeyword("TName")
|
||||
@ -348,7 +375,7 @@ write(Ostream& os) const
|
||||
os.writeKeyword("baffleActivated")
|
||||
<< baffleActivated_ << token::END_STATEMENT << nl;
|
||||
Qs_.writeEntry("Qs", os);
|
||||
solidPtr_->write(os);
|
||||
solidPtr().write(os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -70,8 +70,17 @@ class thermalBaffle1DFvPatchScalarField
|
||||
//- Superficial heat source [W/m2]
|
||||
scalarField Qs_;
|
||||
|
||||
// Solid thermo
|
||||
autoPtr<solidType> solidPtr_;
|
||||
//- Solid dictionary
|
||||
dictionary solidDict_;
|
||||
|
||||
//- Solid thermo
|
||||
mutable autoPtr<solidType> solidPtr_;
|
||||
|
||||
|
||||
// Private members
|
||||
|
||||
//- Return non const solid thermo autoMap
|
||||
const solidType& solidPtr() const;
|
||||
|
||||
|
||||
public:
|
||||
@ -144,6 +153,7 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
|
||||
// Mapping functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
@ -160,6 +170,8 @@ public:
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user