mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into cvm
This commit is contained in:
77
ReleaseNotes-dev
Normal file
77
ReleaseNotes-dev
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# -*- mode: org; -*-
|
||||||
|
#
|
||||||
|
#+TITLE: OpenFOAM release notes for version dev
|
||||||
|
#+AUTHOR: OpenCFD Ltd.
|
||||||
|
#+DATE: TBA
|
||||||
|
#+LINK: http://www.openfoam.com
|
||||||
|
#+OPTIONS: author:nil ^:{}
|
||||||
|
# Copyright (c) 2010 OpenCFD Ltd.
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
OpenFOAM-dev is the latest major release of OpenFOAM including many new
|
||||||
|
developments a number of bug-fixes. This release passes our standard tests
|
||||||
|
and the tutorials have been broadly checked. Please report any bugs by
|
||||||
|
following the link: http://www.openfoam.com/bugs.
|
||||||
|
|
||||||
|
* GNU/Linux version
|
||||||
|
This release of OpenFOAM is distributed primarily in 2 ways: (1) as a Debian
|
||||||
|
pack containing binaries and source; (2) from the SourceForge source code
|
||||||
|
repository (see [[./README.org][README]]).
|
||||||
|
|
||||||
|
The Ubuntu/Debian pack is available for 32 and 64 bit versions of the 10.04
|
||||||
|
LTS operating system using the system compiler and libraries that will be
|
||||||
|
installed automatically from standard Debian packs.
|
||||||
|
|
||||||
|
To use the source version from the SourceForge repository, we provide a source
|
||||||
|
pack of third-party packages that can be compiled on the user's system. This
|
||||||
|
does not include =gcc=, since the system installed version is typically
|
||||||
|
sufficient, but includes =paraview-3.8.0=, =openmpi-1.4.1=, =scotch_5.1=,
|
||||||
|
=metis-5.0pre2=, =ParMetis-3.1= and =ParMGridGen-1.0=.
|
||||||
|
|
||||||
|
* Library developments
|
||||||
|
There have been a number of developments to the libraries to support the
|
||||||
|
extension of functionality in solver and utility applications.
|
||||||
|
*** Core library
|
||||||
|
+ Large number of code refinements and consistency improvements to support
|
||||||
|
other developments.
|
||||||
|
*** Turbulence modelling
|
||||||
|
*** Thermo-physical Models
|
||||||
|
*** DSMC
|
||||||
|
*** Dynamic Mesh
|
||||||
|
*** Numerics
|
||||||
|
|
||||||
|
* Solvers
|
||||||
|
A number of new solvers have been developed for a range of engineering
|
||||||
|
applications. There has been a set of improvements to certain classes of
|
||||||
|
solver that are introduced in this release.
|
||||||
|
*** *New* Solvers
|
||||||
|
+ ...
|
||||||
|
*** Modifications to multiphase and buoyant solvers
|
||||||
|
+ ...
|
||||||
|
*** Modifications to solvers for sensible enthalpy
|
||||||
|
+ ...
|
||||||
|
*** Modifications to steady-state compressible solvers
|
||||||
|
+ ...
|
||||||
|
*** Other modifications
|
||||||
|
+ ...
|
||||||
|
|
||||||
|
* Boundary conditions
|
||||||
|
New boundary conditions have been introduced to support new applications in
|
||||||
|
OpenFOAM.
|
||||||
|
+ ...
|
||||||
|
|
||||||
|
* Utilities
|
||||||
|
There have been some utilities added and updated in this release.
|
||||||
|
*** *New* utilities
|
||||||
|
+ ...
|
||||||
|
*** Updated utilities
|
||||||
|
+ ...
|
||||||
|
|
||||||
|
* Post-processing
|
||||||
|
+ =foamToEnsight=: new =-nodeValues= option to generate and output nodal
|
||||||
|
field data.
|
||||||
|
|
||||||
|
* New tutorials
|
||||||
|
There is a large number of new tutorials to support the new solvers in the
|
||||||
|
release.
|
||||||
|
+ ...
|
||||||
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
volScalarField kappaEff
|
kappat = turbulence->nut()/Prt;
|
||||||
(
|
kappat.correctBoundaryConditions();
|
||||||
"kappaEff",
|
|
||||||
turbulence->nu()/Pr + turbulence->nut()/Prt
|
volScalarField kappaEff("kappaEff", turbulence->nu()/Pr + kappat);
|
||||||
);
|
|
||||||
|
|
||||||
fvScalarMatrix TEqn
|
fvScalarMatrix TEqn
|
||||||
(
|
(
|
||||||
|
|||||||
@ -52,6 +52,21 @@
|
|||||||
incompressible::RASModel::New(U, phi, laminarTransport)
|
incompressible::RASModel::New(U, phi, laminarTransport)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// kinematic turbulent thermal thermal conductivity m2/s
|
||||||
|
Info<< "Reading field kappat\n" << endl;
|
||||||
|
volScalarField kappat
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"kappat",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
label pRefCell = 0;
|
label pRefCell = 0;
|
||||||
scalar pRefValue = 0.0;
|
scalar pRefValue = 0.0;
|
||||||
setRefCell
|
setRefCell
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
volScalarField kappaEff
|
kappat = turbulence->nut()/Prt;
|
||||||
(
|
kappat.correctBoundaryConditions();
|
||||||
"kappaEff",
|
|
||||||
turbulence->nu()/Pr + turbulence->nut()/Prt
|
volScalarField kappaEff("kappaEff", turbulence->nu()/Pr + kappat);
|
||||||
);
|
|
||||||
|
|
||||||
fvScalarMatrix TEqn
|
fvScalarMatrix TEqn
|
||||||
(
|
(
|
||||||
|
|||||||
@ -64,6 +64,21 @@
|
|||||||
1.0 - beta*(T - TRef)
|
1.0 - beta*(T - TRef)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// kinematic turbulent thermal thermal conductivity m2/s
|
||||||
|
Info<< "Reading field kappat\n" << endl;
|
||||||
|
volScalarField kappat
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"kappat",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
Info<< "Calculating field g.h\n" << endl;
|
Info<< "Calculating field g.h\n" << endl;
|
||||||
volScalarField gh("gh", g & mesh.C());
|
volScalarField gh("gh", g & mesh.C());
|
||||||
surfaceScalarField ghf("ghf", g & mesh.Cf());
|
surfaceScalarField ghf("ghf", g & mesh.Cf());
|
||||||
|
|||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -30,6 +30,15 @@ Description
|
|||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
|
template<class ListType>
|
||||||
|
void printInfo(const ListType& lst)
|
||||||
|
{
|
||||||
|
Info<< "addr: " << lst.addressing() << nl
|
||||||
|
<< "list: " << lst << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -42,8 +51,7 @@ int main(int argc, char *argv[])
|
|||||||
completeList[i] = 0.1*i;
|
completeList[i] = 0.1*i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "raw : " << completeList << nl
|
Info<< "raw : " << completeList << nl << endl;
|
||||||
<< endl;
|
|
||||||
|
|
||||||
|
|
||||||
List<label> addresses(5);
|
List<label> addresses(5);
|
||||||
@ -53,11 +61,9 @@ int main(int argc, char *argv[])
|
|||||||
addresses[3] = 8;
|
addresses[3] = 8;
|
||||||
addresses[4] = 5;
|
addresses[4] = 5;
|
||||||
|
|
||||||
IndirectList<double> idl(completeList, addresses);
|
IndirectList<double> idl1(completeList, addresses);
|
||||||
|
|
||||||
Info<< "addr: " << idl.addressing() << nl
|
printInfo(idl1);
|
||||||
<< "list: " << idl() << nl
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
addresses[4] = 1;
|
addresses[4] = 1;
|
||||||
addresses[3] = 0;
|
addresses[3] = 0;
|
||||||
@ -65,11 +71,26 @@ int main(int argc, char *argv[])
|
|||||||
addresses[1] = 8;
|
addresses[1] = 8;
|
||||||
addresses[0] = 5;
|
addresses[0] = 5;
|
||||||
|
|
||||||
idl.resetAddressing(addresses.xfer());
|
idl1.resetAddressing(addresses.xfer());
|
||||||
|
|
||||||
Info<< "addr: " << idl.addressing() << nl
|
printInfo(idl1);
|
||||||
<< "list: " << idl() << nl
|
|
||||||
<< endl;
|
// test copying
|
||||||
|
UIndirectList<double> uidl1(idl1);
|
||||||
|
IndirectList<double> idl2(uidl1);
|
||||||
|
IndirectList<double> idl3(idl2);
|
||||||
|
|
||||||
|
printInfo(uidl1);
|
||||||
|
|
||||||
|
idl1.resetAddressing(List<label>());
|
||||||
|
// idl2.resetAddressing(List<label>());
|
||||||
|
|
||||||
|
Info<<"after resetAddressing:" << nl << endl;
|
||||||
|
|
||||||
|
printInfo(uidl1);
|
||||||
|
printInfo(idl1);
|
||||||
|
printInfo(idl2);
|
||||||
|
printInfo(idl3);
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (args.optionFound("info"))
|
if (args.optionFound("info"))
|
||||||
{
|
{
|
||||||
packLst.print(Info);
|
packLst.printInfo(Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|||||||
@ -42,42 +42,42 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "\ntest allocation with value\n";
|
Info<< "\ntest allocation with value\n";
|
||||||
PackedList<3> list1(5,1);
|
PackedList<3> list1(5,1);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign uniform value\n";
|
Info<< "\ntest assign uniform value\n";
|
||||||
list1 = 3;
|
list1 = 3;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign uniform value (with overflow)\n";
|
Info<< "\ntest assign uniform value (with overflow)\n";
|
||||||
list1 = -1;
|
list1 = -1;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest zero\n";
|
Info<< "\ntest zero\n";
|
||||||
list1 = 0;
|
list1 = 0;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest set() with default argument (max_value)\n";
|
Info<< "\ntest set() with default argument (max_value)\n";
|
||||||
list1.set(1);
|
list1.set(1);
|
||||||
list1.set(3);
|
list1.set(3);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest unset() with in-range and out-of-range\n";
|
Info<< "\ntest unset() with in-range and out-of-range\n";
|
||||||
list1.unset(3);
|
list1.unset(3);
|
||||||
list1.unset(100000);
|
list1.unset(100000);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign between references\n";
|
Info<< "\ntest assign between references\n";
|
||||||
list1[2] = 3;
|
list1[2] = 3;
|
||||||
list1[4] = list1[2];
|
list1[4] = list1[2];
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign between references, with chaining\n";
|
Info<< "\ntest assign between references, with chaining\n";
|
||||||
list1[0] = list1[4] = 1;
|
list1[0] = list1[4] = 1;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign between references, with chaining and auto-vivify\n";
|
Info<< "\ntest assign between references, with chaining and auto-vivify\n";
|
||||||
list1[1] = list1[8] = list1[10] = list1[14] = 2;
|
list1[1] = list1[8] = list1[10] = list1[14] = 2;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntest operator== between references\n";
|
Info<< "\ntest operator== between references\n";
|
||||||
@ -126,7 +126,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const PackedList<3>& constLst = list1;
|
const PackedList<3>& constLst = list1;
|
||||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||||
constLst.print(Info);
|
constLst.printInfo(Info, true);
|
||||||
if (constLst[20])
|
if (constLst[20])
|
||||||
{
|
{
|
||||||
Info<< "[20] is true (unexpected)\n";
|
Info<< "[20] is true (unexpected)\n";
|
||||||
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "[20] is false (expected) list size should be unchanged "
|
Info<< "[20] is false (expected) list size should be unchanged "
|
||||||
<< "(const)\n";
|
<< "(const)\n";
|
||||||
}
|
}
|
||||||
constLst.print(Info);
|
constLst.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
||||||
if (list1[20])
|
if (list1[20])
|
||||||
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "[20] is false (expected) but list was resized?? "
|
Info<< "[20] is false (expected) but list was resized?? "
|
||||||
<< "(non-const)\n";
|
<< "(non-const)\n";
|
||||||
}
|
}
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -157,85 +157,85 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "[20] is false, as expected\n";
|
Info<< "[20] is false, as expected\n";
|
||||||
}
|
}
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest resize with value (without reallocation)\n";
|
Info<< "\ntest resize with value (without reallocation)\n";
|
||||||
list1.resize(8, list1.max_value());
|
list1.resize(8, list1.max_value());
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest flip() function\n";
|
Info<< "\ntest flip() function\n";
|
||||||
list1.flip();
|
list1.flip();
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\nre-flip()\n";
|
Info<< "\nre-flip()\n";
|
||||||
list1.flip();
|
list1.flip();
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest set() function\n";
|
Info<< "\ntest set() function\n";
|
||||||
list1.set(1, 5);
|
list1.set(1, 5);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign bool\n";
|
Info<< "\ntest assign bool\n";
|
||||||
list1 = false;
|
list1 = false;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest assign bool\n";
|
Info<< "\ntest assign bool\n";
|
||||||
list1 = true;
|
list1 = true;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest resize without value (with reallocation)\n";
|
Info<< "\ntest resize without value (with reallocation)\n";
|
||||||
list1.resize(12);
|
list1.resize(12);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest resize with value (with reallocation)\n";
|
Info<< "\ntest resize with value (with reallocation)\n";
|
||||||
list1.resize(25, list1.max_value());
|
list1.resize(25, list1.max_value());
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest resize smaller (should not touch allocation)\n";
|
Info<< "\ntest resize smaller (should not touch allocation)\n";
|
||||||
list1.resize(8);
|
list1.resize(8);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest append() operation\n";
|
Info<< "\ntest append() operation\n";
|
||||||
list1.append(2);
|
list1.append(2);
|
||||||
list1.append(3);
|
list1.append(3);
|
||||||
list1.append(4);
|
list1.append(4);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest reserve() operation\n";
|
Info<< "\ntest reserve() operation\n";
|
||||||
list1.reserve(32);
|
list1.reserve(32);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest shrink() operation\n";
|
Info<< "\ntest shrink() operation\n";
|
||||||
list1.shrink();
|
list1.shrink();
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest setCapacity() operation\n";
|
Info<< "\ntest setCapacity() operation\n";
|
||||||
list1.setCapacity(15);
|
list1.setCapacity(15);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest setCapacity() operation\n";
|
Info<< "\ntest setCapacity() operation\n";
|
||||||
list1.setCapacity(100);
|
list1.setCapacity(100);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest operator[] assignment\n";
|
Info<< "\ntest operator[] assignment\n";
|
||||||
list1[16] = 5;
|
list1[16] = 5;
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest operator[] assignment with auto-vivify\n";
|
Info<< "\ntest operator[] assignment with auto-vivify\n";
|
||||||
list1[36] = list1.max_value();
|
list1[36] = list1.max_value();
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest setCapacity smaller\n";
|
Info<< "\ntest setCapacity smaller\n";
|
||||||
list1.setCapacity(24);
|
list1.setCapacity(24);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest resize much smaller\n";
|
Info<< "\ntest resize much smaller\n";
|
||||||
list1.resize(150);
|
list1.resize(150);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest trim\n";
|
Info<< "\ntest trim\n";
|
||||||
list1.trim();
|
list1.trim();
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
// add in some misc values
|
// add in some misc values
|
||||||
list1[31] = 1;
|
list1[31] = 1;
|
||||||
@ -245,40 +245,40 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "\ntest iterator\n";
|
Info<< "\ntest iterator\n";
|
||||||
PackedList<3>::iterator iter = list1.begin();
|
PackedList<3>::iterator iter = list1.begin();
|
||||||
Info<< "begin():";
|
Info<< "begin():";
|
||||||
iter.print(Info) << "\n";
|
iter.printInfo(Info) << "\n";
|
||||||
|
|
||||||
Info<< "iterator:" << iter() << "\n";
|
Info<< "iterator:" << iter() << "\n";
|
||||||
iter() = 5;
|
iter() = 5;
|
||||||
iter.print(Info);
|
iter.printInfo(Info);
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
iter = list1[31];
|
iter = list1[31];
|
||||||
Info<< "iterator:" << iter() << "\n";
|
Info<< "iterator:" << iter() << "\n";
|
||||||
iter.print(Info);
|
iter.printInfo(Info);
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntest get() method\n";
|
Info<< "\ntest get() method\n";
|
||||||
Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n";
|
Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n";
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest iterator indexing\n";
|
Info<< "\ntest iterator indexing\n";
|
||||||
Info<< "cend() ";
|
Info<< "cend() ";
|
||||||
list1.cend().print(Info) << "\n";
|
list1.cend().printInfo(Info) << "\n";
|
||||||
|
|
||||||
{
|
{
|
||||||
Info<< "\ntest assignment of iterator\n";
|
Info<< "\ntest assignment of iterator\n";
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
Info<< "cend()\n";
|
Info<< "cend()\n";
|
||||||
list1.end().print(Info);
|
list1.end().printInfo(Info);
|
||||||
PackedList<3>::iterator cit = list1[100];
|
PackedList<3>::iterator cit = list1[100];
|
||||||
Info<< "out-of-range: ";
|
Info<< "out-of-range: ";
|
||||||
cit.print(Info);
|
cit.printInfo(Info);
|
||||||
cit = list1[15];
|
cit = list1[15];
|
||||||
Info<< "in-range: ";
|
Info<< "in-range: ";
|
||||||
cit.print(Info);
|
cit.printInfo(Info);
|
||||||
Info<< "out-of-range: ";
|
Info<< "out-of-range: ";
|
||||||
cit = list1[1000];
|
cit = list1[1000];
|
||||||
cit.print(Info);
|
cit.printInfo(Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ int main(int argc, char *argv[])
|
|||||||
++cit
|
++cit
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cit.print(Info);
|
cit.printInfo(Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\ntest operator[] auto-vivify\n";
|
Info<< "\ntest operator[] auto-vivify\n";
|
||||||
@ -304,16 +304,16 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "size after write:" << list1.size() << "\n";
|
Info<< "size after write:" << list1.size() << "\n";
|
||||||
Info<< "list[45]:" << list1[45] << "\n";
|
Info<< "list[45]:" << list1[45] << "\n";
|
||||||
list1[49] = list1[100];
|
list1[49] = list1[100];
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntest copy constructor + append\n";
|
Info<< "\ntest copy constructor + append\n";
|
||||||
PackedList<3> list2(list1);
|
PackedList<3> list2(list1);
|
||||||
list2.append(4);
|
list2.append(4);
|
||||||
Info<< "source list:\n";
|
Info<< "source list:\n";
|
||||||
list1.print(Info);
|
list1.printInfo(Info, true);
|
||||||
Info<< "destination list:\n";
|
Info<< "destination list:\n";
|
||||||
list2.print(Info);
|
list2.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "\ntest pattern that fills all bits\n";
|
Info<< "\ntest pattern that fills all bits\n";
|
||||||
PackedList<4> list3(8, 8);
|
PackedList<4> list3(8, 8);
|
||||||
@ -323,29 +323,50 @@ int main(int argc, char *argv[])
|
|||||||
list3[pos--] = list3.max_value();
|
list3[pos--] = list3.max_value();
|
||||||
list3[pos--] = 0;
|
list3[pos--] = 0;
|
||||||
list3[pos--] = list3.max_value();
|
list3[pos--] = list3.max_value();
|
||||||
list3.print(Info);
|
list3.printInfo(Info, true);
|
||||||
|
|
||||||
Info<< "removed final value: " << list3.remove() << endl;
|
Info<< "removed final value: " << list3.remove() << endl;
|
||||||
list3.print(Info);
|
list3.printInfo(Info, true);
|
||||||
|
|
||||||
|
Info<<"list: " << list3 << endl;
|
||||||
|
|
||||||
|
|
||||||
List<bool> list4(4, true);
|
List<bool> list4(16, false);
|
||||||
{
|
{
|
||||||
const List<bool>& constLst = list4;
|
// fill with some values
|
||||||
|
forAll(list4, i)
|
||||||
|
{
|
||||||
|
list4[i] = i % 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UList<bool>& constLst = list4;
|
||||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||||
Info<< constLst << endl;
|
Info<< constLst << endl;
|
||||||
if (constLst[20])
|
if (constLst[100])
|
||||||
{
|
{
|
||||||
Info<< "[20] is true (unexpected)\n";
|
Info<< "[100] is true (unexpected)\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< "[20] is false (expected) list size should be unchanged "
|
Info<< "[100] is false (expected) "
|
||||||
<< "(const)\n";
|
<< "list size should be unchanged (const)\n";
|
||||||
}
|
}
|
||||||
Info<< constLst << endl;
|
Info<< constLst << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PackedBoolList listb(list4);
|
||||||
|
|
||||||
|
Info<< "copied from bool list " << endl;
|
||||||
|
listb.printInfo(Info, true);
|
||||||
|
|
||||||
|
{
|
||||||
|
labelList indices = listb.used();
|
||||||
|
|
||||||
|
Info<< "indices: " << indices << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Info<< "\n\nDone.\n";
|
Info<< "\n\nDone.\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -33,7 +33,6 @@ Description
|
|||||||
#include "StaticHashTable.H"
|
#include "StaticHashTable.H"
|
||||||
#include "cpuTime.H"
|
#include "cpuTime.H"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "PackedList.H"
|
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|||||||
3
applications/test/PackedList4/Make/files
Normal file
3
applications/test/PackedList4/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PackedListTest4.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/PackedListTest4
|
||||||
0
applications/test/PackedList4/Make/options
Normal file
0
applications/test/PackedList4/Make/options
Normal file
207
applications/test/PackedList4/PackedListTest4.C
Normal file
207
applications/test/PackedList4/PackedListTest4.C
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "uLabel.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "IStringStream.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
PackedBoolList list1(20);
|
||||||
|
// set every third one on
|
||||||
|
forAll(list1, i)
|
||||||
|
{
|
||||||
|
list1[i] = !(i % 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nalternating bit pattern\n";
|
||||||
|
list1.printInfo(Info, true);
|
||||||
|
|
||||||
|
PackedBoolList list2 = ~list1;
|
||||||
|
|
||||||
|
Info<< "\ncomplementary bit pattern\n";
|
||||||
|
list2.printBits(Info);
|
||||||
|
|
||||||
|
// set every other on
|
||||||
|
forAll(list2, i)
|
||||||
|
{
|
||||||
|
list2[i] = !(i % 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nalternating bit pattern\n";
|
||||||
|
list2.printBits(Info);
|
||||||
|
|
||||||
|
list2.resize(28, false);
|
||||||
|
list2.resize(34, true);
|
||||||
|
list2.resize(40, false);
|
||||||
|
for (label i=0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
list2[i] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nresized with false, 6 true + 6 false, bottom 4 bits true\n";
|
||||||
|
list2.printInfo(Info, true);
|
||||||
|
|
||||||
|
labelList list2Labels = list2.used();
|
||||||
|
|
||||||
|
Info<< "\noperator|\n";
|
||||||
|
|
||||||
|
list1.printBits(Info);
|
||||||
|
list2.printBits(Info);
|
||||||
|
Info<< "==\n";
|
||||||
|
(list1 | list2).printBits(Info);
|
||||||
|
|
||||||
|
Info<< "\noperator& : does trim\n";
|
||||||
|
(list1 & list2).printBits(Info);
|
||||||
|
|
||||||
|
Info<< "\noperator^\n";
|
||||||
|
(list1 ^ list2).printBits(Info);
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "\noperator|=\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 |= list2).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator|= with UList<label>\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 |= list2Labels).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator&=\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 &= list2).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator+=\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 += list2).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator+= with UList<label>\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 += list2Labels).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator-=\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 -= list2).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\noperator-= with UList<label>\n";
|
||||||
|
{
|
||||||
|
PackedBoolList list3 = list1;
|
||||||
|
(list3 -= list2Labels).printBits(Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
PackedBoolList list4
|
||||||
|
(
|
||||||
|
IStringStream
|
||||||
|
(
|
||||||
|
"(1 n 1 n 1 n 1 1 off 0 0 f f 0 y yes y true y false on t)"
|
||||||
|
)()
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "\ntest Istream constructor\n";
|
||||||
|
|
||||||
|
list4.printInfo(Info, true);
|
||||||
|
Info<< list4 << " indices: " << list4.used()() <<endl;
|
||||||
|
|
||||||
|
Info<< "\nassign from labelList\n";
|
||||||
|
list4 = labelList
|
||||||
|
(
|
||||||
|
IStringStream
|
||||||
|
(
|
||||||
|
"(0 1 2 3 12 13 14 19 20 21)"
|
||||||
|
)()
|
||||||
|
);
|
||||||
|
|
||||||
|
list4.printInfo(Info, true);
|
||||||
|
Info<< list4 << " indices: " << list4.used()() <<endl;
|
||||||
|
|
||||||
|
Info<< "\nassign from indices\n";
|
||||||
|
list4.read
|
||||||
|
(
|
||||||
|
IStringStream
|
||||||
|
(
|
||||||
|
"{0 1 2 3 12 13 14 19 20 21}"
|
||||||
|
)()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
list4.printInfo(Info, true);
|
||||||
|
Info<< list4 << " indices: " << list4.used()() <<endl;
|
||||||
|
|
||||||
|
List<bool> boolLst(list4.size());
|
||||||
|
forAll(list4, i)
|
||||||
|
{
|
||||||
|
boolLst[i] = list4[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "List<bool>: " << boolLst <<endl;
|
||||||
|
|
||||||
|
|
||||||
|
// check roundabout assignments
|
||||||
|
PackedList<2> pl2
|
||||||
|
(
|
||||||
|
IStringStream
|
||||||
|
(
|
||||||
|
"{(0 3)(1 3)(2 3)(3 3)(12 3)(13 3)(14 3)(19 3)(20 3)(21 3)}"
|
||||||
|
)()
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "roundabout assignment: " << pl2 << endl;
|
||||||
|
|
||||||
|
list4.clear();
|
||||||
|
forAll(pl2, i)
|
||||||
|
{
|
||||||
|
list4[i] = pl2[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
list4.write(Info, true) << endl;
|
||||||
|
|
||||||
|
list4.writeEntry("PackedBoolList", Info);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -57,4 +57,5 @@ EXE_LIBS = \
|
|||||||
-lthermophysicalFunctions \
|
-lthermophysicalFunctions \
|
||||||
-ltopoChangerFvMesh \
|
-ltopoChangerFvMesh \
|
||||||
-ltriSurface \
|
-ltriSurface \
|
||||||
|
-ltwoPhaseInterfaceProperties \
|
||||||
-lutilityFunctionObjects
|
-lutilityFunctionObjects
|
||||||
|
|||||||
@ -402,17 +402,17 @@ int main(int argc, char *argv[])
|
|||||||
PtrList< List<SLList<indexedParticle*>*> > cellParticles(cloudDirs.size());
|
PtrList< List<SLList<indexedParticle*>*> > cellParticles(cloudDirs.size());
|
||||||
|
|
||||||
PtrList<PtrList<labelIOField> > lagrangianLabelFields(cloudDirs.size());
|
PtrList<PtrList<labelIOField> > lagrangianLabelFields(cloudDirs.size());
|
||||||
PtrList<PtrList<labelIOFieldField> > lagrangianLabelFieldFields
|
PtrList<PtrList<labelFieldCompactIOField> > lagrangianLabelFieldFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
PtrList<PtrList<scalarIOField> > lagrangianScalarFields(cloudDirs.size());
|
PtrList<PtrList<scalarIOField> > lagrangianScalarFields(cloudDirs.size());
|
||||||
PtrList<PtrList<scalarIOFieldField> > lagrangianScalarFieldFields
|
PtrList<PtrList<scalarFieldCompactIOField> > lagrangianScalarFieldFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
PtrList<PtrList<vectorIOField> > lagrangianVectorFields(cloudDirs.size());
|
PtrList<PtrList<vectorIOField> > lagrangianVectorFields(cloudDirs.size());
|
||||||
PtrList<PtrList<vectorIOFieldField> > lagrangianVectorFieldFields
|
PtrList<PtrList<vectorFieldCompactIOField> > lagrangianVectorFieldFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
@ -420,13 +420,14 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
PtrList<PtrList<sphericalTensorIOFieldField> >
|
PtrList<PtrList<sphericalTensorFieldCompactIOField> >
|
||||||
lagrangianSphericalTensorFieldFields(cloudDirs.size());
|
lagrangianSphericalTensorFieldFields(cloudDirs.size());
|
||||||
PtrList<PtrList<symmTensorIOField> > lagrangianSymmTensorFields
|
PtrList<PtrList<symmTensorIOField> > lagrangianSymmTensorFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
PtrList<PtrList<symmTensorIOFieldField> > lagrangianSymmTensorFieldFields
|
PtrList<PtrList<symmTensorFieldCompactIOField> >
|
||||||
|
lagrangianSymmTensorFieldFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
@ -434,7 +435,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
PtrList<PtrList<tensorIOFieldField> > lagrangianTensorFieldFields
|
PtrList<PtrList<tensorFieldCompactIOField> > lagrangianTensorFieldFields
|
||||||
(
|
(
|
||||||
cloudDirs.size()
|
cloudDirs.size()
|
||||||
);
|
);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ SourceFiles
|
|||||||
#define lagrangianFieldDecomposer_H
|
#define lagrangianFieldDecomposer_H
|
||||||
|
|
||||||
#include "Cloud.H"
|
#include "Cloud.H"
|
||||||
#include "IOFieldField.H"
|
#include "CompactIOField.H"
|
||||||
#include "indexedParticle.H"
|
#include "indexedParticle.H"
|
||||||
#include "passiveParticle.H"
|
#include "passiveParticle.H"
|
||||||
|
|
||||||
@ -111,9 +111,9 @@ public:
|
|||||||
const IOobjectList& lagrangianObjects,
|
const IOobjectList& lagrangianObjects,
|
||||||
PtrList
|
PtrList
|
||||||
<
|
<
|
||||||
PtrList<IOFieldField<Field<Type>, Type> >
|
PtrList<CompactIOField<Field<Type>, Type> >
|
||||||
>& lagrangianFields
|
>& lagrangianFields
|
||||||
// PtrList<IOFieldField<Field<Type>, Type > >& lagrangianFields
|
// PtrList<CompactIOField<Field<Type>, Type > >& lagrangianFields
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -126,10 +126,10 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<IOFieldField<Field<Type>, Type> > decomposeFieldField
|
tmp<CompactIOField<Field<Type>, Type> > decomposeFieldField
|
||||||
(
|
(
|
||||||
const word& cloudName,
|
const word& cloudName,
|
||||||
const IOFieldField<Field<Type>, Type>& field
|
const CompactIOField<Field<Type>, Type>& field
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
|||||||
(
|
(
|
||||||
const label cloudI,
|
const label cloudI,
|
||||||
const IOobjectList& lagrangianObjects,
|
const IOobjectList& lagrangianObjects,
|
||||||
PtrList<PtrList<IOFieldField<Field<Type>, Type> > >& lagrangianFields
|
PtrList<PtrList<CompactIOField<Field<Type>, Type> > >& lagrangianFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Search list of objects for lagrangian fields
|
// Search list of objects for lagrangian fields
|
||||||
@ -79,13 +79,17 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
|||||||
|
|
||||||
IOobjectList lagrangianTypeObjectsB
|
IOobjectList lagrangianTypeObjectsB
|
||||||
(
|
(
|
||||||
lagrangianObjects.lookupClass(IOFieldField<Field<Type>, Type>::typeName)
|
lagrangianObjects.lookupClass
|
||||||
|
(
|
||||||
|
CompactIOField<Field<Type>,
|
||||||
|
Type>::typeName
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
lagrangianFields.set
|
lagrangianFields.set
|
||||||
(
|
(
|
||||||
cloudI,
|
cloudI,
|
||||||
new PtrList<IOFieldField<Field<Type>, Type> >
|
new PtrList<CompactIOField<Field<Type>, Type> >
|
||||||
(
|
(
|
||||||
lagrangianTypeObjectsA.size() + lagrangianTypeObjectsB.size()
|
lagrangianTypeObjectsA.size() + lagrangianTypeObjectsB.size()
|
||||||
)
|
)
|
||||||
@ -98,7 +102,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
|||||||
lagrangianFields[cloudI].set
|
lagrangianFields[cloudI].set
|
||||||
(
|
(
|
||||||
lagrangianFieldi++,
|
lagrangianFieldi++,
|
||||||
new IOFieldField<Field<Type>, Type>(*iter())
|
new CompactIOField<Field<Type>, Type>(*iter())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +111,7 @@ void Foam::lagrangianFieldDecomposer::readFieldFields
|
|||||||
lagrangianFields[cloudI].set
|
lagrangianFields[cloudI].set
|
||||||
(
|
(
|
||||||
lagrangianFieldi++,
|
lagrangianFieldi++,
|
||||||
new IOFieldField<Field<Type>, Type>(*iter())
|
new CompactIOField<Field<Type>, Type>(*iter())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,20 +149,20 @@ Foam::lagrangianFieldDecomposer::decomposeField
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::IOFieldField<Foam::Field<Type>, Type> >
|
Foam::tmp<Foam::CompactIOField<Foam::Field<Type>, Type> >
|
||||||
Foam::lagrangianFieldDecomposer::decomposeFieldField
|
Foam::lagrangianFieldDecomposer::decomposeFieldField
|
||||||
(
|
(
|
||||||
const word& cloudName,
|
const word& cloudName,
|
||||||
const IOFieldField<Field<Type>, Type>& field
|
const CompactIOField<Field<Type>, Type>& field
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Create and map the internal field values
|
// Create and map the internal field values
|
||||||
Field<Field<Type> > procField(field, particleIndices_);
|
Field<Field<Type> > procField(field, particleIndices_);
|
||||||
|
|
||||||
// Create the field for the processor
|
// Create the field for the processor
|
||||||
return tmp<IOFieldField<Field<Type>, Type> >
|
return tmp<CompactIOField<Field<Type>, Type> >
|
||||||
(
|
(
|
||||||
new IOFieldField<Field<Type>, Type>
|
new CompactIOField<Field<Type>, Type>
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2,6 +2,5 @@ itoa.C
|
|||||||
ensightMesh.C
|
ensightMesh.C
|
||||||
ensightParticlePositions.C
|
ensightParticlePositions.C
|
||||||
foamToEnsight.C
|
foamToEnsight.C
|
||||||
ensightWriteBinary.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/foamToEnsight
|
EXE = $(FOAM_APPBIN)/foamToEnsight
|
||||||
|
|||||||
@ -44,15 +44,6 @@ namespace Foam
|
|||||||
|
|
||||||
class cellSets
|
class cellSets
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
cellSets(const cellSets&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const cellSets&);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
label nHexesWedges;
|
label nHexesWedges;
|
||||||
|
|||||||
@ -0,0 +1,156 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::ensightAsciiStream
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
ensightAsciiStream.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef ensightAsciiStream_H
|
||||||
|
#define ensightAsciiStream_H
|
||||||
|
|
||||||
|
#include "ensightStream.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class ensightAsciiStream Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class ensightAsciiStream
|
||||||
|
:
|
||||||
|
public ensightStream
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Description of data_
|
||||||
|
OFstream str_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
ensightAsciiStream(const ensightAsciiStream&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const ensightAsciiStream&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
ensightAsciiStream(const fileName& f, const Time& runTime)
|
||||||
|
:
|
||||||
|
ensightStream(f),
|
||||||
|
str_
|
||||||
|
(
|
||||||
|
f,
|
||||||
|
runTime.writeFormat(),
|
||||||
|
runTime.writeVersion(),
|
||||||
|
IOstream::UNCOMPRESSED
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
str_.setf(ios_base::scientific, ios_base::floatfield);
|
||||||
|
str_.precision(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~ensightAsciiStream()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual void write(const char* c)
|
||||||
|
{
|
||||||
|
str_ << c << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const int v)
|
||||||
|
{
|
||||||
|
str_ << setw(10) << v << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const scalarField& sf)
|
||||||
|
{
|
||||||
|
forAll(sf, i)
|
||||||
|
{
|
||||||
|
if (mag(sf[i]) >= scalar(floatScalarVSMALL))
|
||||||
|
{
|
||||||
|
str_ << setw(12) << sf[i] << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str_ << setw(12) << scalar(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const List<int>& sf)
|
||||||
|
{
|
||||||
|
forAll(sf, i)
|
||||||
|
{
|
||||||
|
str_ << setw(10) << sf[i];
|
||||||
|
}
|
||||||
|
str_<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writePartHeader(const label partI)
|
||||||
|
{
|
||||||
|
str_<< "part" << nl
|
||||||
|
<< setw(10) << partI << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
// Friend Functions
|
||||||
|
|
||||||
|
// Friend Operators
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::ensightBinaryStream
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
ensightBinaryStream.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef ensightBinaryStream_H
|
||||||
|
#define ensightBinaryStream_H
|
||||||
|
|
||||||
|
#include "ensightStream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class ensightBinaryStream Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class ensightBinaryStream
|
||||||
|
:
|
||||||
|
public ensightStream
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Description of data_
|
||||||
|
autoPtr<std::ofstream> str_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
ensightBinaryStream(const ensightBinaryStream&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const ensightBinaryStream&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
ensightBinaryStream(const fileName& f, const Time&)
|
||||||
|
:
|
||||||
|
ensightStream(f),
|
||||||
|
str_
|
||||||
|
(
|
||||||
|
new std::ofstream
|
||||||
|
(
|
||||||
|
f.c_str(),
|
||||||
|
ios_base::out | ios_base::binary | ios_base::trunc
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~ensightBinaryStream()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual void write(const char* val)
|
||||||
|
{
|
||||||
|
char buffer[80] = {0};
|
||||||
|
strcpy(buffer, val);
|
||||||
|
str_().write(buffer, 80*sizeof(char));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const int val)
|
||||||
|
{
|
||||||
|
str_().write(reinterpret_cast<const char*>(&val), sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const scalarField& sf)
|
||||||
|
{
|
||||||
|
if (sf.size())
|
||||||
|
{
|
||||||
|
List<float> temp(sf.size());
|
||||||
|
|
||||||
|
forAll(sf, i)
|
||||||
|
{
|
||||||
|
temp[i] = float(sf[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
str_().write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(temp.begin()),
|
||||||
|
sf.size()*sizeof(float)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const List<int>& sf)
|
||||||
|
{
|
||||||
|
str_().write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(sf.begin()),
|
||||||
|
sf.size()*sizeof(int)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void writePartHeader(const label partI)
|
||||||
|
{
|
||||||
|
write("part");
|
||||||
|
write(partI);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
// Friend Functions
|
||||||
|
|
||||||
|
// Friend Operators
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -29,28 +29,14 @@ License
|
|||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "itoa.H"
|
#include "itoa.H"
|
||||||
#include "ensightWriteBinary.H"
|
#include "volPointInterpolation.H"
|
||||||
|
#include "ensightBinaryStream.H"
|
||||||
|
#include "ensightAsciiStream.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void writeData(const scalarField& sf, OFstream& ensightFile)
|
|
||||||
{
|
|
||||||
forAll(sf, i)
|
|
||||||
{
|
|
||||||
if (mag( sf[i] ) >= scalar(floatScalarVSMALL))
|
|
||||||
{
|
|
||||||
ensightFile << setw(12) << sf[i] << nl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ensightFile << setw(12) << scalar(0) << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
scalarField map
|
scalarField map
|
||||||
(
|
(
|
||||||
@ -104,64 +90,25 @@ void writeAllData
|
|||||||
const Field<Type>& vf,
|
const Field<Type>& vf,
|
||||||
const labelList& prims,
|
const labelList& prims,
|
||||||
const label nPrims,
|
const label nPrims,
|
||||||
OFstream& ensightFile
|
ensightStream& ensightFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (nPrims)
|
if (nPrims)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile << key << nl;
|
ensightFile.write(key);
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||||
{
|
{
|
||||||
writeData(map(vf, prims, cmpt), ensightFile);
|
scalarField masterData(map(vf, prims, cmpt));
|
||||||
|
ensightFile.write(masterData);
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
scalarField data(fromSlave);
|
scalarField slaveData(fromSlave);
|
||||||
writeData(data, ensightFile);
|
ensightFile.write(slaveData);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
|
||||||
toMaster<< map(vf, prims, cmpt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void writeAllDataBinary
|
|
||||||
(
|
|
||||||
const char* key,
|
|
||||||
const Field<Type>& vf,
|
|
||||||
const labelList& prims,
|
|
||||||
const label nPrims,
|
|
||||||
std::ofstream& ensightFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (nPrims)
|
|
||||||
{
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
writeEnsDataBinary(key,ensightFile);
|
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
writeEnsDataBinary(map(vf, prims, cmpt), ensightFile);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
|
||||||
{
|
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
|
||||||
scalarField data(fromSlave);
|
|
||||||
writeEnsDataBinary(data, ensightFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,66 +131,25 @@ void writeAllFaceData
|
|||||||
const labelList& prims,
|
const labelList& prims,
|
||||||
const label nPrims,
|
const label nPrims,
|
||||||
const Field<Type>& pf,
|
const Field<Type>& pf,
|
||||||
OFstream& ensightFile
|
ensightStream& ensightFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (nPrims)
|
if (nPrims)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile << key << nl;
|
ensightFile.write(key);
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||||
{
|
{
|
||||||
writeData(map(pf, prims, cmpt), ensightFile);
|
ensightFile.write(map(pf, prims, cmpt));
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
scalarField pf(fromSlave);
|
scalarField pf(fromSlave);
|
||||||
|
|
||||||
writeData(pf, ensightFile);
|
ensightFile.write(pf);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
|
||||||
toMaster<< map(pf, prims, cmpt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void writeAllFaceDataBinary
|
|
||||||
(
|
|
||||||
const char* key,
|
|
||||||
const labelList& prims,
|
|
||||||
const label nPrims,
|
|
||||||
const Field<Type>& pf,
|
|
||||||
std::ofstream& ensightFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (nPrims)
|
|
||||||
{
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
writeEnsDataBinary(key,ensightFile);
|
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
|
||||||
{
|
|
||||||
writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
|
||||||
{
|
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
|
||||||
scalarField pf(fromSlave);
|
|
||||||
|
|
||||||
writeEnsDataBinary(pf, ensightFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,16 +173,14 @@ bool writePatchField
|
|||||||
const Foam::label ensightPatchI,
|
const Foam::label ensightPatchI,
|
||||||
const Foam::faceSets& boundaryFaceSet,
|
const Foam::faceSets& boundaryFaceSet,
|
||||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||||
Foam::OFstream& ensightFile
|
ensightStream& ensightFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile
|
ensightFile.writePartHeader(ensightPatchI);
|
||||||
<< "part" << nl
|
|
||||||
<< setw(10) << ensightPatchI << nl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeAllFaceData
|
writeAllFaceData
|
||||||
@ -315,61 +219,6 @@ bool writePatchField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool writePatchFieldBinary
|
|
||||||
(
|
|
||||||
const Foam::Field<Type>& pf,
|
|
||||||
const Foam::label patchi,
|
|
||||||
const Foam::label ensightPatchI,
|
|
||||||
const Foam::faceSets& boundaryFaceSet,
|
|
||||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
|
||||||
std::ofstream& ensightFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
|
||||||
{
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
writeEnsDataBinary("part",ensightFile);
|
|
||||||
writeEnsDataBinary(ensightPatchI,ensightFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeAllFaceDataBinary
|
|
||||||
(
|
|
||||||
"tria3",
|
|
||||||
boundaryFaceSet.tris,
|
|
||||||
nfp.nTris,
|
|
||||||
pf,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
writeAllFaceDataBinary
|
|
||||||
(
|
|
||||||
"quad4",
|
|
||||||
boundaryFaceSet.quads,
|
|
||||||
nfp.nQuads,
|
|
||||||
pf,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
writeAllFaceDataBinary
|
|
||||||
(
|
|
||||||
"nsided",
|
|
||||||
boundaryFaceSet.polys,
|
|
||||||
nfp.nPolys,
|
|
||||||
pf,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writePatchField
|
void writePatchField
|
||||||
(
|
(
|
||||||
@ -380,6 +229,7 @@ void writePatchField
|
|||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& postProcPath,
|
||||||
const Foam::word& prepend,
|
const Foam::word& prepend,
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
|
const bool binary,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -409,7 +259,7 @@ void writePatchField
|
|||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
word timeFile = prepend + itoa(timeIndex);
|
||||||
|
|
||||||
OFstream *ensightFilePtr = NULL;
|
ensightStream* ensightFilePtr = NULL;
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
if (timeIndex == 0)
|
if (timeIndex == 0)
|
||||||
@ -426,20 +276,30 @@ void writePatchField
|
|||||||
|
|
||||||
// set the filename of the ensight file
|
// set the filename of the ensight file
|
||||||
fileName ensightFileName(timeFile + "." + pfName);
|
fileName ensightFileName(timeFile + "." + pfName);
|
||||||
ensightFilePtr = new OFstream
|
|
||||||
|
if (binary)
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
postProcPath/ensightFileName,
|
||||||
runTime.writeFormat(),
|
runTime
|
||||||
runTime.writeVersion(),
|
|
||||||
runTime.writeCompression()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightAsciiStream
|
||||||
|
(
|
||||||
|
postProcPath/ensightFileName,
|
||||||
|
runTime
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OFstream& ensightFile = *ensightFilePtr;
|
ensightStream& ensightFile = *ensightFilePtr;
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile << pTraits<Type>::typeName << nl;
|
ensightFile.write(pTraits<Type>::typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
@ -477,17 +337,18 @@ void writePatchField
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void ensightFieldAscii
|
void ensightField
|
||||||
(
|
(
|
||||||
const Foam::IOobject& fieldObject,
|
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
const Foam::ensightMesh& eMesh,
|
const Foam::ensightMesh& eMesh,
|
||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& postProcPath,
|
||||||
const Foam::word& prepend,
|
const Foam::word& prepend,
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
|
const bool binary,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Converting field " << fieldObject.name() << endl;
|
Info<< "Converting field " << vf.name() << endl;
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
word timeFile = prepend + itoa(timeIndex);
|
||||||
|
|
||||||
@ -512,23 +373,31 @@ void ensightFieldAscii
|
|||||||
const labelList& hexes = meshCellSets.hexes;
|
const labelList& hexes = meshCellSets.hexes;
|
||||||
const labelList& polys = meshCellSets.polys;
|
const labelList& polys = meshCellSets.polys;
|
||||||
|
|
||||||
OFstream *ensightFilePtr = NULL;
|
ensightStream* ensightFilePtr = NULL;
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// set the filename of the ensight file
|
// set the filename of the ensight file
|
||||||
fileName ensightFileName(timeFile + "." + fieldObject.name());
|
fileName ensightFileName(timeFile + "." + vf.name());
|
||||||
ensightFilePtr = new OFstream
|
|
||||||
|
if (binary)
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
postProcPath/ensightFileName,
|
postProcPath/ensightFileName,
|
||||||
runTime.writeFormat(),
|
runTime
|
||||||
runTime.writeVersion(),
|
|
||||||
IOstream::UNCOMPRESSED
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightAsciiStream
|
||||||
|
(
|
||||||
|
postProcPath/ensightFileName,
|
||||||
|
runTime
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OFstream& ensightFile = *ensightFilePtr;
|
ensightStream& ensightFile = *ensightFilePtr;
|
||||||
|
|
||||||
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
|
|
||||||
|
|
||||||
if (patchNames.empty())
|
if (patchNames.empty())
|
||||||
{
|
{
|
||||||
@ -548,34 +417,26 @@ void ensightFieldAscii
|
|||||||
<< nl;
|
<< nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightFile
|
ensightFile.write(pTraits<Type>::typeName);
|
||||||
<< pTraits<Type>::typeName << nl
|
ensightFile.writePartHeader(1);
|
||||||
<< "part" << nl
|
|
||||||
<< setw(10) << 1 << nl;
|
|
||||||
|
|
||||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
|
||||||
ensightFile.precision(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meshCellSets.nHexesWedges)
|
if (meshCellSets.nHexesWedges)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile << "hexa8" << nl;
|
ensightFile.write("hexa8");
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||||
{
|
{
|
||||||
writeData
|
scalarField masterData(map(vf, hexes, wedges, cmpt));
|
||||||
(
|
ensightFile.write(masterData);
|
||||||
map(vf, hexes, wedges, cmpt),
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
scalarField data(fromSlave);
|
scalarField data(fromSlave);
|
||||||
writeData(data, ensightFile);
|
ensightFile.write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -727,7 +588,6 @@ void ensightFieldAscii
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
delete ensightFilePtr;
|
delete ensightFilePtr;
|
||||||
@ -736,59 +596,48 @@ void ensightFieldAscii
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void ensightFieldBinary
|
void ensightPointField
|
||||||
(
|
(
|
||||||
const Foam::IOobject& fieldObject,
|
const GeometricField<Type, pointPatchField, pointMesh>& pf,
|
||||||
const Foam::ensightMesh& eMesh,
|
const Foam::ensightMesh& eMesh,
|
||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& postProcPath,
|
||||||
const Foam::word& prepend,
|
const Foam::word& prepend,
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
|
const bool binary,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Converting field (binary) " << fieldObject.name() << endl;
|
Info<< "Converting field " << pf.name() << endl;
|
||||||
|
|
||||||
word timeFile = prepend + itoa(timeIndex);
|
word timeFile = prepend + itoa(timeIndex);
|
||||||
|
|
||||||
const fvMesh& mesh = eMesh.mesh();
|
ensightStream* ensightFilePtr = NULL;
|
||||||
//const Time& runTime = mesh.time();
|
|
||||||
|
|
||||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
|
||||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
|
||||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
|
||||||
const wordHashSet& patchNames = eMesh.patchNames();
|
|
||||||
const HashTable<ensightMesh::nFacePrimitives>&
|
|
||||||
nPatchPrims = eMesh.nPatchPrims();
|
|
||||||
const List<faceSets>& faceZoneFaceSets = eMesh.faceZoneFaceSets();
|
|
||||||
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
|
||||||
const HashTable<ensightMesh::nFacePrimitives>&
|
|
||||||
nFaceZonePrims = eMesh.nFaceZonePrims();
|
|
||||||
|
|
||||||
const labelList& tets = meshCellSets.tets;
|
|
||||||
const labelList& pyrs = meshCellSets.pyrs;
|
|
||||||
const labelList& prisms = meshCellSets.prisms;
|
|
||||||
const labelList& wedges = meshCellSets.wedges;
|
|
||||||
const labelList& hexes = meshCellSets.hexes;
|
|
||||||
const labelList& polys = meshCellSets.polys;
|
|
||||||
|
|
||||||
std::ofstream *ensightFilePtr = NULL;
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// set the filename of the ensight file
|
// set the filename of the ensight file
|
||||||
fileName ensightFileName(timeFile + "." + fieldObject.name());
|
fileName ensightFileName(timeFile + "." + pf.name());
|
||||||
ensightFilePtr = new std::ofstream
|
|
||||||
|
if (binary)
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightBinaryStream
|
||||||
(
|
(
|
||||||
(postProcPath/ensightFileName).c_str(),
|
postProcPath/ensightFileName,
|
||||||
ios_base::out | ios_base::binary | ios_base::trunc
|
eMesh.mesh().time()
|
||||||
);
|
);
|
||||||
// Check on file opened?
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ensightFilePtr = new ensightAsciiStream
|
||||||
|
(
|
||||||
|
postProcPath/ensightFileName,
|
||||||
|
eMesh.mesh().time()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream& ensightFile = *ensightFilePtr;
|
ensightStream& ensightFile = *ensightFilePtr;
|
||||||
|
|
||||||
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
|
if (eMesh.patchNames().empty())
|
||||||
|
|
||||||
if (patchNames.empty())
|
|
||||||
{
|
{
|
||||||
eMesh.barrier();
|
eMesh.barrier();
|
||||||
|
|
||||||
@ -800,192 +649,49 @@ void ensightFieldBinary
|
|||||||
|
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
<< pTraits<Type>::typeName
|
<< pTraits<Type>::typeName
|
||||||
<< " per element: 1 "
|
<< " per node: 1 "
|
||||||
<< setw(15) << vf.name()
|
<< setw(15) << pf.name()
|
||||||
<< (' ' + prepend + "***." + vf.name()).c_str()
|
<< (' ' + prepend + "***." + pf.name()).c_str()
|
||||||
<< nl;
|
<< nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeEnsDataBinary(pTraits<Type>::typeName,ensightFile);
|
ensightFile.write(pTraits<Type>::typeName);
|
||||||
writeEnsDataBinary("part",ensightFile);
|
ensightFile.write("part");
|
||||||
writeEnsDataBinary(1,ensightFile);
|
ensightFile.write(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meshCellSets.nHexesWedges)
|
|
||||||
{
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
writeEnsDataBinary("hexa8",ensightFile);
|
ensightFile.write("coordinates");
|
||||||
|
|
||||||
|
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap());
|
||||||
|
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary
|
ensightFile.write(uniqueFld.component(cmpt));
|
||||||
(
|
|
||||||
map(vf, hexes, wedges, cmpt),
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::scheduled, slave);
|
IPstream fromSlave(Pstream::scheduled, slave);
|
||||||
scalarField data(fromSlave);
|
scalarField data(fromSlave);
|
||||||
writeEnsDataBinary(data, ensightFile);
|
ensightFile.write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap());
|
||||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||||
{
|
{
|
||||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
toMaster<< map(vf, hexes, wedges, cmpt);
|
toMaster<< uniqueFld.component(cmpt);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writeAllDataBinary
|
|
||||||
(
|
|
||||||
"penta6",
|
|
||||||
vf,
|
|
||||||
prisms,
|
|
||||||
meshCellSets.nPrisms,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
writeAllDataBinary
|
|
||||||
(
|
|
||||||
"pyramid5",
|
|
||||||
vf,
|
|
||||||
pyrs,
|
|
||||||
meshCellSets.nPyrs,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
writeAllDataBinary
|
|
||||||
(
|
|
||||||
"tetra4",
|
|
||||||
vf,
|
|
||||||
tets,
|
|
||||||
meshCellSets.nTets,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
writeAllDataBinary
|
|
||||||
(
|
|
||||||
"nfaced",
|
|
||||||
vf,
|
|
||||||
polys,
|
|
||||||
meshCellSets.nPolys,
|
|
||||||
ensightFile
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
label ensightPatchI = eMesh.patchPartOffset();
|
|
||||||
|
|
||||||
forAll(allPatchNames, patchi)
|
|
||||||
{
|
|
||||||
const word& patchName = allPatchNames[patchi];
|
|
||||||
|
|
||||||
eMesh.barrier();
|
|
||||||
|
|
||||||
if (patchNames.empty() || patchNames.found(patchName))
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
writePatchFieldBinary
|
|
||||||
(
|
|
||||||
vf.boundaryField()[patchi],
|
|
||||||
patchi,
|
|
||||||
ensightPatchI,
|
|
||||||
boundaryFaceSets[patchi],
|
|
||||||
nPatchPrims.find(patchName)(),
|
|
||||||
ensightFile
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ensightPatchI++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// write faceZones, if requested
|
|
||||||
if (faceZoneNames.size())
|
|
||||||
{
|
|
||||||
// Interpolates cell values to faces - needed only when exporting
|
|
||||||
// faceZones...
|
|
||||||
GeometricField<Type, fvsPatchField, surfaceMesh> sf
|
|
||||||
(
|
|
||||||
linearInterpolate(vf)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllConstIter(wordHashSet, faceZoneNames, iter)
|
|
||||||
{
|
|
||||||
const word& faceZoneName = iter.key();
|
|
||||||
|
|
||||||
eMesh.barrier();
|
|
||||||
|
|
||||||
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
|
||||||
|
|
||||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
|
||||||
|
|
||||||
// Prepare data to write
|
|
||||||
label nIncluded = 0;
|
|
||||||
forAll(fz, i)
|
|
||||||
{
|
|
||||||
if (eMesh.faceToBeIncluded(fz[i]))
|
|
||||||
{
|
|
||||||
++nIncluded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Field<Type> values(nIncluded);
|
|
||||||
|
|
||||||
// Loop on the faceZone and store the needed field values
|
|
||||||
label j = 0;
|
|
||||||
forAll(fz, i)
|
|
||||||
{
|
|
||||||
label faceI = fz[i];
|
|
||||||
if (mesh.isInternalFace(faceI))
|
|
||||||
{
|
|
||||||
values[j] = sf[faceI];
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (eMesh.faceToBeIncluded(faceI))
|
|
||||||
{
|
|
||||||
label patchI = mesh.boundaryMesh().whichPatch(faceI);
|
|
||||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
|
||||||
label patchFaceI = pp.whichFace(faceI);
|
|
||||||
Type value = sf.boundaryField()[patchI][patchFaceI];
|
|
||||||
values[j] = value;
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
writePatchFieldBinary
|
|
||||||
(
|
|
||||||
values,
|
|
||||||
zoneID,
|
|
||||||
ensightPatchI,
|
|
||||||
faceZoneFaceSets[zoneID],
|
|
||||||
nFaceZonePrims.find(faceZoneName)(),
|
|
||||||
ensightFile
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ensightPatchI++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightFile.close();
|
delete ensightFilePtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,30 +705,42 @@ void ensightField
|
|||||||
const Foam::word& prepend,
|
const Foam::word& prepend,
|
||||||
const Foam::label timeIndex,
|
const Foam::label timeIndex,
|
||||||
const bool binary,
|
const bool binary,
|
||||||
|
const bool nodeValues,
|
||||||
Foam::Ostream& ensightCaseFile
|
Foam::Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (binary)
|
// Read field
|
||||||
|
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, eMesh.mesh());
|
||||||
|
|
||||||
|
if (nodeValues)
|
||||||
{
|
{
|
||||||
ensightFieldBinary<Type>
|
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
|
||||||
(
|
(
|
||||||
fieldObject,
|
volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
|
||||||
|
);
|
||||||
|
pfld().rename(vf.name());
|
||||||
|
|
||||||
|
ensightPointField<Type>
|
||||||
|
(
|
||||||
|
pfld,
|
||||||
eMesh,
|
eMesh,
|
||||||
postProcPath,
|
postProcPath,
|
||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
|
binary,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ensightFieldAscii<Type>
|
ensightField<Type>
|
||||||
(
|
(
|
||||||
fieldObject,
|
vf,
|
||||||
eMesh,
|
eMesh,
|
||||||
postProcPath,
|
postProcPath,
|
||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
|
binary,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -38,10 +38,13 @@ SourceFiles
|
|||||||
#include "faceSets.H"
|
#include "faceSets.H"
|
||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include <fstream>
|
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
#include "wordReList.H"
|
||||||
|
#include "scalarField.H"
|
||||||
|
#include "cellShapeList.H"
|
||||||
|
#include "cellList.H"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ namespace Foam
|
|||||||
class fvMesh;
|
class fvMesh;
|
||||||
class argList;
|
class argList;
|
||||||
class globalIndex;
|
class globalIndex;
|
||||||
|
class ensightStream;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class ensightMesh Declaration
|
Class ensightMesh Declaration
|
||||||
@ -82,8 +86,19 @@ private:
|
|||||||
//- Reference to the OpenFOAM mesh
|
//- Reference to the OpenFOAM mesh
|
||||||
const fvMesh& mesh_;
|
const fvMesh& mesh_;
|
||||||
|
|
||||||
|
//- Suppress patches
|
||||||
|
const bool noPatches_;
|
||||||
|
|
||||||
|
//- Output selected patches only
|
||||||
|
const bool patches_;
|
||||||
|
const wordReList patchPatterns_;
|
||||||
|
|
||||||
|
//- Output selected faceZones
|
||||||
|
const bool faceZones_;
|
||||||
|
const wordReList faceZonePatterns_;
|
||||||
|
|
||||||
//- Set binary file output
|
//- Set binary file output
|
||||||
bool binary_;
|
const bool binary_;
|
||||||
|
|
||||||
//- The ensight part id for the first patch
|
//- The ensight part id for the first patch
|
||||||
label patchPartOffset_;
|
label patchPartOffset_;
|
||||||
@ -109,6 +124,19 @@ private:
|
|||||||
PackedBoolList boundaryFaceToBeIncluded_;
|
PackedBoolList boundaryFaceToBeIncluded_;
|
||||||
|
|
||||||
|
|
||||||
|
// Parallel merged points
|
||||||
|
|
||||||
|
//- Global numbering for merged points
|
||||||
|
autoPtr<globalIndex> globalPointsPtr_;
|
||||||
|
|
||||||
|
//- From mesh point to global merged point
|
||||||
|
labelList pointToGlobal_;
|
||||||
|
|
||||||
|
//- Local points that are unique
|
||||||
|
labelList uniquePointMap_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
@ -120,7 +148,7 @@ private:
|
|||||||
void writePoints
|
void writePoints
|
||||||
(
|
(
|
||||||
const scalarField& pointsComponent,
|
const scalarField& pointsComponent,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
cellShapeList map
|
cellShapeList map
|
||||||
@ -141,14 +169,14 @@ private:
|
|||||||
void writePrims
|
void writePrims
|
||||||
(
|
(
|
||||||
const cellShapeList& cellShapes,
|
const cellShapeList& cellShapes,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writePolysNFaces
|
void writePolysNFaces
|
||||||
(
|
(
|
||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writePolysNPointsPerFace
|
void writePolysNPointsPerFace
|
||||||
@ -156,7 +184,7 @@ private:
|
|||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writePolysPoints
|
void writePolysPoints
|
||||||
@ -164,13 +192,13 @@ private:
|
|||||||
const labelList& polys,
|
const labelList& polys,
|
||||||
const cellList& cellFaces,
|
const cellList& cellFaces,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllPolys
|
void writeAllPolys
|
||||||
(
|
(
|
||||||
const labelList& pointToGlobal,
|
const labelList& pointToGlobal,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllPrims
|
void writeAllPrims
|
||||||
@ -178,13 +206,13 @@ private:
|
|||||||
const char* key,
|
const char* key,
|
||||||
const label nPrims,
|
const label nPrims,
|
||||||
const cellShapeList& cellShapes,
|
const cellShapeList& cellShapes,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeFacePrims
|
void writeFacePrims
|
||||||
(
|
(
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllFacePrims
|
void writeAllFacePrims
|
||||||
@ -193,19 +221,19 @@ private:
|
|||||||
const labelList& prims,
|
const labelList& prims,
|
||||||
const label nPrims,
|
const label nPrims,
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeNSidedNPointsPerFace
|
void writeNSidedNPointsPerFace
|
||||||
(
|
(
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeNSidedPoints
|
void writeNSidedPoints
|
||||||
(
|
(
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllNSided
|
void writeAllNSided
|
||||||
@ -213,14 +241,14 @@ private:
|
|||||||
const labelList& prims,
|
const labelList& prims,
|
||||||
const label nPrims,
|
const label nPrims,
|
||||||
const faceList& patchFaces,
|
const faceList& patchFaces,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllInternalPoints
|
void writeAllInternalPoints
|
||||||
(
|
(
|
||||||
const pointField& uniquePoints,
|
const pointField& uniquePoints,
|
||||||
const label nPoints,
|
const label nPoints,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllPatchPoints
|
void writeAllPatchPoints
|
||||||
@ -229,123 +257,7 @@ private:
|
|||||||
const word& patchName,
|
const word& patchName,
|
||||||
const pointField& uniquePoints,
|
const pointField& uniquePoints,
|
||||||
const label nPoints,
|
const label nPoints,
|
||||||
OFstream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllInternalPointsBinary
|
|
||||||
(
|
|
||||||
const pointField& uniquePoints,
|
|
||||||
const label nPoints,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllPatchPointsBinary
|
|
||||||
(
|
|
||||||
label ensightPatchI,
|
|
||||||
const word& patchName,
|
|
||||||
const pointField& uniquePoints,
|
|
||||||
const label nPoints,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAscii
|
|
||||||
(
|
|
||||||
const fileName& postProcPath,
|
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
|
||||||
Ostream& ensightCaseFile,
|
|
||||||
const labelList& pointToGlobal,
|
|
||||||
const pointField& uniquePoints,
|
|
||||||
const globalIndex& globalPoints
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeBinary
|
|
||||||
(
|
|
||||||
const fileName& postProcPath,
|
|
||||||
const word& prepend,
|
|
||||||
const label timeIndex,
|
|
||||||
Ostream& ensightCaseFile,
|
|
||||||
const labelList& pointToGlobal,
|
|
||||||
const pointField& uniquePoints,
|
|
||||||
const globalIndex& globalPoints
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writePrimsBinary
|
|
||||||
(
|
|
||||||
const cellShapeList& cellShapes,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllPrimsBinary
|
|
||||||
(
|
|
||||||
const char* key,
|
|
||||||
const label nPrims,
|
|
||||||
const cellShapeList& cellShapes,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writePolysNFacesBinary
|
|
||||||
(
|
|
||||||
const labelList& polys,
|
|
||||||
const cellList& cellFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writePolysNPointsPerFaceBinary
|
|
||||||
(
|
|
||||||
const labelList& polys,
|
|
||||||
const cellList& cellFaces,
|
|
||||||
const faceList& faces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writePolysPointsBinary
|
|
||||||
(
|
|
||||||
const labelList& polys,
|
|
||||||
const cellList& cellFaces,
|
|
||||||
const faceList& faces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllPolysBinary
|
|
||||||
(
|
|
||||||
const labelList& pointToGlobal,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllFacePrimsBinary
|
|
||||||
(
|
|
||||||
const char* key,
|
|
||||||
const labelList& prims,
|
|
||||||
const label nPrims,
|
|
||||||
const faceList& patchFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeFacePrimsBinary
|
|
||||||
(
|
|
||||||
const faceList& patchFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeNSidedPointsBinary
|
|
||||||
(
|
|
||||||
const faceList& patchFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeNSidedNPointsPerFaceBinary
|
|
||||||
(
|
|
||||||
const faceList& patchFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllNSidedBinary
|
|
||||||
(
|
|
||||||
const labelList& prims,
|
|
||||||
const label nPrims,
|
|
||||||
const faceList& patchFaces,
|
|
||||||
std::ofstream& ensightGeometryFile
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -355,8 +267,12 @@ public:
|
|||||||
//- Construct from fvMesh
|
//- Construct from fvMesh
|
||||||
ensightMesh
|
ensightMesh
|
||||||
(
|
(
|
||||||
const fvMesh&,
|
const fvMesh& mesh,
|
||||||
const argList& args,
|
const bool noPatches,
|
||||||
|
const bool patches,
|
||||||
|
const wordReList& patchPatterns,
|
||||||
|
const bool faceZones,
|
||||||
|
const wordReList& faceZonePatterns,
|
||||||
const bool binary
|
const bool binary
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -420,8 +336,35 @@ public:
|
|||||||
return patchPartOffset_;
|
return patchPartOffset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Parallel point merging
|
||||||
|
|
||||||
|
//- Global numbering for merged points
|
||||||
|
const globalIndex& globalPoints() const
|
||||||
|
{
|
||||||
|
return globalPointsPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- From mesh point to global merged point
|
||||||
|
const labelList& pointToGlobal() const
|
||||||
|
{
|
||||||
|
return pointToGlobal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Local points that are unique
|
||||||
|
const labelList& uniquePointMap() const
|
||||||
|
{
|
||||||
|
return uniquePointMap_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
//- Update for new mesh
|
||||||
|
void correct();
|
||||||
|
|
||||||
//- When exporting faceZones, check if a given face has to be included
|
//- When exporting faceZones, check if a given face has to be included
|
||||||
// or not (i.e. faces on processor boundaries)
|
// or not (i.e. faces on processor boundaries)
|
||||||
bool faceToBeIncluded(const label faceI) const;
|
bool faceToBeIncluded(const label faceI) const;
|
||||||
|
|||||||
@ -0,0 +1,112 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::ensightStream
|
||||||
|
|
||||||
|
Description
|
||||||
|
Abstract base class for writing Ensight data
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
ensightStream.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef ensightStream_H
|
||||||
|
#define ensightStream_H
|
||||||
|
|
||||||
|
#include "fileName.H"
|
||||||
|
#include "scalarField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class ensightStream Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class ensightStream
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const fileName name_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
ensightStream(const ensightStream&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const ensightStream&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
ensightStream(const fileName& f)
|
||||||
|
:
|
||||||
|
name_(f)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~ensightStream()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
const fileName& name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void write(const char*) = 0;
|
||||||
|
|
||||||
|
virtual void write(const int) = 0;
|
||||||
|
|
||||||
|
virtual void write(const scalarField&) = 0;
|
||||||
|
|
||||||
|
virtual void write(const List<int>&) = 0;
|
||||||
|
|
||||||
|
virtual void writePartHeader(const label) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -1,78 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "ensightWriteBinary.H"
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const char* val,
|
|
||||||
std::ofstream& ensFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
char buffer[80] = {0};
|
|
||||||
strcpy(buffer, val);
|
|
||||||
ensFile.write(buffer, 80*sizeof(char));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const int val,
|
|
||||||
std::ofstream& ensFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ensFile.write(reinterpret_cast<const char*>(&val), sizeof(int));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const scalarField& sf,
|
|
||||||
std::ofstream& ensightFile
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (sf.size())
|
|
||||||
{
|
|
||||||
List<float> temp(sf.size());
|
|
||||||
|
|
||||||
forAll(sf, i)
|
|
||||||
{
|
|
||||||
temp[i] = float(sf[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ensightFile.write
|
|
||||||
(
|
|
||||||
reinterpret_cast<char*>(temp.begin()),
|
|
||||||
sf.size()*sizeof(float)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 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/>.
|
|
||||||
|
|
||||||
InApplication
|
|
||||||
foamToEnsight
|
|
||||||
|
|
||||||
Description
|
|
||||||
Collection of functions for binary write in EnSight files
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
ensightWriteBinary.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef ensightWriteBinary_H
|
|
||||||
#define ensightWriteBinary_H
|
|
||||||
|
|
||||||
#include "ensightMesh.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const char* val,
|
|
||||||
std::ofstream& ensFile
|
|
||||||
);
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const int val,
|
|
||||||
std::ofstream& ensFile
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
void writeEnsDataBinary
|
|
||||||
(
|
|
||||||
const scalarField& sf,
|
|
||||||
std::ofstream& ensightFile
|
|
||||||
);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -44,15 +44,6 @@ namespace Foam
|
|||||||
|
|
||||||
class faceSets
|
class faceSets
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
faceSets(const faceSets&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const faceSets&);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
label nTris;
|
label nTris;
|
||||||
|
|||||||
@ -104,6 +104,11 @@ int main(int argc, char *argv[])
|
|||||||
"write in ASCII format instead of 'C Binary'"
|
"write in ASCII format instead of 'C Binary'"
|
||||||
);
|
);
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"nodeValues",
|
||||||
|
"write values in nodes"
|
||||||
|
);
|
||||||
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"noPatches",
|
"noPatches",
|
||||||
"suppress writing any patches"
|
"suppress writing any patches"
|
||||||
@ -126,6 +131,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Check options
|
// Check options
|
||||||
const bool binary = !args.optionFound("ascii");
|
const bool binary = !args.optionFound("ascii");
|
||||||
|
const bool nodeValues = args.optionFound("nodeValues");
|
||||||
|
|
||||||
# include "createTime.H"
|
# include "createTime.H"
|
||||||
|
|
||||||
@ -191,7 +197,29 @@ int main(int argc, char *argv[])
|
|||||||
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
||||||
|
|
||||||
// Construct the EnSight mesh
|
// Construct the EnSight mesh
|
||||||
ensightMesh eMesh(mesh, args, binary);
|
const bool selectedPatches = args.optionFound("patches");
|
||||||
|
wordReList patchPatterns;
|
||||||
|
if (selectedPatches)
|
||||||
|
{
|
||||||
|
patchPatterns = wordReList(args.optionLookup("patches")());
|
||||||
|
}
|
||||||
|
const bool selectedZones = args.optionFound("faceZones");
|
||||||
|
wordReList zonePatterns;
|
||||||
|
if (selectedZones)
|
||||||
|
{
|
||||||
|
zonePatterns = wordReList(args.optionLookup("faceZones")());
|
||||||
|
}
|
||||||
|
|
||||||
|
ensightMesh eMesh
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
args.optionFound("noPatches"),
|
||||||
|
selectedPatches,
|
||||||
|
patchPatterns,
|
||||||
|
selectedZones,
|
||||||
|
zonePatterns,
|
||||||
|
binary
|
||||||
|
);
|
||||||
|
|
||||||
// Set Time to the last time before looking for the lagrangian objects
|
// Set Time to the last time before looking for the lagrangian objects
|
||||||
runTime.setTime(Times.last(), Times.size()-1);
|
runTime.setTime(Times.last(), Times.size()-1);
|
||||||
@ -313,6 +341,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||||
|
|
||||||
|
if (meshState != polyMesh::UNCHANGED)
|
||||||
|
{
|
||||||
|
eMesh.correct();
|
||||||
|
}
|
||||||
|
|
||||||
if (timeIndex == 0 || (meshState != polyMesh::UNCHANGED))
|
if (timeIndex == 0 || (meshState != polyMesh::UNCHANGED))
|
||||||
{
|
{
|
||||||
eMesh.write
|
eMesh.write
|
||||||
@ -371,6 +404,7 @@ int main(int argc, char *argv[])
|
|||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
binary,
|
||||||
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -384,6 +418,7 @@ int main(int argc, char *argv[])
|
|||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
binary,
|
||||||
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -397,6 +432,7 @@ int main(int argc, char *argv[])
|
|||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
binary,
|
||||||
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -410,6 +446,7 @@ int main(int argc, char *argv[])
|
|||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
binary,
|
||||||
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -423,6 +460,7 @@ int main(int argc, char *argv[])
|
|||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
binary,
|
binary,
|
||||||
|
nodeValues,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ Description
|
|||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
#include "meshToMesh.H"
|
#include "meshToMesh.H"
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
#include "IOFieldField.H"
|
#include "CompactIOField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -106,9 +106,9 @@ void MapLagrangianFields
|
|||||||
// Read field (does not need mesh)
|
// Read field (does not need mesh)
|
||||||
IOField<Field<Type> > fieldSource(*fieldIter());
|
IOField<Field<Type> > fieldSource(*fieldIter());
|
||||||
|
|
||||||
// Map - use IOFieldField to automatically write in
|
// Map - use CompactIOField to automatically write in
|
||||||
// compact form for binary format.
|
// compact form for binary format.
|
||||||
IOFieldField<Field<Type>, Type> fieldTarget
|
CompactIOField<Field<Type>, Type> fieldTarget
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -135,7 +135,7 @@ void MapLagrangianFields
|
|||||||
|
|
||||||
{
|
{
|
||||||
IOobjectList fieldFields =
|
IOobjectList fieldFields =
|
||||||
objects.lookupClass(IOFieldField<Field<Type>, Type>::typeName);
|
objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
|
||||||
|
|
||||||
forAllIter(IOobjectList, fieldFields, fieldIter)
|
forAllIter(IOobjectList, fieldFields, fieldIter)
|
||||||
{
|
{
|
||||||
@ -143,10 +143,10 @@ void MapLagrangianFields
|
|||||||
<< fieldIter()->name() << endl;
|
<< fieldIter()->name() << endl;
|
||||||
|
|
||||||
// Read field (does not need mesh)
|
// Read field (does not need mesh)
|
||||||
IOFieldField<Field<Type>, Type> fieldSource(*fieldIter());
|
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
|
||||||
|
|
||||||
// Map
|
// Map
|
||||||
IOFieldField<Field<Type>, Type> fieldTarget
|
CompactIOField<Field<Type>, Type> fieldTarget
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
|
|||||||
@ -76,6 +76,11 @@ cleanCase()
|
|||||||
sets/streamLines \
|
sets/streamLines \
|
||||||
> /dev/null 2>&1
|
> /dev/null 2>&1
|
||||||
|
|
||||||
|
if [ -e constant/polyMesh/blockMeshDict.m4 ]
|
||||||
|
then
|
||||||
|
rm -f constant/polyMesh/blockMeshDict > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
for f in `find . -name "*Dict"`
|
for f in `find . -name "*Dict"`
|
||||||
do
|
do
|
||||||
sed -e /arguments/d $f > temp.$$
|
sed -e /arguments/d $f > temp.$$
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# Script
|
# Script
|
||||||
# doxyFilt
|
# doxyFilter
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# pass-through filter for doxygen
|
# pass-through filter for doxygen
|
||||||
@ -43,19 +43,19 @@ then
|
|||||||
dirName=${filePath%/[^/]*}
|
dirName=${filePath%/[^/]*}
|
||||||
fileName=${filePath##*/}
|
fileName=${filePath##*/}
|
||||||
|
|
||||||
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt.awk
|
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter.awk
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*/applications/solvers/*.C | */applications/utilities/*.C )
|
*/applications/solvers/*.C | */applications/utilities/*.C )
|
||||||
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-top.awk
|
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter-top.awk
|
||||||
;;
|
;;
|
||||||
# */applications/solvers/*.H | */applications/utilities/*.H )
|
# */applications/solvers/*.H | */applications/utilities/*.H )
|
||||||
# awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk
|
# awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilter-ignore.awk
|
||||||
# ;;
|
# ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
awk -f $awkScript $1 | \
|
awk -f $awkScript $1 | \
|
||||||
sed -f $WM_PROJECT_DIR/bin/tools/doxyFilt.sed \
|
sed -f $WM_PROJECT_DIR/bin/tools/doxyFilter.sed \
|
||||||
-e s@%filePath%@$filePath@g \
|
-e s@%filePath%@$filePath@g \
|
||||||
-e s@%fileName%@$fileName@g \
|
-e s@%fileName%@$fileName@g \
|
||||||
-e s@%dirName%@$dirName@g
|
-e s@%dirName%@$dirName@g
|
||||||
@ -22,7 +22,7 @@
|
|||||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# Script
|
# Script
|
||||||
# doxyFilt-ignore.awk
|
# doxyFilter-ignore.awk
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# - Prefix file contents with doxygen @file tag and %filePath% tag
|
# - Prefix file contents with doxygen @file tag and %filePath% tag
|
||||||
@ -22,7 +22,7 @@
|
|||||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# Script
|
# Script
|
||||||
# doxyFilt-top.awk
|
# doxyFilter-top.awk
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Only output the first /* ... */ comment section found in the file
|
# Only output the first /* ... */ comment section found in the file
|
||||||
@ -22,7 +22,7 @@
|
|||||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# Script
|
# Script
|
||||||
# doxyFilt.awk
|
# doxyFilter.awk
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Converts cocoon style sentinel strings into doxygen style strings
|
# Converts cocoon style sentinel strings into doxygen style strings
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Script
|
# Script
|
||||||
# doxyFilt.sed
|
# doxyFilter.sed
|
||||||
#
|
#
|
||||||
# Description
|
# Description
|
||||||
# Transform human-readable tags such as 'Description' into the Doxygen
|
# Transform human-readable tags such as 'Description' into the Doxygen
|
||||||
@ -45,6 +45,9 @@
|
|||||||
# Note
|
# Note
|
||||||
# Using "git commit --no-verify" it is possible to override the hook.
|
# Using "git commit --no-verify" it is possible to override the hook.
|
||||||
#
|
#
|
||||||
|
# By supplying arguments to the hook, it can also be used to manually
|
||||||
|
# test the specified files/directories for standards conformance.
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
die()
|
die()
|
||||||
{
|
{
|
||||||
@ -52,13 +55,14 @@ die()
|
|||||||
echo '-----------------------' 1>&2
|
echo '-----------------------' 1>&2
|
||||||
echo '' 1>&2
|
echo '' 1>&2
|
||||||
echo "$@" 1>&2
|
echo "$@" 1>&2
|
||||||
|
echo '' 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Check content that will be added by this commit.
|
# Check content that will be added by this commit.
|
||||||
|
|
||||||
if git rev-parse --verify -q HEAD > /dev/null
|
if git rev-parse --verify HEAD > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
against=HEAD
|
against=HEAD
|
||||||
else
|
else
|
||||||
@ -66,10 +70,30 @@ else
|
|||||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# list of all files
|
# called manually with arguments for the files/directories to be tested?
|
||||||
fileList=$(git diff-index --name-only $against --)
|
if [ "$#" -gt 0 ]
|
||||||
unset badFiles
|
then
|
||||||
|
case "$1" in
|
||||||
|
-h | -help)
|
||||||
|
die "interactive usage: supply list of files/directories to check"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# obtain list of all specified files/directories
|
||||||
|
fileList=$(git ls-files -- $@ 2>/dev/null)
|
||||||
|
else
|
||||||
|
# list of all files to be committed
|
||||||
|
fileList=$(git diff-index --cached --name-only $against --)
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# no files changed: can skip all the checks
|
||||||
|
# this usage can correspond to a 'git commit --amend'
|
||||||
|
#
|
||||||
|
[ -n "$fileList" ] || exit 0
|
||||||
|
|
||||||
|
|
||||||
|
unset badFiles
|
||||||
# join list of files with this amount of space
|
# join list of files with this amount of space
|
||||||
Indent=" "
|
Indent=" "
|
||||||
|
|
||||||
@ -97,16 +121,18 @@ dieOnBadFiles()
|
|||||||
#
|
#
|
||||||
checkIllegalCode()
|
checkIllegalCode()
|
||||||
{
|
{
|
||||||
|
echo "pre-commit: check bad strings/characters etc ..." 1>&2
|
||||||
|
|
||||||
reBad="(N""abla|"$'\t'")"
|
reBad="(N""abla|"$'\t'")"
|
||||||
msgBad="N""abla or <TAB>"
|
msgBad="N""abla or <TAB>"
|
||||||
|
|
||||||
badFiles=$(
|
badFiles=$(
|
||||||
for f in $fileList
|
for f in $fileList
|
||||||
do
|
do
|
||||||
# parse line numbers from this:
|
# parse line numbers from grep output:
|
||||||
# path/fileName:<lineNr>: contents
|
# <lineNr>: contents
|
||||||
lines=$(git grep --cached -n -E -e "$reBad" -- "$f" |
|
lines=$(git grep --cached -E -hn -e "$reBad" -- "$f" |
|
||||||
sed -e 's@^[^:]*:\([0-9]*\):.*@\1@' |
|
sed -e 's@:.*@@' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)
|
)
|
||||||
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
||||||
@ -123,18 +149,22 @@ checkIllegalCode()
|
|||||||
checkCopyright()
|
checkCopyright()
|
||||||
{
|
{
|
||||||
year=$(date +%Y)
|
year=$(date +%Y)
|
||||||
|
echo "pre-commit: check copyright ..." 1>&2
|
||||||
|
|
||||||
badFiles=$(
|
badFiles=$(
|
||||||
for f in $fileList
|
for f in $fileList
|
||||||
do
|
do
|
||||||
# parse line numbers from this:
|
# NB: need to have OpenCFD on a separate line to prevent
|
||||||
# path/fileName:<lineNr>: contents
|
# this check being caught by itself!
|
||||||
# for Copyright lines without the current year
|
#
|
||||||
lines=$(git grep --cached -n -e Copyright -- "$f" |
|
# parse line numbers from grep output:
|
||||||
sed -n \
|
# <lineNr>: contents
|
||||||
-e '/OpenCFD/{ ' \
|
#
|
||||||
-e "/$year/b" \
|
lines=$(git grep --cached -F -hn -e Copyright \
|
||||||
-e 's@^[^:]*:\([0-9]*\):.*@\1@p }' |
|
--and -e OpenCFD \
|
||||||
|
--and --not -e "$year" \
|
||||||
|
-- "$f" |
|
||||||
|
sed -e 's@:.*@@' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)
|
)
|
||||||
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
||||||
@ -150,16 +180,18 @@ checkCopyright()
|
|||||||
#
|
#
|
||||||
checkLineLength()
|
checkLineLength()
|
||||||
{
|
{
|
||||||
|
echo "pre-commit: check line lengths ..." 1>&2
|
||||||
|
|
||||||
badFiles=$(
|
badFiles=$(
|
||||||
for f in $fileList
|
for f in $fileList
|
||||||
do
|
do
|
||||||
# limit to *.[CH] files
|
# limit to *.[CH] files
|
||||||
case "$f" in
|
case "$f" in
|
||||||
(*.[CH])
|
(*.[CH])
|
||||||
# parse line numbers from this:
|
# parse line numbers from grep output:
|
||||||
# path/fileName:<lineNr>: contents
|
# <lineNr>: contents
|
||||||
lines=$(git grep --cached -n -e ".\{81,\}" -- "$f" |
|
lines=$(git grep --cached -hn -e '^.\{81,\}' -- "$f" |
|
||||||
sed -e 's@^[^:]*:\([0-9]*\):.*@\1@' |
|
sed -e 's@:.*@@' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)
|
)
|
||||||
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
||||||
@ -177,18 +209,20 @@ checkLineLength()
|
|||||||
#
|
#
|
||||||
checkLineLengthNonComments()
|
checkLineLengthNonComments()
|
||||||
{
|
{
|
||||||
|
echo "pre-commit: check line lengths ..." 1>&2
|
||||||
|
|
||||||
badFiles=$(
|
badFiles=$(
|
||||||
for f in $fileList
|
for f in $fileList
|
||||||
do
|
do
|
||||||
# limit to *.[CH] files
|
# limit to *.[CH] files
|
||||||
case "$f" in
|
case "$f" in
|
||||||
(*.[CH])
|
(*.[CH])
|
||||||
# parse line numbers from this (strip comment lines):
|
# parse line numbers from grep output:
|
||||||
# path/fileName:<lineNr>: contents
|
# <lineNr>: contents
|
||||||
lines=$(git grep --cached -n -e ".\{81,\}" -- "$f" |
|
lines=$(git grep --cached -hn -e '^.\{81,\}' \
|
||||||
sed -n \
|
--and --not -e "^ *//" \
|
||||||
-e '\@^[^:]*:[^:]*: *//.*@b' \
|
-- "$f" |
|
||||||
-e 's@^[^:]*:\([0-9]*\):.*@\1@p' |
|
sed -e 's@:.*@@' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)
|
)
|
||||||
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
||||||
@ -205,18 +239,20 @@ checkLineLengthNonComments()
|
|||||||
#
|
#
|
||||||
checkLineLengthNonDirective()
|
checkLineLengthNonDirective()
|
||||||
{
|
{
|
||||||
|
echo "pre-commit: check line lengths ..." 1>&2
|
||||||
|
|
||||||
badFiles=$(
|
badFiles=$(
|
||||||
for f in $fileList
|
for f in $fileList
|
||||||
do
|
do
|
||||||
# limit to *.[CH] files
|
# limit to *.[CH] files
|
||||||
case "$f" in
|
case "$f" in
|
||||||
(*.[CH])
|
(*.[CH])
|
||||||
# parse line numbers from this (strip comment lines):
|
# parse line numbers from grep output:
|
||||||
# path/fileName:<lineNr>: contents
|
# <lineNr>: contents
|
||||||
lines=$(git grep --cached -n -e ".\{81,\}" -- "$f" |
|
lines=$(git grep --cached -hn -e '^.\{81,\}' \
|
||||||
sed -n \
|
--and --not -e "^ *#" \
|
||||||
-e '\@^[^:]*:[^:]*: *#.*@b' \
|
-- "$f" |
|
||||||
-e 's@^[^:]*:\([0-9]*\):.*@\1@p' |
|
sed -e 's@:.*@@' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)
|
)
|
||||||
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
[ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
|
||||||
|
|||||||
@ -567,7 +567,7 @@ IMAGE_PATH =
|
|||||||
# to standard output. If FILTER_PATTERNS is specified, this tag will be
|
# to standard output. If FILTER_PATTERNS is specified, this tag will be
|
||||||
# ignored.
|
# ignored.
|
||||||
|
|
||||||
INPUT_FILTER = doxyFilt
|
INPUT_FILTER = $(WM_PROJECT_DIR)/bin/tools/doxyFilter
|
||||||
|
|
||||||
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
|
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
|
||||||
# basis. Doxygen will compare the file name with each pattern and apply the
|
# basis. Doxygen will compare the file name with each pattern and apply the
|
||||||
|
|||||||
@ -669,7 +669,7 @@ IMAGE_PATH =
|
|||||||
# If FILTER_PATTERNS is specified, this tag will be
|
# If FILTER_PATTERNS is specified, this tag will be
|
||||||
# ignored.
|
# ignored.
|
||||||
|
|
||||||
INPUT_FILTER = doxyFilt
|
INPUT_FILTER = $(WM_PROJECT_DIR)/bin/tools/doxyFilter
|
||||||
|
|
||||||
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
|
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
|
||||||
# basis.
|
# basis.
|
||||||
|
|||||||
17
doc/tools/find-trailingspace
Executable file
17
doc/tools/find-trailingspace
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Script
|
||||||
|
# find-trailingspace
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Search for files with trailing whitesapce
|
||||||
|
#
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
set -x
|
||||||
|
cd $WM_PROJECT_DIR || exit 1
|
||||||
|
|
||||||
|
tab=$'\t'
|
||||||
|
|
||||||
|
git grep -c -E "[ $tab]+"'$' -- $@
|
||||||
|
|
||||||
|
#------------------------------------------------------------------ end-of-file
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
// The begin-of-line (^) and end-of-line ($) anchors are implicit
|
// The begin-of-line (^) and end-of-line ($) anchors are implicit
|
||||||
bool match(const string&, List<string>& groups) const;
|
bool match(const string&, List<string>& groups) const;
|
||||||
|
|
||||||
//- Return true if the regex was found in within string
|
//- Return true if the regex was found within string
|
||||||
bool search(const std::string& str) const
|
bool search(const std::string& str) const
|
||||||
{
|
{
|
||||||
return std::string::npos != find(str);
|
return std::string::npos != find(str);
|
||||||
|
|||||||
@ -52,8 +52,8 @@ $(strings)/word/word.C
|
|||||||
$(strings)/word/wordIO.C
|
$(strings)/word/wordIO.C
|
||||||
$(strings)/fileName/fileName.C
|
$(strings)/fileName/fileName.C
|
||||||
$(strings)/fileName/fileNameIO.C
|
$(strings)/fileName/fileNameIO.C
|
||||||
$(strings)/keyType/keyTypeIO.C
|
$(strings)/keyType/keyType.C
|
||||||
$(strings)/wordRe/wordReIO.C
|
$(strings)/wordRe/wordRe.C
|
||||||
|
|
||||||
primitives/hashes/Hasher/Hasher.C
|
primitives/hashes/Hasher/Hasher.C
|
||||||
|
|
||||||
@ -66,7 +66,8 @@ primitives/random/Random.C
|
|||||||
containers/HashTables/HashTable/HashTableCore.C
|
containers/HashTables/HashTable/HashTableCore.C
|
||||||
containers/HashTables/StaticHashTable/StaticHashTableCore.C
|
containers/HashTables/StaticHashTable/StaticHashTableCore.C
|
||||||
containers/Lists/SortableList/ParSortableListName.C
|
containers/Lists/SortableList/ParSortableListName.C
|
||||||
containers/Lists/PackedList/PackedListName.C
|
containers/Lists/PackedList/PackedListCore.C
|
||||||
|
containers/Lists/PackedList/PackedBoolList.C
|
||||||
containers/Lists/ListOps/ListOps.C
|
containers/Lists/ListOps/ListOps.C
|
||||||
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
|
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
|
||||||
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C
|
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C
|
||||||
@ -329,7 +330,7 @@ $(cellShape)/cellShapeEqual.C
|
|||||||
$(cellShape)/cellShapeIO.C
|
$(cellShape)/cellShapeIO.C
|
||||||
$(cellShape)/cellShapeIOList.C
|
$(cellShape)/cellShapeIOList.C
|
||||||
|
|
||||||
meshes/patchIdentifier/patchIdentifier.C
|
meshes/Identifiers/patch/patchIdentifier.C
|
||||||
|
|
||||||
polyMesh = meshes/polyMesh
|
polyMesh = meshes/polyMesh
|
||||||
|
|
||||||
|
|||||||
@ -180,13 +180,22 @@ public:
|
|||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Append an element at the end of the list
|
//- Append an element at the end of the list
|
||||||
inline void append(const T&);
|
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||||
|
(
|
||||||
|
const T&
|
||||||
|
);
|
||||||
|
|
||||||
//- Append a List at the end of this list
|
//- Append a List at the end of this list
|
||||||
inline void append(const UList<T>&);
|
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||||
|
(
|
||||||
|
const UList<T>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Append a UIndirectList at the end of this list
|
//- Append a UIndirectList at the end of this list
|
||||||
inline void append(const UIndirectList<T>&);
|
inline DynamicList<T, SizeInc, SizeMult, SizeDiv>& append
|
||||||
|
(
|
||||||
|
const UIndirectList<T>&
|
||||||
|
);
|
||||||
|
|
||||||
//- Remove and return the top element
|
//- Remove and return the top element
|
||||||
inline T remove();
|
inline T remove();
|
||||||
|
|||||||
@ -305,7 +305,8 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::xfer()
|
|||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
(
|
(
|
||||||
const T& t
|
const T& t
|
||||||
)
|
)
|
||||||
@ -314,11 +315,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
|||||||
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>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
(
|
(
|
||||||
const UList<T>& lst
|
const UList<T>& lst
|
||||||
)
|
)
|
||||||
@ -339,11 +342,13 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
|||||||
{
|
{
|
||||||
this->operator[](nextFree++) = lst[elemI];
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
||||||
(
|
(
|
||||||
const UIndirectList<T>& lst
|
const UIndirectList<T>& lst
|
||||||
)
|
)
|
||||||
@ -355,6 +360,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
|
|||||||
{
|
{
|
||||||
this->operator[](nextFree++) = lst[elemI];
|
this->operator[](nextFree++) = lst[elemI];
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,11 @@ Class
|
|||||||
Foam::IndirectList
|
Foam::IndirectList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A List with indirect addressing
|
A List with indirect addressing.
|
||||||
|
|
||||||
|
SeeAlso
|
||||||
|
Foam::UIndirectList for a version without any allocation for the
|
||||||
|
addressing.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
IndirectListI.H
|
IndirectListI.H
|
||||||
@ -35,24 +39,79 @@ SourceFiles
|
|||||||
#ifndef IndirectList_H
|
#ifndef IndirectList_H
|
||||||
#define IndirectList_H
|
#define IndirectList_H
|
||||||
|
|
||||||
#include "List.H"
|
#include "UIndirectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class IndirectListAddressing Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//- A helper class for storing addresses.
|
||||||
|
class IndirectListAddressing
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Storage for the list addressing
|
||||||
|
List<label> addressing_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
IndirectListAddressing(const IndirectListAddressing&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const IndirectListAddressing&);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct by copying the addressing array
|
||||||
|
explicit inline IndirectListAddressing(const UList<label>& addr);
|
||||||
|
|
||||||
|
//- Construct by transferring addressing array
|
||||||
|
explicit inline IndirectListAddressing(const Xfer<List<label> >& addr);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return the list addressing
|
||||||
|
inline const List<label>& addressing() const;
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Reset addressing
|
||||||
|
inline void resetAddressing(const UList<label>&);
|
||||||
|
inline void resetAddressing(const Xfer<List<label> >&);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class IndirectList Declaration
|
Class IndirectList Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class IndirectList
|
class IndirectList
|
||||||
|
:
|
||||||
|
private IndirectListAddressing,
|
||||||
|
public UIndirectList<T>
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Member Functions
|
||||||
|
|
||||||
UList<T>& completeList_;
|
//- Disable default assignment operator
|
||||||
List<label> addressing_;
|
void operator=(const IndirectList<T>&);
|
||||||
|
|
||||||
|
//- Disable assignment from UIndirectList
|
||||||
|
void operator=(const UIndirectList<T>&);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -65,59 +124,32 @@ public:
|
|||||||
//- Construct given the complete list and by transferring addressing
|
//- Construct given the complete list and by transferring addressing
|
||||||
inline IndirectList(const UList<T>&, const Xfer<List<label> >&);
|
inline IndirectList(const UList<T>&, const Xfer<List<label> >&);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
inline IndirectList(const IndirectList<T>&);
|
||||||
|
|
||||||
|
//- Construct from UIndirectList
|
||||||
|
explicit inline IndirectList(const UIndirectList<T>&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return the number of elements in the list
|
|
||||||
inline label size() const;
|
|
||||||
|
|
||||||
//- Return true if the list is empty (ie, size() is zero).
|
|
||||||
inline bool empty() const;
|
|
||||||
|
|
||||||
//- Return the first element of the list.
|
|
||||||
inline T& first();
|
|
||||||
|
|
||||||
//- Return first element of the list.
|
|
||||||
inline const T& first() const;
|
|
||||||
|
|
||||||
//- Return the last element of the list.
|
|
||||||
inline T& last();
|
|
||||||
|
|
||||||
//- Return the last element of the list.
|
|
||||||
inline const T& last() const;
|
|
||||||
|
|
||||||
//- Return the complete list
|
|
||||||
inline const UList<T>& completeList() const;
|
|
||||||
|
|
||||||
//- Return the list addressing
|
//- Return the list addressing
|
||||||
inline const List<label>& addressing() const;
|
using UIndirectList<T>::addressing;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Reset addressing
|
//- Reset addressing
|
||||||
inline void resetAddressing(const UList<label>&);
|
using IndirectListAddressing::resetAddressing;
|
||||||
inline void resetAddressing(const Xfer<List<label> >&);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Return the addressed elements as a List
|
//- Assignment operator
|
||||||
inline List<T> operator()() const;
|
using UIndirectList<T>::operator=;
|
||||||
|
|
||||||
//- Return non-const access to an element
|
|
||||||
inline T& operator[](const label);
|
|
||||||
|
|
||||||
//- Return const access to an element
|
|
||||||
inline const T& operator[](const label) const;
|
|
||||||
|
|
||||||
//- Assignment from UList of addressed elements
|
|
||||||
inline void operator=(const UList<T>&);
|
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
|
||||||
inline void operator=(const T&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,6 +25,25 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::IndirectListAddressing::IndirectListAddressing
|
||||||
|
(
|
||||||
|
const UList<label>& addr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
addressing_(addr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::IndirectListAddressing::IndirectListAddressing
|
||||||
|
(
|
||||||
|
const Xfer<List<label> >& addr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
addressing_(addr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::IndirectList<T>::IndirectList
|
inline Foam::IndirectList<T>::IndirectList
|
||||||
(
|
(
|
||||||
@ -32,8 +51,12 @@ inline Foam::IndirectList<T>::IndirectList
|
|||||||
const UList<label>& addr
|
const UList<label>& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
completeList_(const_cast<UList<T>&>(completeList)),
|
IndirectListAddressing(addr),
|
||||||
addressing_(addr)
|
UIndirectList<T>
|
||||||
|
(
|
||||||
|
completeList,
|
||||||
|
IndirectListAddressing::addressing()
|
||||||
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -44,71 +67,55 @@ inline Foam::IndirectList<T>::IndirectList
|
|||||||
const Xfer<List<label> >& addr
|
const Xfer<List<label> >& addr
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
completeList_(const_cast<UList<T>&>(completeList)),
|
IndirectListAddressing(addr),
|
||||||
addressing_(addr)
|
UIndirectList<T>
|
||||||
|
(
|
||||||
|
completeList,
|
||||||
|
IndirectListAddressing::addressing()
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::IndirectList<T>::IndirectList
|
||||||
|
(
|
||||||
|
const IndirectList<T>& lst
|
||||||
|
)
|
||||||
|
:
|
||||||
|
IndirectListAddressing(lst.addressing()),
|
||||||
|
UIndirectList<T>
|
||||||
|
(
|
||||||
|
lst.completeList(),
|
||||||
|
IndirectListAddressing::addressing()
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline Foam::IndirectList<T>::IndirectList
|
||||||
|
(
|
||||||
|
const UIndirectList<T>& lst
|
||||||
|
)
|
||||||
|
:
|
||||||
|
IndirectListAddressing(lst.addressing()),
|
||||||
|
UIndirectList<T>
|
||||||
|
(
|
||||||
|
lst.completeList(),
|
||||||
|
IndirectListAddressing::addressing()
|
||||||
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
inline const Foam::List<Foam::label>&
|
||||||
inline Foam::label Foam::IndirectList<T>::size() const
|
Foam::IndirectListAddressing::addressing() const
|
||||||
{
|
|
||||||
return addressing_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline bool Foam::IndirectList<T>::empty() const
|
|
||||||
{
|
|
||||||
return addressing_.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T& Foam::IndirectList<T>::first()
|
|
||||||
{
|
|
||||||
return completeList_[addressing_.first()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::IndirectList<T>::first() const
|
|
||||||
{
|
|
||||||
return completeList_[addressing_.first()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T& Foam::IndirectList<T>::last()
|
|
||||||
{
|
|
||||||
return completeList_[addressing_.last()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::IndirectList<T>::last() const
|
|
||||||
{
|
|
||||||
return completeList_[addressing_.last()];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const Foam::UList<T>& Foam::IndirectList<T>::completeList() const
|
|
||||||
{
|
|
||||||
return completeList_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const Foam::List<Foam::label>& Foam::IndirectList<T>::addressing() const
|
|
||||||
{
|
{
|
||||||
return addressing_;
|
return addressing_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
inline void Foam::IndirectListAddressing::resetAddressing
|
||||||
inline void Foam::IndirectList<T>::resetAddressing
|
|
||||||
(
|
(
|
||||||
const UList<label>& addr
|
const UList<label>& addr
|
||||||
)
|
)
|
||||||
@ -117,8 +124,7 @@ inline void Foam::IndirectList<T>::resetAddressing
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
inline void Foam::IndirectListAddressing::resetAddressing
|
||||||
inline void Foam::IndirectList<T>::resetAddressing
|
|
||||||
(
|
(
|
||||||
const Xfer<List<label> >& addr
|
const Xfer<List<label> >& addr
|
||||||
)
|
)
|
||||||
@ -127,63 +133,4 @@ inline void Foam::IndirectList<T>::resetAddressing
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline Foam::List<T> Foam::IndirectList<T>::operator()() const
|
|
||||||
{
|
|
||||||
List<T> result(size());
|
|
||||||
|
|
||||||
forAll(*this, i)
|
|
||||||
{
|
|
||||||
result[i] = operator[](i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T& Foam::IndirectList<T>::operator[](const label i)
|
|
||||||
{
|
|
||||||
return completeList_[addressing_[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::IndirectList<T>::operator[](const label i) const
|
|
||||||
{
|
|
||||||
return completeList_[addressing_[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void Foam::IndirectList<T>::operator=(const UList<T>& ae)
|
|
||||||
{
|
|
||||||
if (addressing_.size() != ae.size())
|
|
||||||
{
|
|
||||||
FatalErrorIn("IndirectList<T>::operator=(const UList<T>&)")
|
|
||||||
<< "Addressing and list of addressed elements "
|
|
||||||
"have different sizes: "
|
|
||||||
<< addressing_.size() << " " << ae.size()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(addressing_, i)
|
|
||||||
{
|
|
||||||
completeList_[addressing_[i]] = ae[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void Foam::IndirectList<T>::operator=(const T& t)
|
|
||||||
{
|
|
||||||
forAll(addressing_, i)
|
|
||||||
{
|
|
||||||
completeList_[addressing_[i]] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -266,24 +266,6 @@ Foam::List<T>::List(const SLList<T>& lst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct as copy of IndirectList<T>
|
|
||||||
template<class T>
|
|
||||||
Foam::List<T>::List(const IndirectList<T>& lst)
|
|
||||||
:
|
|
||||||
UList<T>(NULL, lst.size())
|
|
||||||
{
|
|
||||||
if (this->size_)
|
|
||||||
{
|
|
||||||
this->v_ = new T[this->size_];
|
|
||||||
|
|
||||||
forAll(*this, i)
|
|
||||||
{
|
|
||||||
this->operator[](i) = lst[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Construct as copy of UIndirectList<T>
|
// Construct as copy of UIndirectList<T>
|
||||||
template<class T>
|
template<class T>
|
||||||
Foam::List<T>::List(const UIndirectList<T>& lst)
|
Foam::List<T>::List(const UIndirectList<T>& lst)
|
||||||
@ -381,7 +363,7 @@ void Foam::List<T>::setSize(const label newSize)
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::List<T>::setSize(const label newSize, const T& a)
|
void Foam::List<T>::setSize(const label newSize, const T& a)
|
||||||
{
|
{
|
||||||
label oldSize = this->size_;
|
label oldSize = label(this->size_);
|
||||||
this->setSize(newSize);
|
this->setSize(newSize);
|
||||||
|
|
||||||
if (newSize > oldSize)
|
if (newSize > oldSize)
|
||||||
@ -517,25 +499,6 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Assignment operator. Takes linear time.
|
|
||||||
template<class T>
|
|
||||||
void Foam::List<T>::operator=(const IndirectList<T>& lst)
|
|
||||||
{
|
|
||||||
if (lst.size() != this->size_)
|
|
||||||
{
|
|
||||||
if (this->v_) delete[] this->v_;
|
|
||||||
this->v_ = 0;
|
|
||||||
this->size_ = lst.size();
|
|
||||||
if (this->size_) this->v_ = new T[this->size_];
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(*this, i)
|
|
||||||
{
|
|
||||||
this->operator[](i) = lst[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Assignment operator. Takes linear time.
|
// Assignment operator. Takes linear time.
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::List<T>::operator=(const UIndirectList<T>& lst)
|
void Foam::List<T>::operator=(const UIndirectList<T>& lst)
|
||||||
|
|||||||
@ -131,9 +131,6 @@ public:
|
|||||||
//- Construct as copy of SLList<T>
|
//- Construct as copy of SLList<T>
|
||||||
explicit List(const SLList<T>&);
|
explicit List(const SLList<T>&);
|
||||||
|
|
||||||
//- Construct as copy of IndirectList<T>
|
|
||||||
explicit List(const IndirectList<T>&);
|
|
||||||
|
|
||||||
//- Construct as copy of UIndirectList<T>
|
//- Construct as copy of UIndirectList<T>
|
||||||
explicit List(const UIndirectList<T>&);
|
explicit List(const UIndirectList<T>&);
|
||||||
|
|
||||||
@ -219,9 +216,6 @@ public:
|
|||||||
//- Assignment from SLList operator. Takes linear time.
|
//- Assignment from SLList operator. Takes linear time.
|
||||||
void operator=(const SLList<T>&);
|
void operator=(const SLList<T>&);
|
||||||
|
|
||||||
//- Assignment from IndirectList operator. Takes linear time.
|
|
||||||
void operator=(const IndirectList<T>&);
|
|
||||||
|
|
||||||
//- Assignment from UIndirectList operator. Takes linear time.
|
//- Assignment from UIndirectList operator. Takes linear time.
|
||||||
void operator=(const UIndirectList<T>&);
|
void operator=(const UIndirectList<T>&);
|
||||||
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Putback the openning bracket
|
// Putback the opening bracket
|
||||||
is.putBack(firstToken);
|
is.putBack(firstToken);
|
||||||
|
|
||||||
// Now read as a singly-linked list
|
// Now read as a singly-linked list
|
||||||
|
|||||||
375
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
Normal file
375
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C
Normal file
@ -0,0 +1,375 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::PackedBoolList::bitorPrepare
|
||||||
|
(
|
||||||
|
const PackedList<1>& lst,
|
||||||
|
label& maxPackLen
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const StorageList& lhs = this->storage();
|
||||||
|
const StorageList& rhs = lst.storage();
|
||||||
|
|
||||||
|
const label packLen1 = this->packedLength();
|
||||||
|
const label packLen2 = lst.packedLength();
|
||||||
|
|
||||||
|
|
||||||
|
// check how the lists interact and if bit trimming is needed
|
||||||
|
bool needTrim = false;
|
||||||
|
maxPackLen = packLen1;
|
||||||
|
|
||||||
|
if (packLen1 == packLen2)
|
||||||
|
{
|
||||||
|
// identical packed lengths - only resize if absolutely necessary
|
||||||
|
if
|
||||||
|
(
|
||||||
|
this->size() != lst.size()
|
||||||
|
&& maxPackLen
|
||||||
|
&& rhs[maxPackLen-1] > lhs[maxPackLen-1]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// second list has a higher bit set
|
||||||
|
// extend addressable area and use trim
|
||||||
|
resize(lst.size());
|
||||||
|
needTrim = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (packLen2 < packLen1)
|
||||||
|
{
|
||||||
|
// second list is shorter, this limits the or
|
||||||
|
maxPackLen = packLen2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// second list is longer, find the highest bit set
|
||||||
|
for (label storeI = packLen1; storeI < packLen2; ++storeI)
|
||||||
|
{
|
||||||
|
if (rhs[storeI])
|
||||||
|
{
|
||||||
|
maxPackLen = storeI+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the upper limit moved - resize for full coverage and trim later
|
||||||
|
if (maxPackLen > packLen1)
|
||||||
|
{
|
||||||
|
resize(maxPackLen * packing());
|
||||||
|
needTrim = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return needTrim;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class LabelListType>
|
||||||
|
Foam::label Foam::PackedBoolList::setIndices(const LabelListType& indices)
|
||||||
|
{
|
||||||
|
// no better information, just guess something about the size
|
||||||
|
reserve(indices.size());
|
||||||
|
|
||||||
|
label cnt = 0;
|
||||||
|
forAll(indices, elemI)
|
||||||
|
{
|
||||||
|
if (set(indices[elemI]))
|
||||||
|
{
|
||||||
|
++cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class LabelListType>
|
||||||
|
Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices)
|
||||||
|
{
|
||||||
|
label cnt = 0;
|
||||||
|
forAll(indices, elemI)
|
||||||
|
{
|
||||||
|
if (unset(indices[elemI]))
|
||||||
|
{
|
||||||
|
++cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class LabelListType>
|
||||||
|
Foam::label Foam::PackedBoolList::subsetIndices(const LabelListType& indices)
|
||||||
|
{
|
||||||
|
// handle trivial case
|
||||||
|
if (empty() || indices.empty())
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal case
|
||||||
|
PackedBoolList anded;
|
||||||
|
anded.reserve(size());
|
||||||
|
|
||||||
|
label cnt = 0;
|
||||||
|
forAll(indices, elemI)
|
||||||
|
{
|
||||||
|
const label& index = indices[elemI];
|
||||||
|
if (operator[](index))
|
||||||
|
{
|
||||||
|
anded.set(index);
|
||||||
|
++cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transfer(anded);
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::PackedBoolList::PackedBoolList(Istream& is)
|
||||||
|
:
|
||||||
|
PackedList<1>()
|
||||||
|
{
|
||||||
|
is >> *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::PackedBoolList::set(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
// extend addressable area if needed, return maximum size possible
|
||||||
|
label len = 0;
|
||||||
|
const bool needTrim = bitorPrepare(lst, len);
|
||||||
|
|
||||||
|
// operate directly with the underlying storage
|
||||||
|
StorageList& lhs = this->storage();
|
||||||
|
const StorageList& rhs = lst.storage();
|
||||||
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
|
{
|
||||||
|
lhs[i] |= rhs[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needTrim)
|
||||||
|
{
|
||||||
|
trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::set(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
return setIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::set(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
return setIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::PackedBoolList::unset(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
// operate directly with the underlying storage
|
||||||
|
StorageList& lhs = this->storage();
|
||||||
|
const StorageList& rhs = lst.storage();
|
||||||
|
|
||||||
|
// overlapping storage size
|
||||||
|
const label len = min(this->packedLength(), lst.packedLength());
|
||||||
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
|
{
|
||||||
|
lhs[i] &= ~rhs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::unset(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
return unsetIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::unset(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
return unsetIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::PackedBoolList::subset(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
// shrink addressable area if needed
|
||||||
|
if (this->size() > lst.size())
|
||||||
|
{
|
||||||
|
this->resize(lst.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
// operate directly with the underlying storage
|
||||||
|
StorageList& lhs = this->storage();
|
||||||
|
const StorageList& rhs = lst.storage();
|
||||||
|
|
||||||
|
const label len = this->packedLength();
|
||||||
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
|
{
|
||||||
|
lhs[i] &= rhs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::subset(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
return subsetIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::PackedBoolList::subset(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
return subsetIndices(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
|
||||||
|
{
|
||||||
|
labelList lst(this->count());
|
||||||
|
|
||||||
|
if (lst.size())
|
||||||
|
{
|
||||||
|
label nElem = 0;
|
||||||
|
|
||||||
|
forAll(*this, elemI)
|
||||||
|
{
|
||||||
|
if (get(elemI))
|
||||||
|
{
|
||||||
|
lst[nElem++] = elemI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lst.setSize(nElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lst.xfer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const UList<bool>& lst)
|
||||||
|
{
|
||||||
|
this->setSize(lst.size());
|
||||||
|
|
||||||
|
// overwrite with new true/false values
|
||||||
|
forAll(*this, elemI)
|
||||||
|
{
|
||||||
|
set(elemI, lst[elemI]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator^=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
// extend addressable area if needed, return maximum size possible
|
||||||
|
label len = 0;
|
||||||
|
const bool needTrim = bitorPrepare(lst, len);
|
||||||
|
|
||||||
|
// operate directly with the underlying storage
|
||||||
|
StorageList& lhs = this->storage();
|
||||||
|
const StorageList& rhs = lst.storage();
|
||||||
|
|
||||||
|
for (label i=0; i < len; ++i)
|
||||||
|
{
|
||||||
|
lhs[i] ^= rhs[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needTrim)
|
||||||
|
{
|
||||||
|
trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::PackedBoolList Foam::operator&
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PackedBoolList result(lst1);
|
||||||
|
result &= lst2;
|
||||||
|
|
||||||
|
// trim to bits actually used
|
||||||
|
result.trim();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::PackedBoolList Foam::operator^
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PackedBoolList result(lst1);
|
||||||
|
result ^= lst2;
|
||||||
|
|
||||||
|
// trim to bits actually used
|
||||||
|
result.trim();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::PackedBoolList Foam::operator|
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PackedBoolList result(lst1);
|
||||||
|
result |= lst2;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
296
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
Normal file
296
src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::PackedBoolList
|
||||||
|
|
||||||
|
Description
|
||||||
|
A bit-packed bool list.
|
||||||
|
|
||||||
|
In addition to the obvious memory advantage over using a
|
||||||
|
List\<bool\>, this class also provides a number of bit-like
|
||||||
|
operations.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
PackedBoolListI.H
|
||||||
|
PackedBoolList.C
|
||||||
|
|
||||||
|
SeeAlso
|
||||||
|
Foam::PackedList
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef PackedBoolList_H
|
||||||
|
#define PackedBoolList_H
|
||||||
|
|
||||||
|
#include "PackedList.H"
|
||||||
|
#include "UIndirectList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class PackedBoolList Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class PackedBoolList
|
||||||
|
:
|
||||||
|
public PackedList<1>
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Preparation, resizing before a bitor operation
|
||||||
|
// returns true if the later result needs trimming
|
||||||
|
bool bitorPrepare(const PackedList<1>& lst, label& maxPackLen);
|
||||||
|
|
||||||
|
//- Set the listed indices. Return number of elements changed.
|
||||||
|
// Does auto-vivify for non-existent entries.
|
||||||
|
template<class LabelListType>
|
||||||
|
label setIndices(const LabelListType& indices);
|
||||||
|
|
||||||
|
//- Unset the listed indices. Return number of elements changed.
|
||||||
|
// Never auto-vivify entries.
|
||||||
|
template<class LabelListType>
|
||||||
|
label unsetIndices(const LabelListType& indices);
|
||||||
|
|
||||||
|
//- Subset with the listed indices. Return number of elements subsetted.
|
||||||
|
template<class LabelListType>
|
||||||
|
label subsetIndices(const LabelListType& indices);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
inline PackedBoolList();
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
PackedBoolList(Istream&);
|
||||||
|
|
||||||
|
//- Construct with given size, initializes list to 0
|
||||||
|
explicit inline PackedBoolList(const label size);
|
||||||
|
|
||||||
|
//- Construct with given size and value for all elements
|
||||||
|
inline PackedBoolList(const label size, const bool val);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
inline PackedBoolList(const PackedBoolList&);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
explicit inline PackedBoolList(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Construct by transferring the parameter contents
|
||||||
|
inline PackedBoolList(const Xfer<PackedBoolList>&);
|
||||||
|
|
||||||
|
//- Construct by transferring the parameter contents
|
||||||
|
inline PackedBoolList(const Xfer<PackedList<1> >&);
|
||||||
|
|
||||||
|
//- Construct from a list of bools
|
||||||
|
explicit inline PackedBoolList(const UList<bool>&);
|
||||||
|
|
||||||
|
//- Construct from a list of labels
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
explicit inline PackedBoolList(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Construct from a list of labels
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
explicit inline PackedBoolList(const UIndirectList<label>& indices);
|
||||||
|
|
||||||
|
//- Clone
|
||||||
|
inline autoPtr<PackedBoolList> clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
using PackedList<1>::set;
|
||||||
|
using PackedList<1>::unset;
|
||||||
|
|
||||||
|
//- Set specified bits.
|
||||||
|
void set(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Set the listed indices. Return number of elements changed.
|
||||||
|
// Does auto-vivify for non-existent entries.
|
||||||
|
label set(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Set the listed indices. Return number of elements changed.
|
||||||
|
// Does auto-vivify for non-existent entries.
|
||||||
|
label set(const UIndirectList<label>& indices);
|
||||||
|
|
||||||
|
//- Unset specified bits.
|
||||||
|
void unset(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Unset the listed indices. Return number of elements changed.
|
||||||
|
// Never auto-vivify entries.
|
||||||
|
label unset(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Unset the listed indices. Return number of elements changed.
|
||||||
|
// Never auto-vivify entries.
|
||||||
|
label unset(const UIndirectList<label>& indices);
|
||||||
|
|
||||||
|
//- Subset with the specified list.
|
||||||
|
void subset(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Subset with the listed indices.
|
||||||
|
// Return number of elements subsetted.
|
||||||
|
label subset(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Subset with the listed indices.
|
||||||
|
// Return number of elements subsetted.
|
||||||
|
label subset(const UIndirectList<label>& indices);
|
||||||
|
|
||||||
|
|
||||||
|
//- Return indices of the used (true) elements as a list of labels
|
||||||
|
Xfer<labelList> used() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Transfer the contents of the argument list into this list
|
||||||
|
// and annul the argument list.
|
||||||
|
inline void transfer(PackedBoolList&);
|
||||||
|
|
||||||
|
//- Transfer the contents of the argument list into this list
|
||||||
|
// and annul the argument list.
|
||||||
|
inline void transfer(PackedList<1>&);
|
||||||
|
|
||||||
|
//- Transfer contents to the Xfer container
|
||||||
|
inline Xfer<PackedBoolList> xfer();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Assignment of all entries to the given value.
|
||||||
|
inline PackedBoolList& operator=(const bool val);
|
||||||
|
|
||||||
|
//- Assignment operator.
|
||||||
|
inline PackedBoolList& operator=(const PackedBoolList&);
|
||||||
|
|
||||||
|
//- Assignment operator.
|
||||||
|
inline PackedBoolList& operator=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Assignment operator.
|
||||||
|
PackedBoolList& operator=(const UList<bool>&);
|
||||||
|
|
||||||
|
//- Assignment operator,
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator=(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Assignment operator,
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator=(const UIndirectList<label>&);
|
||||||
|
|
||||||
|
//- Complement operator
|
||||||
|
inline PackedBoolList operator~() const;
|
||||||
|
|
||||||
|
//- And operator (lists may be dissimilar sizes)
|
||||||
|
inline PackedBoolList& operator&=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- And operator (lists may be dissimilar sizes)
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator&=(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- And operator (lists may be dissimilar sizes)
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator&=(const UIndirectList<label>&);
|
||||||
|
|
||||||
|
//- Xor operator (lists may be dissimilar sizes)
|
||||||
|
// Retains unique entries
|
||||||
|
PackedBoolList& operator^=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Or operator (lists may be dissimilar sizes)
|
||||||
|
inline PackedBoolList& operator|=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Or operator (lists may be dissimilar sizes),
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator|=(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Or operator (lists may be dissimilar sizes),
|
||||||
|
// using the labels as indices to indicate which bits are set
|
||||||
|
inline PackedBoolList& operator|=(const UIndirectList<label>&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Add entries to this list, synonymous with the or operator
|
||||||
|
inline PackedBoolList& operator+=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Add entries to this list, synonymous with the or operator
|
||||||
|
inline PackedBoolList& operator+=(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Add entries to this list, synonymous with the or operator
|
||||||
|
inline PackedBoolList& operator+=(const UIndirectList<label>&);
|
||||||
|
|
||||||
|
//- Remove entries from this list - unset the specified bits
|
||||||
|
inline PackedBoolList& operator-=(const PackedList<1>&);
|
||||||
|
|
||||||
|
//- Remove entries from this list - unset the specified bits
|
||||||
|
inline PackedBoolList& operator-=(const UList<label>& indices);
|
||||||
|
|
||||||
|
//- Remove entries from this list - unset the specified bits
|
||||||
|
inline PackedBoolList& operator-=(const UIndirectList<label>&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Global Operators
|
||||||
|
|
||||||
|
//- Intersect lists - the result is trimmed to the smallest intersecting size
|
||||||
|
PackedBoolList operator&
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Combine to form a unique list (xor)
|
||||||
|
// The result is trimmed to the smallest intersecting size
|
||||||
|
PackedBoolList operator^
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Combine lists
|
||||||
|
PackedBoolList operator|
|
||||||
|
(
|
||||||
|
const PackedBoolList& lst1,
|
||||||
|
const PackedBoolList& lst2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "PackedBoolListI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
276
src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
Normal file
276
src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList()
|
||||||
|
:
|
||||||
|
PackedList<1>()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const label size)
|
||||||
|
:
|
||||||
|
PackedList<1>(size)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList
|
||||||
|
(
|
||||||
|
const label size,
|
||||||
|
const bool val
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PackedList<1>(size, (val ? 1u : 0u))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const PackedBoolList& lst)
|
||||||
|
:
|
||||||
|
PackedList<1>(lst)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const PackedList<1>& lst)
|
||||||
|
:
|
||||||
|
PackedList<1>(lst)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedBoolList>& lst)
|
||||||
|
:
|
||||||
|
PackedList<1>()
|
||||||
|
{
|
||||||
|
transfer(lst());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1> >& lst)
|
||||||
|
:
|
||||||
|
PackedList<1>(lst)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
|
||||||
|
:
|
||||||
|
PackedList<1>()
|
||||||
|
{
|
||||||
|
operator=(lst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const UList<label>& indices)
|
||||||
|
:
|
||||||
|
PackedList<1>(indices.size(), 0u)
|
||||||
|
{
|
||||||
|
set(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList::PackedBoolList(const UIndirectList<label>& indices)
|
||||||
|
:
|
||||||
|
PackedList<1>(indices.size(), 0u)
|
||||||
|
{
|
||||||
|
set(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::autoPtr<Foam::PackedBoolList>
|
||||||
|
Foam::PackedBoolList::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<PackedBoolList>(new PackedBoolList(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline void Foam::PackedBoolList::transfer(PackedBoolList& lst)
|
||||||
|
{
|
||||||
|
PackedList<1>::transfer(static_cast<PackedList<1>&>(lst));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::PackedBoolList::transfer(PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
PackedList<1>::transfer(lst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Xfer<Foam::PackedBoolList> Foam::PackedBoolList::xfer()
|
||||||
|
{
|
||||||
|
return xferMove(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const bool val)
|
||||||
|
{
|
||||||
|
PackedList<1>::operator=(val);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const PackedBoolList& lst)
|
||||||
|
{
|
||||||
|
PackedList<1>::operator=(lst);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
PackedList<1>::operator=(lst);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
set(indices);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator=(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
set(indices);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList
|
||||||
|
Foam::PackedBoolList::operator~() const
|
||||||
|
{
|
||||||
|
PackedBoolList result(*this);
|
||||||
|
result.flip();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator&=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
subset(lst);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator&=(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
subset(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator&=(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
subset(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator|=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
set(lst);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator|=(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
set(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator|=(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
set(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator+=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
return operator|=(lst);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator+=(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
return operator|=(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator+=(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
return operator|=(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator-=(const PackedList<1>& lst)
|
||||||
|
{
|
||||||
|
unset(lst);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator-=(const UList<label>& indices)
|
||||||
|
{
|
||||||
|
unset(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::PackedBoolList&
|
||||||
|
Foam::PackedBoolList::operator-=(const UIndirectList<label>& indices)
|
||||||
|
{
|
||||||
|
unset(indices);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -24,35 +24,11 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "PackedList.H"
|
#include "PackedList.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
|
||||||
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
|
||||||
:
|
|
||||||
StorageList(packedLength(size), 0u),
|
|
||||||
size_(size)
|
|
||||||
{
|
|
||||||
operator=(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
|
||||||
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
|
||||||
:
|
|
||||||
StorageList(packedLength(lst.size()), 0u),
|
|
||||||
size_(lst.size())
|
|
||||||
{
|
|
||||||
forAll(lst, i)
|
|
||||||
{
|
|
||||||
set(i, lst[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
#if (UINT_MAX == 0xFFFFFFFF)
|
#if (UINT_MAX == 0xFFFFFFFF)
|
||||||
// 32-bit counting, Hamming weight method
|
// 32-bit counting, Hamming weight method
|
||||||
# define COUNT_PACKEDBITS(sum, x) \
|
# define COUNT_PACKEDBITS(sum, x) \
|
||||||
@ -82,25 +58,10 @@ unsigned int Foam::PackedList<nBits>::count() const
|
|||||||
|
|
||||||
if (size_)
|
if (size_)
|
||||||
{
|
{
|
||||||
// mask value for complete segments
|
const label packLen = packedLength();
|
||||||
unsigned int mask = maskLower(packing());
|
for (label i = 0; i < packLen; ++i)
|
||||||
|
|
||||||
const unsigned int endSeg = size_ / packing();
|
|
||||||
const unsigned int endOff = size_ % packing();
|
|
||||||
|
|
||||||
// count bits in complete segments
|
|
||||||
for (unsigned i = 0; i < endSeg; ++i)
|
|
||||||
{
|
{
|
||||||
register unsigned int bits = StorageList::operator[](i) & mask;
|
register unsigned int bits = StorageList::operator[](i);
|
||||||
COUNT_PACKEDBITS(c, bits);
|
|
||||||
}
|
|
||||||
|
|
||||||
// count bits in partial segment
|
|
||||||
if (endOff)
|
|
||||||
{
|
|
||||||
mask = maskLower(endOff);
|
|
||||||
|
|
||||||
register unsigned int bits = StorageList::operator[](endSeg) & mask;
|
|
||||||
COUNT_PACKEDBITS(c, bits);
|
COUNT_PACKEDBITS(c, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,64 +78,60 @@ bool Foam::PackedList<nBits>::trim()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mask value for complete segments
|
const label oldSize = size_;
|
||||||
unsigned int mask = maskLower(packing());
|
for (label storeI = packedLength()-1; storeI >= 0; --storeI)
|
||||||
|
|
||||||
label currElem = packedLength(size_) - 1;
|
|
||||||
unsigned int endOff = size_ % packing();
|
|
||||||
|
|
||||||
// clear trailing bits on final segment
|
|
||||||
if (endOff)
|
|
||||||
{
|
{
|
||||||
StorageList::operator[](currElem) &= maskLower(endOff);
|
size_ = storeI * packing();
|
||||||
|
unsigned int bits = StorageList::operator[](storeI);
|
||||||
|
|
||||||
|
// found some bits
|
||||||
|
if (bits)
|
||||||
|
{
|
||||||
|
while (bits)
|
||||||
|
{
|
||||||
|
bits >>= nBits;
|
||||||
|
++size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test entire segment
|
|
||||||
while (currElem > 0 && !(StorageList::operator[](currElem) &= mask))
|
|
||||||
{
|
|
||||||
currElem--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// test segment
|
|
||||||
label newsize = (currElem + 1) * packing();
|
|
||||||
|
|
||||||
// mask for the final segment
|
|
||||||
mask = max_value() << (nBits * (packing() - 1));
|
|
||||||
|
|
||||||
for (endOff = packing(); endOff >= 1; --endOff, --newsize)
|
|
||||||
{
|
|
||||||
if (StorageList::operator[](currElem) & mask)
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mask >>= nBits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size_ == newsize)
|
return (size_ != oldSize);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_ = newsize;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
void Foam::PackedList<nBits>::flip()
|
void Foam::PackedList<nBits>::flip()
|
||||||
{
|
{
|
||||||
label packLen = packedLength(size_);
|
if (!size_)
|
||||||
|
|
||||||
for (label i=0; i < packLen; i++)
|
|
||||||
{
|
{
|
||||||
StorageList::operator[](i) = ~StorageList::operator[](i);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask value for complete segments
|
||||||
|
const unsigned int mask = maskLower(packing());
|
||||||
|
|
||||||
|
const label packLen = packedLength();
|
||||||
|
for (label i=0; i < packLen; ++i)
|
||||||
|
{
|
||||||
|
StorageList::operator[](i) = mask & ~StorageList::operator[](i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask off the final partial segment
|
||||||
|
{
|
||||||
|
const unsigned int off = size_ % packing();
|
||||||
|
if (off)
|
||||||
|
{
|
||||||
|
const unsigned int seg = size_ / packing();
|
||||||
|
|
||||||
|
StorageList::operator[](seg) &= maskLower(off);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
Foam::labelList Foam::PackedList<nBits>::values() const
|
Foam::Xfer<Foam::labelList> Foam::PackedList<nBits>::values() const
|
||||||
{
|
{
|
||||||
labelList elems(size_);
|
labelList elems(size_);
|
||||||
|
|
||||||
@ -182,12 +139,16 @@ Foam::labelList Foam::PackedList<nBits>::values() const
|
|||||||
{
|
{
|
||||||
elems[i] = get(i);
|
elems[i] = get(i);
|
||||||
}
|
}
|
||||||
return elems;
|
|
||||||
|
return elems.xfer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
|
Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::printInfo
|
||||||
|
(
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
os << "iterator<" << label(nBits) << "> ["
|
os << "iterator<" << label(nBits) << "> ["
|
||||||
<< this->index_ << "]"
|
<< this->index_ << "]"
|
||||||
@ -201,44 +162,45 @@ Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
|
|||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
Foam::Ostream& Foam::PackedList<nBits>::printBits
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const bool fullOutput
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
const label packLen = packedLength(size_);
|
const label packLen = packedLength();
|
||||||
|
|
||||||
os << "PackedList<" << nBits << ">"
|
|
||||||
<< " max_value:" << max_value()
|
|
||||||
<< " packing:" << packing() << nl
|
|
||||||
<< " count: " << count() << nl
|
|
||||||
<< " size/capacity: " << size_ << "/" << capacity() << nl
|
|
||||||
<< " storage/capacity: " << packLen << "/" << StorageList::size()
|
|
||||||
<< "\n(\n";
|
|
||||||
|
|
||||||
// mask value for complete segments
|
// mask value for complete segments
|
||||||
unsigned int mask = maskLower(packing());
|
unsigned int mask = maskLower(packing());
|
||||||
|
const label outputLen = fullOutput ? StorageList::size() : packLen;
|
||||||
|
|
||||||
for (label i=0; i < packLen; i++)
|
os << "(\n";
|
||||||
|
for (label i=0; i < outputLen; ++i)
|
||||||
{
|
{
|
||||||
const StorageType& rawBits = StorageList::operator[](i);
|
const StorageType& rawBits = StorageList::operator[](i);
|
||||||
|
|
||||||
// the final segment may not be full, modify mask accordingly
|
// the final segment may not be full, modify mask accordingly
|
||||||
if (i+1 == packLen)
|
if (i == packLen-1)
|
||||||
{
|
{
|
||||||
unsigned int endOff = size_ % packing();
|
const unsigned int off = size_ % packing();
|
||||||
|
|
||||||
if (endOff)
|
if (off)
|
||||||
{
|
{
|
||||||
mask = maskLower(endOff);
|
mask = maskLower(off);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else if (i == packLen)
|
||||||
{
|
{
|
||||||
continue;
|
// no mask for unaddressed bit
|
||||||
}
|
mask = 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int testBit = (1u << max_bits()); testBit; testBit >>= 1)
|
for (unsigned int testBit = (1u << max_bits()); testBit; testBit >>= 1)
|
||||||
{
|
{
|
||||||
if (mask & testBit)
|
if (mask & testBit)
|
||||||
{
|
{
|
||||||
|
// addressable region
|
||||||
if (rawBits & testBit)
|
if (rawBits & testBit)
|
||||||
{
|
{
|
||||||
os << '1';
|
os << '1';
|
||||||
@ -250,7 +212,14 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << 'x';
|
if (rawBits & testBit)
|
||||||
|
{
|
||||||
|
os << '!';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << '.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << '\n';
|
os << '\n';
|
||||||
@ -261,18 +230,313 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
Foam::Ostream& Foam::PackedList<nBits>::printInfo
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const bool fullOutput
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
StorageList::operator=(lst);
|
os << "PackedList<" << nBits << ">"
|
||||||
size_ = lst.size();
|
<< " max_value:" << max_value()
|
||||||
|
<< " packing:" << packing() << nl
|
||||||
|
<< " count: " << count() << nl
|
||||||
|
<< " size/capacity: " << size_ << "/" << capacity() << nl
|
||||||
|
<< " storage/capacity: "
|
||||||
|
<< packedLength() << "/" << StorageList::size()
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
return printBits(os, fullOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
Foam::Istream& Foam::PackedList<nBits>::read(Istream& is)
|
||||||
|
{
|
||||||
|
PackedList<nBits>& lst = *this;
|
||||||
|
|
||||||
|
lst.clear();
|
||||||
|
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||||
|
|
||||||
|
token firstTok(is);
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&) : "
|
||||||
|
"reading first token"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (firstTok.isLabel())
|
||||||
|
{
|
||||||
|
const label sz = firstTok.labelToken();
|
||||||
|
|
||||||
|
// Set list length to that read
|
||||||
|
lst.resize(sz);
|
||||||
|
|
||||||
|
// Read list contents depending on data format
|
||||||
|
if (is.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
// Read beginning of contents
|
||||||
|
const char delimiter = is.readBeginList("PackedList<nBits>");
|
||||||
|
|
||||||
|
if (sz)
|
||||||
|
{
|
||||||
|
if (delimiter == token::BEGIN_LIST)
|
||||||
|
{
|
||||||
|
for (register label i=0; i<sz; ++i)
|
||||||
|
{
|
||||||
|
lst[i] = lst.readValue(is);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&) : "
|
||||||
|
"reading entry"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (delimiter == token::BEGIN_BLOCK)
|
||||||
|
{
|
||||||
|
// assign for all entries
|
||||||
|
lst = lst.readValue(is);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&) : "
|
||||||
|
"reading the single entry"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&)",
|
||||||
|
is
|
||||||
|
)
|
||||||
|
<< "incorrect list token, expected '(' or '{', found "
|
||||||
|
<< firstTok.info()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read end of contents
|
||||||
|
is.readEndList("PackedList<nBits>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sz)
|
||||||
|
{
|
||||||
|
is.read
|
||||||
|
(
|
||||||
|
reinterpret_cast<char*>(lst.storage().data()),
|
||||||
|
lst.byteSize()
|
||||||
|
);
|
||||||
|
|
||||||
|
is.fatalCheck
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&) : "
|
||||||
|
"reading the binary block"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (firstTok.isPunctuation())
|
||||||
|
{
|
||||||
|
if (firstTok.pToken() == token::BEGIN_LIST)
|
||||||
|
{
|
||||||
|
token nextTok(is);
|
||||||
|
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||||
|
|
||||||
|
while
|
||||||
|
(
|
||||||
|
!( nextTok.isPunctuation()
|
||||||
|
&& nextTok.pToken() == token::END_LIST
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
is.putBack(nextTok);
|
||||||
|
lst.append(lst.readValue(is));
|
||||||
|
|
||||||
|
is >> nextTok;
|
||||||
|
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (firstTok.pToken() == token::BEGIN_BLOCK)
|
||||||
|
{
|
||||||
|
token nextTok(is);
|
||||||
|
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||||
|
|
||||||
|
while
|
||||||
|
(
|
||||||
|
!( nextTok.isPunctuation()
|
||||||
|
&& nextTok.pToken() == token::END_BLOCK
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
is.putBack(nextTok);
|
||||||
|
lst.setPair(is);
|
||||||
|
|
||||||
|
is >> nextTok;
|
||||||
|
is.fatalCheck("PackedList<nBits>::read(Istream&)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&)",
|
||||||
|
is
|
||||||
|
)
|
||||||
|
<< "incorrect first token, expected '(', found "
|
||||||
|
<< firstTok.info()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::read(Istream&)",
|
||||||
|
is
|
||||||
|
)
|
||||||
|
<< "incorrect first token, expected <int>, '(' or '{', found "
|
||||||
|
<< firstTok.info()
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
Foam::Ostream& Foam::PackedList<nBits>::write
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const bool indexedOutput
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const PackedList<nBits>& lst = *this;
|
||||||
|
const label sz = lst.size();
|
||||||
|
|
||||||
|
// Write list contents depending on data format
|
||||||
|
if (os.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
bool uniform = false;
|
||||||
|
|
||||||
|
if (sz > 1 && !indexedOutput)
|
||||||
|
{
|
||||||
|
uniform = true;
|
||||||
|
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
if (lst[i] != lst[0])
|
||||||
|
{
|
||||||
|
uniform = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uniform)
|
||||||
|
{
|
||||||
|
// uniform values:
|
||||||
|
os << sz << token::BEGIN_BLOCK << lst[0] << token::END_BLOCK;
|
||||||
|
}
|
||||||
|
else if (indexedOutput)
|
||||||
|
{
|
||||||
|
// indexed output
|
||||||
|
os << nl << token::BEGIN_BLOCK << nl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename PackedList<nBits>::const_iterator iter = lst.cbegin();
|
||||||
|
iter != lst.cend();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (iter.writeIfSet(os))
|
||||||
|
{
|
||||||
|
os << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os << token::END_BLOCK << nl;
|
||||||
|
}
|
||||||
|
else if (sz < 11)
|
||||||
|
{
|
||||||
|
// short list:
|
||||||
|
os << sz << token::BEGIN_LIST;
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
if (i)
|
||||||
|
{
|
||||||
|
os << token::SPACE;
|
||||||
|
}
|
||||||
|
os << lst[i];
|
||||||
|
}
|
||||||
|
os << token::END_LIST;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// longer list:
|
||||||
|
os << nl << sz << nl << token::BEGIN_LIST;
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
os << nl << lst[i];
|
||||||
|
}
|
||||||
|
os << nl << token::END_LIST << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << nl << sz << nl;
|
||||||
|
if (sz)
|
||||||
|
{
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(lst.storage().cdata()),
|
||||||
|
lst.byteSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
void Foam::PackedList<nBits>::writeEntry(Ostream& os) const
|
||||||
|
{
|
||||||
|
os << *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
void Foam::PackedList<nBits>::writeEntry
|
||||||
|
(
|
||||||
|
const word& keyword,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
os.writeKeyword(keyword);
|
||||||
|
writeEntry(os);
|
||||||
|
os << token::END_STATEMENT << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
Foam::PackedList<nBits>&
|
||||||
|
Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||||
|
{
|
||||||
|
StorageList::operator=(lst);
|
||||||
|
size_ = lst.size();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
Foam::PackedList<nBits>&
|
||||||
|
Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||||
{
|
{
|
||||||
setCapacity(lst.size());
|
setCapacity(lst.size());
|
||||||
size_ = lst.size();
|
size_ = lst.size();
|
||||||
@ -281,19 +545,39 @@ void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
|||||||
{
|
{
|
||||||
set(i, lst[i]);
|
set(i, lst[i]);
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
template<unsigned nBits>
|
||||||
|
Foam::PackedList<nBits>&
|
||||||
|
Foam::PackedList<nBits>::operator=(const UIndirectList<label>& lst)
|
||||||
|
{
|
||||||
|
setCapacity(lst.size());
|
||||||
|
size_ = lst.size();
|
||||||
|
|
||||||
//template<unsigned nBits>
|
forAll(lst, i)
|
||||||
//Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
|
{
|
||||||
//{
|
set(i, lst[i]);
|
||||||
// os << lst();
|
}
|
||||||
// return os;
|
return *this;
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
Foam::Istream& Foam::operator>>(Istream& is, PackedList<nBits>& lst)
|
||||||
|
{
|
||||||
|
return lst.read(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
|
||||||
|
{
|
||||||
|
return lst.write(os, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -72,6 +72,23 @@ Note
|
|||||||
list[8] = 1;
|
list[8] = 1;
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
Also note that all unused internal storage elements are guaranteed to
|
||||||
|
always be bit-wise zero. This property must not be violated by any
|
||||||
|
inheriting classes.
|
||||||
|
|
||||||
|
In addition to the normal output format, PackedList also supports a
|
||||||
|
compact ASCII format that may be convenient for user input in some
|
||||||
|
situations. The general format is a group of index/value pairs:
|
||||||
|
@verbatim
|
||||||
|
{ (index1 value1) (index2 value2) (index3 value3) }
|
||||||
|
@endverbatim
|
||||||
|
The bool specialization just uses the indices corresponding to
|
||||||
|
non-zero entries instead of a index/value pair:
|
||||||
|
@verbatim
|
||||||
|
{ index1 index2 index3 }
|
||||||
|
@endverbatim
|
||||||
|
In both cases, the supplied indices can be randomly ordered.
|
||||||
|
|
||||||
SeeAlso
|
SeeAlso
|
||||||
Foam::DynamicList
|
Foam::DynamicList
|
||||||
|
|
||||||
@ -85,6 +102,7 @@ SourceFiles
|
|||||||
#define PackedList_H
|
#define PackedList_H
|
||||||
|
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
#include "UIndirectList.H"
|
||||||
#include "StaticAssert.H"
|
#include "StaticAssert.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -92,18 +110,34 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
class Istream;
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
template<unsigned nBits> class PackedList;
|
template<unsigned nBits> class PackedList;
|
||||||
|
|
||||||
// template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
// Ostream& operator<<(Ostream&, const PackedList<nBits>&);
|
Istream& operator>>(Istream&, PackedList<nBits>&);
|
||||||
|
template<unsigned nBits>
|
||||||
|
Ostream& operator<<(Ostream&, const PackedList<nBits>&);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class PackedListName Declaration
|
Class PackedListCore Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
TemplateName(PackedList);
|
//- Template-invariant bits for PackedList
|
||||||
|
struct PackedListCore
|
||||||
|
{
|
||||||
|
//- Construct null
|
||||||
|
PackedListCore()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Define template name and debug
|
||||||
|
ClassName("PackedList");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class PackedList Declaration
|
Class PackedList Declaration
|
||||||
@ -112,25 +146,41 @@ TemplateName(PackedList);
|
|||||||
template<unsigned nBits=1>
|
template<unsigned nBits=1>
|
||||||
class PackedList
|
class PackedList
|
||||||
:
|
:
|
||||||
|
public PackedListCore,
|
||||||
private List<unsigned int>
|
private List<unsigned int>
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
typedef unsigned int StorageType;
|
typedef unsigned int StorageType;
|
||||||
typedef List<StorageType> StorageList;
|
typedef List<StorageType> StorageList;
|
||||||
|
|
||||||
//- nBits must be positive (non-zero) and fit within the storage
|
// Protected Member Functions
|
||||||
// For simplicity, assume 8-bit bytes
|
|
||||||
StaticAssert(nBits && nBits < (sizeof(StorageType) << 3));
|
//- Calculate the list length when packed
|
||||||
|
inline static label packedLength(const label);
|
||||||
|
|
||||||
|
//- Read a list entry (allows for specialization)
|
||||||
|
inline static unsigned int readValue(Istream&);
|
||||||
|
|
||||||
|
//- Read an index/value pair and set accordingly.
|
||||||
|
// For bool specialization, read a single index value
|
||||||
|
inline void setPair(Istream&);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- nBits must be positive (non-zero) and fit within the storage.
|
||||||
|
// For efficiency, however, require packing at least 2 items otherwise
|
||||||
|
// it is more efficient to use a normal list.
|
||||||
|
// Thus max nBits is 1/2 of the base storage size.
|
||||||
|
// For simplicity, assume 8-bit bytes in the assert.
|
||||||
|
StaticAssert(nBits && nBits <= (sizeof(StorageType) << 2));
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Number of nBits entries
|
//- Number of nBits entries
|
||||||
label size_;
|
label size_;
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Calculate the list length when packed
|
|
||||||
inline static label packedLength(const label);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -163,20 +213,26 @@ public:
|
|||||||
//- Null constructor
|
//- Null constructor
|
||||||
inline PackedList();
|
inline PackedList();
|
||||||
|
|
||||||
//- Construct with given size, initializes list to 0.
|
//- Construct with given size, initializes list to 0
|
||||||
explicit inline PackedList(const label size);
|
explicit inline PackedList(const label size);
|
||||||
|
|
||||||
//- Construct with given size and value for all elements.
|
//- Construct with given size and value for all elements
|
||||||
PackedList(const label size, const unsigned val);
|
inline PackedList(const label size, const unsigned val);
|
||||||
|
|
||||||
//- Copy constructor.
|
//- Construct from Istream
|
||||||
|
inline PackedList(Istream&);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
inline PackedList(const PackedList<nBits>&);
|
inline PackedList(const PackedList<nBits>&);
|
||||||
|
|
||||||
//- Construct by transferring the parameter contents
|
//- Construct by transferring the parameter contents
|
||||||
inline PackedList(const Xfer<PackedList<nBits> >&);
|
inline PackedList(const Xfer<PackedList<nBits> >&);
|
||||||
|
|
||||||
//- Construct from a list of labels
|
//- Construct from a list of labels
|
||||||
explicit PackedList(const UList<label>&);
|
explicit inline PackedList(const UList<label>&);
|
||||||
|
|
||||||
|
//- Construct from an indirect list of labels
|
||||||
|
explicit inline PackedList(const UIndirectList<label>&);
|
||||||
|
|
||||||
//- Clone
|
//- Clone
|
||||||
inline autoPtr< PackedList<nBits> > clone() const;
|
inline autoPtr< PackedList<nBits> > clone() const;
|
||||||
@ -209,30 +265,52 @@ public:
|
|||||||
inline bool unset(const label);
|
inline bool unset(const label);
|
||||||
|
|
||||||
//- Return the underlying packed storage
|
//- Return the underlying packed storage
|
||||||
|
// Manipulate with utmost caution
|
||||||
inline List<unsigned int>& storage();
|
inline List<unsigned int>& storage();
|
||||||
|
|
||||||
//- Return the underlying packed storage
|
//- Return the underlying packed storage
|
||||||
inline const List<unsigned int>& storage() const;
|
inline const List<unsigned int>& storage() const;
|
||||||
|
|
||||||
|
//- The list length when packed
|
||||||
|
inline label packedLength() const;
|
||||||
|
|
||||||
|
//- Return the binary size in number of characters
|
||||||
|
// used in the underlying storage
|
||||||
|
inline label byteSize() const;
|
||||||
|
|
||||||
//- Count number of bits set, O(log(n))
|
//- Count number of bits set, O(log(n))
|
||||||
// Uses the Hamming weight (population count) method
|
// Uses the Hamming weight (population count) method
|
||||||
// http://en.wikipedia.org/wiki/Hamming_weight
|
// http://en.wikipedia.org/wiki/Hamming_weight
|
||||||
unsigned int count() const;
|
unsigned int count() const;
|
||||||
|
|
||||||
//- Return the values as a labelList
|
//- Return the values as a list of labels
|
||||||
labelList values() const;
|
Xfer<labelList> values() const;
|
||||||
|
|
||||||
|
//- Print bit patterns, optionally output unused elements
|
||||||
|
//
|
||||||
|
// addressable bits:
|
||||||
|
// on: '1', off: '-'
|
||||||
|
//
|
||||||
|
// non-addressable bits:
|
||||||
|
// on: '!', off: '.'
|
||||||
|
//
|
||||||
|
Ostream& printBits(Ostream&, const bool fullOutput=false) const;
|
||||||
|
|
||||||
|
//- Print information and bit patterns (with printBits)
|
||||||
|
Ostream& printInfo(Ostream&, const bool fullOutput=false) const;
|
||||||
|
|
||||||
//- Print values and information
|
|
||||||
Ostream& print(Ostream&) const;
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Trim any trailing zero elements
|
//- Trim any trailing zero elements
|
||||||
bool trim();
|
bool trim();
|
||||||
|
|
||||||
//- Invert the bits in the addressable region.
|
//- Invert the bits in the addressable region
|
||||||
void flip();
|
void flip();
|
||||||
|
|
||||||
|
//- Clear all bits
|
||||||
|
inline void reset();
|
||||||
|
|
||||||
//- Alter the size of the underlying storage.
|
//- Alter the size of the underlying storage.
|
||||||
// The addressed size will be truncated if needed to fit, but will
|
// The addressed size will be truncated if needed to fit, but will
|
||||||
// remain otherwise untouched.
|
// remain otherwise untouched.
|
||||||
@ -240,10 +318,10 @@ public:
|
|||||||
|
|
||||||
//- Reset addressable list size, does not shrink the allocated size.
|
//- Reset addressable list size, does not shrink the allocated size.
|
||||||
// Optionally specify a value for new elements.
|
// Optionally specify a value for new elements.
|
||||||
inline void resize(const label, const unsigned int& val = 0);
|
inline void resize(const label, const unsigned int& val = 0u);
|
||||||
|
|
||||||
//- Alias for resize()
|
//- Alias for resize()
|
||||||
inline void setSize(const label, const unsigned int& val = 0);
|
inline void setSize(const label, const unsigned int& val = 0u);
|
||||||
|
|
||||||
//- Reserve allocation space for at least this size.
|
//- Reserve allocation space for at least this size.
|
||||||
// Never shrinks the allocated size.
|
// Never shrinks the allocated size.
|
||||||
@ -269,10 +347,43 @@ public:
|
|||||||
inline Xfer<PackedList<nBits> > xfer();
|
inline Xfer<PackedList<nBits> > xfer();
|
||||||
|
|
||||||
|
|
||||||
|
// IO
|
||||||
|
|
||||||
|
//- Clear list and read from stream
|
||||||
|
Istream& read(Istream&);
|
||||||
|
|
||||||
|
//- Write, optionally with indexedOutput
|
||||||
|
//
|
||||||
|
// The indexed output may be convenient in some situations.
|
||||||
|
// The general format is a group of index/value pairs:
|
||||||
|
// @verbatim
|
||||||
|
// { (index1 value1) (index2 value2) (index3 value3) }
|
||||||
|
// @endverbatim
|
||||||
|
// The bool specialization just uses the indices corresponding to
|
||||||
|
// non-zero entries instead of a index/value pair:
|
||||||
|
// @verbatim
|
||||||
|
// { index1 index2 index3 }
|
||||||
|
// @endverbatim
|
||||||
|
//
|
||||||
|
// Note the indexed output is only supported for ASCII streams.
|
||||||
|
Ostream& write
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const bool indexedOutput=false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write as a dictionary entry
|
||||||
|
void writeEntry(Ostream&) const;
|
||||||
|
|
||||||
|
//- Write as a dictionary entry with keyword
|
||||||
|
void writeEntry(const word& keyword, Ostream&) const;
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
//- Append a value at the end of the list
|
//- Append a value at the end of the list
|
||||||
inline void append(const unsigned int val);
|
inline PackedList<nBits>& append(const unsigned int val);
|
||||||
|
|
||||||
//- Remove and return the last element
|
//- Remove and return the last element
|
||||||
inline unsigned int remove();
|
inline unsigned int remove();
|
||||||
@ -287,23 +398,16 @@ public:
|
|||||||
inline iteratorBase operator[](const label);
|
inline iteratorBase operator[](const label);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value. Takes linear time.
|
//- Assignment of all entries to the given value. Takes linear time.
|
||||||
inline void operator=(const unsigned int val);
|
inline PackedList<nBits>& operator=(const unsigned int val);
|
||||||
|
|
||||||
//- Assignment operator. Takes linear time.
|
//- Assignment operator.
|
||||||
void operator=(const PackedList<nBits>&);
|
PackedList<nBits>& operator=(const PackedList<nBits>&);
|
||||||
|
|
||||||
//- Assignment operator. Takes linear time.
|
//- Assignment operator.
|
||||||
void operator=(const UList<label>&);
|
PackedList<nBits>& operator=(const UList<label>&);
|
||||||
|
|
||||||
|
//- Assignment operator.
|
||||||
// Ostream operator
|
PackedList<nBits>& operator=(const UIndirectList<label>&);
|
||||||
|
|
||||||
// // Write PackedList to Ostream.
|
|
||||||
// friend Ostream& operator<< <nBits>
|
|
||||||
// (
|
|
||||||
// Ostream&,
|
|
||||||
// const PackedList<nBits>&
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
|
||||||
// Iterators and helpers
|
// Iterators and helpers
|
||||||
@ -347,6 +451,15 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the element index corresponding to the iterator
|
||||||
|
inline label key() const;
|
||||||
|
|
||||||
|
//- Write index/value for a non-zero entry
|
||||||
|
// The bool specialization writes the index only
|
||||||
|
inline bool writeIfSet(Ostream&) const;
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Compare values (not positions)
|
//- Compare values (not positions)
|
||||||
@ -365,8 +478,8 @@ public:
|
|||||||
// Never auto-vivify entries.
|
// Never auto-vivify entries.
|
||||||
inline operator unsigned int () const;
|
inline operator unsigned int () const;
|
||||||
|
|
||||||
//- Print value and information
|
//- Print information and values
|
||||||
Ostream& print(Ostream&) const;
|
Ostream& printInfo(Ostream&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -376,11 +489,12 @@ public:
|
|||||||
public iteratorBase
|
public iteratorBase
|
||||||
{
|
{
|
||||||
|
|
||||||
//- Disallow copy constructor from const_iterator -
|
//- Disallow copy constructor from const_iterator
|
||||||
// violates const-ness!
|
// This would violate const-ness!
|
||||||
iterator(const const_iterator&);
|
iterator(const const_iterator&);
|
||||||
|
|
||||||
//- Disallow assignment from const_iterator - violates const-ness!
|
//- Disallow assignment from const_iterator
|
||||||
|
// This would violate const-ness!
|
||||||
void operator=(const const_iterator&);
|
void operator=(const const_iterator&);
|
||||||
|
|
||||||
|
|
||||||
@ -497,6 +611,20 @@ public:
|
|||||||
//- const_iterator set to beyond the end of the PackedList
|
//- const_iterator set to beyond the end of the PackedList
|
||||||
inline const_iterator end() const;
|
inline const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
|
// IOstream Operators
|
||||||
|
|
||||||
|
friend Istream& operator>> <nBits>
|
||||||
|
(
|
||||||
|
Istream&,
|
||||||
|
PackedList<nBits>&
|
||||||
|
);
|
||||||
|
|
||||||
|
friend Ostream& operator<< <nBits>
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const PackedList<nBits>&
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,6 +27,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeNameAndDebug(Foam::PackedListName, 0);
|
defineTypeNameAndDebug(Foam::PackedListCore, 0);
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -21,7 +21,6 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
@ -67,11 +66,117 @@ inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
// Template specialization for bool entries
|
||||||
|
template<>
|
||||||
|
inline unsigned int Foam::PackedList<1>::readValue(Istream& is)
|
||||||
|
{
|
||||||
|
return readBool(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Template specialization for bool entries
|
||||||
|
template<>
|
||||||
|
inline void Foam::PackedList<1>::setPair(Istream& is)
|
||||||
|
{
|
||||||
|
set(readLabel(is), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Template specialization for bool entries
|
||||||
|
template<>
|
||||||
|
inline bool Foam::PackedList<1>::iteratorBase::writeIfSet(Ostream& os) const
|
||||||
|
{
|
||||||
|
if (this->get())
|
||||||
|
{
|
||||||
|
os << index_;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline unsigned int Foam::PackedList<nBits>::readValue(Istream& is)
|
||||||
|
{
|
||||||
|
const unsigned int val = readLabel(is);
|
||||||
|
|
||||||
|
if (val > max_value())
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::readValue(Istream&)",
|
||||||
|
is
|
||||||
|
)
|
||||||
|
<< "Out-of-range value " << val << " for PackedList<" << nBits
|
||||||
|
<< ">. Maximum permitted value is " << max_value() << "."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline void Foam::PackedList<nBits>::setPair(Istream& is)
|
||||||
|
{
|
||||||
|
is.readBegin("Tuple2<label, unsigned int>");
|
||||||
|
|
||||||
|
const label ind = readLabel(is);
|
||||||
|
const unsigned int val = readLabel(is);
|
||||||
|
|
||||||
|
is.readEnd("Tuple2<label, unsigned int>");
|
||||||
|
|
||||||
|
if (val > max_value())
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"PackedList<nBits>::setPair(Istream&)",
|
||||||
|
is
|
||||||
|
)
|
||||||
|
<< "Out-of-range value " << val << " for PackedList<" << nBits
|
||||||
|
<< "> at index " << ind
|
||||||
|
<< ". Maximum permitted value is " << max_value() << "."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
set(ind, val);
|
||||||
|
|
||||||
|
// Check state of Istream
|
||||||
|
is.check("PackedList<nBits>::setPair(Istream&)");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline bool Foam::PackedList<nBits>::iteratorBase::writeIfSet(Ostream& os) const
|
||||||
|
{
|
||||||
|
const label val = this->get();
|
||||||
|
|
||||||
|
if (val)
|
||||||
|
{
|
||||||
|
os << token::BEGIN_LIST
|
||||||
|
<< index_ << token::SPACE << val
|
||||||
|
<< token::END_LIST;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline Foam::PackedList<nBits>::PackedList()
|
inline Foam::PackedList<nBits>::PackedList()
|
||||||
:
|
:
|
||||||
|
PackedListCore(),
|
||||||
StorageList(),
|
StorageList(),
|
||||||
size_(0)
|
size_(0)
|
||||||
{}
|
{}
|
||||||
@ -80,14 +185,45 @@ inline Foam::PackedList<nBits>::PackedList()
|
|||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline Foam::PackedList<nBits>::PackedList(const label size)
|
inline Foam::PackedList<nBits>::PackedList(const label size)
|
||||||
:
|
:
|
||||||
|
PackedListCore(),
|
||||||
StorageList(packedLength(size), 0u),
|
StorageList(packedLength(size), 0u),
|
||||||
size_(size)
|
size_(size)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::PackedList<nBits>::PackedList
|
||||||
|
(
|
||||||
|
const label size,
|
||||||
|
const unsigned int val
|
||||||
|
)
|
||||||
|
:
|
||||||
|
PackedListCore(),
|
||||||
|
StorageList(packedLength(size), 0u),
|
||||||
|
size_(size)
|
||||||
|
{
|
||||||
|
if (val)
|
||||||
|
{
|
||||||
|
operator=(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::PackedList<nBits>::PackedList(Istream& is)
|
||||||
|
:
|
||||||
|
PackedListCore(),
|
||||||
|
StorageList(),
|
||||||
|
size_(0)
|
||||||
|
{
|
||||||
|
read(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
|
inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
|
||||||
:
|
:
|
||||||
|
PackedListCore(),
|
||||||
StorageList(lst),
|
StorageList(lst),
|
||||||
size_(lst.size_)
|
size_(lst.size_)
|
||||||
{}
|
{}
|
||||||
@ -100,6 +236,34 @@ inline Foam::PackedList<nBits>::PackedList(const Xfer<PackedList<nBits> >& lst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||||
|
:
|
||||||
|
PackedListCore(),
|
||||||
|
StorageList(packedLength(lst.size()), 0u),
|
||||||
|
size_(lst.size())
|
||||||
|
{
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
set(i, lst[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::PackedList<nBits>::PackedList(const UIndirectList<label>& lst)
|
||||||
|
:
|
||||||
|
PackedListCore(),
|
||||||
|
StorageList(packedLength(lst.size()), 0u),
|
||||||
|
size_(lst.size())
|
||||||
|
{
|
||||||
|
forAll(lst, i)
|
||||||
|
{
|
||||||
|
set(i, lst[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline Foam::autoPtr<Foam::PackedList<nBits> >
|
inline Foam::autoPtr<Foam::PackedList<nBits> >
|
||||||
Foam::PackedList<nBits>::clone() const
|
Foam::PackedList<nBits>::clone() const
|
||||||
@ -151,27 +315,34 @@ Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val)
|
|||||||
const unsigned int seg = index_ / packing();
|
const unsigned int seg = index_ / packing();
|
||||||
const unsigned int off = index_ % packing();
|
const unsigned int off = index_ % packing();
|
||||||
|
|
||||||
|
const unsigned int startBit = nBits * off;
|
||||||
|
const unsigned int mask = max_value() << startBit;
|
||||||
|
|
||||||
unsigned int& stored = list_->StorageList::operator[](seg);
|
unsigned int& stored = list_->StorageList::operator[](seg);
|
||||||
const unsigned int prev = stored;
|
const unsigned int prev = stored;
|
||||||
|
|
||||||
const unsigned int startBit = nBits * off;
|
if (val >= max_value())
|
||||||
const unsigned int maskNew = max_value() << startBit;
|
|
||||||
|
|
||||||
if (val & ~max_value())
|
|
||||||
{
|
{
|
||||||
// overflow is max_value, fill everything
|
// overflow is max_value, fill everything
|
||||||
stored |= maskNew;
|
stored |= mask;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stored &= ~maskNew;
|
stored &= ~mask;
|
||||||
stored |= maskNew & (val << startBit);
|
stored |= mask & (val << startBit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return prev != stored;
|
return prev != stored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::label Foam::PackedList<nBits>::iteratorBase::key() const
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline bool Foam::PackedList<nBits>::iteratorBase::operator==
|
inline bool Foam::PackedList<nBits>::iteratorBase::operator==
|
||||||
(
|
(
|
||||||
@ -564,24 +735,27 @@ inline bool Foam::PackedList<nBits>::empty() const
|
|||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::resize
|
inline void Foam::PackedList<nBits>::resize
|
||||||
(
|
(
|
||||||
const label nElem,
|
const label newSize,
|
||||||
const unsigned int& val
|
const unsigned int& val
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
reserve(nElem);
|
reserve(newSize);
|
||||||
|
|
||||||
if (nElem > size_)
|
const label oldSize = size_;
|
||||||
|
size_ = newSize;
|
||||||
|
|
||||||
|
if (size_ > oldSize)
|
||||||
{
|
{
|
||||||
// fill new elements or newly exposed elements
|
// fill new elements or newly exposed elements
|
||||||
if (size_)
|
if (val)
|
||||||
{
|
{
|
||||||
// fill value for complete segments
|
// fill value for complete segments
|
||||||
unsigned int fill = val;
|
unsigned int fill = val;
|
||||||
|
|
||||||
if (fill & ~max_value())
|
if (val >= max_value())
|
||||||
{
|
{
|
||||||
// overflow is max_value, fill everything
|
// fill everything
|
||||||
fill = ~0u;
|
fill = maskLower(packing());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -591,36 +765,64 @@ inline void Foam::PackedList<nBits>::resize
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int seg = size_ / packing();
|
// fill in complete segments
|
||||||
unsigned int off = size_ % packing();
|
const label oldLen = packedLength(oldSize);
|
||||||
|
const label newLen = packedLength(size_);
|
||||||
|
for (label i=oldLen; i < newLen; ++i)
|
||||||
|
{
|
||||||
|
StorageList::operator[](i) = fill;
|
||||||
|
}
|
||||||
|
|
||||||
// partial segment, preserve existing value
|
// finish previous partial segment, preserve existing value
|
||||||
|
{
|
||||||
|
const unsigned int off = oldSize % packing();
|
||||||
if (off)
|
if (off)
|
||||||
{
|
{
|
||||||
unsigned int maskOld = maskLower(off);
|
const unsigned int seg = oldSize / packing();
|
||||||
|
const unsigned int mask = maskLower(off);
|
||||||
|
|
||||||
StorageList::operator[](seg) &= maskOld;
|
StorageList::operator[](seg) &= mask;
|
||||||
StorageList::operator[](seg) |= ~maskOld & fill;
|
StorageList::operator[](seg) |= ~mask & fill;
|
||||||
|
}
|
||||||
// continue with the next segment
|
|
||||||
seg++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int endSeg = nElem / packing();
|
|
||||||
// fill in complete elements
|
// mask off the (new) final partial segment
|
||||||
while (seg < endSeg)
|
|
||||||
{
|
{
|
||||||
StorageList::operator[](seg++) = fill;
|
const unsigned int off = size_ % packing();
|
||||||
}
|
if (off)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// no original size - simply flood-fill
|
const unsigned int seg = size_ / packing();
|
||||||
operator=(val);
|
|
||||||
|
StorageList::operator[](seg) &= maskLower(off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (size_ < oldSize)
|
||||||
|
{
|
||||||
|
// resize shrinking
|
||||||
|
// - clear newly exposed elements
|
||||||
|
|
||||||
|
// fill in complete segments
|
||||||
|
const label oldLen = packedLength(oldSize);
|
||||||
|
const label newLen = packedLength(size_);
|
||||||
|
for (label i=newLen; i < oldLen; ++i)
|
||||||
|
{
|
||||||
|
StorageList::operator[](i) = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
size_ = nElem;
|
// mask off the final partial segment
|
||||||
|
{
|
||||||
|
const unsigned int off = size_ % packing();
|
||||||
|
if (off)
|
||||||
|
{
|
||||||
|
const unsigned int seg = size_ / packing();
|
||||||
|
|
||||||
|
StorageList::operator[](seg) &= maskLower(off);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -648,21 +850,27 @@ inline void Foam::PackedList<nBits>::setCapacity(const label nElem)
|
|||||||
{
|
{
|
||||||
StorageList::setSize(packedLength(nElem), 0u);
|
StorageList::setSize(packedLength(nElem), 0u);
|
||||||
|
|
||||||
// truncate addressed size too?
|
// truncate addressed size too
|
||||||
if (size_ > nElem)
|
if (size_ > nElem)
|
||||||
{
|
{
|
||||||
size_ = nElem;
|
size_ = nElem;
|
||||||
|
|
||||||
|
// mask off the final partial segment
|
||||||
|
const unsigned int off = size_ % packing();
|
||||||
|
if (off)
|
||||||
|
{
|
||||||
|
const unsigned int seg = size_ / packing();
|
||||||
|
|
||||||
|
StorageList::operator[](seg) &= maskLower(off);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::reserve
|
inline void Foam::PackedList<nBits>::reserve(const label nElem)
|
||||||
(
|
|
||||||
const label nElem
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
label len = packedLength(nElem);
|
const label len = packedLength(nElem);
|
||||||
|
|
||||||
// need more capacity?
|
// need more capacity?
|
||||||
if (len > StorageList::size())
|
if (len > StorageList::size())
|
||||||
@ -681,9 +889,17 @@ inline void Foam::PackedList<nBits>::reserve
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline void Foam::PackedList<nBits>::reset()
|
||||||
|
{
|
||||||
|
StorageList::operator=(0u);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::clear()
|
inline void Foam::PackedList<nBits>::clear()
|
||||||
{
|
{
|
||||||
|
reset();
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,9 +915,8 @@ inline void Foam::PackedList<nBits>::clearStorage()
|
|||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::shrink()
|
inline void Foam::PackedList<nBits>::shrink()
|
||||||
{
|
{
|
||||||
label len = packedLength(size_);
|
// any uneed space allocated?
|
||||||
|
const label len = packedLength();
|
||||||
// we have unused space?
|
|
||||||
if (len < StorageList::size())
|
if (len < StorageList::size())
|
||||||
{
|
{
|
||||||
StorageList::setSize(len);
|
StorageList::setSize(len);
|
||||||
@ -722,6 +937,20 @@ inline const Foam::List<unsigned int>& Foam::PackedList<nBits>::storage() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::label Foam::PackedList<nBits>::packedLength() const
|
||||||
|
{
|
||||||
|
return packedLength(size_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<unsigned nBits>
|
||||||
|
inline Foam::label Foam::PackedList<nBits>::byteSize() const
|
||||||
|
{
|
||||||
|
return packedLength() * sizeof(StorageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
inline void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
||||||
{
|
{
|
||||||
@ -742,23 +971,14 @@ inline Foam::Xfer<Foam::PackedList<nBits> > Foam::PackedList<nBits>::xfer()
|
|||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
|
||||||
if (i < 0)
|
|
||||||
{
|
|
||||||
FatalErrorIn("PackedList<nBits>::get(const label)")
|
|
||||||
<< "negative index " << i << " max=" << size_-1
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// lazy evaluation - return 0 for out-of-range
|
// lazy evaluation - return 0 for out-of-range
|
||||||
if (i < size_)
|
if (i < 0 || i >= size_)
|
||||||
{
|
{
|
||||||
return iteratorBase(this, i).get();
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return iteratorBase(this, i).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,13 +987,13 @@ template<unsigned nBits>
|
|||||||
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
// lazy evaluation - return 0 for out-of-range
|
// lazy evaluation - return 0 for out-of-range
|
||||||
if (i < size_)
|
if (i < 0 || i >= size_)
|
||||||
{
|
{
|
||||||
return iteratorBase(this, i).get();
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return iteratorBase(this, i).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,18 +1005,14 @@ inline bool Foam::PackedList<nBits>::set
|
|||||||
const unsigned int val
|
const unsigned int val
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn("PackedList<nBits>::set(const label)")
|
// lazy evaluation - ignore out-of-bounds
|
||||||
<< "negative index " << i << " max=" << size_-1
|
return false;
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
}
|
||||||
# endif
|
else if (i >= size_)
|
||||||
|
|
||||||
// lazy evaluation - increase size on assigment
|
|
||||||
if (i >= size_)
|
|
||||||
{
|
{
|
||||||
|
// lazy evaluation - increase size on assigment
|
||||||
resize(i + 1);
|
resize(i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,24 +1023,28 @@ inline bool Foam::PackedList<nBits>::set
|
|||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline bool Foam::PackedList<nBits>::unset(const label i)
|
inline bool Foam::PackedList<nBits>::unset(const label i)
|
||||||
{
|
{
|
||||||
// lazy - ignore out-of-bounds
|
// lazy evaluation - ignore out-of-bounds
|
||||||
if (i < 0 || i >= size_)
|
if (i < 0 || i >= size_)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return iteratorBase(this, i).set(0u);
|
return iteratorBase(this, i).set(0u);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::append(const unsigned int val)
|
inline Foam::PackedList<nBits>&
|
||||||
|
Foam::PackedList<nBits>::append(const unsigned int val)
|
||||||
{
|
{
|
||||||
label elemI = size_;
|
const label elemI = size_;
|
||||||
reserve(elemI + 1);
|
reserve(elemI + 1);
|
||||||
size_++;
|
size_++;
|
||||||
|
|
||||||
iteratorBase(this, elemI).set(val);
|
iteratorBase(this, elemI).set(val);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -855,35 +1075,20 @@ Foam::PackedList<nBits>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
// specialization for nBits=1
|
|
||||||
template<>
|
|
||||||
inline void Foam::PackedList<1>::operator=(const unsigned int val)
|
|
||||||
{
|
|
||||||
if (val)
|
|
||||||
{
|
|
||||||
StorageList::operator=(~0u);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StorageList::operator=(0u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
inline Foam::PackedList<nBits>&
|
||||||
|
Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||||
{
|
{
|
||||||
if (val)
|
const label packLen = packedLength();
|
||||||
|
|
||||||
|
if (val && size_)
|
||||||
{
|
{
|
||||||
unsigned int fill = val;
|
unsigned int fill = val;
|
||||||
|
|
||||||
if (fill & ~max_value())
|
if (val >= max_value())
|
||||||
{
|
{
|
||||||
// treat overflow as max_value
|
// fill everything
|
||||||
fill = ~0u;
|
fill = maskLower(packing());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -893,12 +1098,31 @@ inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageList::operator=(fill);
|
for (label i=0; i < packLen; ++i)
|
||||||
|
{
|
||||||
|
StorageList::operator[](i) = fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mask off the final partial segment
|
||||||
|
{
|
||||||
|
const unsigned int off = size_ % packing();
|
||||||
|
if (off)
|
||||||
|
{
|
||||||
|
const unsigned int seg = size_ / packing();
|
||||||
|
|
||||||
|
StorageList::operator[](seg) &= maskLower(off);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StorageList::operator=(0u);
|
for (label i=0; i < packLen; ++i)
|
||||||
|
{
|
||||||
|
StorageList::operator[](i) = 0u;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,13 +23,13 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOFieldField.H"
|
#include "CompactIOField.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
void Foam::IOFieldField<T, BaseType>::readFromStream()
|
void Foam::CompactIOField<T, BaseType>::readFromStream()
|
||||||
{
|
{
|
||||||
Istream& is = readStream(word::null);
|
Istream& is = readStream(word::null);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ void Foam::IOFieldField<T, BaseType>::readFromStream()
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"IOFieldField<T, BaseType>::readFromStream()",
|
"CompactIOField<T, BaseType>::readFromStream()",
|
||||||
is
|
is
|
||||||
) << "unexpected class name " << headerClassName()
|
) << "unexpected class name " << headerClassName()
|
||||||
<< " expected " << typeName << " or " << IOField<T>::typeName
|
<< " expected " << typeName << " or " << IOField<T>::typeName
|
||||||
@ -61,7 +61,7 @@ void Foam::IOFieldField<T, BaseType>::readFromStream()
|
|||||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
Foam::IOFieldField<T, BaseType>::IOFieldField(const IOobject& io)
|
Foam::CompactIOField<T, BaseType>::CompactIOField(const IOobject& io)
|
||||||
:
|
:
|
||||||
regIOobject(io)
|
regIOobject(io)
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField(const IOobject& io)
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const label size
|
const label size
|
||||||
@ -101,7 +101,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const Field<T>& list
|
const Field<T>& list
|
||||||
@ -125,7 +125,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
Foam::IOFieldField<T, BaseType>::IOFieldField
|
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
const Xfer<Field<T> >& list
|
const Xfer<Field<T> >& list
|
||||||
@ -149,7 +149,7 @@ Foam::IOFieldField<T, BaseType>::IOFieldField
|
|||||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
Foam::IOFieldField<T, BaseType>::~IOFieldField()
|
Foam::CompactIOField<T, BaseType>::~CompactIOField()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ Foam::IOFieldField<T, BaseType>::~IOFieldField()
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
bool Foam::IOFieldField<T, BaseType>::writeObject
|
bool Foam::CompactIOField<T, BaseType>::writeObject
|
||||||
(
|
(
|
||||||
IOstream::streamFormat fmt,
|
IOstream::streamFormat fmt,
|
||||||
IOstream::versionNumber ver,
|
IOstream::versionNumber ver,
|
||||||
@ -186,7 +186,7 @@ bool Foam::IOFieldField<T, BaseType>::writeObject
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
bool Foam::IOFieldField<T, BaseType>::writeData(Ostream& os) const
|
bool Foam::CompactIOField<T, BaseType>::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
return (os << *this).good();
|
return (os << *this).good();
|
||||||
}
|
}
|
||||||
@ -195,9 +195,9 @@ bool Foam::IOFieldField<T, BaseType>::writeData(Ostream& os) const
|
|||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
void Foam::IOFieldField<T, BaseType>::operator=
|
void Foam::CompactIOField<T, BaseType>::operator=
|
||||||
(
|
(
|
||||||
const IOFieldField<T, BaseType>& rhs
|
const CompactIOField<T, BaseType>& rhs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Field<T>::operator=(rhs);
|
Field<T>::operator=(rhs);
|
||||||
@ -205,7 +205,7 @@ void Foam::IOFieldField<T, BaseType>::operator=
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
void Foam::IOFieldField<T, BaseType>::operator=(const Field<T>& rhs)
|
void Foam::CompactIOField<T, BaseType>::operator=(const Field<T>& rhs)
|
||||||
{
|
{
|
||||||
Field<T>::operator=(rhs);
|
Field<T>::operator=(rhs);
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ template<class T, class BaseType>
|
|||||||
Foam::Istream& Foam::operator>>
|
Foam::Istream& Foam::operator>>
|
||||||
(
|
(
|
||||||
Foam::Istream& is,
|
Foam::Istream& is,
|
||||||
Foam::IOFieldField<T, BaseType>& L
|
Foam::CompactIOField<T, BaseType>& L
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Read compact
|
// Read compact
|
||||||
@ -248,7 +248,7 @@ template<class T, class BaseType>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Foam::Ostream& os,
|
Foam::Ostream& os,
|
||||||
const Foam::IOFieldField<T, BaseType>& L
|
const Foam::CompactIOField<T, BaseType>& L
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Keep ascii writing same.
|
// Keep ascii writing same.
|
||||||
@ -22,18 +22,22 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::IOFieldField
|
Foam::CompactIOField
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A Field of objects of type \<T\> with automated input and output.
|
A Field of objects of type \<T\> with automated input and output using
|
||||||
|
a compact storage. Behaves like IOField except when binary output in
|
||||||
|
case it writes a CompactListList.
|
||||||
|
|
||||||
|
Useful for fields of small subfields e.g. in lagrangian
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
IOFieldField.C
|
CompactIOField.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef IOFieldField_H
|
#ifndef CompactIOField_H
|
||||||
#define IOFieldField_H
|
#define CompactIOField_H
|
||||||
|
|
||||||
#include "IOField.H"
|
#include "IOField.H"
|
||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
@ -47,25 +51,25 @@ class Istream;
|
|||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
template<class T, class BaseType> class IOFieldField;
|
template<class T, class BaseType> class CompactIOField;
|
||||||
|
|
||||||
template<class T, class BaseType> Istream& operator>>
|
template<class T, class BaseType> Istream& operator>>
|
||||||
(
|
(
|
||||||
Istream&,
|
Istream&,
|
||||||
IOFieldField<T, BaseType>&
|
CompactIOField<T, BaseType>&
|
||||||
);
|
);
|
||||||
template<class T, class BaseType> Ostream& operator<<
|
template<class T, class BaseType> Ostream& operator<<
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const IOFieldField<T, BaseType>&
|
const CompactIOField<T, BaseType>&
|
||||||
);
|
);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class IOFieldField Declaration
|
Class CompactIOField Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class T, class BaseType>
|
template<class T, class BaseType>
|
||||||
class IOFieldField
|
class CompactIOField
|
||||||
:
|
:
|
||||||
public regIOobject,
|
public regIOobject,
|
||||||
public Field<T>
|
public Field<T>
|
||||||
@ -84,21 +88,21 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
IOFieldField(const IOobject&);
|
CompactIOField(const IOobject&);
|
||||||
|
|
||||||
//- Construct from IOobject and size of IOFieldField
|
//- Construct from IOobject and size
|
||||||
IOFieldField(const IOobject&, const label);
|
CompactIOField(const IOobject&, const label);
|
||||||
|
|
||||||
//- Construct from IOobject and a Field
|
//- Construct from IOobject and a Field
|
||||||
IOFieldField(const IOobject&, const Field<T>&);
|
CompactIOField(const IOobject&, const Field<T>&);
|
||||||
|
|
||||||
//- Construct by transferring the Field contents
|
//- Construct by transferring the Field contents
|
||||||
IOFieldField(const IOobject&, const Xfer<Field<T> >&);
|
CompactIOField(const IOobject&, const Xfer<Field<T> >&);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
virtual ~IOFieldField();
|
virtual ~CompactIOField();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
@ -115,7 +119,7 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
void operator=(const IOFieldField<T, BaseType>&);
|
void operator=(const CompactIOField<T, BaseType>&);
|
||||||
|
|
||||||
void operator=(const Field<T>&);
|
void operator=(const Field<T>&);
|
||||||
|
|
||||||
@ -126,14 +130,14 @@ public:
|
|||||||
friend Istream& operator>> <T, BaseType>
|
friend Istream& operator>> <T, BaseType>
|
||||||
(
|
(
|
||||||
Istream&,
|
Istream&,
|
||||||
IOFieldField<T, BaseType>&
|
CompactIOField<T, BaseType>&
|
||||||
);
|
);
|
||||||
|
|
||||||
// Write Field to Ostream.
|
// Write Field to Ostream.
|
||||||
friend Ostream& operator<< <T, BaseType>
|
friend Ostream& operator<< <T, BaseType>
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const IOFieldField<T, BaseType>&
|
const CompactIOField<T, BaseType>&
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -145,7 +149,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
# include "IOFieldField.C"
|
# include "CompactIOField.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -22,11 +22,12 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Read of a non-delimited hex label
|
Read a non-delimited hex label
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "readHexLabel.H"
|
#include "readHexLabel.H"
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ Foam::label Foam::readHexLabel(ISstream& is)
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
result *= 16;
|
result <<= 4;
|
||||||
|
|
||||||
if (isdigit(c))
|
if (isdigit(c))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
diagTensorIOFieldField,
|
diagTensorFieldCompactIOField,
|
||||||
"diagTensorCompactFieldField",
|
"diagTensorFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,15 @@ Description
|
|||||||
#define diagTensorFieldIOField_H
|
#define diagTensorFieldIOField_H
|
||||||
|
|
||||||
#include "diagTensorField.H"
|
#include "diagTensorField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<diagTensorField> diagTensorFieldIOField;
|
typedef IOField<diagTensorField> diagTensorFieldIOField;
|
||||||
typedef IOFieldField<diagTensorField, diagTensor> diagTensorIOFieldField;
|
typedef CompactIOField<diagTensorField, diagTensor>
|
||||||
|
diagTensorFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
labelIOFieldField,
|
labelFieldCompactIOField,
|
||||||
"labelCompactFieldField",
|
"labelFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,14 +34,14 @@ Description
|
|||||||
|
|
||||||
#include "labelField.H"
|
#include "labelField.H"
|
||||||
#include "IOField.H"
|
#include "IOField.H"
|
||||||
#include "IOFieldField.H"
|
#include "CompactIOField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<labelField> labelFieldIOField;
|
typedef IOField<labelField> labelFieldIOField;
|
||||||
typedef IOFieldField<labelField, label> labelIOFieldField;
|
typedef CompactIOField<labelField, label> labelFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
scalarIOFieldField,
|
scalarFieldCompactIOField,
|
||||||
"scalarCompactFieldField",
|
"scalarFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,14 @@ Description
|
|||||||
#define scalarFieldIOField_H
|
#define scalarFieldIOField_H
|
||||||
|
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<scalarField> scalarFieldIOField;
|
typedef IOField<scalarField> scalarFieldIOField;
|
||||||
typedef IOFieldField<scalarField, scalar> scalarIOFieldField;
|
typedef CompactIOField<scalarField, scalar> scalarFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
sphericalTensorIOFieldField,
|
sphericalTensorFieldCompactIOField,
|
||||||
"sphericalTensorCompactFieldField",
|
"sphericalTensorFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,8 +33,7 @@ Description
|
|||||||
#define sphericalTensorFieldIOField_H
|
#define sphericalTensorFieldIOField_H
|
||||||
|
|
||||||
#include "sphericalTensorField.H"
|
#include "sphericalTensorField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -42,8 +41,8 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
typedef IOField<sphericalTensorField> sphericalTensorFieldIOField;
|
typedef IOField<sphericalTensorField> sphericalTensorFieldIOField;
|
||||||
|
|
||||||
typedef IOFieldField<sphericalTensorField, sphericalTensor>
|
typedef CompactIOField<sphericalTensorField, sphericalTensor>
|
||||||
sphericalTensorIOFieldField;
|
sphericalTensorFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
symmTensorIOFieldField,
|
symmTensorFieldCompactIOField,
|
||||||
"symmTensorCompactFieldField",
|
"symmTensorFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,15 @@ Description
|
|||||||
#define symmTensorFieldIOField_H
|
#define symmTensorFieldIOField_H
|
||||||
|
|
||||||
#include "symmTensorField.H"
|
#include "symmTensorField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<symmTensorField> symmTensorFieldIOField;
|
typedef IOField<symmTensorField> symmTensorFieldIOField;
|
||||||
typedef IOFieldField<symmTensorField, symmTensor> symmTensorIOFieldField;
|
typedef CompactIOField<symmTensorField, symmTensor>
|
||||||
|
symmTensorFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
tensorIOFieldField,
|
tensorFieldCompactIOField,
|
||||||
"tensorCompactFieldField",
|
"tensorFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,14 @@ Description
|
|||||||
#define tensorFieldIOField_H
|
#define tensorFieldIOField_H
|
||||||
|
|
||||||
#include "tensorField.H"
|
#include "tensorField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<tensorField> tensorFieldIOField;
|
typedef IOField<tensorField> tensorFieldIOField;
|
||||||
typedef IOFieldField<tensorField, tensor> tensorIOFieldField;
|
typedef CompactIOField<tensorField, tensor> tensorFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
vector2DIOFieldField,
|
vector2DFieldCompactIOField,
|
||||||
"vector2DCompactFieldField",
|
"vector2DFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,14 @@ Description
|
|||||||
#define vector2DFieldIOField_H
|
#define vector2DFieldIOField_H
|
||||||
|
|
||||||
#include "vector2DField.H"
|
#include "vector2DField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<vector2DField> vector2DFieldIOField;
|
typedef IOField<vector2DField> vector2DFieldIOField;
|
||||||
typedef IOFieldField<vector2DField, vector2D> vector2DIOFieldField;
|
typedef CompactIOField<vector2DField, vector2D> vector2DFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,8 +41,8 @@ namespace Foam
|
|||||||
|
|
||||||
defineTemplateTypeNameAndDebugWithName
|
defineTemplateTypeNameAndDebugWithName
|
||||||
(
|
(
|
||||||
vectorIOFieldField,
|
vectorFieldCompactIOField,
|
||||||
"vectorCompactFieldField",
|
"vectorFieldCompactField",
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,15 +33,14 @@ Description
|
|||||||
#define vectorFieldIOField_H
|
#define vectorFieldIOField_H
|
||||||
|
|
||||||
#include "vectorField.H"
|
#include "vectorField.H"
|
||||||
#include "IOField.H"
|
#include "CompactIOField.H"
|
||||||
#include "IOFieldField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef IOField<vectorField> vectorFieldIOField;
|
typedef IOField<vectorField> vectorFieldIOField;
|
||||||
typedef IOFieldField<vectorField, vector> vectorIOFieldField;
|
typedef CompactIOField<vectorField, vector> vectorFieldCompactIOField;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,51 +22,48 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::ZoneID
|
Foam::DynamicID
|
||||||
|
|
||||||
Description
|
Description
|
||||||
A class that holds the data needed to identify a zone in a dynamic mesh.
|
A class that holds the data needed to identify things (zones, patches)
|
||||||
|
in a dynamic mesh.
|
||||||
|
|
||||||
The zone is identified by name.
|
The thing is identified by name.
|
||||||
Its index in the zoneMesh is updated if the mesh has changed.
|
Its indices are updated if the mesh has changed.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ZoneID_H
|
#ifndef DynamicID_H
|
||||||
#define ZoneID_H
|
#define DynamicID_H
|
||||||
|
|
||||||
#include "label.H"
|
#include "keyType.H"
|
||||||
#include "word.H"
|
#include "labelList.H"
|
||||||
#include "polyMesh.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class ZoneType, class MeshType> class ZoneMesh;
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
template<class> class DynamicID;
|
||||||
|
|
||||||
template<class ZoneType> class ZoneID;
|
template<class ObjectType>
|
||||||
|
Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&);
|
||||||
template<class ZoneType>
|
|
||||||
Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&);
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class ZoneID Declaration
|
Class DynamicID Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class ZoneType>
|
template<class ObjectType>
|
||||||
class ZoneID
|
class DynamicID
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Zone name
|
//- Zone name
|
||||||
word name_;
|
keyType key_;
|
||||||
|
|
||||||
//- Zone index
|
//- Zone indices
|
||||||
label index_;
|
labelList indices_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -74,17 +71,17 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from name
|
//- Construct from name
|
||||||
ZoneID(const word& name, const ZoneMesh<ZoneType, polyMesh>& zm)
|
DynamicID(const keyType& key, const ObjectType& obj)
|
||||||
:
|
:
|
||||||
name_(name),
|
key_(key),
|
||||||
index_(zm.findZoneID(name))
|
indices_(obj.findIndices(key_))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
ZoneID(Istream& is, const ZoneMesh<ZoneType, polyMesh>& zm)
|
DynamicID(Istream& is, const ObjectType& obj)
|
||||||
:
|
:
|
||||||
name_(is),
|
key_(is),
|
||||||
index_(zm.findZoneID(name_))
|
indices_(obj.findIndices(key_))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -96,57 +93,57 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return name
|
//- Return name
|
||||||
const word& name() const
|
const keyType& name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return key_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return index
|
//- Return indices of matching zones
|
||||||
|
const labelList& indices() const
|
||||||
|
{
|
||||||
|
return indices_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return index of first matching zone
|
||||||
label index() const
|
label index() const
|
||||||
{
|
{
|
||||||
return index_;
|
return indices_.empty() ? -1 : indices_[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Has the zone been found
|
//- Has the zone been found
|
||||||
bool active() const
|
bool active() const
|
||||||
{
|
{
|
||||||
return index_ > -1;
|
return !indices_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Update
|
//- Update
|
||||||
void update(const ZoneMesh<ZoneType, polyMesh>& zm)
|
void update(const ObjectType& obj)
|
||||||
{
|
{
|
||||||
index_ = zm.findZoneID(name_);
|
indices_ = obj.findIndices(key_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
friend Ostream& operator<< <ZoneType>
|
friend Ostream& operator<< <ObjectType>
|
||||||
(
|
(Ostream&, const DynamicID<ObjectType>&);
|
||||||
Ostream& os, const ZoneID<ZoneType>& p
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class ZoneType>
|
template<class ObjectType>
|
||||||
Ostream& operator<<
|
Ostream& operator<<(Ostream& os, const DynamicID<ObjectType>& dynId)
|
||||||
(
|
|
||||||
Ostream& os, const ZoneID<ZoneType>& p
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
os << token::BEGIN_LIST
|
os << token::BEGIN_LIST
|
||||||
<< p.name_ << token::SPACE
|
<< dynId.name() << token::SPACE << dynId.index()
|
||||||
<< p.index_
|
|
||||||
<< token::END_LIST;
|
<< token::END_LIST;
|
||||||
|
|
||||||
// Check state of Ostream
|
// Check state of Ostream
|
||||||
os.check("Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&)");
|
os.check("Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&)");
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -21,25 +21,20 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Typedef
|
|
||||||
Foam::PackedBoolList
|
|
||||||
|
|
||||||
Description
|
|
||||||
A bit-packed bool list
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef PackedBoolList_H
|
#ifndef polyPatchID_H
|
||||||
#define PackedBoolList_H
|
#define polyPatchID_H
|
||||||
|
|
||||||
#include "bool.H"
|
#include "DynamicID.H"
|
||||||
#include "PackedList.H"
|
#include "polyBoundaryMesh.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef PackedList<> PackedBoolList;
|
//- Foam::polyPatchID
|
||||||
|
typedef DynamicID<polyBoundaryMesh> polyPatchID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -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) 2010-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -26,21 +26,26 @@ License
|
|||||||
#ifndef ZoneIDs_H
|
#ifndef ZoneIDs_H
|
||||||
#define ZoneIDs_H
|
#define ZoneIDs_H
|
||||||
|
|
||||||
#include "ZoneID.H"
|
#include "DynamicID.H"
|
||||||
#include "pointZone.H"
|
|
||||||
#include "faceZone.H"
|
#include "cellZoneMeshFwd.H"
|
||||||
#include "cellZone.H"
|
#include "faceZoneMeshFwd.H"
|
||||||
|
#include "pointZoneMeshFwd.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
//- Foam::pointZoneID
|
|
||||||
typedef ZoneID<pointZone> pointZoneID;
|
|
||||||
//- Foam::faceZoneID
|
|
||||||
typedef ZoneID<faceZone> faceZoneID;
|
|
||||||
//- Foam::cellZoneID
|
//- Foam::cellZoneID
|
||||||
typedef ZoneID<cellZone> cellZoneID;
|
typedef DynamicID<cellZoneMesh> cellZoneID;
|
||||||
|
|
||||||
|
//- Foam::faceZoneID
|
||||||
|
typedef DynamicID<faceZoneMesh> faceZoneID;
|
||||||
|
|
||||||
|
//- Foam::pointZoneID
|
||||||
|
typedef DynamicID<pointZoneMesh> pointZoneID;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -31,6 +31,7 @@ License
|
|||||||
#include "PstreamBuffers.H"
|
#include "PstreamBuffers.H"
|
||||||
#include "lduSchedule.H"
|
#include "lduSchedule.H"
|
||||||
#include "globalMeshData.H"
|
#include "globalMeshData.H"
|
||||||
|
#include "stringListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -413,6 +414,66 @@ Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::labelList Foam::polyBoundaryMesh::findIndices(const keyType& key) const
|
||||||
|
{
|
||||||
|
labelList indices;
|
||||||
|
|
||||||
|
if (!key.empty())
|
||||||
|
{
|
||||||
|
if (key.isPattern())
|
||||||
|
{
|
||||||
|
indices = findStrings(key, this->names());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
indices.setSize(this->size());
|
||||||
|
label nFound = 0;
|
||||||
|
forAll(*this, i)
|
||||||
|
{
|
||||||
|
if (key == operator[](i).name())
|
||||||
|
{
|
||||||
|
indices[nFound++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indices.setSize(nFound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return indices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::polyBoundaryMesh::findIndex(const keyType& key) const
|
||||||
|
{
|
||||||
|
if (!key.empty())
|
||||||
|
{
|
||||||
|
if (key.isPattern())
|
||||||
|
{
|
||||||
|
labelList indices = this->findIndices(key);
|
||||||
|
|
||||||
|
// return first element
|
||||||
|
if (!indices.empty())
|
||||||
|
{
|
||||||
|
return indices[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(*this, i)
|
||||||
|
{
|
||||||
|
if (key == operator[](i).name())
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// not found
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
|
Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
|
||||||
{
|
{
|
||||||
const polyPatchList& patches = *this;
|
const polyPatchList& patches = *this;
|
||||||
@ -444,7 +505,11 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
|
|||||||
// with patch start labels.
|
// with patch start labels.
|
||||||
// If the face is internal, return -1;
|
// If the face is internal, return -1;
|
||||||
// if it is off the end of the list, abort
|
// if it is off the end of the list, abort
|
||||||
if (faceIndex >= mesh().nFaces())
|
if (faceIndex < mesh().nInternalFaces())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (faceIndex >= mesh().nFaces())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -453,10 +518,6 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (faceIndex < mesh().nInternalFaces())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(*this, patchI)
|
forAll(*this, patchI)
|
||||||
{
|
{
|
||||||
@ -578,7 +639,7 @@ bool Foam::polyBoundaryMesh::checkParallelSync(const bool report) const
|
|||||||
|
|
||||||
// Have every processor check but only master print error.
|
// Have every processor check but only master print error.
|
||||||
|
|
||||||
for (label procI = 1; procI < allNames.size(); procI++)
|
for (label procI = 1; procI < allNames.size(); ++procI)
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
|||||||
@ -38,6 +38,7 @@ SourceFiles
|
|||||||
#include "polyPatchList.H"
|
#include "polyPatchList.H"
|
||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
#include "labelPair.H"
|
#include "labelPair.H"
|
||||||
|
#include "HashSet.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -151,6 +152,12 @@ public:
|
|||||||
//- Return a list of physical types
|
//- Return a list of physical types
|
||||||
wordList physicalTypes() const;
|
wordList physicalTypes() const;
|
||||||
|
|
||||||
|
//- Return patch indices for all matches
|
||||||
|
labelList findIndices(const keyType&) const;
|
||||||
|
|
||||||
|
//- Return patch index for the first match, return -1 if not found
|
||||||
|
label findIndex(const keyType&) const;
|
||||||
|
|
||||||
//- Find patch index given a name
|
//- Find patch index given a name
|
||||||
label findPatchID(const word& patchName) const;
|
label findPatchID(const word& patchName) const;
|
||||||
|
|
||||||
|
|||||||
@ -1,142 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 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/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::polyPatchID
|
|
||||||
|
|
||||||
Description
|
|
||||||
A class holds the data needed to identify a patch in a dynamic mesh.
|
|
||||||
|
|
||||||
The patch is identified by name and its index in the boundary mesh
|
|
||||||
is updated if the mesh has changed.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef polyPatchID_H
|
|
||||||
#define polyPatchID_H
|
|
||||||
|
|
||||||
#include "polyBoundaryMesh.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
|
|
||||||
class polyPatchID;
|
|
||||||
Ostream& operator<<(Ostream& os, const polyPatchID& p);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class polyPatchID Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class polyPatchID
|
|
||||||
{
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Patch name
|
|
||||||
word name_;
|
|
||||||
|
|
||||||
//- Patch index
|
|
||||||
label index_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from name
|
|
||||||
polyPatchID(const word& name, const polyBoundaryMesh& bm)
|
|
||||||
:
|
|
||||||
name_(name),
|
|
||||||
index_(bm.findPatchID(name))
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct from Istream
|
|
||||||
polyPatchID(Istream& is, const polyBoundaryMesh& bm)
|
|
||||||
:
|
|
||||||
name_(is),
|
|
||||||
index_(bm.findPatchID(name_))
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Return name
|
|
||||||
const word& name() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return index
|
|
||||||
label index() const
|
|
||||||
{
|
|
||||||
return index_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Has the patch been found
|
|
||||||
bool active() const
|
|
||||||
{
|
|
||||||
return index_ > -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Update
|
|
||||||
void update(const polyBoundaryMesh& bm)
|
|
||||||
{
|
|
||||||
index_ = bm.findPatchID(name_);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const polyPatchID& p)
|
|
||||||
{
|
|
||||||
os << token::BEGIN_LIST
|
|
||||||
<< p.name_ << token::SPACE
|
|
||||||
<< p.index_
|
|
||||||
<< token::END_LIST;
|
|
||||||
|
|
||||||
// Check state of Ostream
|
|
||||||
os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -250,6 +250,9 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::findIndices
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
labelList indices;
|
labelList indices;
|
||||||
|
|
||||||
|
if (!key.empty())
|
||||||
|
{
|
||||||
if (key.isPattern())
|
if (key.isPattern())
|
||||||
{
|
{
|
||||||
indices = findStrings(key, this->names());
|
indices = findStrings(key, this->names());
|
||||||
@ -267,6 +270,7 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::findIndices
|
|||||||
}
|
}
|
||||||
indices.setSize(nFound);
|
indices.setSize(nFound);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
@ -278,9 +282,12 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
|
|||||||
const keyType& key
|
const keyType& key
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
if (!key.empty())
|
||||||
|
{
|
||||||
if (key.isPattern())
|
if (key.isPattern())
|
||||||
{
|
{
|
||||||
labelList indices = this->findIndices(key);
|
labelList indices = this->findIndices(key);
|
||||||
|
|
||||||
// return first element
|
// return first element
|
||||||
if (!indices.empty())
|
if (!indices.empty())
|
||||||
{
|
{
|
||||||
@ -297,6 +304,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// not found
|
// not found
|
||||||
return -1;
|
return -1;
|
||||||
@ -332,6 +340,24 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class ZoneType, class MeshType>
|
||||||
|
Foam::PackedBoolList Foam::ZoneMesh<ZoneType, MeshType>::findMatching
|
||||||
|
(
|
||||||
|
const keyType& key
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
PackedBoolList lst;
|
||||||
|
|
||||||
|
const labelList indices = this->findIndices(key);
|
||||||
|
forAll(indices, i)
|
||||||
|
{
|
||||||
|
lst |= static_cast<const labelList&>(this->operator[](indices[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class ZoneType, class MeshType>
|
template<class ZoneType, class MeshType>
|
||||||
void Foam::ZoneMesh<ZoneType, MeshType>::clearAddressing()
|
void Foam::ZoneMesh<ZoneType, MeshType>::clearAddressing()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,7 +25,7 @@ Class
|
|||||||
Foam::ZoneMesh
|
Foam::ZoneMesh
|
||||||
|
|
||||||
Description
|
Description
|
||||||
List of mesh zones
|
A list of mesh zones.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ZoneMesh.C
|
ZoneMesh.C
|
||||||
@ -37,8 +37,9 @@ SourceFiles
|
|||||||
|
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "regIOobject.H"
|
#include "regIOobject.H"
|
||||||
#include "HashSet.H"
|
|
||||||
#include "pointFieldsFwd.H"
|
#include "pointFieldsFwd.H"
|
||||||
|
#include "Map.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -131,15 +132,18 @@ public:
|
|||||||
//- Return a list of zone names
|
//- Return a list of zone names
|
||||||
wordList names() const;
|
wordList names() const;
|
||||||
|
|
||||||
//- Find zone index given a name
|
|
||||||
label findZoneID(const word& zoneName) const;
|
|
||||||
|
|
||||||
//- Return zone indices for all matches
|
//- Return zone indices for all matches
|
||||||
labelList findIndices(const keyType&) const;
|
labelList findIndices(const keyType&) const;
|
||||||
|
|
||||||
//- Return zone index for the first match, return -1 if not found
|
//- Return zone index for the first match, return -1 if not found
|
||||||
label findIndex(const keyType&) const;
|
label findIndex(const keyType&) const;
|
||||||
|
|
||||||
|
//- Find zone index given a name
|
||||||
|
label findZoneID(const word& zoneName) const;
|
||||||
|
|
||||||
|
//- Mark cells that match the zone specification
|
||||||
|
PackedBoolList findMatching(const keyType&) const;
|
||||||
|
|
||||||
//- Clear addressing
|
//- Clear addressing
|
||||||
void clearAddressing();
|
void clearAddressing();
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const char * const Foam::cellZone::labelsName = "cellLabels";
|
|||||||
Foam::cellZone::cellZone
|
Foam::cellZone::cellZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const cellZoneMesh& zm
|
const cellZoneMesh& zm
|
||||||
)
|
)
|
||||||
@ -86,7 +86,7 @@ Foam::cellZone::cellZone
|
|||||||
Foam::cellZone::cellZone
|
Foam::cellZone::cellZone
|
||||||
(
|
(
|
||||||
const cellZone& cz,
|
const cellZone& cz,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const cellZoneMesh& zm
|
const cellZoneMesh& zm
|
||||||
)
|
)
|
||||||
@ -154,7 +154,14 @@ void Foam::cellZone::operator=(const cellZone& zn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::cellZone::operator=(const labelList& addr)
|
void Foam::cellZone::operator=(const unallocLabelList& addr)
|
||||||
|
{
|
||||||
|
clearAddressing();
|
||||||
|
labelList::operator=(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellZone::operator=(const Xfer<labelList>& addr)
|
||||||
{
|
{
|
||||||
clearAddressing();
|
clearAddressing();
|
||||||
labelList::operator=(addr);
|
labelList::operator=(addr);
|
||||||
|
|||||||
@ -113,7 +113,7 @@ public:
|
|||||||
cellZone
|
cellZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const cellZoneMesh&
|
const cellZoneMesh&
|
||||||
);
|
);
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
cellZone
|
cellZone
|
||||||
(
|
(
|
||||||
const cellZone&,
|
const cellZone&,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const cellZoneMesh&
|
const cellZoneMesh&
|
||||||
);
|
);
|
||||||
@ -169,7 +169,7 @@ public:
|
|||||||
// and zone mesh
|
// and zone mesh
|
||||||
virtual autoPtr<cellZone> clone
|
virtual autoPtr<cellZone> clone
|
||||||
(
|
(
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const cellZoneMesh& zm
|
const cellZoneMesh& zm
|
||||||
) const
|
) const
|
||||||
@ -222,11 +222,14 @@ public:
|
|||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Assign to zone clearing demand-driven data
|
//- Assign to zone, clearing demand-driven data
|
||||||
void operator=(const cellZone&);
|
void operator=(const cellZone&);
|
||||||
|
|
||||||
//- Assign addressing clearing demand-driven data
|
//- Assign addressing, clearing demand-driven data
|
||||||
void operator=(const labelList&);
|
void operator=(const unallocLabelList&);
|
||||||
|
|
||||||
|
//- Assign addressing, clearing demand-driven data
|
||||||
|
void operator=(const Xfer<labelList>&);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|||||||
@ -180,7 +180,7 @@ void Foam::faceZone::checkAddressing() const
|
|||||||
Foam::faceZone::faceZone
|
Foam::faceZone::faceZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& fm,
|
const boolList& fm,
|
||||||
const label index,
|
const label index,
|
||||||
const faceZoneMesh& zm
|
const faceZoneMesh& zm
|
||||||
@ -242,7 +242,7 @@ Foam::faceZone::faceZone
|
|||||||
Foam::faceZone::faceZone
|
Foam::faceZone::faceZone
|
||||||
(
|
(
|
||||||
const faceZone& fz,
|
const faceZone& fz,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& fm,
|
const boolList& fm,
|
||||||
const label index,
|
const label index,
|
||||||
const faceZoneMesh& zm
|
const faceZoneMesh& zm
|
||||||
@ -392,7 +392,7 @@ void Foam::faceZone::clearAddressing()
|
|||||||
|
|
||||||
void Foam::faceZone::resetAddressing
|
void Foam::faceZone::resetAddressing
|
||||||
(
|
(
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& flipMap
|
const boolList& flipMap
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
|
|||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
label faceI = operator[](i);
|
const label faceI = operator[](i);
|
||||||
|
|
||||||
if (faceMap[faceI] >= 0)
|
if (faceMap[faceI] >= 0)
|
||||||
{
|
{
|
||||||
@ -454,7 +454,7 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
|
|||||||
boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false);
|
boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false);
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
label faceI = operator[](i);
|
const label faceI = operator[](i);
|
||||||
|
|
||||||
if (!mesh.isInternalFace(faceI))
|
if (!mesh.isInternalFace(faceI))
|
||||||
{
|
{
|
||||||
@ -469,13 +469,12 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
|
|||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
label faceI = operator[](i);
|
const label faceI = operator[](i);
|
||||||
|
const label patchI = bm.whichPatch(faceI);
|
||||||
label patchI = bm.whichPatch(faceI);
|
|
||||||
|
|
||||||
if (patchI != -1 && bm[patchI].coupled())
|
if (patchI != -1 && bm[patchI].coupled())
|
||||||
{
|
{
|
||||||
label bFaceI = faceI-mesh.nInternalFaces();
|
const label bFaceI = faceI-mesh.nInternalFaces();
|
||||||
|
|
||||||
// Check face in zone on both sides
|
// Check face in zone on both sides
|
||||||
if (myZoneFace[bFaceI] != neiZoneFace[bFaceI])
|
if (myZoneFace[bFaceI] != neiZoneFace[bFaceI])
|
||||||
|
|||||||
@ -154,7 +154,7 @@ public:
|
|||||||
faceZone
|
faceZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& fm,
|
const boolList& fm,
|
||||||
const label index,
|
const label index,
|
||||||
const faceZoneMesh& zm
|
const faceZoneMesh& zm
|
||||||
@ -184,7 +184,7 @@ public:
|
|||||||
faceZone
|
faceZone
|
||||||
(
|
(
|
||||||
const faceZone&,
|
const faceZone&,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& fm,
|
const boolList& fm,
|
||||||
const label index,
|
const label index,
|
||||||
const faceZoneMesh&
|
const faceZoneMesh&
|
||||||
@ -214,7 +214,7 @@ public:
|
|||||||
// and zone mesh
|
// and zone mesh
|
||||||
virtual autoPtr<faceZone> clone
|
virtual autoPtr<faceZone> clone
|
||||||
(
|
(
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const boolList& fm,
|
const boolList& fm,
|
||||||
const label index,
|
const label index,
|
||||||
const faceZoneMesh& zm
|
const faceZoneMesh& zm
|
||||||
@ -279,7 +279,7 @@ public:
|
|||||||
virtual void clearAddressing();
|
virtual void clearAddressing();
|
||||||
|
|
||||||
//- Reset addressing and flip map (clearing demand-driven data)
|
//- Reset addressing and flip map (clearing demand-driven data)
|
||||||
virtual void resetAddressing(const labelList&, const boolList&);
|
virtual void resetAddressing(const unallocLabelList&, const boolList&);
|
||||||
|
|
||||||
//- Check zone definition. Return true if in error.
|
//- Check zone definition. Return true if in error.
|
||||||
virtual bool checkDefinition(const bool report = false) const;
|
virtual bool checkDefinition(const bool report = false) const;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const char* const Foam::pointZone::labelsName = "pointLabels";
|
|||||||
Foam::pointZone::pointZone
|
Foam::pointZone::pointZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const pointZoneMesh& zm
|
const pointZoneMesh& zm
|
||||||
)
|
)
|
||||||
@ -86,7 +86,7 @@ Foam::pointZone::pointZone
|
|||||||
Foam::pointZone::pointZone
|
Foam::pointZone::pointZone
|
||||||
(
|
(
|
||||||
const pointZone& pz,
|
const pointZone& pz,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const pointZoneMesh& zm
|
const pointZoneMesh& zm
|
||||||
)
|
)
|
||||||
@ -198,7 +198,14 @@ void Foam::pointZone::operator=(const pointZone& zn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::pointZone::operator=(const labelList& addr)
|
void Foam::pointZone::operator=(const unallocLabelList& addr)
|
||||||
|
{
|
||||||
|
clearAddressing();
|
||||||
|
labelList::operator=(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::pointZone::operator=(const Xfer<labelList>& addr)
|
||||||
{
|
{
|
||||||
clearAddressing();
|
clearAddressing();
|
||||||
labelList::operator=(addr);
|
labelList::operator=(addr);
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public:
|
|||||||
pointZone
|
pointZone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const pointZoneMesh&
|
const pointZoneMesh&
|
||||||
);
|
);
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
pointZone
|
pointZone
|
||||||
(
|
(
|
||||||
const pointZone&,
|
const pointZone&,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index,
|
const label index,
|
||||||
const pointZoneMesh&
|
const pointZoneMesh&
|
||||||
);
|
);
|
||||||
@ -170,7 +170,7 @@ public:
|
|||||||
(
|
(
|
||||||
const pointZoneMesh& zm,
|
const pointZoneMesh& zm,
|
||||||
const label index,
|
const label index,
|
||||||
const labelList& addr
|
const unallocLabelList& addr
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return autoPtr<pointZone>
|
return autoPtr<pointZone>
|
||||||
@ -222,11 +222,14 @@ public:
|
|||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Assign to zone clearing demand-driven data
|
//- Assign to zone, clearing demand-driven data
|
||||||
void operator=(const pointZone&);
|
void operator=(const pointZone&);
|
||||||
|
|
||||||
//- Assign addressing clearing demand-driven data
|
//- Assign addressing, clearing demand-driven data
|
||||||
void operator=(const labelList&);
|
void operator=(const unallocLabelList&);
|
||||||
|
|
||||||
|
//- Assign addressing, clearing demand-driven data
|
||||||
|
void operator=(const Xfer<labelList>&);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|||||||
@ -85,7 +85,7 @@ void Foam::zone::calcLookupMap() const
|
|||||||
Foam::zone::zone
|
Foam::zone::zone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index
|
const label index
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
@ -128,7 +128,7 @@ Foam::zone::zone
|
|||||||
Foam::zone::zone
|
Foam::zone::zone
|
||||||
(
|
(
|
||||||
const zone& z,
|
const zone& z,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index
|
const label index
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
|||||||
@ -101,7 +101,7 @@ public:
|
|||||||
zone
|
zone
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index
|
const label index
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
zone
|
zone
|
||||||
(
|
(
|
||||||
const zone&,
|
const zone&,
|
||||||
const labelList& addr,
|
const unallocLabelList& addr,
|
||||||
const label index
|
const label index
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
|
|||||||
"off", "on",
|
"off", "on",
|
||||||
"no", "yes",
|
"no", "yes",
|
||||||
"n", "y",
|
"n", "y",
|
||||||
|
"f", "t",
|
||||||
"none", "true", // is there a reasonable counterpart to "none"?
|
"none", "true", // is there a reasonable counterpart to "none"?
|
||||||
"invalid"
|
"invalid"
|
||||||
};
|
};
|
||||||
@ -54,18 +55,39 @@ Foam::Switch::switchType Foam::Switch::asEnum
|
|||||||
{
|
{
|
||||||
if (str == names[sw])
|
if (str == names[sw])
|
||||||
{
|
{
|
||||||
// convert n/y to no/yes - perhaps should deprecate y/n
|
// handle aliases
|
||||||
if (sw == Switch::NO_1 || sw == Switch::NONE)
|
switch (sw)
|
||||||
|
{
|
||||||
|
case Switch::NO_1:
|
||||||
|
case Switch::NONE:
|
||||||
{
|
{
|
||||||
return Switch::NO;
|
return Switch::NO;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (sw == Switch::YES_1)
|
|
||||||
|
case Switch::YES_1:
|
||||||
{
|
{
|
||||||
return Switch::YES;
|
return Switch::YES;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
case Switch::FALSE_1:
|
||||||
|
{
|
||||||
|
return Switch::FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Switch::TRUE_1:
|
||||||
|
{
|
||||||
|
return Switch::TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
{
|
{
|
||||||
return switchType(sw);
|
return switchType(sw);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A simple wrapper around bool so that it can be read as a word:
|
A simple wrapper around bool so that it can be read as a word:
|
||||||
true/false, on/off, yes/no or y/n or none.
|
true/false, on/off, yes/no, y/n, t/f, or none.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
Switch.C
|
Switch.C
|
||||||
@ -78,6 +78,8 @@ public:
|
|||||||
#undef YES
|
#undef YES
|
||||||
#undef NO_1
|
#undef NO_1
|
||||||
#undef YES_1
|
#undef YES_1
|
||||||
|
#undef FALSE_1
|
||||||
|
#undef TRUE_1
|
||||||
#undef NONE
|
#undef NONE
|
||||||
#undef PLACEHOLDER
|
#undef PLACEHOLDER
|
||||||
#undef INVALID
|
#undef INVALID
|
||||||
@ -90,7 +92,8 @@ public:
|
|||||||
OFF = 2, ON = 3,
|
OFF = 2, ON = 3,
|
||||||
NO = 4, YES = 5,
|
NO = 4, YES = 5,
|
||||||
NO_1 = 6, YES_1 = 7,
|
NO_1 = 6, YES_1 = 7,
|
||||||
NONE = 8, PLACEHOLDER = 9,
|
FALSE_1 = 8, TRUE_1 = 9,
|
||||||
|
NONE = 10, PLACEHOLDER = 11,
|
||||||
INVALID
|
INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,8 @@ public:
|
|||||||
|
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
|
//- An empty fileName
|
||||||
static const fileName null;
|
static const fileName null;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,24 +22,54 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Istream constructor and IOstream operators for word.
|
Istream constructor and IOstream operators for keyType.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "keyType.H"
|
#include "keyType.H"
|
||||||
|
#include "regExp.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::keyType Foam::keyType::null;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::keyType::keyType(Istream& is)
|
Foam::keyType::keyType(Istream& is)
|
||||||
:
|
:
|
||||||
word()
|
word(),
|
||||||
|
isPattern_(false)
|
||||||
{
|
{
|
||||||
is >> *this;
|
is >> *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::keyType::match
|
||||||
|
(
|
||||||
|
const std::string& str,
|
||||||
|
bool literalMatch
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (literalMatch || !isPattern_)
|
||||||
|
{
|
||||||
|
// check as string
|
||||||
|
return (str == *this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check as regex
|
||||||
|
return regExp(*this).match(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Istream& Foam::operator>>(Istream& is, keyType& kw)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
|
|
||||||
@ -51,15 +81,16 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
|||||||
|
|
||||||
if (t.isWord())
|
if (t.isWord())
|
||||||
{
|
{
|
||||||
w = t.wordToken();
|
kw = t.wordToken();
|
||||||
}
|
}
|
||||||
else if (t.isString())
|
else if (t.isString())
|
||||||
{
|
{
|
||||||
// Assign from string. Sets regular expression.
|
// Assign from string. Set as regular expression.
|
||||||
w = t.stringToken();
|
kw = t.stringToken();
|
||||||
|
kw.isPattern_ = true;
|
||||||
|
|
||||||
// flag empty strings as an error
|
// flag empty strings as an error
|
||||||
if (w.empty())
|
if (kw.empty())
|
||||||
{
|
{
|
||||||
is.setBad();
|
is.setBad();
|
||||||
FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
|
FatalIOErrorIn("operator>>(Istream&, keyType&)", is)
|
||||||
@ -86,9 +117,9 @@ Foam::Istream& Foam::operator>>(Istream& is, keyType& w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& w)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const keyType& kw)
|
||||||
{
|
{
|
||||||
os.write(w);
|
os.write(kw);
|
||||||
os.check("Ostream& operator<<(Ostream&, const keyType&)");
|
os.check("Ostream& operator<<(Ostream&, const keyType&)");
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,6 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
keyType.C
|
keyType.C
|
||||||
keyTypeIO.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ class keyType
|
|||||||
:
|
:
|
||||||
public word
|
public word
|
||||||
{
|
{
|
||||||
// Private member data
|
// Private data
|
||||||
|
|
||||||
//- Is the keyType a pattern (regular expression)
|
//- Is the keyType a pattern (regular expression)
|
||||||
bool isPattern_;
|
bool isPattern_;
|
||||||
@ -71,6 +70,11 @@ class keyType
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
|
||||||
|
//- An empty keyType
|
||||||
|
static const keyType null;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
@ -80,19 +84,21 @@ public:
|
|||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
inline keyType(const keyType&);
|
inline keyType(const keyType&);
|
||||||
|
|
||||||
//- Construct as copy of word
|
//- Construct as copy of word. Not treated as a regular expression
|
||||||
inline keyType(const word&);
|
inline keyType(const word&);
|
||||||
|
|
||||||
//- Construct as copy of string. Expect it to be regular expression.
|
//- Construct as copy of string. Treat as regular expression.
|
||||||
inline keyType(const string&);
|
inline keyType(const string&);
|
||||||
|
|
||||||
//- Construct as copy of character array
|
//- Construct as copy of character array.
|
||||||
|
// Not treated as a regular expression
|
||||||
inline keyType(const char*);
|
inline keyType(const char*);
|
||||||
|
|
||||||
//- Construct as copy of std::string
|
//- Construct as copy of std::string with specified treatment
|
||||||
inline keyType(const std::string&, const bool isPattern);
|
inline keyType(const std::string&, const bool isPattern);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
|
// Treat as regular expression if surrounded by quotation marks.
|
||||||
keyType(Istream&);
|
keyType(Istream&);
|
||||||
|
|
||||||
|
|
||||||
@ -101,15 +107,24 @@ public:
|
|||||||
//- Should be treated as a match rather than a literal string
|
//- Should be treated as a match rather than a literal string
|
||||||
inline bool isPattern() const;
|
inline bool isPattern() const;
|
||||||
|
|
||||||
|
//- Smart match as regular expression or as a string
|
||||||
|
// Optionally force a literal match only
|
||||||
|
bool match(const std::string&, bool literalMatch=false) const;
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
// Assignment
|
// Assignment
|
||||||
|
|
||||||
|
//- Assignment operator
|
||||||
inline const keyType& operator=(const keyType&);
|
inline const keyType& operator=(const keyType&);
|
||||||
|
|
||||||
|
//- Assign as word, not as non regular expression
|
||||||
inline const keyType& operator=(const word&);
|
inline const keyType& operator=(const word&);
|
||||||
|
|
||||||
//- Assign from regular expression.
|
//- Assign as regular expression
|
||||||
inline const keyType& operator=(const string&);
|
inline const keyType& operator=(const string&);
|
||||||
|
|
||||||
|
//- Assign as word, not as non regular expression
|
||||||
inline const keyType& operator=(const char*);
|
inline const keyType& operator=(const char*);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,10 +23,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::keyType::keyType()
|
inline Foam::keyType::keyType()
|
||||||
@ -50,7 +46,6 @@ inline Foam::keyType::keyType(const word& s)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Construct as copy of string. Expect it to be regular expression
|
|
||||||
inline Foam::keyType::keyType(const string& s)
|
inline Foam::keyType::keyType(const string& s)
|
||||||
:
|
:
|
||||||
word(s, false),
|
word(s, false),
|
||||||
@ -58,7 +53,6 @@ inline Foam::keyType::keyType(const string& s)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Construct as copy of character array
|
|
||||||
inline Foam::keyType::keyType(const char* s)
|
inline Foam::keyType::keyType(const char* s)
|
||||||
:
|
:
|
||||||
word(s, false),
|
word(s, false),
|
||||||
@ -66,7 +60,6 @@ inline Foam::keyType::keyType(const char* s)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct as copy of std::string
|
|
||||||
inline Foam::keyType::keyType
|
inline Foam::keyType::keyType
|
||||||
(
|
(
|
||||||
const std::string& s,
|
const std::string& s,
|
||||||
|
|||||||
@ -82,6 +82,8 @@ public:
|
|||||||
|
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
|
//- An empty string
|
||||||
static const string null;
|
static const string null;
|
||||||
|
|
||||||
|
|
||||||
@ -143,6 +145,9 @@ public:
|
|||||||
template<class String>
|
template<class String>
|
||||||
static inline string quotemeta(const string&, const char quote='\\');
|
static inline string quotemeta(const string&, const char quote='\\');
|
||||||
|
|
||||||
|
//- True when strings match literally
|
||||||
|
inline bool match(const std::string&) const;
|
||||||
|
|
||||||
//- Avoid masking the normal std::string replace
|
//- Avoid masking the normal std::string replace
|
||||||
using std::string::replace;
|
using std::string::replace;
|
||||||
|
|
||||||
|
|||||||
@ -176,6 +176,12 @@ inline String Foam::string::validate(const string& str)
|
|||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool Foam::string::match(const std::string& str) const
|
||||||
|
{
|
||||||
|
// check as string
|
||||||
|
return (str == *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user