mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -91,6 +91,9 @@
|
|||||||
*** *New* ptscotch decomposition method
|
*** *New* ptscotch decomposition method
|
||||||
*** *Updated* particle tracking algorithm
|
*** *Updated* particle tracking algorithm
|
||||||
*** *Updated* split cyclics into two separate patches. See doc/changed/splitCyclics.txt
|
*** *Updated* split cyclics into two separate patches. See doc/changed/splitCyclics.txt
|
||||||
|
* *Updated* interpolation (volPointInterpolation) now works without the
|
||||||
|
globalPointPatch. Moving mesh cases can now be run non-parallel and
|
||||||
|
continued in parallel and reconstructed without any limitation.
|
||||||
*** *New* compact binary I/O for faces and cells. This speeds up reading/writing meshes in binary.
|
*** *New* compact binary I/O for faces and cells. This speeds up reading/writing meshes in binary.
|
||||||
*** *Updated* runTimeModifiable
|
*** *Updated* runTimeModifiable
|
||||||
+ on linux uses inotify instead of time stamps - more efficient for large
|
+ on linux uses inotify instead of time stamps - more efficient for large
|
||||||
|
|||||||
@ -37,18 +37,16 @@ Foam::scalar Foam::solidRegionDiffNo
|
|||||||
scalar DiNum = 0.0;
|
scalar DiNum = 0.0;
|
||||||
scalar meanDiNum = 0.0;
|
scalar meanDiNum = 0.0;
|
||||||
|
|
||||||
//- Can have fluid domains with 0 cells so do not test.
|
//- Take care: can have fluid domains with 0 cells so do not test for
|
||||||
if (mesh.nInternalFaces())
|
// zero internal faces.
|
||||||
{
|
surfaceScalarField KrhoCpbyDelta =
|
||||||
surfaceScalarField KrhoCpbyDelta =
|
mesh.surfaceInterpolation::deltaCoeffs()
|
||||||
mesh.surfaceInterpolation::deltaCoeffs()
|
* fvc::interpolate(K)
|
||||||
* fvc::interpolate(K)
|
/ fvc::interpolate(Cprho);
|
||||||
/ fvc::interpolate(Cprho);
|
|
||||||
|
|
||||||
DiNum = max(KrhoCpbyDelta.internalField())*runTime.deltaT().value();
|
DiNum = gMax(KrhoCpbyDelta.internalField())*runTime.deltaT().value();
|
||||||
|
|
||||||
meanDiNum = (average(KrhoCpbyDelta)).value()*runTime.deltaT().value();
|
meanDiNum = (average(KrhoCpbyDelta)).value()*runTime.deltaT().value();
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "Region: " << mesh.name() << " Diffusion Number mean: " << meanDiNum
|
Info<< "Region: " << mesh.name() << " Diffusion Number mean: " << meanDiNum
|
||||||
<< " max: " << DiNum << endl;
|
<< " max: " << DiNum << endl;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,9 +25,9 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "point.H"
|
||||||
#include "DynamicField.H"
|
#include "DynamicField.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "labelField.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -36,44 +36,62 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
{
|
DynamicField<point, 0, 10, 11> testField;
|
||||||
DynamicField<label> dl(10);
|
DynamicField<point, 0, 10, 11> testField2;
|
||||||
Pout<< "null construct dl:" << dl << endl;
|
|
||||||
dl.append(3);
|
|
||||||
dl.append(2);
|
|
||||||
dl.append(1);
|
|
||||||
Pout<< "appending : dl:" << dl << endl;
|
|
||||||
|
|
||||||
dl[2] *= 10;
|
testField.setSize(5);
|
||||||
Pout<< "assigning : dl:" << dl << endl;
|
testField2.setSize(5);
|
||||||
}
|
|
||||||
|
|
||||||
{
|
testField[0] = testField2[0] = vector(1.0, 4.5, 6.3);
|
||||||
DynamicField<label> dl(IStringStream("(1 2 3)")());
|
testField[1] = testField2[1] = vector(5.2, 2.3, 3.5);
|
||||||
Pout<< "reading : dl:" << dl << endl;
|
testField[2] = testField2[2] = vector(7.5, 4.7, 7.7);
|
||||||
}
|
testField[3] = testField2[3] = vector(2.8, 8.2, 2.3);
|
||||||
|
testField[4] = testField2[4] = vector(6.1, 1.7, 8.8);
|
||||||
|
|
||||||
{
|
Info << "testField:" << testField << endl;
|
||||||
labelField lf(3);
|
|
||||||
lf[0] = 1;
|
|
||||||
lf[1] = 2;
|
|
||||||
lf[2] = 3;
|
|
||||||
DynamicField<label> dl;
|
|
||||||
dl = lf;
|
|
||||||
Pout<< "assigning from labelField : dl:" << dl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
testField.append(vector(0.5, 4.8, 6.2));
|
||||||
labelField lf(3);
|
|
||||||
lf[0] = 1;
|
|
||||||
lf[1] = 2;
|
|
||||||
lf[2] = 3;
|
|
||||||
DynamicField<label> dl(lf);
|
|
||||||
Pout<< "constructing from labelField dl:" << dl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Info << "testField after appending:" << testField << endl;
|
||||||
|
|
||||||
Info<< "\nEnd\n";
|
testField.append(vector(2.7, 2.3, 6.1));
|
||||||
|
|
||||||
|
Info << "testField after appending:" << testField << endl;
|
||||||
|
|
||||||
|
vector elem = testField.remove();
|
||||||
|
|
||||||
|
Info << "removed element:" << elem << endl;
|
||||||
|
Info << "testField:" << testField << endl;
|
||||||
|
|
||||||
|
testField.append(vector(3.0, 1.3, 9.2));
|
||||||
|
|
||||||
|
Info << "testField:" << testField << endl;
|
||||||
|
|
||||||
|
testField.setSize(10, vector(1.5, 0.6, -1.0));
|
||||||
|
|
||||||
|
Info << "testField after setSize:" << testField << endl;
|
||||||
|
|
||||||
|
testField.append(testField2);
|
||||||
|
|
||||||
|
Info << "testField after appending testField2:" << testField << endl;
|
||||||
|
|
||||||
|
testField = testField2;
|
||||||
|
|
||||||
|
Info << "testField after assignment:" << testField << endl;
|
||||||
|
|
||||||
|
testField += testField2;
|
||||||
|
|
||||||
|
Info << "testField after field algebra:" << testField << endl;
|
||||||
|
|
||||||
|
testField.clear();
|
||||||
|
|
||||||
|
testField.append(vector(3.0, 1.3, 9.2));
|
||||||
|
|
||||||
|
Info << "testField after clear and append:" << testField << endl;
|
||||||
|
|
||||||
|
testField.clearStorage();
|
||||||
|
|
||||||
|
Info << "testField after clearStorage:" << testField << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,8 +34,12 @@ Description
|
|||||||
- any face inbetween differing cellZones (-cellZones)
|
- any face inbetween differing cellZones (-cellZones)
|
||||||
|
|
||||||
Output is:
|
Output is:
|
||||||
- volScalarField with regions as different scalars (-detectOnly) or
|
- volScalarField with regions as different scalars (-detectOnly)
|
||||||
- mesh with multiple regions or
|
or
|
||||||
|
- mesh with multiple regions and directMapped patches. These patches
|
||||||
|
either cover the whole interface between two region (default) or
|
||||||
|
only part according to faceZones (-useFaceZones)
|
||||||
|
or
|
||||||
- mesh with cells put into cellZones (-makeCellZones)
|
- mesh with cells put into cellZones (-makeCellZones)
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
@ -495,18 +499,70 @@ labelList getNonRegionCells(const labelList& cellRegion, const label regionI)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get per region-region interface the sizes. If sumParallel sums sizes.
|
void addToInterface
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const label zoneID,
|
||||||
|
const label ownRegion,
|
||||||
|
const label neiRegion,
|
||||||
|
EdgeMap<Map<label> >& regionsToSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
edge interface
|
||||||
|
(
|
||||||
|
min(ownRegion, neiRegion),
|
||||||
|
max(ownRegion, neiRegion)
|
||||||
|
);
|
||||||
|
|
||||||
|
EdgeMap<Map<label> >::iterator iter = regionsToSize.find
|
||||||
|
(
|
||||||
|
interface
|
||||||
|
);
|
||||||
|
|
||||||
|
if (iter != regionsToSize.end())
|
||||||
|
{
|
||||||
|
// Check if zone present
|
||||||
|
Map<label>::iterator zoneFnd = iter().find(zoneID);
|
||||||
|
if (zoneFnd != iter().end())
|
||||||
|
{
|
||||||
|
// Found zone. Increment count.
|
||||||
|
zoneFnd()++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// New or no zone. Insert with count 1.
|
||||||
|
iter().insert(zoneID, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create new interface of size 1.
|
||||||
|
Map<label> zoneToSize;
|
||||||
|
zoneToSize.insert(zoneID, 1);
|
||||||
|
regionsToSize.insert(interface, zoneToSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get region-region interface name and sizes.
|
||||||
// Returns interfaces as straight list for looping in identical order.
|
// Returns interfaces as straight list for looping in identical order.
|
||||||
void getInterfaceSizes
|
void getInterfaceSizes
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
|
const bool useFaceZones,
|
||||||
const labelList& cellRegion,
|
const labelList& cellRegion,
|
||||||
const bool sumParallel,
|
const wordList& regionNames,
|
||||||
|
|
||||||
edgeList& interfaces,
|
edgeList& interfaces,
|
||||||
EdgeMap<label>& interfaceSizes
|
List<Pair<word> >& interfaceNames,
|
||||||
|
labelList& interfaceSizes,
|
||||||
|
labelList& faceToInterface
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// From region-region to faceZone (or -1) to number of faces.
|
||||||
|
|
||||||
|
EdgeMap<Map<label> > regionsToSize;
|
||||||
|
|
||||||
|
|
||||||
// Internal faces
|
// Internal faces
|
||||||
// ~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~
|
||||||
@ -518,22 +574,14 @@ void getInterfaceSizes
|
|||||||
|
|
||||||
if (ownRegion != neiRegion)
|
if (ownRegion != neiRegion)
|
||||||
{
|
{
|
||||||
edge interface
|
addToInterface
|
||||||
(
|
(
|
||||||
min(ownRegion, neiRegion),
|
mesh,
|
||||||
max(ownRegion, neiRegion)
|
(useFaceZones ? mesh.faceZones().whichZone(faceI) : -1),
|
||||||
|
ownRegion,
|
||||||
|
neiRegion,
|
||||||
|
regionsToSize
|
||||||
);
|
);
|
||||||
|
|
||||||
EdgeMap<label>::iterator iter = interfaceSizes.find(interface);
|
|
||||||
|
|
||||||
if (iter != interfaceSizes.end())
|
|
||||||
{
|
|
||||||
iter()++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
interfaceSizes.insert(interface, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,27 +606,19 @@ void getInterfaceSizes
|
|||||||
|
|
||||||
if (ownRegion != neiRegion)
|
if (ownRegion != neiRegion)
|
||||||
{
|
{
|
||||||
edge interface
|
addToInterface
|
||||||
(
|
(
|
||||||
min(ownRegion, neiRegion),
|
mesh,
|
||||||
max(ownRegion, neiRegion)
|
(useFaceZones ? mesh.faceZones().whichZone(faceI) : -1),
|
||||||
|
ownRegion,
|
||||||
|
neiRegion,
|
||||||
|
regionsToSize
|
||||||
);
|
);
|
||||||
|
|
||||||
EdgeMap<label>::iterator iter = interfaceSizes.find(interface);
|
|
||||||
|
|
||||||
if (iter != interfaceSizes.end())
|
|
||||||
{
|
|
||||||
iter()++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
interfaceSizes.insert(interface, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sumParallel && Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
@ -592,57 +632,169 @@ void getInterfaceSizes
|
|||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::blocking, slave);
|
IPstream fromSlave(Pstream::blocking, slave);
|
||||||
|
|
||||||
EdgeMap<label> slaveSizes(fromSlave);
|
EdgeMap<Map<label> > slaveSizes(fromSlave);
|
||||||
|
|
||||||
forAllConstIter(EdgeMap<label>, slaveSizes, slaveIter)
|
forAllConstIter(EdgeMap<Map<label> >, slaveSizes, slaveIter)
|
||||||
{
|
{
|
||||||
EdgeMap<label>::iterator masterIter =
|
EdgeMap<Map<label> >::iterator masterIter =
|
||||||
interfaceSizes.find(slaveIter.key());
|
regionsToSize.find(slaveIter.key());
|
||||||
|
|
||||||
if (masterIter != interfaceSizes.end())
|
if (masterIter != regionsToSize.end())
|
||||||
{
|
{
|
||||||
masterIter() += slaveIter();
|
// Same inter-region
|
||||||
|
const Map<label>& slaveInfo = slaveIter();
|
||||||
|
Map<label>& masterInfo = masterIter();
|
||||||
|
|
||||||
|
forAllConstIter(Map<label>, slaveInfo, iter)
|
||||||
|
{
|
||||||
|
label zoneID = iter.key();
|
||||||
|
label slaveSize = iter();
|
||||||
|
|
||||||
|
Map<label>::iterator zoneFnd = masterInfo.find
|
||||||
|
(
|
||||||
|
zoneID
|
||||||
|
);
|
||||||
|
if (zoneFnd != masterInfo.end())
|
||||||
|
{
|
||||||
|
zoneFnd() += slaveSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
masterInfo.insert(zoneID, slaveSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interfaceSizes.insert(slaveIter.key(), slaveIter());
|
regionsToSize.insert(slaveIter.key(), slaveIter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Distribute
|
|
||||||
for
|
|
||||||
(
|
|
||||||
int slave=Pstream::firstSlave();
|
|
||||||
slave<=Pstream::lastSlave();
|
|
||||||
slave++
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Receive the edges using shared points from the slave.
|
|
||||||
OPstream toSlave(Pstream::blocking, slave);
|
|
||||||
toSlave << interfaceSizes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send to master
|
// Send to master
|
||||||
{
|
{
|
||||||
OPstream toMaster(Pstream::blocking, Pstream::masterNo());
|
OPstream toMaster(Pstream::blocking, Pstream::masterNo());
|
||||||
toMaster << interfaceSizes;
|
toMaster << regionsToSize;
|
||||||
}
|
|
||||||
// Receive from master
|
|
||||||
{
|
|
||||||
IPstream fromMaster(Pstream::blocking, Pstream::masterNo());
|
|
||||||
fromMaster >> interfaceSizes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all processors have interfaces in same order
|
// Rework
|
||||||
interfaces = interfaceSizes.toc();
|
|
||||||
if (sumParallel)
|
Pstream::scatter(regionsToSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Now we have the global sizes of all inter-regions.
|
||||||
|
// Invert this on master and distribute.
|
||||||
|
label nInterfaces = 0;
|
||||||
|
forAllConstIter(EdgeMap<Map<label> >, regionsToSize, iter)
|
||||||
{
|
{
|
||||||
Pstream::scatter(interfaces);
|
const Map<label>& info = iter();
|
||||||
|
nInterfaces += info.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces.setSize(nInterfaces);
|
||||||
|
interfaceNames.setSize(nInterfaces);
|
||||||
|
interfaceSizes.setSize(nInterfaces);
|
||||||
|
EdgeMap<Map<label> > regionsToInterface(nInterfaces);
|
||||||
|
|
||||||
|
nInterfaces = 0;
|
||||||
|
forAllConstIter(EdgeMap<Map<label> >, regionsToSize, iter)
|
||||||
|
{
|
||||||
|
const edge& e = iter.key();
|
||||||
|
const word& name0 = regionNames[e[0]];
|
||||||
|
const word& name1 = regionNames[e[1]];
|
||||||
|
|
||||||
|
const Map<label>& info = iter();
|
||||||
|
forAllConstIter(Map<label>, info, infoIter)
|
||||||
|
{
|
||||||
|
interfaces[nInterfaces] = iter.key();
|
||||||
|
label zoneID = infoIter.key();
|
||||||
|
if (zoneID == -1)
|
||||||
|
{
|
||||||
|
interfaceNames[nInterfaces] = Pair<word>
|
||||||
|
(
|
||||||
|
name0 + "_to_" + name1,
|
||||||
|
name1 + "_to_" + name0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const word& zoneName = mesh.faceZones()[zoneID].name();
|
||||||
|
interfaceNames[nInterfaces] = Pair<word>
|
||||||
|
(
|
||||||
|
zoneName + "_" + name0 + "_to_" + name1,
|
||||||
|
zoneName + "_" + name1 + "_to_" + name0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
interfaceSizes[nInterfaces] = infoIter();
|
||||||
|
|
||||||
|
Map<label> zoneAndInterface;
|
||||||
|
zoneAndInterface.insert(zoneID, nInterfaces);
|
||||||
|
regionsToInterface.insert(e, zoneAndInterface);
|
||||||
|
|
||||||
|
nInterfaces++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Now all processor have consistent interface information
|
||||||
|
|
||||||
|
Pstream::scatter(interfaces);
|
||||||
|
Pstream::scatter(interfaceNames);
|
||||||
|
Pstream::scatter(interfaceSizes);
|
||||||
|
Pstream::scatter(regionsToInterface);
|
||||||
|
|
||||||
|
// Mark all inter-region faces.
|
||||||
|
faceToInterface.setSize(mesh.nFaces(), -1);
|
||||||
|
|
||||||
|
forAll(mesh.faceNeighbour(), faceI)
|
||||||
|
{
|
||||||
|
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
|
||||||
|
label neiRegion = cellRegion[mesh.faceNeighbour()[faceI]];
|
||||||
|
|
||||||
|
if (ownRegion != neiRegion)
|
||||||
|
{
|
||||||
|
label zoneID = -1;
|
||||||
|
if (useFaceZones)
|
||||||
|
{
|
||||||
|
zoneID = mesh.faceZones().whichZone(faceI);
|
||||||
|
}
|
||||||
|
|
||||||
|
edge interface
|
||||||
|
(
|
||||||
|
min(ownRegion, neiRegion),
|
||||||
|
max(ownRegion, neiRegion)
|
||||||
|
);
|
||||||
|
|
||||||
|
faceToInterface[faceI] = regionsToInterface[interface][zoneID];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forAll(coupledRegion, i)
|
||||||
|
{
|
||||||
|
label faceI = i+mesh.nInternalFaces();
|
||||||
|
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
|
||||||
|
label neiRegion = coupledRegion[i];
|
||||||
|
|
||||||
|
if (ownRegion != neiRegion)
|
||||||
|
{
|
||||||
|
label zoneID = -1;
|
||||||
|
if (useFaceZones)
|
||||||
|
{
|
||||||
|
zoneID = mesh.faceZones().whichZone(faceI);
|
||||||
|
}
|
||||||
|
|
||||||
|
edge interface
|
||||||
|
(
|
||||||
|
min(ownRegion, neiRegion),
|
||||||
|
max(ownRegion, neiRegion)
|
||||||
|
);
|
||||||
|
|
||||||
|
faceToInterface[faceI] = regionsToInterface[interface][zoneID];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,11 +802,15 @@ void getInterfaceSizes
|
|||||||
// Create mesh for region.
|
// Create mesh for region.
|
||||||
autoPtr<mapPolyMesh> createRegionMesh
|
autoPtr<mapPolyMesh> createRegionMesh
|
||||||
(
|
(
|
||||||
const labelList& cellRegion,
|
|
||||||
const EdgeMap<label>& interfaceToPatch,
|
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
|
// Region info
|
||||||
|
const labelList& cellRegion,
|
||||||
const label regionI,
|
const label regionI,
|
||||||
const word& regionName,
|
const word& regionName,
|
||||||
|
// Interface info
|
||||||
|
const labelList& interfacePatches,
|
||||||
|
const labelList& faceToInterface,
|
||||||
|
|
||||||
autoPtr<fvMesh>& newMesh
|
autoPtr<fvMesh>& newMesh
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -739,6 +895,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
|||||||
forAll(exposedFaces, i)
|
forAll(exposedFaces, i)
|
||||||
{
|
{
|
||||||
label faceI = exposedFaces[i];
|
label faceI = exposedFaces[i];
|
||||||
|
label interfaceI = faceToInterface[faceI];
|
||||||
|
|
||||||
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
|
label ownRegion = cellRegion[mesh.faceOwner()[faceI]];
|
||||||
label neiRegion = -1;
|
label neiRegion = -1;
|
||||||
@ -752,6 +909,10 @@ autoPtr<mapPolyMesh> createRegionMesh
|
|||||||
neiRegion = coupledRegion[faceI-mesh.nInternalFaces()];
|
neiRegion = coupledRegion[faceI-mesh.nInternalFaces()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check which side is being kept - determines which of the two
|
||||||
|
// patches will be used.
|
||||||
|
|
||||||
label otherRegion = -1;
|
label otherRegion = -1;
|
||||||
|
|
||||||
if (ownRegion == regionI && neiRegion != regionI)
|
if (ownRegion == regionI && neiRegion != regionI)
|
||||||
@ -773,19 +934,14 @@ autoPtr<mapPolyMesh> createRegionMesh
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherRegion != -1)
|
// Find the patch.
|
||||||
|
if (regionI < otherRegion)
|
||||||
{
|
{
|
||||||
edge interface(regionI, otherRegion);
|
exposedPatchIDs[i] = interfacePatches[interfaceI];
|
||||||
|
}
|
||||||
// Find the patch.
|
else
|
||||||
if (regionI < otherRegion)
|
{
|
||||||
{
|
exposedPatchIDs[i] = interfacePatches[interfaceI]+1;
|
||||||
exposedPatchIDs[i] = interfaceToPatch[interface];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
exposedPatchIDs[i] = interfaceToPatch[interface]+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +977,8 @@ void createAndWriteRegion
|
|||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
const labelList& cellRegion,
|
const labelList& cellRegion,
|
||||||
const wordList& regionNames,
|
const wordList& regionNames,
|
||||||
const EdgeMap<label>& interfaceToPatch,
|
const labelList& faceToInterface,
|
||||||
|
const labelList& interfacePatches,
|
||||||
const label regionI,
|
const label regionI,
|
||||||
const word& newMeshInstance
|
const word& newMeshInstance
|
||||||
)
|
)
|
||||||
@ -832,21 +989,22 @@ void createAndWriteRegion
|
|||||||
autoPtr<fvMesh> newMesh;
|
autoPtr<fvMesh> newMesh;
|
||||||
autoPtr<mapPolyMesh> map = createRegionMesh
|
autoPtr<mapPolyMesh> map = createRegionMesh
|
||||||
(
|
(
|
||||||
cellRegion,
|
|
||||||
interfaceToPatch,
|
|
||||||
mesh,
|
mesh,
|
||||||
|
cellRegion,
|
||||||
regionI,
|
regionI,
|
||||||
regionNames[regionI],
|
regionNames[regionI],
|
||||||
|
interfacePatches,
|
||||||
|
faceToInterface,
|
||||||
newMesh
|
newMesh
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Make map of all added patches
|
// Make map of all added patches
|
||||||
labelHashSet addedPatches(2*interfaceToPatch.size());
|
labelHashSet addedPatches(2*interfacePatches.size());
|
||||||
forAllConstIter(EdgeMap<label>, interfaceToPatch, iter)
|
forAll(interfacePatches, interfaceI)
|
||||||
{
|
{
|
||||||
addedPatches.insert(iter());
|
addedPatches.insert(interfacePatches[interfaceI]);
|
||||||
addedPatches.insert(iter()+1);
|
addedPatches.insert(interfacePatches[interfaceI]+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Mapping fields" << endl;
|
Info<< "Mapping fields" << endl;
|
||||||
@ -1074,70 +1232,67 @@ void createAndWriteRegion
|
|||||||
// First one is for minimumregion to maximumregion.
|
// First one is for minimumregion to maximumregion.
|
||||||
// Note that patches get created in same order on all processors (if parallel)
|
// Note that patches get created in same order on all processors (if parallel)
|
||||||
// since looping over synchronised 'interfaces'.
|
// since looping over synchronised 'interfaces'.
|
||||||
EdgeMap<label> addRegionPatches
|
labelList addRegionPatches
|
||||||
(
|
(
|
||||||
fvMesh& mesh,
|
fvMesh& mesh,
|
||||||
const labelList& cellRegion,
|
const wordList& regionNames,
|
||||||
const label nCellRegions,
|
|
||||||
const edgeList& interfaces,
|
const edgeList& interfaces,
|
||||||
const EdgeMap<label>& interfaceSizes,
|
const List<Pair<word> >& interfaceNames
|
||||||
const wordList& regionNames
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Check that all patches are present in same order.
|
|
||||||
mesh.boundaryMesh().checkParallelSync(true);
|
|
||||||
|
|
||||||
Info<< nl << "Adding patches" << nl << endl;
|
Info<< nl << "Adding patches" << nl << endl;
|
||||||
|
|
||||||
EdgeMap<label> interfaceToPatch(nCellRegions);
|
labelList interfacePatches(interfaces.size());
|
||||||
|
|
||||||
forAll(interfaces, interI)
|
forAll(interfaces, interI)
|
||||||
{
|
{
|
||||||
const edge& e = interfaces[interI];
|
const edge& e = interfaces[interI];
|
||||||
|
const Pair<word>& names = interfaceNames[interI];
|
||||||
|
|
||||||
if (interfaceSizes[e] > 0)
|
//Info<< "For interface " << interI
|
||||||
{
|
// << " between regions " << e
|
||||||
const word inter1 = regionNames[e[0]] + "_to_" + regionNames[e[1]];
|
// << " trying to add patches " << names << endl;
|
||||||
const word inter2 = regionNames[e[1]] + "_to_" + regionNames[e[0]];
|
|
||||||
|
|
||||||
directMappedWallPolyPatch patch1
|
|
||||||
(
|
|
||||||
inter1,
|
|
||||||
0, // overridden
|
|
||||||
0, // overridden
|
|
||||||
0, // overridden
|
|
||||||
regionNames[e[1]], // sampleRegion
|
|
||||||
directMappedPatchBase::NEARESTPATCHFACE,
|
|
||||||
inter2, // samplePatch
|
|
||||||
point::zero, // offset
|
|
||||||
mesh.boundaryMesh()
|
|
||||||
);
|
|
||||||
|
|
||||||
label patchI = addPatch(mesh, patch1);
|
directMappedWallPolyPatch patch1
|
||||||
|
(
|
||||||
|
names[0],
|
||||||
|
0, // overridden
|
||||||
|
0, // overridden
|
||||||
|
0, // overridden
|
||||||
|
regionNames[e[1]], // sampleRegion
|
||||||
|
directMappedPatchBase::NEARESTPATCHFACE,
|
||||||
|
names[1], // samplePatch
|
||||||
|
point::zero, // offset
|
||||||
|
mesh.boundaryMesh()
|
||||||
|
);
|
||||||
|
|
||||||
directMappedWallPolyPatch patch2
|
interfacePatches[interI] = addPatch(mesh, patch1);
|
||||||
(
|
|
||||||
inter2,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
regionNames[e[0]], // sampleRegion
|
|
||||||
directMappedPatchBase::NEARESTPATCHFACE,
|
|
||||||
inter1,
|
|
||||||
point::zero, // offset
|
|
||||||
mesh.boundaryMesh()
|
|
||||||
);
|
|
||||||
addPatch(mesh, patch2);
|
|
||||||
|
|
||||||
Info<< "For interface between region " << e[0]
|
directMappedWallPolyPatch patch2
|
||||||
<< " and " << e[1] << " added patch " << patchI
|
(
|
||||||
<< " " << mesh.boundaryMesh()[patchI].name()
|
names[1],
|
||||||
<< endl;
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
regionNames[e[0]], // sampleRegion
|
||||||
|
directMappedPatchBase::NEARESTPATCHFACE,
|
||||||
|
names[0],
|
||||||
|
point::zero, // offset
|
||||||
|
mesh.boundaryMesh()
|
||||||
|
);
|
||||||
|
addPatch(mesh, patch2);
|
||||||
|
|
||||||
interfaceToPatch.insert(e, patchI);
|
Info<< "For interface between region " << regionNames[e[0]]
|
||||||
}
|
<< " and " << regionNames[e[1]] << " added patches" << endl
|
||||||
|
<< " " << interfacePatches[interI]
|
||||||
|
<< "\t" << mesh.boundaryMesh()[interfacePatches[interI]].name()
|
||||||
|
<< endl
|
||||||
|
<< " " << interfacePatches[interI]+1
|
||||||
|
<< "\t" << mesh.boundaryMesh()[interfacePatches[interI]+1].name()
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
return interfaceToPatch;
|
return interfacePatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1195,76 +1350,6 @@ label findCorrespondingRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//// Checks if cellZone has corresponding cellRegion.
|
|
||||||
//label findCorrespondingRegion
|
|
||||||
//(
|
|
||||||
// const cellZoneMesh& cellZones,
|
|
||||||
// const labelList& existingZoneID, // per cell the (unique) zoneID
|
|
||||||
// const labelList& cellRegion,
|
|
||||||
// const label nCellRegions,
|
|
||||||
// const label zoneI
|
|
||||||
//)
|
|
||||||
//{
|
|
||||||
// // Region corresponding to zone. Start off with special value: no
|
|
||||||
// // corresponding region.
|
|
||||||
// label regionI = labelMax;
|
|
||||||
//
|
|
||||||
// const cellZone& cz = cellZones[zoneI];
|
|
||||||
//
|
|
||||||
// if (cz.empty())
|
|
||||||
// {
|
|
||||||
// // My local portion is empty. Maps to any empty cellZone. Mark with
|
|
||||||
// // special value which can get overwritten by other processors.
|
|
||||||
// regionI = -1;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// regionI = cellRegion[cz[0]];
|
|
||||||
//
|
|
||||||
// forAll(cz, i)
|
|
||||||
// {
|
|
||||||
// if (cellRegion[cz[i]] != regionI)
|
|
||||||
// {
|
|
||||||
// regionI = labelMax;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Determine same zone over all processors.
|
|
||||||
// reduce(regionI, maxOp<label>());
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // 2. All of region present?
|
|
||||||
//
|
|
||||||
// if (regionI == labelMax)
|
|
||||||
// {
|
|
||||||
// regionI = -1;
|
|
||||||
// }
|
|
||||||
// else if (regionI != -1)
|
|
||||||
// {
|
|
||||||
// forAll(cellRegion, cellI)
|
|
||||||
// {
|
|
||||||
// if
|
|
||||||
// (
|
|
||||||
// cellRegion[cellI] == regionI
|
|
||||||
// && existingZoneID[cellI] != zoneI
|
|
||||||
// )
|
|
||||||
// {
|
|
||||||
// // cellI in regionI but not in zoneI
|
|
||||||
// regionI = -1;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // If one in error, all should be in error. Note that branch
|
|
||||||
// // gets taken on all procs.
|
|
||||||
// reduce(regionI, minOp<label>());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return regionI;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// Get zone per cell
|
// Get zone per cell
|
||||||
// - non-unique zoning
|
// - non-unique zoning
|
||||||
// - coupled zones
|
// - coupled zones
|
||||||
@ -1484,6 +1569,7 @@ void writeCellToRegion(const fvMesh& mesh, const labelList& cellRegion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -1541,6 +1627,11 @@ int main(int argc, char *argv[])
|
|||||||
"sloppyCellZones",
|
"sloppyCellZones",
|
||||||
"try to match heuristically regions to existing cell zones"
|
"try to match heuristically regions to existing cell zones"
|
||||||
);
|
);
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"useFaceZones",
|
||||||
|
"use faceZones to patch inter-region faces instead of single patch"
|
||||||
|
);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
@ -1564,6 +1655,8 @@ int main(int argc, char *argv[])
|
|||||||
const bool overwrite = args.optionFound("overwrite");
|
const bool overwrite = args.optionFound("overwrite");
|
||||||
const bool detectOnly = args.optionFound("detectOnly");
|
const bool detectOnly = args.optionFound("detectOnly");
|
||||||
const bool sloppyCellZones = args.optionFound("sloppyCellZones");
|
const bool sloppyCellZones = args.optionFound("sloppyCellZones");
|
||||||
|
const bool useFaceZones = args.optionFound("useFaceZones");
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
(useCellZonesOnly || useCellZonesFile)
|
(useCellZonesOnly || useCellZonesFile)
|
||||||
@ -1579,6 +1672,20 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (useFaceZones)
|
||||||
|
{
|
||||||
|
Info<< "Using current faceZones to divide inter-region interfaces"
|
||||||
|
<< " into multiple patches."
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "Creating single patch per inter-region interface."
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (insidePoint && largestOnly)
|
if (insidePoint && largestOnly)
|
||||||
{
|
{
|
||||||
FatalErrorIn(args.executable())
|
FatalErrorIn(args.executable())
|
||||||
@ -1768,6 +1875,7 @@ int main(int argc, char *argv[])
|
|||||||
writeCellToRegion(mesh, cellRegion);
|
writeCellToRegion(mesh, cellRegion);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sizes per region
|
// Sizes per region
|
||||||
// ~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -1805,34 +1913,48 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Since we're going to mess with patches make sure all non-processor ones
|
// Since we're going to mess with patches and zones make sure all
|
||||||
// are on all processors.
|
// is synchronised
|
||||||
mesh.boundaryMesh().checkParallelSync(true);
|
mesh.boundaryMesh().checkParallelSync(true);
|
||||||
|
mesh.faceZones().checkParallelSync(true);
|
||||||
|
|
||||||
|
|
||||||
// Sizes of interface between regions. From pair of regions to number of
|
// Interfaces
|
||||||
// faces.
|
// ----------
|
||||||
|
// per interface:
|
||||||
|
// - the two regions on either side
|
||||||
|
// - the name
|
||||||
|
// - the (global) size
|
||||||
edgeList interfaces;
|
edgeList interfaces;
|
||||||
EdgeMap<label> interfaceSizes;
|
List<Pair<word> > interfaceNames;
|
||||||
|
labelList interfaceSizes;
|
||||||
|
// per face the interface
|
||||||
|
labelList faceToInterface;
|
||||||
|
|
||||||
getInterfaceSizes
|
getInterfaceSizes
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
|
useFaceZones,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
true, // sum in parallel?
|
regionNames,
|
||||||
|
|
||||||
interfaces,
|
interfaces,
|
||||||
interfaceSizes
|
interfaceNames,
|
||||||
|
interfaceSizes,
|
||||||
|
faceToInterface
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "Sizes inbetween regions:" << nl << nl
|
Info<< "Sizes of interfaces between regions:" << nl << nl
|
||||||
<< "Region\tRegion\tFaces" << nl
|
<< "Interface\tRegion\tRegion\tFaces" << nl
|
||||||
<< "------\t------\t-----" << endl;
|
<< "---------\t------\t------\t-----" << endl;
|
||||||
|
|
||||||
forAll(interfaces, interI)
|
forAll(interfaces, interI)
|
||||||
{
|
{
|
||||||
const edge& e = interfaces[interI];
|
const edge& e = interfaces[interI];
|
||||||
|
|
||||||
Info<< e[0] << '\t' << e[1] << '\t' << interfaceSizes[e] << nl;
|
Info<< interI
|
||||||
|
<< "\t\t" << e[0] << '\t' << e[1]
|
||||||
|
<< '\t' << interfaceSizes[interI] << nl;
|
||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
@ -1982,16 +2104,14 @@ int main(int argc, char *argv[])
|
|||||||
// Add all possible patches. Empty ones get filtered later on.
|
// Add all possible patches. Empty ones get filtered later on.
|
||||||
Info<< nl << "Adding patches" << nl << endl;
|
Info<< nl << "Adding patches" << nl << endl;
|
||||||
|
|
||||||
EdgeMap<label> interfaceToPatch
|
labelList interfacePatches
|
||||||
(
|
(
|
||||||
addRegionPatches
|
addRegionPatches
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
cellRegion,
|
regionNames,
|
||||||
nCellRegions,
|
|
||||||
interfaces,
|
interfaces,
|
||||||
interfaceSizes,
|
interfaceNames
|
||||||
regionNames
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2041,7 +2161,8 @@ int main(int argc, char *argv[])
|
|||||||
mesh,
|
mesh,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
regionNames,
|
regionNames,
|
||||||
interfaceToPatch,
|
faceToInterface,
|
||||||
|
interfacePatches,
|
||||||
regionI,
|
regionI,
|
||||||
(overwrite ? oldInstance : runTime.timeName())
|
(overwrite ? oldInstance : runTime.timeName())
|
||||||
);
|
);
|
||||||
@ -2059,7 +2180,8 @@ int main(int argc, char *argv[])
|
|||||||
mesh,
|
mesh,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
regionNames,
|
regionNames,
|
||||||
interfaceToPatch,
|
faceToInterface,
|
||||||
|
interfacePatches,
|
||||||
regionI,
|
regionI,
|
||||||
(overwrite ? oldInstance : runTime.timeName())
|
(overwrite ? oldInstance : runTime.timeName())
|
||||||
);
|
);
|
||||||
@ -2078,7 +2200,8 @@ int main(int argc, char *argv[])
|
|||||||
mesh,
|
mesh,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
regionNames,
|
regionNames,
|
||||||
interfaceToPatch,
|
faceToInterface,
|
||||||
|
interfacePatches,
|
||||||
regionI,
|
regionI,
|
||||||
(overwrite ? oldInstance : runTime.timeName())
|
(overwrite ? oldInstance : runTime.timeName())
|
||||||
);
|
);
|
||||||
|
|||||||
@ -162,12 +162,14 @@ do
|
|||||||
procCmdFile="$PWD/processor${proc}.sh"
|
procCmdFile="$PWD/processor${proc}.sh"
|
||||||
procLog="processor${proc}.log"
|
procLog="processor${proc}.log"
|
||||||
geom="-geometry 120x20+$xpos+$ypos"
|
geom="-geometry 120x20+$xpos+$ypos"
|
||||||
node=""
|
|
||||||
|
|
||||||
if [ "$WM_MPLIB" = OPENMPI ]
|
case "$WM_MPLIB" in
|
||||||
then
|
*OPENMPI)
|
||||||
node="-np 1 "
|
node="-np 1 "
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
node=""
|
||||||
|
esac
|
||||||
|
|
||||||
echo "#!/bin/sh" > $procCmdFile
|
echo "#!/bin/sh" > $procCmdFile
|
||||||
case "$method" in
|
case "$method" in
|
||||||
|
|||||||
@ -28,8 +28,8 @@ License
|
|||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
|
||||||
:
|
:
|
||||||
List<T>(SizeInc),
|
List<T>(0),
|
||||||
capacity_(SizeInc)
|
capacity_(0)
|
||||||
{
|
{
|
||||||
List<T>::size(0);
|
List<T>::size(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,87 +25,53 @@ License
|
|||||||
|
|
||||||
#include "DynamicField.H"
|
#include "DynamicField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
{
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField(Istream& is)
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const char* const DynamicField<Type>::typeName("DynamicField");
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
DynamicField<Type>::DynamicField(Istream& is)
|
|
||||||
:
|
:
|
||||||
Field<Type>(is),
|
Field<T>(is),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
tmp<DynamicField<Type> > DynamicField<Type>::clone() const
|
Foam::tmp<Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv> >
|
||||||
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clone() const
|
||||||
{
|
{
|
||||||
return tmp<DynamicField<Type> >(new DynamicField<Type>(*this));
|
return tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv> >
|
||||||
|
(
|
||||||
|
new DynamicField<T, SizeInc, SizeMult, SizeDiv>(*this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void DynamicField<Type>::setSize(const label nElem)
|
|
||||||
{
|
|
||||||
// allocate more capacity?
|
|
||||||
if (nElem > capacity_)
|
|
||||||
{
|
|
||||||
capacity_ = max(nElem, label(1 + capacity_*2));
|
|
||||||
|
|
||||||
Field<Type>::setSize(capacity_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// adjust addressed size
|
|
||||||
Field<Type>::size(nElem);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Ostream& operator<<(Ostream& os, const DynamicField<Type>& f)
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
|
)
|
||||||
{
|
{
|
||||||
os << static_cast<const Field<Type>&>(f);
|
os << static_cast<const Field<T>&>(lst);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Ostream& operator<<(Ostream& os, const tmp<DynamicField<Type> >& tf)
|
Foam::Istream& Foam::operator>>
|
||||||
|
(
|
||||||
|
Istream& is,
|
||||||
|
DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
|
)
|
||||||
{
|
{
|
||||||
os << tf();
|
is >> static_cast<Field<T>&>(lst);
|
||||||
tf.clear();
|
lst.capacity_ = lst.Field<T>::size();
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Istream& operator>>(Istream& is, DynamicField<Type>& lst)
|
|
||||||
{
|
|
||||||
is >> static_cast<Field<Type>&>(lst);
|
|
||||||
lst.capacity_ = lst.Field<Type>::size();
|
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -25,9 +25,10 @@ Class
|
|||||||
Foam::DynamicField
|
Foam::DynamicField
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Dynamically sized Field. WIP.
|
Dynamically sized Field.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
|
DynamicFieldI.H
|
||||||
DynamicField.C
|
DynamicField.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -44,89 +45,78 @@ namespace Foam
|
|||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
class DynamicField;
|
class DynamicField;
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Ostream& operator<<(Ostream&, const DynamicField<Type>&);
|
Ostream& operator<<
|
||||||
|
(
|
||||||
template<class Type>
|
Ostream&,
|
||||||
Ostream& operator<<(Ostream&, const tmp<DynamicField<Type> >&);
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Istream& operator>>(Istream&, DynamicField<Type>&);
|
Istream& operator>>
|
||||||
|
(
|
||||||
|
Istream&,
|
||||||
|
DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class DynamicField Declaration
|
Class DynamicField Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc=0, unsigned SizeMult=2, unsigned SizeDiv=1>
|
||||||
class DynamicField
|
class DynamicField
|
||||||
:
|
:
|
||||||
public Field<Type>
|
public Field<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- The capacity (allocated size) of the underlying field.
|
//- The capacity (allocated size) of the underlying field.
|
||||||
label capacity_;
|
label capacity_;
|
||||||
|
|
||||||
|
|
||||||
//- Construct given size and initial value
|
|
||||||
DynamicField(const label, const Type&);
|
|
||||||
|
|
||||||
//- Construct as copy of tmp<DynamicField>
|
|
||||||
# ifdef ConstructFromTmp
|
|
||||||
DynamicField(const tmp<DynamicField<Type> >&);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
//- Construct from a dictionary entry
|
|
||||||
DynamicField(const word&, const dictionary&, const label);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
|
||||||
|
|
||||||
static const char* const typeName;
|
|
||||||
|
|
||||||
|
|
||||||
// Static Member Functions
|
// Static Member Functions
|
||||||
|
|
||||||
//- Return a null field
|
//- Return a null field
|
||||||
inline static const DynamicField<Type>& null()
|
inline static const DynamicField<T, SizeInc, SizeMult, SizeDiv>& null()
|
||||||
{
|
{
|
||||||
return *reinterpret_cast< DynamicField<Type>* >(0);
|
return *reinterpret_cast
|
||||||
|
<
|
||||||
|
DynamicField<T, SizeInc, SizeMult, SizeDiv>*
|
||||||
|
>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
// Used for temporary fields which are initialised after construction
|
inline DynamicField();
|
||||||
DynamicField();
|
|
||||||
|
|
||||||
//- Construct given size
|
//- Construct given size.
|
||||||
// Used for temporary fields which are initialised after construction
|
|
||||||
explicit inline DynamicField(const label);
|
explicit inline DynamicField(const label);
|
||||||
|
|
||||||
//- Construct as copy of a UList\<Type\>
|
//- Construct from UList. Size set to UList size.
|
||||||
explicit inline DynamicField(const UList<Type>&);
|
// Also constructs from DynamicField with different sizing parameters.
|
||||||
|
explicit inline DynamicField(const UList<T>&);
|
||||||
|
|
||||||
//- Construct by transferring the List contents
|
//- Construct by transferring the parameter contents
|
||||||
explicit inline DynamicField(const Xfer<List<Type> >&);
|
explicit inline DynamicField(const Xfer<List<T> >&);
|
||||||
|
|
||||||
//- Construct by 1 to 1 mapping from the given field
|
//- Construct by 1 to 1 mapping from the given field
|
||||||
inline DynamicField
|
inline DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const labelList& mapAddressing
|
const labelList& mapAddressing
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct by interpolative mapping from the given field
|
//- Construct by interpolative mapping from the given field
|
||||||
inline DynamicField
|
inline DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const labelListList& mapAddressing,
|
const labelListList& mapAddressing,
|
||||||
const scalarListList& weights
|
const scalarListList& weights
|
||||||
);
|
);
|
||||||
@ -134,59 +124,129 @@ public:
|
|||||||
//- Construct by mapping from the given field
|
//- Construct by mapping from the given field
|
||||||
inline DynamicField
|
inline DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const FieldMapper& map
|
const FieldMapper& map
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct copy
|
||||||
inline DynamicField(const DynamicField<Type>&);
|
inline DynamicField(const DynamicField<T, SizeInc, SizeMult, SizeDiv>&);
|
||||||
|
|
||||||
//- Construct as copy or re-use as specified.
|
|
||||||
inline DynamicField(DynamicField<Type>&, bool reUse);
|
|
||||||
|
|
||||||
//- Construct by transferring the Field contents
|
//- Construct by transferring the Field contents
|
||||||
inline DynamicField(const Xfer<DynamicField<Type> >&);
|
inline DynamicField
|
||||||
|
(
|
||||||
|
const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv> >&
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream. Size set to size of list read.
|
||||||
inline DynamicField(Istream&);
|
explicit DynamicField(Istream&);
|
||||||
|
|
||||||
//- Clone
|
//- Clone
|
||||||
tmp<DynamicField<Type> > clone() const;
|
tmp<DynamicField<T, SizeInc, SizeMult, SizeDiv> > clone() const;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Size of the underlying storage.
|
// Access
|
||||||
inline label capacity() const;
|
|
||||||
|
|
||||||
//- Append an element at the end of the list
|
//- Size of the underlying storage.
|
||||||
inline void append(const Type&);
|
inline label capacity() const;
|
||||||
|
|
||||||
//- Alter the addressed list size.
|
// Edit
|
||||||
// New space will be allocated if required.
|
|
||||||
// Use this to resize the list prior to using the operator[] for
|
|
||||||
// setting values (as per List usage).
|
|
||||||
void setSize(const label nElem);
|
|
||||||
|
|
||||||
// Member operators
|
//- Alter the size of the underlying storage.
|
||||||
|
// The addressed size will be truncated if needed to fit, but will
|
||||||
|
// remain otherwise untouched.
|
||||||
|
// Use this or reserve() in combination with append().
|
||||||
|
inline void setCapacity(const label);
|
||||||
|
|
||||||
inline void operator=(const DynamicField<Type>&);
|
//- Alter the addressed list size.
|
||||||
inline void operator=(const UList<Type>&);
|
// New space will be allocated if required.
|
||||||
inline void operator=(const tmp<DynamicField<Type> >&);
|
// Use this to resize the list prior to using the operator[] for
|
||||||
|
// setting values (as per List usage).
|
||||||
|
inline void setSize(const label);
|
||||||
|
|
||||||
//- Return element of Field.
|
//- Alter the addressed list size and fill new space with a
|
||||||
using Field<Type>::operator[];
|
// constant.
|
||||||
|
inline void setSize(const label, const T&);
|
||||||
|
|
||||||
// IOstream operators
|
//- Alter the addressed list size.
|
||||||
|
// New space will be allocated if required.
|
||||||
|
// Use this to resize the list prior to using the operator[] for
|
||||||
|
// setting values (as per List usage).
|
||||||
|
inline void resize(const label);
|
||||||
|
|
||||||
friend Ostream& operator<< <Type>
|
//- Alter the addressed list size and fill new space with a
|
||||||
(Ostream&, const DynamicField<Type>&);
|
// constant.
|
||||||
|
inline void resize(const label, const T&);
|
||||||
|
|
||||||
friend Ostream& operator<< <Type>
|
//- Reserve allocation space for at least this size.
|
||||||
(Ostream&, const tmp<DynamicField<Type> >&);
|
// Never shrinks the allocated size, use setCapacity() for that.
|
||||||
|
inline void reserve(const label);
|
||||||
|
|
||||||
friend Istream& operator>> <Type>
|
//- Clear the addressed list, i.e. set the size to zero.
|
||||||
(Istream&, DynamicField<Type>&);
|
// Allocated size does not change
|
||||||
|
inline void clear();
|
||||||
|
|
||||||
|
//- Clear the list and delete storage.
|
||||||
|
inline void clearStorage();
|
||||||
|
|
||||||
|
//- Shrink the allocated space to the number of elements used.
|
||||||
|
// Returns a reference to the DynamicField.
|
||||||
|
inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& shrink();
|
||||||
|
|
||||||
|
//- Transfer contents to the Xfer container as a plain List
|
||||||
|
inline Xfer<List<T> > xfer();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Append an element at the end of the list
|
||||||
|
inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append
|
||||||
|
(
|
||||||
|
const T&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Append a List at the end of this list
|
||||||
|
inline DynamicField<T, SizeInc, SizeMult, SizeDiv>& append
|
||||||
|
(
|
||||||
|
const UList<T>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Remove and return the top element
|
||||||
|
inline T remove();
|
||||||
|
|
||||||
|
//- Return non-const access to an element, resizing list if
|
||||||
|
// necessary
|
||||||
|
inline T& operator()(const label);
|
||||||
|
|
||||||
|
//- Assignment of all addressed entries to the given value
|
||||||
|
inline void operator=(const T&);
|
||||||
|
|
||||||
|
//- Assignment from DynamicField
|
||||||
|
inline void operator=
|
||||||
|
(
|
||||||
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Assignment from UList
|
||||||
|
inline void operator=(const UList<T>&);
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream operators
|
||||||
|
|
||||||
|
// Write DynamicField to Ostream.
|
||||||
|
friend Ostream& operator<< <T, SizeInc, SizeMult, SizeDiv>
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Read from Istream, discarding contents of existing DynamicField.
|
||||||
|
friend Istream& operator>> <T, SizeInc, SizeMult, SizeDiv>
|
||||||
|
(
|
||||||
|
Istream&,
|
||||||
|
DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,175 +23,441 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "DynamicField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField()
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField()
|
||||||
:
|
:
|
||||||
Field<Type>(),
|
Field<T>(0),
|
||||||
capacity_(0)
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField(const label size)
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
|
(
|
||||||
|
const label nElem
|
||||||
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(size),
|
Field<T>(nElem),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{
|
{
|
||||||
Field<Type>::size(0);
|
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||||
|
Field<T>::size(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicField<Type>::DynamicField
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& lst
|
const UList<T>& lst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(lst),
|
Field<T>(lst),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicField<Type>::DynamicField
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
(
|
(
|
||||||
const Xfer<List<Type> >& lst
|
const Xfer<List<T> >& lst
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(lst),
|
Field<T>(lst),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const labelList& mapAddressing
|
const labelList& mapAddressing
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(mapF, mapAddressing),
|
Field<T>(mapF, mapAddressing),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const labelListList& mapAddressing,
|
const labelListList& mapAddressing,
|
||||||
const scalarListList& weights
|
const scalarListList& weights
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(mapF, mapAddressing, weights),
|
Field<T>(mapF, mapAddressing, weights),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct by mapping from the given field
|
//- Construct by mapping from the given field
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
(
|
(
|
||||||
const UList<Type>& mapF,
|
const UList<T>& mapF,
|
||||||
const FieldMapper& map
|
const FieldMapper& map
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
DynamicField<Type>(mapF, map),
|
Field<T>(mapF, map),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField(const DynamicField<Type>& f)
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
|
(
|
||||||
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(f),
|
Field<T>(lst),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(lst.capacity())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicField<Type>::DynamicField(DynamicField<Type>& f, bool reUse)
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::DynamicField
|
||||||
|
(
|
||||||
|
const Xfer<DynamicField<T, SizeInc, SizeMult, SizeDiv> >& lst
|
||||||
|
)
|
||||||
:
|
:
|
||||||
Field<Type>(f, reUse),
|
Field<T>(lst),
|
||||||
capacity_(Field<Type>::size())
|
capacity_(Field<T>::size())
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::DynamicField<Type>::DynamicField(const Xfer<DynamicField<Type> >& f)
|
|
||||||
:
|
|
||||||
Field<Type>(f),
|
|
||||||
capacity_(Field<Type>::size())
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::label Foam::DynamicField<Type>::capacity() const
|
inline Foam::label Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::capacity()
|
||||||
|
const
|
||||||
{
|
{
|
||||||
return capacity_;
|
return capacity_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void Foam::DynamicField<Type>::append(const Type& t)
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setCapacity
|
||||||
|
(
|
||||||
|
const label nElem
|
||||||
|
)
|
||||||
{
|
{
|
||||||
label elemI = Field<Type>::size();
|
label nextFree = Field<T>::size();
|
||||||
|
capacity_ = nElem;
|
||||||
|
|
||||||
|
if (nextFree > capacity_)
|
||||||
|
{
|
||||||
|
// truncate addressed sizes too
|
||||||
|
nextFree = capacity_;
|
||||||
|
}
|
||||||
|
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||||
|
|
||||||
|
Field<T>::setSize(capacity_);
|
||||||
|
Field<T>::size(nextFree);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::reserve
|
||||||
|
(
|
||||||
|
const label nElem
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// allocate more capacity?
|
||||||
|
if (nElem > capacity_)
|
||||||
|
{
|
||||||
|
// TODO: convince the compiler that division by zero does not occur
|
||||||
|
// if (SizeInc && (!SizeMult || !SizeDiv))
|
||||||
|
// {
|
||||||
|
// // resize with SizeInc as the granularity
|
||||||
|
// capacity_ = nElem;
|
||||||
|
// unsigned pad = SizeInc - (capacity_ % SizeInc);
|
||||||
|
// if (pad != SizeInc)
|
||||||
|
// {
|
||||||
|
// capacity_ += pad;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
capacity_ = max
|
||||||
|
(
|
||||||
|
nElem,
|
||||||
|
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// adjust allocated size, leave addressed size untouched
|
||||||
|
label nextFree = Field<T>::size();
|
||||||
|
Field<T>::setSize(capacity_);
|
||||||
|
Field<T>::size(nextFree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize
|
||||||
|
(
|
||||||
|
const label nElem
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// allocate more capacity?
|
||||||
|
if (nElem > capacity_)
|
||||||
|
{
|
||||||
|
// TODO: convince the compiler that division by zero does not occur
|
||||||
|
// if (SizeInc && (!SizeMult || !SizeDiv))
|
||||||
|
// {
|
||||||
|
// // resize with SizeInc as the granularity
|
||||||
|
// capacity_ = nElem;
|
||||||
|
// unsigned pad = SizeInc - (capacity_ % SizeInc);
|
||||||
|
// if (pad != SizeInc)
|
||||||
|
// {
|
||||||
|
// capacity_ += pad;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
capacity_ = max
|
||||||
|
(
|
||||||
|
nElem,
|
||||||
|
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Field<T>::setSize(capacity_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// adjust addressed size
|
||||||
|
Field<T>::size(nElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::setSize
|
||||||
|
(
|
||||||
|
const label nElem,
|
||||||
|
const T& t
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label nextFree = Field<T>::size();
|
||||||
|
setSize(nElem);
|
||||||
|
|
||||||
|
// set new elements to constant value
|
||||||
|
while (nextFree < nElem)
|
||||||
|
{
|
||||||
|
this->operator[](nextFree++) = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize
|
||||||
|
(
|
||||||
|
const label nElem
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->setSize(nElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::resize
|
||||||
|
(
|
||||||
|
const label nElem,
|
||||||
|
const T& t
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->setSize(nElem, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clear()
|
||||||
|
{
|
||||||
|
Field<T>::size(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
|
||||||
|
{
|
||||||
|
Field<T>::clear();
|
||||||
|
capacity_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::shrink()
|
||||||
|
{
|
||||||
|
label nextFree = Field<T>::size();
|
||||||
|
if (capacity_ > nextFree)
|
||||||
|
{
|
||||||
|
// use the full list when resizing
|
||||||
|
Field<T>::size(capacity_);
|
||||||
|
|
||||||
|
// the new size
|
||||||
|
capacity_ = nextFree;
|
||||||
|
Field<T>::setSize(capacity_);
|
||||||
|
Field<T>::size(nextFree);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::Xfer<Foam::List<T> >
|
||||||
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::xfer()
|
||||||
|
{
|
||||||
|
return xferMoveTo< List<T> >(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
|
(
|
||||||
|
const T& t
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const label elemI = List<T>::size();
|
||||||
setSize(elemI + 1);
|
setSize(elemI + 1);
|
||||||
|
|
||||||
this->operator[](elemI) = t;
|
this->operator[](elemI) = t;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
|
(
|
||||||
|
const UList<T>& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (this == &lst)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"DynamicField<T, SizeInc, SizeMult, SizeDiv>::append"
|
||||||
|
"(const UList<T>&)"
|
||||||
|
) << "attempted appending to self" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
label nextFree = List<T>::size();
|
||||||
|
setSize(nextFree + lst.size());
|
||||||
|
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline T Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove()
|
||||||
|
{
|
||||||
|
const label elemI = List<T>::size() - 1;
|
||||||
|
|
||||||
|
if (elemI < 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::remove()"
|
||||||
|
) << "List is empty" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& val = List<T>::operator[](elemI);
|
||||||
|
|
||||||
|
List<T>::size(elemI);
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void Foam::DynamicField<Type>::operator=(const DynamicField<Type>& rhs)
|
inline T& Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator()
|
||||||
|
(
|
||||||
|
const label elemI
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (this == &rhs)
|
if (elemI >= Field<T>::size())
|
||||||
{
|
{
|
||||||
FatalErrorIn("DynamicField<Type>::operator=(const DynamicField<Type>&)")
|
setSize(elemI + 1);
|
||||||
<< "attempted assignment to self"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Field<Type>::operator=(rhs);
|
return this->operator[](elemI);
|
||||||
capacity_ = Field<Type>::size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void Foam::DynamicField<Type>::operator=(const UList<Type>& rhs)
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
|
||||||
|
(
|
||||||
|
const T& t
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Field<Type>::operator=(rhs);
|
UList<T>::operator=(t);
|
||||||
capacity_ = Field<Type>::size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void Foam::DynamicField<Type>::operator=(const tmp<DynamicField>& rhs)
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
|
||||||
|
(
|
||||||
|
const DynamicField<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (this == &(rhs()))
|
if (this == &lst)
|
||||||
{
|
{
|
||||||
FatalErrorIn("DynamicField<Type>::operator=(const tmp<DynamicField>&)")
|
FatalErrorIn
|
||||||
<< "attempted assignment to self"
|
(
|
||||||
<< abort(FatalError);
|
"DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator="
|
||||||
|
"(const DynamicField<T, SizeInc, SizeMult, SizeDiv>&)"
|
||||||
|
) << "attempted assignment to self" << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is dodgy stuff, don't try it at home.
|
if (capacity_ >= lst.size())
|
||||||
DynamicField* fieldPtr = rhs.ptr();
|
{
|
||||||
List<Type>::transfer(*fieldPtr);
|
// can copy w/o reallocating, match initial size to avoid reallocation
|
||||||
delete fieldPtr;
|
Field<T>::size(lst.size());
|
||||||
capacity_ = Field<Type>::size();
|
Field<T>::operator=(lst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make everything available for the copy operation
|
||||||
|
Field<T>::size(capacity_);
|
||||||
|
|
||||||
|
Field<T>::operator=(lst);
|
||||||
|
capacity_ = Field<T>::size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
|
inline void Foam::DynamicField<T, SizeInc, SizeMult, SizeDiv>::operator=
|
||||||
|
(
|
||||||
|
const UList<T>& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (capacity_ >= lst.size())
|
||||||
|
{
|
||||||
|
// can copy w/o reallocating, match initial size to avoid reallocation
|
||||||
|
Field<T>::size(lst.size());
|
||||||
|
Field<T>::operator=(lst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make everything available for the copy operation
|
||||||
|
Field<T>::size(capacity_);
|
||||||
|
|
||||||
|
Field<T>::operator=(lst);
|
||||||
|
capacity_ = Field<T>::size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -27,7 +27,7 @@ License
|
|||||||
|
|
||||||
inline bool Foam::smoothData::update
|
inline bool Foam::smoothData::update
|
||||||
(
|
(
|
||||||
const smoothData::smoothData& svf,
|
const smoothData& svf,
|
||||||
const scalar scale,
|
const scalar scale,
|
||||||
const scalar tol
|
const scalar tol
|
||||||
)
|
)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License
|
|||||||
|
|
||||||
inline bool Foam::sweepData::update
|
inline bool Foam::sweepData::update
|
||||||
(
|
(
|
||||||
const sweepData::sweepData& svf,
|
const sweepData& svf,
|
||||||
const point& position,
|
const point& position,
|
||||||
const scalar tol
|
const scalar tol
|
||||||
)
|
)
|
||||||
|
|||||||
@ -617,30 +617,25 @@ bool Foam::meshSearch::pointInCell(const point& p, label cellI) const
|
|||||||
{
|
{
|
||||||
label faceI = cFaces[i];
|
label faceI = cFaces[i];
|
||||||
|
|
||||||
const face& f = mesh_.faces()[faceI];
|
pointHit inter = mesh_.faces()[faceI].ray
|
||||||
|
(
|
||||||
|
ctr,
|
||||||
|
dir,
|
||||||
|
mesh_.points(),
|
||||||
|
intersection::HALF_RAY,
|
||||||
|
intersection::VECTOR
|
||||||
|
);
|
||||||
|
|
||||||
forAll(f, fp)
|
if (inter.hit())
|
||||||
{
|
{
|
||||||
pointHit inter = f.ray
|
scalar dist = inter.distance();
|
||||||
(
|
|
||||||
ctr,
|
|
||||||
dir,
|
|
||||||
mesh_.points(),
|
|
||||||
intersection::HALF_RAY,
|
|
||||||
intersection::VECTOR
|
|
||||||
);
|
|
||||||
|
|
||||||
if (inter.hit())
|
if (dist < magDir)
|
||||||
{
|
{
|
||||||
scalar dist = inter.distance();
|
// Valid hit. Hit face so point is not in cell.
|
||||||
|
intersection::setPlanarTol(oldTol);
|
||||||
|
|
||||||
if (dist < magDir)
|
return false;
|
||||||
{
|
|
||||||
// Valid hit. Hit face so point is not in cell.
|
|
||||||
intersection::setPlanarTol(oldTol);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,9 +51,10 @@ Foam::scalar Foam::streamLineParticle::calcSubCycleDeltaT
|
|||||||
td.keepParticle = oldKeepParticle;
|
td.keepParticle = oldKeepParticle;
|
||||||
td.switchProcessor = oldSwitchProcessor;
|
td.switchProcessor = oldSwitchProcessor;
|
||||||
// Adapt the dt to subdivide the trajectory into 4 substeps.
|
// Adapt the dt to subdivide the trajectory into 4 substeps.
|
||||||
return dt *fraction/td.nSubCycle_;
|
return dt*fraction/td.nSubCycle_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vector Foam::streamLineParticle::interpolateFields
|
Foam::vector Foam::streamLineParticle::interpolateFields
|
||||||
(
|
(
|
||||||
const streamLineParticle::trackData& td,
|
const streamLineParticle::trackData& td,
|
||||||
@ -191,8 +192,12 @@ bool Foam::streamLineParticle::move(streamLineParticle::trackData& td)
|
|||||||
// set the lagrangian time-step
|
// set the lagrangian time-step
|
||||||
scalar dt = min(dtMax, tEnd);
|
scalar dt = min(dtMax, tEnd);
|
||||||
|
|
||||||
// Cross cell in steps
|
// Cross cell in steps:
|
||||||
for (label subIter = 0; subIter < td.nSubCycle_; subIter++)
|
// - at subiter 0 calculate dt to cross cell in nSubCycle steps
|
||||||
|
// - at the last subiter do all of the remaining track
|
||||||
|
// - do a few more subiters than nSubCycle since velocity might
|
||||||
|
// be decreasing
|
||||||
|
for (label subIter = 0; subIter < 2*td.nSubCycle_; subIter++)
|
||||||
{
|
{
|
||||||
--lifeTime_;
|
--lifeTime_;
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ functions
|
|||||||
// Names of fields to sample. Should contain above velocity field!
|
// Names of fields to sample. Should contain above velocity field!
|
||||||
fields (p U k);
|
fields (p U k);
|
||||||
|
|
||||||
// Cells particles can travel before being removed
|
// Steps particles can travel before being removed
|
||||||
lifeTime 10000;
|
lifeTime 10000;
|
||||||
|
|
||||||
// Number of steps per cell (estimate). Set to 1 to disable subcycling.
|
// Number of steps per cell (estimate). Set to 1 to disable subcycling.
|
||||||
|
|||||||
@ -84,7 +84,7 @@ functions
|
|||||||
// Names of fields to sample. Should contain above velocity field!
|
// Names of fields to sample. Should contain above velocity field!
|
||||||
fields (p k U);
|
fields (p k U);
|
||||||
|
|
||||||
// Cells particles can travel before being removed
|
// Steps particles can travel before being removed
|
||||||
lifeTime 10000;
|
lifeTime 10000;
|
||||||
|
|
||||||
// Number of steps per cell (estimate). Set to 1 to disable subcycling.
|
// Number of steps per cell (estimate). Set to 1 to disable subcycling.
|
||||||
|
|||||||
Reference in New Issue
Block a user