mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -433,7 +433,7 @@ mtype {space}"MTYPE:"{space}
|
||||
}
|
||||
else
|
||||
{
|
||||
curGroupID = readLabel(groupStream);;
|
||||
curGroupID = readLabel(groupStream);
|
||||
}
|
||||
|
||||
BEGIN(cellStreams);
|
||||
|
||||
@ -11,4 +11,4 @@ EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lgenericPatchFields \
|
||||
-lrenumberMethods \
|
||||
-ldecompositionMethods
|
||||
-ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
renumbering all fields from all the time directories.
|
||||
|
||||
By default uses bandCompression (CuthillMcKee) but will
|
||||
read system/renumberMeshDict if present and use the method from there.
|
||||
read system/renumberMeshDict if -dict option is present
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -45,6 +45,7 @@ Description
|
||||
#include "renumberMethod.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "CuthillMcKeeRenumber.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -455,6 +456,69 @@ autoPtr<mapPolyMesh> reorderMesh
|
||||
}
|
||||
|
||||
|
||||
// Return new to old cell numbering
|
||||
labelList regionRenumber
|
||||
(
|
||||
const renumberMethod& method,
|
||||
const fvMesh& mesh,
|
||||
const labelList& cellToRegion
|
||||
)
|
||||
{
|
||||
Info<< "Determining cell order:" << endl;
|
||||
|
||||
labelList cellOrder(cellToRegion.size());
|
||||
|
||||
label nRegions = max(cellToRegion)+1;
|
||||
|
||||
labelListList regionToCells(invertOneToMany(nRegions, cellToRegion));
|
||||
|
||||
label cellI = 0;
|
||||
|
||||
forAll(regionToCells, regionI)
|
||||
{
|
||||
Info<< " region " << regionI << " starts at " << cellI << endl;
|
||||
|
||||
// Make sure no parallel comms
|
||||
bool oldParRun = UPstream::parRun();
|
||||
UPstream::parRun() = false;
|
||||
|
||||
// Per region do a reordering.
|
||||
fvMeshSubset subsetter(mesh);
|
||||
subsetter.setLargeCellSubset(cellToRegion, regionI);
|
||||
|
||||
const fvMesh& subMesh = subsetter.subMesh();
|
||||
|
||||
labelList subReverseCellOrder = method.renumber
|
||||
(
|
||||
subMesh,
|
||||
subMesh.cellCentres()
|
||||
);
|
||||
|
||||
labelList subCellOrder
|
||||
(
|
||||
invert
|
||||
(
|
||||
subMesh.nCells(),
|
||||
subReverseCellOrder
|
||||
)
|
||||
);
|
||||
|
||||
// Restore state
|
||||
UPstream::parRun() = oldParRun;
|
||||
|
||||
const labelList& cellMap = subsetter.cellMap();
|
||||
|
||||
forAll(subCellOrder, i)
|
||||
{
|
||||
cellOrder[cellI++] = cellMap[subCellOrder[i]];
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
return cellOrder;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -505,23 +569,28 @@ int main(int argc, char *argv[])
|
||||
label blockSize = 0;
|
||||
|
||||
// Construct renumberMethod
|
||||
autoPtr<IOdictionary> renumberDictPtr;
|
||||
autoPtr<renumberMethod> renumberPtr;
|
||||
|
||||
if (readDict)
|
||||
{
|
||||
Info<< "Renumber according to renumberMeshDict." << nl << endl;
|
||||
|
||||
IOdictionary renumberDict
|
||||
renumberDictPtr.reset
|
||||
(
|
||||
IOobject
|
||||
new IOdictionary
|
||||
(
|
||||
"renumberMeshDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
IOobject
|
||||
(
|
||||
"renumberMeshDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
const IOdictionary renumberDict = renumberDictPtr();
|
||||
|
||||
renumberPtr = renumberMethod::New(renumberDict);
|
||||
|
||||
@ -562,7 +631,7 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
writeMaps = readLabel(renumberDict.lookup("writeMaps"));
|
||||
renumberDict.lookup("writeMaps") >> writeMaps;
|
||||
if (writeMaps)
|
||||
{
|
||||
Info<< "Writing renumber maps (new to old) to polyMesh." << nl
|
||||
@ -683,22 +752,15 @@ int main(int argc, char *argv[])
|
||||
// fields is done correctly!
|
||||
|
||||
label nBlocks = mesh.nCells() / blockSize;
|
||||
Info<< "nBlocks = " << nBlocks << endl;
|
||||
Info<< "nBlocks = " << nBlocks << endl;
|
||||
|
||||
// Read decomposePar dictionary
|
||||
IOdictionary decomposeDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"decomposeParDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
// Read decompositionMethod dictionary
|
||||
dictionary decomposeDict(renumberDictPtr().subDict("blockCoeffs"));
|
||||
decomposeDict.set("numberOfSubdomains", nBlocks);
|
||||
|
||||
bool oldParRun = UPstream::parRun();
|
||||
UPstream::parRun() = false;
|
||||
|
||||
autoPtr<decompositionMethod> decomposePtr = decompositionMethod::New
|
||||
(
|
||||
decomposeDict
|
||||
@ -713,6 +775,9 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
// Restore state
|
||||
UPstream::parRun() = oldParRun;
|
||||
|
||||
// For debugging: write out region
|
||||
createScalarField
|
||||
(
|
||||
@ -726,23 +791,7 @@ int main(int argc, char *argv[])
|
||||
<< nl << endl;
|
||||
|
||||
|
||||
// Find point per region
|
||||
pointField regionPoints(nBlocks, vector::zero);
|
||||
forAll(cellToRegion, cellI)
|
||||
{
|
||||
regionPoints[cellToRegion[cellI]] = mesh.cellCentres()[cellI];
|
||||
}
|
||||
|
||||
// Use block based renumbering.
|
||||
// Detemines old to new cell ordering
|
||||
labelList reverseCellOrder = renumberPtr().renumber
|
||||
(
|
||||
mesh,
|
||||
cellToRegion,
|
||||
regionPoints
|
||||
);
|
||||
|
||||
cellOrder = invert(mesh.nCells(), reverseCellOrder);
|
||||
cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
|
||||
|
||||
// Determine new to old face order with new cell numbering
|
||||
faceOrder = getRegionFaceOrder
|
||||
|
||||
@ -22,10 +22,14 @@ writeMaps true;
|
||||
// e.g. nonBlockingGaussSeidel.
|
||||
sortCoupledFaceCells false;
|
||||
|
||||
// Optional entry: renumber on a block-by-block basis. This can be used on
|
||||
// large cases to keep the blocks fitting in cache with all the the cache
|
||||
// missed bunched at the end.
|
||||
//blockSize 0;
|
||||
// Optional entry: renumber on a block-by-block basis. It uses a
|
||||
// blockCoeffs dictionary to construct a decompositionMethod to do
|
||||
// a block subdivision) and then applies the renumberMethod to each
|
||||
// block in turn. This can be used in large cases to keep the blocks
|
||||
// fitting in cache with all the the cache misses bunched at the end.
|
||||
// This number is the approximate size of the blocks - this gets converted
|
||||
// to a number of blocks that is the input to the decomposition method.
|
||||
//blockSize 1000;
|
||||
|
||||
// Optional entry: sort points into internal and boundary points
|
||||
//orderPoints false;
|
||||
@ -37,11 +41,11 @@ method CuthillMcKee;
|
||||
//method random;
|
||||
//method spring;
|
||||
|
||||
CuthillMcKeeCoeffs
|
||||
{
|
||||
// Reverse CuthillMcKee (RCM) or plain
|
||||
reverse true;
|
||||
}
|
||||
//CuthillMcKeeCoeffs
|
||||
//{
|
||||
// // Reverse CuthillMcKee (RCM) or plain
|
||||
// reverse true;
|
||||
//}
|
||||
|
||||
|
||||
manualCoeffs
|
||||
@ -65,4 +69,17 @@ springCoeffs
|
||||
}
|
||||
|
||||
|
||||
blockCoeffs
|
||||
{
|
||||
method scotch;
|
||||
//method hierarchical;
|
||||
//hierarchicalCoeffs
|
||||
//{
|
||||
// n (1 2 1);
|
||||
// delta 0.001;
|
||||
// order xyz;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -528,7 +528,7 @@ int main(int argc, char *argv[])
|
||||
<< "Cell number should be between 0 and "
|
||||
<< mesh.nCells()-1 << nl
|
||||
<< "On this mesh the particle should be in cell "
|
||||
<< mesh.findCell(iter().position())
|
||||
<< mesh.findCell(iter().position())
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -789,6 +789,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Point fields
|
||||
if
|
||||
(
|
||||
pointScalarFields.size()
|
||||
|| pointVectorFields.size()
|
||||
|| pointSphericalTensorFields.size()
|
||||
|| pointSymmTensorFields.size()
|
||||
|| pointTensorFields.size()
|
||||
)
|
||||
{
|
||||
labelIOList pointProcAddressing
|
||||
(
|
||||
|
||||
@ -795,9 +795,9 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
fvMesh& mesh = meshPtr();
|
||||
|
||||
//Pout<< "Read mesh:" << endl;
|
||||
//printMeshData(Pout, mesh);
|
||||
//Pout<< endl;
|
||||
// Print some statistics
|
||||
Info<< "Before distribution:" << endl;
|
||||
printMeshData(mesh);
|
||||
|
||||
|
||||
|
||||
@ -1022,7 +1022,6 @@ int main(int argc, char *argv[])
|
||||
//map().distributeFaceData(faceCc);
|
||||
|
||||
|
||||
// Print a bit
|
||||
// Print some statistics
|
||||
Info<< "After distribution:" << endl;
|
||||
printMeshData(mesh);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
set -x
|
||||
#set -x
|
||||
|
||||
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
|
||||
then
|
||||
@ -15,6 +15,8 @@ then
|
||||
wmake libso vtkPV3Readers
|
||||
PV3blockMeshReader/Allwmake
|
||||
PV3FoamReader/Allwmake
|
||||
else
|
||||
echo "ERROR: ParaView not found in $ParaView_DIR"
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
|
||||
@ -9,5 +9,5 @@ int USERD_get_number_of_files_in_dataset(void)
|
||||
|
||||
// use 1 insted of 0 which gives an un-necessary warning.
|
||||
Num_dataset_files = 1;
|
||||
return Num_dataset_files;;
|
||||
return Num_dataset_files;
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lincompressibleRASModels \
|
||||
-lincompressibleTransportModels \
|
||||
-lincompressibleRASModels \
|
||||
-lbasicThermophysicalModels \
|
||||
-lspecie \
|
||||
-lcompressibleRASModels \
|
||||
-lfiniteVolume \
|
||||
-lgenericPatchFields
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
Info<< "Reading field U\n" << endl;
|
||||
volVectorField U
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
singlePhaseTransportModel laminarTransport(U, phi);
|
||||
|
||||
autoPtr<incompressible::RASModel> RASModel
|
||||
(
|
||||
incompressible::RASModel::New(U, phi, laminarTransport)
|
||||
);
|
||||
@ -25,23 +25,130 @@ Application
|
||||
wallShearStress
|
||||
|
||||
Description
|
||||
Calculates and writes the wall shear stress, for the specified times.
|
||||
Calculates and reports wall shear stress for all patches, for the
|
||||
specified times when using RAS turbulence models.
|
||||
|
||||
Default behaviour assumes operating in incompressible mode.
|
||||
Use the -compressible option for compressible RAS cases.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
|
||||
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
|
||||
#include "RASModel.H"
|
||||
#include "incompressible/RAS/RASModel/RASModel.H"
|
||||
|
||||
#include "basicPsiThermo.H"
|
||||
#include "compressible/RAS/RASModel/RASModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void calcIncompressible
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const Time& runTime,
|
||||
const volVectorField& U,
|
||||
volVectorField& wallShearStress
|
||||
)
|
||||
{
|
||||
#include "createPhi.H"
|
||||
|
||||
singlePhaseTransportModel laminarTransport(U, phi);
|
||||
|
||||
autoPtr<incompressible::RASModel> model
|
||||
(
|
||||
incompressible::RASModel::New(U, phi, laminarTransport)
|
||||
);
|
||||
|
||||
const volSymmTensorField Reff(model->devReff());
|
||||
|
||||
forAll(wallShearStress.boundaryField(), patchI)
|
||||
{
|
||||
wallShearStress.boundaryField()[patchI] =
|
||||
(
|
||||
-mesh.Sf().boundaryField()[patchI]
|
||||
/mesh.magSf().boundaryField()[patchI]
|
||||
) & Reff.boundaryField()[patchI];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void calcCompressible
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const Time& runTime,
|
||||
const volVectorField& U,
|
||||
volVectorField& wallShearStress
|
||||
)
|
||||
{
|
||||
IOobject rhoHeader
|
||||
(
|
||||
"rho",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (!rhoHeader.headerOk())
|
||||
{
|
||||
Info<< " no rho field" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Info<< "Reading field rho\n" << endl;
|
||||
volScalarField rho(rhoHeader, mesh);
|
||||
|
||||
#include "compressibleCreatePhi.H"
|
||||
|
||||
autoPtr<basicPsiThermo> pThermo
|
||||
(
|
||||
basicPsiThermo::New(mesh)
|
||||
);
|
||||
basicPsiThermo& thermo = pThermo();
|
||||
|
||||
autoPtr<compressible::RASModel> model
|
||||
(
|
||||
compressible::RASModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
const volSymmTensorField Reff(model->devRhoReff());
|
||||
|
||||
forAll(wallShearStress.boundaryField(), patchI)
|
||||
{
|
||||
wallShearStress.boundaryField()[patchI] =
|
||||
(
|
||||
-mesh.Sf().boundaryField()[patchI]
|
||||
/mesh.magSf().boundaryField()[patchI]
|
||||
) & Reff.boundaryField()[patchI];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
|
||||
#include "addRegionOption.H"
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"compressible",
|
||||
"calculate compressible wall shear stress"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
#include "createMesh.H"
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
const bool compressible = args.optionFound("compressible");
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
@ -49,10 +156,6 @@ int main(int argc, char *argv[])
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
mesh.readUpdate();
|
||||
|
||||
#include "createFields.H"
|
||||
|
||||
volSymmTensorField Reff(RASModel->devReff());
|
||||
|
||||
volVectorField wallShearStress
|
||||
(
|
||||
IOobject
|
||||
@ -67,19 +170,41 @@ int main(int argc, char *argv[])
|
||||
dimensionedVector
|
||||
(
|
||||
"wallShearStress",
|
||||
Reff.dimensions(),
|
||||
sqr(dimLength)/sqr(dimTime),
|
||||
vector::zero
|
||||
)
|
||||
);
|
||||
|
||||
forAll(wallShearStress.boundaryField(), patchi)
|
||||
IOobject UHeader
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (UHeader.headerOk())
|
||||
{
|
||||
wallShearStress.boundaryField()[patchi] =
|
||||
(
|
||||
-mesh.Sf().boundaryField()[patchi]
|
||||
/mesh.magSf().boundaryField()[patchi]
|
||||
) & Reff.boundaryField()[patchi];
|
||||
Info<< "Reading field U\n" << endl;
|
||||
volVectorField U(UHeader, mesh);
|
||||
|
||||
if (compressible)
|
||||
{
|
||||
calcCompressible(mesh, runTime, U, wallShearStress);
|
||||
}
|
||||
else
|
||||
{
|
||||
calcIncompressible(mesh, runTime, U, wallShearStress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " no U field" << endl;
|
||||
}
|
||||
|
||||
Info<< "Writing wall shear stress to field " << wallShearStress.name()
|
||||
<< nl << endl;
|
||||
|
||||
wallShearStress.write();
|
||||
}
|
||||
|
||||
@ -35,12 +35,13 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
template<class Type, class CombineOp>
|
||||
void MapConsistentVolFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
const meshToMesh& meshToMeshInterp,
|
||||
const meshToMesh::order& mapOrder
|
||||
const meshToMesh::order& mapOrder,
|
||||
const CombineOp& cop
|
||||
)
|
||||
{
|
||||
const fvMesh& meshSource = meshToMeshInterp.fromMesh();
|
||||
@ -84,7 +85,13 @@ void MapConsistentVolFields
|
||||
);
|
||||
|
||||
// Interpolate field
|
||||
meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder);
|
||||
meshToMeshInterp.interpolate//<Type, eqOp<Type> >
|
||||
(
|
||||
fieldTarget,
|
||||
fieldSource,
|
||||
mapOrder,
|
||||
cop
|
||||
);
|
||||
|
||||
// Write field
|
||||
fieldTarget.write();
|
||||
@ -97,7 +104,12 @@ void MapConsistentVolFields
|
||||
GeometricField<Type, fvPatchField, volMesh> fieldTarget
|
||||
(
|
||||
fieldTargetIOobject,
|
||||
meshToMeshInterp.interpolate(fieldSource, mapOrder)
|
||||
meshToMeshInterp.interpolate//<Type, eqOp<Type> >
|
||||
(
|
||||
fieldSource,
|
||||
mapOrder,
|
||||
cop
|
||||
)
|
||||
);
|
||||
|
||||
// Write field
|
||||
|
||||
263
applications/utilities/preProcessing/mapFields/MapMeshes.H
Normal file
263
applications/utilities/preProcessing/mapFields/MapMeshes.H
Normal file
@ -0,0 +1,263 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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 "MapConsistentVolFields.H"
|
||||
#include "mapLagrangian.H"
|
||||
#include "UnMapped.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<template<class> class CombineOp>
|
||||
void MapConsistentMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const meshToMesh::order& mapOrder
|
||||
)
|
||||
{
|
||||
// Create the interpolation scheme
|
||||
meshToMesh meshToMeshInterp(meshSource, meshTarget);
|
||||
|
||||
Info<< nl
|
||||
<< "Consistently creating and mapping fields for time "
|
||||
<< meshSource.time().timeName() << nl << endl;
|
||||
|
||||
{
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(meshSource, meshSource.time().timeName());
|
||||
|
||||
// Map volFields
|
||||
// ~~~~~~~~~~~~~
|
||||
MapConsistentVolFields<scalar>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<scalar>()
|
||||
);
|
||||
MapConsistentVolFields<vector>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<vector>()
|
||||
);
|
||||
MapConsistentVolFields<sphericalTensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<sphericalTensor>()
|
||||
);
|
||||
MapConsistentVolFields<symmTensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<symmTensor>()
|
||||
);
|
||||
MapConsistentVolFields<tensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<tensor>()
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
mapLagrangian(meshToMeshInterp);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class CombineOp>
|
||||
void MapSubMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches,
|
||||
const meshToMesh::order& mapOrder
|
||||
)
|
||||
{
|
||||
// Create the interpolation scheme
|
||||
meshToMesh meshToMeshInterp
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
);
|
||||
|
||||
Info<< nl
|
||||
<< "Mapping fields for time " << meshSource.time().timeName()
|
||||
<< nl << endl;
|
||||
|
||||
{
|
||||
// Search for list of source objects for this time
|
||||
IOobjectList objects(meshSource, meshSource.time().timeName());
|
||||
|
||||
// Map volFields
|
||||
// ~~~~~~~~~~~~~
|
||||
MapVolFields<scalar>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<scalar>()
|
||||
);
|
||||
MapVolFields<vector>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<vector>()
|
||||
);
|
||||
MapVolFields<sphericalTensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<sphericalTensor>()
|
||||
);
|
||||
MapVolFields<symmTensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<symmTensor>()
|
||||
);
|
||||
MapVolFields<tensor>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
mapOrder,
|
||||
CombineOp<tensor>()
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
mapLagrangian(meshToMeshInterp);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class CombineOp>
|
||||
void MapConsistentSubMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const meshToMesh::order& mapOrder
|
||||
)
|
||||
{
|
||||
HashTable<word> patchMap;
|
||||
HashTable<label> cuttingPatchTable;
|
||||
|
||||
forAll(meshTarget.boundary(), patchi)
|
||||
{
|
||||
if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
|
||||
{
|
||||
patchMap.insert
|
||||
(
|
||||
meshTarget.boundary()[patchi].name(),
|
||||
meshTarget.boundary()[patchi].name()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
cuttingPatchTable.insert
|
||||
(
|
||||
meshTarget.boundaryMesh()[patchi].name(),
|
||||
-1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MapSubMesh<CombineOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatchTable.toc(),
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -35,12 +35,13 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
template<class Type, class CombineOp>
|
||||
void MapVolFields
|
||||
(
|
||||
const IOobjectList& objects,
|
||||
const meshToMesh& meshToMeshInterp,
|
||||
const meshToMesh::order& mapOrder
|
||||
const meshToMesh::order& mapOrder,
|
||||
const CombineOp& cop
|
||||
)
|
||||
{
|
||||
const fvMesh& meshSource = meshToMeshInterp.fromMesh();
|
||||
@ -84,7 +85,13 @@ void MapVolFields
|
||||
);
|
||||
|
||||
// Interpolate field
|
||||
meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder);
|
||||
meshToMeshInterp.interpolate//<Type, eqOp<Type> >
|
||||
(
|
||||
fieldTarget,
|
||||
fieldSource,
|
||||
mapOrder,
|
||||
cop
|
||||
);
|
||||
|
||||
// Write field
|
||||
fieldTarget.write();
|
||||
|
||||
@ -34,11 +34,8 @@ Description
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "meshToMesh.H"
|
||||
#include "MapVolFields.H"
|
||||
#include "MapConsistentVolFields.H"
|
||||
#include "UnMapped.H"
|
||||
#include "processorFvPatch.H"
|
||||
#include "mapLagrangian.H"
|
||||
#include "MapMeshes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,56 +43,28 @@ void mapConsistentMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const meshToMesh::order& mapOrder
|
||||
const meshToMesh::order& mapOrder,
|
||||
const bool subtract
|
||||
)
|
||||
{
|
||||
// Create the interpolation scheme
|
||||
meshToMesh meshToMeshInterp(meshSource, meshTarget);
|
||||
|
||||
Info<< nl
|
||||
<< "Consistently creating and mapping fields for time "
|
||||
<< meshSource.time().timeName() << nl << endl;
|
||||
|
||||
if (subtract)
|
||||
{
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(meshSource, meshSource.time().timeName());
|
||||
|
||||
// Map volFields
|
||||
// ~~~~~~~~~~~~~
|
||||
MapConsistentVolFields<scalar>(objects, meshToMeshInterp, mapOrder);
|
||||
MapConsistentVolFields<vector>(objects, meshToMeshInterp, mapOrder);
|
||||
MapConsistentVolFields<sphericalTensor>
|
||||
MapConsistentMesh<minusEqOp>
|
||||
(
|
||||
objects,
|
||||
meshToMeshInterp,
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder
|
||||
);
|
||||
MapConsistentVolFields<symmTensor>(objects, meshToMeshInterp, mapOrder);
|
||||
MapConsistentVolFields<tensor>(objects, meshToMeshInterp, mapOrder);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
MapConsistentMesh<eqOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
mapLagrangian(meshToMeshInterp);
|
||||
}
|
||||
|
||||
|
||||
@ -105,57 +74,32 @@ void mapSubMesh
|
||||
const fvMesh& meshTarget,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches,
|
||||
const meshToMesh::order& mapOrder
|
||||
const meshToMesh::order& mapOrder,
|
||||
const bool subtract
|
||||
)
|
||||
{
|
||||
// Create the interpolation scheme
|
||||
meshToMesh meshToMeshInterp
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
);
|
||||
|
||||
Info<< nl
|
||||
<< "Mapping fields for time " << meshSource.time().timeName()
|
||||
<< nl << endl;
|
||||
|
||||
if (subtract)
|
||||
{
|
||||
// Search for list of source objects for this time
|
||||
IOobjectList objects(meshSource, meshSource.time().timeName());
|
||||
|
||||
// Map volFields
|
||||
// ~~~~~~~~~~~~~
|
||||
MapVolFields<scalar>(objects, meshToMeshInterp, mapOrder);
|
||||
MapVolFields<vector>(objects, meshToMeshInterp, mapOrder);
|
||||
MapVolFields<sphericalTensor>(objects, meshToMeshInterp, mapOrder);
|
||||
MapVolFields<symmTensor>(objects, meshToMeshInterp, mapOrder);
|
||||
MapVolFields<tensor>(objects, meshToMeshInterp, mapOrder);
|
||||
MapSubMesh<minusEqOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches,
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
MapSubMesh<eqOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches,
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
mapLagrangian(meshToMeshInterp);
|
||||
}
|
||||
|
||||
|
||||
@ -163,40 +107,28 @@ void mapConsistentSubMesh
|
||||
(
|
||||
const fvMesh& meshSource,
|
||||
const fvMesh& meshTarget,
|
||||
const meshToMesh::order& mapOrder
|
||||
const meshToMesh::order& mapOrder,
|
||||
const bool subtract
|
||||
)
|
||||
{
|
||||
HashTable<word> patchMap;
|
||||
HashTable<label> cuttingPatchTable;
|
||||
|
||||
forAll(meshTarget.boundary(), patchi)
|
||||
if (subtract)
|
||||
{
|
||||
if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
|
||||
{
|
||||
patchMap.insert
|
||||
(
|
||||
meshTarget.boundary()[patchi].name(),
|
||||
meshTarget.boundary()[patchi].name()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
cuttingPatchTable.insert
|
||||
(
|
||||
meshTarget.boundaryMesh()[patchi].name(),
|
||||
-1
|
||||
);
|
||||
}
|
||||
MapConsistentSubMesh<minusEqOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapConsistentSubMesh<eqOp>
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
mapSubMesh
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatchTable.toc(),
|
||||
mapOrder
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -288,6 +220,11 @@ int main(int argc, char *argv[])
|
||||
"word",
|
||||
"specify the mapping method"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"subtract",
|
||||
"subtract mapped source from target"
|
||||
);
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
@ -350,6 +287,13 @@ int main(int argc, char *argv[])
|
||||
Info<< "Mapping method: " << mapMethod << endl;
|
||||
}
|
||||
|
||||
const bool subtract = args.optionFound("subtract");
|
||||
if (subtract)
|
||||
{
|
||||
Info<< "Subtracting mapped source field from target" << endl;
|
||||
}
|
||||
|
||||
|
||||
#include "createTimes.H"
|
||||
|
||||
HashTable<word> patchMap;
|
||||
@ -431,7 +375,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (consistent)
|
||||
{
|
||||
mapConsistentSubMesh(meshSource, meshTarget, mapOrder);
|
||||
mapConsistentSubMesh
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -441,7 +391,8 @@ int main(int argc, char *argv[])
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches,
|
||||
mapOrder
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -503,7 +454,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (consistent)
|
||||
{
|
||||
mapConsistentSubMesh(meshSource, meshTarget, mapOrder);
|
||||
mapConsistentSubMesh
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -513,7 +470,8 @@ int main(int argc, char *argv[])
|
||||
meshTarget,
|
||||
patchMap,
|
||||
addProcessorPatches(meshTarget, cuttingPatches),
|
||||
mapOrder
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -629,7 +587,8 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
meshSource,
|
||||
meshTarget,
|
||||
mapOrder
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -640,7 +599,8 @@ int main(int argc, char *argv[])
|
||||
meshTarget,
|
||||
patchMap,
|
||||
addProcessorPatches(meshTarget, cuttingPatches),
|
||||
mapOrder
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -679,7 +639,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (consistent)
|
||||
{
|
||||
mapConsistentMesh(meshSource, meshTarget, mapOrder);
|
||||
mapConsistentMesh(meshSource, meshTarget, mapOrder, subtract);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -689,7 +649,8 @@ int main(int argc, char *argv[])
|
||||
meshTarget,
|
||||
patchMap,
|
||||
cuttingPatches,
|
||||
mapOrder
|
||||
mapOrder,
|
||||
subtract
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user