Merge branch 'master' into molecularDynamics

This commit is contained in:
graham
2008-12-12 10:49:08 +00:00
302 changed files with 8656 additions and 5341 deletions

View File

@ -23,12 +23,42 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
basicSubGrid
Foam::XiEqModels::basicSubGrid
Description
Basic sub-grid obstacle flame-wrinking enhancement factor model.
Details supplied by J Puttock 2/7/06.
<b> Sub-grid flame area generation </b>
\f$ n = N - \hat{\dwea{\vec{U}}}.n_{s}.\hat{\dwea{\vec{U}}} \f$
\f$ n_{r} = \sqrt{n} \f$
where:
\f$ \hat{\dwea{\vec{U}}} = \dwea{\vec{U}} / \vert \dwea{\vec{U}}
\vert \f$
\f$ b = \hat{\dwea{\vec{U}}}.B.\hat{\dwea{\vec{U}}} / n_{r} \f$
where:
\f$ B \f$ is the file "B".
\f$ N \f$ is the file "N".
\f$ n_{s} \f$ is the file "ns".
The flame area enhancement factor \f$ \Xi_{sub} \f$ is expected to
approach:
\f[
\Xi_{{sub}_{eq}} =
1 + max(2.2 \sqrt{b}, min(0.34 \frac{\vert \dwea{\vec{U}}
\vert}{{\vec{U}}^{'}}, 1.6)) \times min(\frac{n}{4}, 1)
\f]
SourceFiles
basicSubGrid.C

View File

@ -23,12 +23,30 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
basicSubGrid
Foam::XiGModel::basicSubGrid
Description
Basic sub-grid obstacle flame-wrinking generation rate coefficient model.
Details supplied by J Puttock 2/7/06.
\f$ G_{sub} \f$ denotes the generation coefficient and it is given by
\f[
G_{sub} = k_{1} /frac{\vert \dwea{\vec{U}} \vert}{L_{obs}}
\frac{/Xi_{{sub}_{eq}}-1}{/Xi_{sub}}
\f]
and the removal:
\f[ - k_{1} /frac{\vert \dwea{\vec{U}} \vert}{L_{sub}}
\frac{\Xi_{sub}-1}{\Xi_{sub}} \f]
Finally, \f$ G_{sub} \f$ is added to generation rate \f$ G_{in} \f$
due to the turbulence.
SourceFiles
basicSubGrid.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
PDRDragModel
Foam::PDRDragModel
Description
Base-class for sub-grid obstacle drag models.

View File

@ -23,12 +23,56 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
basic
Foam::PDRDragModels::basic
Description
Basic sub-grid obstacle drag model.
Details supplied by J Puttock 2/7/06.
<b> Sub-grid drag term </b>
The resistance term (force per unit of volume) is given by:
\f[
R = -\frac{1}{2} \rho \vert \dwea{\vec{U}} \vert \dwea{\vec{U}}.D
\f]
where:
\f$ D \f$ is the tensor field "CR" in \f$ m^{-1} \f$
This is term is treated implicitly in UEqn.H
<b> Sub-grid turbulence generation </b>
The turbulence source term \f$ G_{R} \f$ occurring in the
\f$ \kappa-\epsilon \f$ equations for the generation of turbulence due
to interaction with unresolved obstacles :
\f$ G_{R} = C_{s}\beta_{\nu}
\mu_{eff} A_{w}^{2}(\dwea{\vec{U}}-\dwea{\vec{U}_{s}})^2 + \frac{1}{2}
\rho \vert \dwea{\vec{U}} \vert \dwea{\vec{U}}.T.\dwea{\vec{U}} \f$
where:
\f$ C_{s} \f$ = 1
\f$ \beta_{\nu} \f$ is the volume porosity (file "betav").
\f$ \mu_{eff} \f$ is the effective viscosity.
\f$ A_{w}^{2}\f$ is the obstacle surface area per unit of volume
(file "Aw").
\f$ \dwea{\vec{U}_{s}} \f$ is the slip velocity and is considered
\f$ \frac{1}{2}. \dwea{\vec{U}} \f$.
\f$ T \f$ is a tensor in the file CT.
The term \f$ G_{R} \f$ is treated explicitly in the \f$ \kappa-\epsilon
\f$ Eqs in the PDRkEpsilon.C file.
SourceFiles
basic.C
@ -40,7 +84,6 @@ SourceFiles
#include "PDRDragModel.H"
#include "XiEqModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{

View File

@ -23,10 +23,20 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
PDRkEpsilon
Foam::compressible::RASModels::PDRkEpsilon
Description
Standard k-epsilon turbulence model.
Standard k-epsilon turbulence model with additional source terms
corresponding to PDR basic drag model (basic.H)
The turbulence source term \f$ G_{R} \f$ appears in the
\f$ \kappa-\epsilon \f$ equation for the generation of turbulence due to
interaction with unresolved obstacles.
In the \f$ \epsilon \f$ equation \f$ C_{1} G_{R} \f$ is added as a source
term.
In the \f$ \kappa \f$ equation \f$ G_{R} \f$ is added as a source term.
SourceFiles
PDRkEpsilon.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Gulder
Foam::XiEqModels::Gulder
Description
Simple Gulder model for XiEq based on Gulders correlation

View File

@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
SCOPEBlend
Foam::XiEqModels::SCOPEBlend
Description
SourceFiles
SCOPEBlend.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
SCOPEXiEq
Foam::XiEqModel::SCOPEXiEq
Description
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
XiEqModel
Foam::XiEqModel
Description
Base-class for all XiEq models used by the b-XiEq combustion model.

View File

@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
instability
Foam::XiEqModels::instability
Description
SourceFiles
instability.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
KTS
Foam::XiGModels::KTS
Description
Simple Kolmogorov time-scale model for the flame-wrinling generation rate.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
XiGModel
Foam::XiGModel
Description
Base-class for all Xi generation models used by the b-Xi combustion model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
instabilityG
Foam::XiGModels::instabilityG
Description
Flame-surface instabilityG flame-wrinking generation rate coefficient model.

View File

@ -23,10 +23,61 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
XiModel
Foam::XiModel
Description
Base-class for all Xi models used by the b-Xi combustion model.
See Technical Report SH/RE/01R for details on the PDR modelling.
Xi is given through an algebraic expression (algebraic.H),
by solving a transport equation (transport.H) or a fixed value (fixed.H).
See report TR/HGW/10 for details on the Weller two equations model.
In the algebraic and transport methods \f$\Xi_{eq}\f$ is calculated in
similar way. In the algebraic approach, \f$\Xi_{eq}\f$ is the value used in
the \f$ b \f$ transport equation.
\f$\Xi_{eq}\f$ is calculated as follows:
\f$\Xi_{eq} = 1 + (1 + 2\Xi_{coeff}(0.5 - \dwea{b}))(\Xi^* - 1)\f$
where:
\f$ \dwea{b} \f$ is the regress variable.
\f$ \Xi^* \f$ is the total equilibrium wrinkling combining the effects
of the flame inestability and turbulence interaction and is given by
\f[
\Xi^* = \frac {R}{R - G_\eta - G_{in}}
\f]
where:
\f$ G_\eta \f$ is the generation rate of wrinkling due to turbulence
interaction.
\f$ G_{in} = \kappa \rho_{u}/\rho_{b} \f$ is the generation
rate due to the flame inestability.
By adding the removal rates of the two effects:
\f[
R = G_\eta \frac{\Xi_{\eta_{eq}}}{\Xi_{\eta_{eq}} - 1}
+ G_{in} \frac{\Xi_{{in}_{eq}}}{\Xi_{{in}_{eq}} - 1}
\f]
where:
\f$ R \f$ is the total removal.
\f$ G_\eta \f$ is a model constant.
\f$ \Xi_{\eta_{eq}} \f$ is the flame wrinkling due to turbulence.
\f$ \Xi_{{in}_{eq}} \f$ is the equilibrium level of the flame wrinkling
generated by inestability. It is a constant (default 2.5).
SourceFiles
XiModel.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
algebraic
Foam::XiModels::algebraic
Description
Simple algebraic model for Xi based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
fixed
Foam::XiModels::fixed
Description
Fixed value model for Xi.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
transport
Foam::XiModels::transport
Description
Simple transport model for Xi based on Gulders correlation

View File

@ -23,11 +23,38 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
SCOPE
Foam::laminarFlameSpeedModels::SCOPE
Description
Laminar flame speed obtained from the SCOPE correlation.
Seven parameters are specified in terms of polynomial functions of
stoichiometry. Two polynomials are fitted, covering different parts of the
flammable range. If the mixture is outside the fitted range, linear
interpolation is used between the extreme of the polynomio and the upper or
lower flammable limit with the Markstein number constant.
Variations of pressure and temperature from the reference values are taken
into account through \f$ pexp \f$ and \f$ texp \f$
The laminar burning velocity fitting polynomial is:
\f$ Su = a_{0}(1+a_{1}x+K+..a_{i}x^{i}..+a_{6}x^{6}) (p/p_{ref})^{pexp}
(T/T_{ref})^{texp} \f$
where:
\f$ a_{i} \f$ are the polinomial coefficients.
\f$ pexp \f$ and \f$ texp \f$ are the pressure and temperature factors
respectively.
\f$ x \f$ is the equivalence ratio.
\f$ T_{ref} \f$ and \f$ p_{ref} \f$ are the temperature and pressure
references for the laminar burning velocity.
SourceFiles
SCOPELaminarFlameSpeed.C
@ -125,7 +152,7 @@ class SCOPE
// corrected for temperature and pressure dependence
inline scalar Su0pTphi(scalar p, scalar Tu, scalar phi) const;
//- Laminar flame speed evaluated from the given uniform
//- Laminar flame speed evaluated from the given uniform
// equivalence ratio corrected for temperature and pressure dependence
tmp<volScalarField> Su0pTphi
(
@ -134,7 +161,7 @@ class SCOPE
scalar phi
) const;
//- Laminar flame speed evaluated from the given equivalence ratio
//- Laminar flame speed evaluated from the given equivalence ratio
// distribution corrected for temperature and pressure dependence
tmp<volScalarField> Su0pTphi
(
@ -144,7 +171,7 @@ class SCOPE
) const;
//- Return the Markstein number
// evaluated from the given equivalence ratio
// evaluated from the given equivalence ratio
tmp<volScalarField> Ma(const volScalarField& phi) const;
//- Construct as copy (not implemented)

View File

@ -74,24 +74,26 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
// Do any mesh changes
mesh.update();
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
// Store divU from the previous mesh for the correctPhi
volScalarField divU = fvc::div(phi);
gh = g & mesh.C();
ghf = g & mesh.Cf();
}
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
if (mesh.changing() && correctPhi)
{
//***HGW#include "correctPhi.H"
// Do any mesh changes
mesh.update();
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
if (mesh.changing() && correctPhi)
{
#include "correctPhi.H"
}
}
// Make the fluxes relative to the mesh motion
@ -102,6 +104,12 @@ int main(int argc, char *argv[])
#include "meshCourantNo.H"
}
if (mesh.changing())
{
gh = g & mesh.C();
ghf = g & mesh.Cf();
}
turbulence->correct();
// --- Outer-corrector loop

View File

@ -0,0 +1,39 @@
{
#include "continuityErrs.H"
volScalarField pcorr
(
IOobject
(
"pcorr",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("pcorr", pd.dimensions(), 0.0),
pcorrTypes
);
dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0);
adjustPhi(phi, U, pcorr);
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
);
pcorrEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pcorrEqn.flux();
}
}
#include "continuityErrs.H"
}

View File

@ -150,3 +150,14 @@
(
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
);
wordList pcorrTypes(pd.boundaryField().types());
for (label i=0; i<pd.boundaryField().size(); i++)
{
if (pd.boundaryField()[i].fixesValue())
{
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
}
}

View File

@ -43,16 +43,21 @@ int main(int argc, char *argv[])
ldl[0](3) = 3;
ldl[0](1) = 1;
ldl[0].setSize(5); // increase allocated size
ldl[1].setSize(10); // increase allocated size
ldl[1](2) = 2;
ldl[0].setCapacity(5); // increase allocated size
ldl[1].setCapacity(10); // increase allocated size
ldl[0].reserve(15); // should increase allocated size
ldl[1].reserve(5); // should not decrease allocated size
ldl[1](3) = 2; // allocates space and sets value
// this works without a segfault, but doesn't change the list size
ldl[0][4] = 4;
ldl[1] = 3;
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
forAll(ldl, i)
{
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
}
Info<< endl;
@ -63,7 +68,7 @@ int main(int argc, char *argv[])
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
forAll(ldl, i)
{
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
}
Info<< endl;
@ -78,10 +83,10 @@ int main(int argc, char *argv[])
{
dlA.append(i);
}
dlA.setSize(10);
dlA.setCapacity(10);
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
<< " " << dlA.size() << "/" << dlA.capacity() << endl;
dlB.transfer(dlA);
@ -91,10 +96,54 @@ int main(int argc, char *argv[])
Info<< "Transferred to dlB" << endl;
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
<< " " << dlA.size() << "/" << dlA.capacity() << endl;
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
<< " " << dlB.size() << "/" << dlB.allocSize() << endl;
<< " " << dlB.size() << "/" << dlB.capacity() << endl;
// try with a normal list:
List<label> lstA;
lstA.transfer(dlB);
Info<< "Transferred to normal list" << endl;
Info<< "<lstA>" << lstA << "</lstA>" << nl << "sizes: "
<< " " << lstA.size() << endl;
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
<< " " << dlB.size() << "/" << dlB.capacity() << endl;
// Copy back and append a few time
for (label i=0; i < 3; i++)
{
dlB.append(lstA);
}
Info<< "appended list a few times" << endl;
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
<< " " << dlB.size() << "/" << dlB.capacity() << endl;
// assign the list (should maintain allocated space)
dlB = lstA;
Info<< "assigned list" << endl;
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
<< " " << dlB.size() << "/" << dlB.capacity() << endl;
// Copy back and append a few time
for (label i=0; i < 3; i++)
{
dlB.append(lstA);
}
// check allocation granularity
DynamicList<label, 6, 0> dlC;
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
dlC.reserve(dlB.size());
dlC = dlB;
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
return 0;
}

View File

@ -1,4 +1,3 @@
namedEnumTest.C
EXE = $(FOAM_APPBIN)/NamedEnum
EXE = $(FOAM_USER_APPBIN)/NamedEnum

View File

@ -1,3 +1,3 @@
callbackTest.C
EXE = $(FOAM_APPBIN)/callbackTest
EXE = $(FOAM_USER_APPBIN)/callbackTest

View File

@ -1,3 +1,3 @@
testDataEntry.C
EXE = $(FOAM_APPBIN)/testDataEntry
EXE = $(FOAM_USER_APPBIN)/testDataEntry

View File

@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
@ -40,10 +41,37 @@ using namespace Foam;
int main(int argc, char *argv[])
{
IFstream dictStream("testDict");
dictionary testDict(dictStream);
Info<< dictionary(IFstream("testDict")()) << endl;
Info<< testDict << endl;
IOobject::writeDivider(Info);
{
dictionary dict(IFstream("testDictRegex")());
Info<< "dict:" << dict << endl;
// Wildcard find.
Info<< "Wildcard find \"abc\" in top directory : "
<< dict.lookup("abc") << endl;
Info<< "Wildcard find \"abc\" in sub directory : "
<< dict.subDict("someDict").lookup("abc")
<< endl;
Info<< "Recursive wildcard find \"def\" in sub directory : "
<< dict.subDict("someDict").lookup("def", true)
<< endl;
Info<< "Recursive wildcard find \"foo\" in sub directory : "
<< dict.subDict("someDict").lookup("foo", true)
<< endl;
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
<< dict.subDict("someDict").lookup("fooz", true)
<< endl;
Info<< "Recursive wildcard find \"bar\" in sub directory : "
<< dict.subDict("someDict").lookup("bar", true)
<< endl;
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
<< dict.subDict("someDict").lookup("xxx", true)
<< endl;
}
return 0;
}

View File

@ -0,0 +1,34 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDictRegex;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge
".*" parentValue1;
"[n-z].*" parentValue2;
"f.*" parentValue3;
someDict
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
// result is dependent on insert order!
"a.*c" subdictValue3;
"ab.*" subdictValue2;
"a.*" subdictValue1;
abcd subdictValue4;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,6 +28,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "timeSelector.H"
using namespace Foam;
@ -36,13 +37,19 @@ using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
// timeSelector::addOptions();
timeSelector::addOptions(true, true);
# include "setRootCase.H"
# include "createTime.H"
Info<< runTime.times() << endl;
Info<< "Times found:" << runTime.times() << endl;
Info << "End\n" << endl;
instantList timeDirs = timeSelector::select0(runTime, args);
Info<< "Times selected:" << timeDirs << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -0,0 +1,3 @@
regexTest.C
EXE = $(FOAM_USER_APPBIN)/regexTest

View File

@ -0,0 +1,3 @@
EXE_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o

View File

@ -22,55 +22,61 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
polyDualMesh
Description
Calculate the dual of a polyMesh. Adheres to all the feature&patch edges
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyDualMesh.H"
#include "mathematicalConstants.H"
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "regExp.H"
#include "List.H"
#include "Tuple2.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createPolyMesh.H"
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
bool overwrite = args.options().found("overwrite");
List<string> groups;
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
Info<< "Feature:" << featureAngle << endl
<< "minCos :" << minCos << endl
<< endl;
polyDualMesh dualMesh(mesh, minCos);
if (!overwrite)
// report matches:
forAll(rawList, elemI)
{
runTime++;
const string& pat = rawList[elemI].first();
const string& str = rawList[elemI].second();
regExp re(pat);
Info<< str << " =~ m/" << pat.c_str() << "/ == ";
if (re.match(str, groups))
{
Info<< "true";
if (re.ngroups())
{
Info<< groups;
}
}
else
{
Info<< "false";
if (re.match(str, true))
{
Info<< " partial match";
}
}
Info << endl;
}
Pout<< "Writing dualMesh to " << runTime.timeName() << endl;
dualMesh.write();
Info << "End\n" << endl;
Info<< endl;
return 0;
}

View File

@ -0,0 +1,20 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// pattern, string
(
( "a.*" "abc" )
( "a.*" "bac" )
( "a.*" "abcd" )
( "a.*" "def" )
( "d(.*)f" "def" )
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,6 +27,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "SortableList.H"
#include "ListOps.H"
using namespace Foam;
@ -35,42 +36,101 @@ using namespace Foam;
int main(int argc, char *argv[])
{
labelList orig(5);
labelList orig(8);
orig[0] = 7;
orig[1] = 4;
orig[1] = 9;
orig[2] = 1;
orig[3] = 2;
orig[4] = 9;
orig[4] = 4;
orig[5] = 7;
orig[6] = 4;
orig[7] = 0;
labelList order;
labelList a(orig);
Info << "before: " << a << endl;
sortedOrder(a, order);
Info<< "unsorted: " << a << endl;
sort(a);
Info << "after: " << a << endl;
Info<< "sorted: " << a << endl;
Info<< "indices: " << order << endl;
SortableList<label> b(orig);
Info << "sorted: " << b << endl;
Info << "indices: " << b.indices() << endl;
Info<< "unsorted: " << orig << endl;
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
Info << "shrunk: " << b.shrink() << endl;
Info << "indices: " << b.indices() << endl;
Info<< "shrunk: " << b.shrink() << endl;
Info<< "indices: " << b.indices() << endl;
// repeat by assignment
b = orig;
Info << "unsorted: " << b << endl;
Info<< "unsorted: " << b << endl;
b.sort();
Info << "sorted: " << b << endl;
Info << "indices: " << b.indices() << endl;
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
// find unique/duplicate values
b = orig;
Info<< "unsorted: " << b << endl;
uniqueOrder(b, order);
Info<< "unique: " << order << endl;
duplicateOrder(b, order);
Info<< "duplicate:" << order << endl;
// sort reverse
Info<< "unsorted: " << b << endl;
b.reverseSort();
Info<< "rsort: " << b << endl;
Info<< "indices: " << b.indices() << endl;
// transfer assignment
b.transfer(orig);
Info << "unsorted: " << b << endl;
a = orig;
b.transfer(a);
Info<< "unsorted: " << b << endl;
b.sort();
Info << "sorted: " << b << endl;
Info << "indices: " << b.indices() << endl;
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
Info << "End\n" << endl;
a.transfer(b);
Info<< "plain: " << a << endl;
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
// sort/duplicate/unique with identical values
b.setSize(8);
b = 5;
Info<< "unsorted: " << b << endl;
uniqueOrder(b, order);
Info<< "unique: " << order << endl;
duplicateOrder(b, order);
Info<< "duplicate:" << order << endl;
b.sort();
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
// with a single value
b.setSize(1);
Info<< "unsorted: " << b << endl;
uniqueOrder(b, order);
Info<< "unique: " << order << endl;
duplicateOrder(b, order);
Info<< "duplicate:" << order << endl;
b.sort();
Info<< "sorted: " << b << endl;
Info<< "indices: " << b.indices() << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -26,7 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "stringList.H"
#include "stringListOps.H"
#include "IOstreams.H"
using namespace Foam;

View File

@ -1,4 +1,3 @@
xferListTest.C
/* EXE = $(FOAM_USER_APPBIN)/xferListTest */
EXE = ./xferListTest
EXE = $(FOAM_USER_APPBIN)/xferListTest

View File

@ -108,13 +108,13 @@ int main(int argc, char *argv[])
face f1(dl);
face f2(xferCopy<labelList>(dl));
Info<< "dl[" << dl.size() << "/" << dl.allocSize() << "] " << dl << endl;
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f1: " << f1 << endl;
Info<< "f2: " << f2 << endl;
// note: using xferMoveTo to ensure the correct transfer() method is called
face f3( xferMoveTo<labelList>(dl) );
Info<< "dl[" << dl.size() << "/" << dl.allocSize() << "] " << dl << endl;
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f3: " << f3 << endl;
return 0;

View File

@ -1,3 +1,4 @@
polyDualMeshApp.C
meshDualiser.C
makePolyDualMesh.C
EXE = $(FOAM_APPBIN)/polyDualMesh

View File

@ -1,6 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools -lconversion
-lfiniteVolume \
-ldynamicMesh \
-lmeshTools

View File

@ -0,0 +1,515 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Calculate the dual of a polyMesh. Adheres to all the feature&patch edges.
Feature angle:
convex features : point becomes single boundary cell with multiple
boundary faces.
concave features: point becomes multiple boundary cells.
-splitAllFaces:
Normally only constructs a single face between two cells. This single face
might be too distorted. splitAllFaces will create a single face for every
original cell the face passes through. The mesh will thus have
multiple faces inbetween two cells! (so is not strictly upper-triangular
anymore - checkMesh will complain)
-doNotPreserveFaceZones:
By default all faceZones are preserved by marking all faces, edges and
points on them as features. The -doNotPreserveFaceZones disables this
behaviour.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "mathematicalConstants.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "PackedList.H"
#include "meshTools.H"
#include "OFstream.H"
#include "meshDualiser.H"
#include "ReadFields.H"
#include "volFields.H"
#include "surfaceFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Naive feature detection. All boundary edges with angle > featureAngle become
// feature edges. All points on feature edges become feature points. All
// boundary faces become feature faces.
void simpleMarkFeatures
(
const polyMesh& mesh,
const PackedList<1>& isBoundaryEdge,
const scalar featureAngle,
const bool doNotPreserveFaceZones,
labelList& featureFaces,
labelList& featureEdges,
labelList& singleCellFeaturePoints,
labelList& multiCellFeaturePoints
)
{
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Working sets
labelHashSet featureEdgeSet;
labelHashSet singleCellFeaturePointSet;
labelHashSet multiCellFeaturePointSet;
// 1. Mark all edges between patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const labelList& meshEdges = pp.meshEdges();
// All patch corner edges. These need to be feature points & edges!
for (label edgeI = pp.nInternalEdges(); edgeI < pp.nEdges(); edgeI++)
{
label meshEdgeI = meshEdges[edgeI];
featureEdgeSet.insert(meshEdgeI);
singleCellFeaturePointSet.insert(mesh.edges()[meshEdgeI][0]);
singleCellFeaturePointSet.insert(mesh.edges()[meshEdgeI][1]);
}
}
// 2. Mark all geometric feature edges
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Make distinction between convex features where the boundary point becomes
// a single cell and concave features where the boundary point becomes
// multiple 'half' cells.
// Addressing for all outside faces
primitivePatch allBoundary
(
SubList<face>
(
mesh.faces(),
mesh.nFaces()-mesh.nInternalFaces(),
mesh.nInternalFaces()
),
mesh.points()
);
// Check for non-manifold points (surface pinched at point)
allBoundary.checkPointManifold(false, &singleCellFeaturePointSet);
// Check for non-manifold edges (surface pinched at edge)
const labelListList& edgeFaces = allBoundary.edgeFaces();
const labelList& meshPoints = allBoundary.meshPoints();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() > 2)
{
const edge& e = allBoundary.edges()[edgeI];
//Info<< "Detected non-manifold boundary edge:" << edgeI
// << " coords:"
// << allBoundary.points()[meshPoints[e[0]]]
// << allBoundary.points()[meshPoints[e[1]]] << endl;
singleCellFeaturePointSet.insert(meshPoints[e[0]]);
singleCellFeaturePointSet.insert(meshPoints[e[1]]);
}
}
// Check for features.
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() == 2)
{
label f0 = eFaces[0];
label f1 = eFaces[1];
// check angle
const vector& n0 = allBoundary.faceNormals()[f0];
const vector& n1 = allBoundary.faceNormals()[f1];
if ((n0 & n1) < minCos)
{
const edge& e = allBoundary.edges()[edgeI];
label v0 = meshPoints[e[0]];
label v1 = meshPoints[e[1]];
label meshEdgeI = meshTools::findEdge(mesh, v0, v1);
featureEdgeSet.insert(meshEdgeI);
// Check if convex or concave by looking at angle
// between face centres and normal
vector c1c0
(
allBoundary[f1].centre(allBoundary.points())
- allBoundary[f0].centre(allBoundary.points())
);
if ((c1c0 & n0) > SMALL)
{
// Found concave edge. Make into multiCell features
Info<< "Detected concave feature edge:" << edgeI
<< " cos:" << (c1c0 & n0)
<< " coords:"
<< allBoundary.points()[v0]
<< allBoundary.points()[v1]
<< endl;
singleCellFeaturePointSet.erase(v0);
multiCellFeaturePointSet.insert(v0);
singleCellFeaturePointSet.erase(v1);
multiCellFeaturePointSet.insert(v1);
}
else
{
// Convex. singleCell feature.
if (!multiCellFeaturePointSet.found(v0))
{
singleCellFeaturePointSet.insert(v0);
}
if (!multiCellFeaturePointSet.found(v1))
{
singleCellFeaturePointSet.insert(v1);
}
}
}
}
}
// 3. Mark all feature faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// Face centres that need inclusion in the dual mesh
labelHashSet featureFaceSet(mesh.nFaces()-mesh.nInternalFaces());
// A. boundary faces.
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
{
featureFaceSet.insert(faceI);
}
// B. face zones.
const faceZoneMesh& faceZones = mesh.faceZones();
if (doNotPreserveFaceZones)
{
if (faceZones.size() > 0)
{
WarningIn("simpleMarkFeatures(..)")
<< "Detected " << faceZones.size()
<< " faceZones. These will not be preserved."
<< endl;
}
}
else
{
if (faceZones.size() > 0)
{
Info<< "Detected " << faceZones.size()
<< " faceZones. Preserving these by marking their"
<< " points, edges and faces as features." << endl;
}
forAll(faceZones, zoneI)
{
const faceZone& fz = faceZones[zoneI];
Info<< "Inserting all faces in faceZone " << fz.name()
<< " as features." << endl;
forAll(fz, i)
{
label faceI = fz[i];
const face& f = mesh.faces()[faceI];
const labelList& fEdges = mesh.faceEdges()[faceI];
featureFaceSet.insert(faceI);
forAll(f, fp)
{
// Mark point as multi cell point (since both sides of
// face should have different cells)
singleCellFeaturePointSet.erase(f[fp]);
multiCellFeaturePointSet.insert(f[fp]);
// Make sure there are points on the edges.
featureEdgeSet.insert(fEdges[fp]);
}
}
}
}
// Transfer to arguments
featureFaces = featureFaceSet.toc();
featureEdges = featureEdgeSet.toc();
singleCellFeaturePoints = singleCellFeaturePointSet.toc();
multiCellFeaturePoints = multiCellFeaturePointSet.toc();
}
// Dump features to .obj files
void dumpFeatures
(
const polyMesh& mesh,
const labelList& featureFaces,
const labelList& featureEdges,
const labelList& singleCellFeaturePoints,
const labelList& multiCellFeaturePoints
)
{
{
OFstream str("featureFaces.obj");
Info<< "Dumping centres of featureFaces to obj file " << str.name()
<< endl;
forAll(featureFaces, i)
{
meshTools::writeOBJ(str, mesh.faceCentres()[featureFaces[i]]);
}
}
{
OFstream str("featureEdges.obj");
Info<< "Dumping featureEdges to obj file " << str.name() << endl;
label vertI = 0;
forAll(featureEdges, i)
{
const edge& e = mesh.edges()[featureEdges[i]];
meshTools::writeOBJ(str, mesh.points()[e[0]]);
vertI++;
meshTools::writeOBJ(str, mesh.points()[e[1]]);
vertI++;
str<< "l " << vertI-1 << ' ' << vertI << nl;
}
}
{
OFstream str("singleCellFeaturePoints.obj");
Info<< "Dumping featurePoints that become a single cell to obj file "
<< str.name() << endl;
forAll(singleCellFeaturePoints, i)
{
meshTools::writeOBJ(str, mesh.points()[singleCellFeaturePoints[i]]);
}
}
{
OFstream str("multiCellFeaturePoints.obj");
Info<< "Dumping featurePoints that become multiple cells to obj file "
<< str.name() << endl;
forAll(multiCellFeaturePoints, i)
{
meshTools::writeOBJ(str, mesh.points()[multiCellFeaturePoints[i]]);
}
}
}
int main(int argc, char *argv[])
{
argList::noParallel();
# include "addTimeOptions.H"
argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("splitAllFaces", "");
argList::validOptions.insert("doNotPreserveFaceZones", "");
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedList<1> isBoundaryEdge(mesh.nEdges());
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
{
const labelList& fEdges = mesh.faceEdges()[faceI];
forAll(fEdges, i)
{
isBoundaryEdge.set(fEdges[i], 1);
}
}
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
Info<< "Feature:" << featureAngle << endl
<< "minCos :" << minCos << endl
<< endl;
const bool splitAllFaces = args.options().found("splitAllFaces");
const bool overwrite = args.options().found("overwrite");
const bool doNotPreserveFaceZones = args.options().found
(
"doNotPreserveFaceZones"
);
// Face(centre)s that need inclusion in the dual mesh
labelList featureFaces;
// Edge(centre)s ,,
labelList featureEdges;
// Points (that become a single cell) that need inclusion in the dual mesh
labelList singleCellFeaturePoints;
// Points (that become a mulitple cells) ,,
labelList multiCellFeaturePoints;
// Sample implementation of feature detection.
simpleMarkFeatures
(
mesh,
isBoundaryEdge,
featureAngle,
doNotPreserveFaceZones,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints
);
// If we want to split all polyMesh faces into one dualface per cell
// we are passing through we also need a point
// at the polyMesh facecentre and edgemid of the faces we want to
// split.
if (splitAllFaces)
{
featureEdges = identity(mesh.nEdges());
featureFaces = identity(mesh.nFaces());
}
// Write obj files for debugging
dumpFeatures
(
mesh,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints
);
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
// Read vol fields.
PtrList<volScalarField> vsFlds;
ReadFields(mesh, objects, vsFlds);
PtrList<volVectorField> vvFlds;
ReadFields(mesh, objects, vvFlds);
PtrList<volSphericalTensorField> vstFlds;
ReadFields(mesh, objects, vstFlds);
PtrList<volSymmTensorField> vsymtFlds;
ReadFields(mesh, objects, vsymtFlds);
PtrList<volTensorField> vtFlds;
ReadFields(mesh, objects, vtFlds);
// Read surface fields.
PtrList<surfaceScalarField> ssFlds;
ReadFields(mesh, objects, ssFlds);
PtrList<surfaceVectorField> svFlds;
ReadFields(mesh, objects, svFlds);
PtrList<surfaceSphericalTensorField> sstFlds;
ReadFields(mesh, objects, sstFlds);
PtrList<surfaceSymmTensorField> ssymtFlds;
ReadFields(mesh, objects, ssymtFlds);
PtrList<surfaceTensorField> stFlds;
ReadFields(mesh, objects, stFlds);
// Topo change container
polyTopoChange meshMod(mesh.boundaryMesh().size());
// Mesh dualiser engine
meshDualiser dualMaker(mesh);
// Insert all commands into polyTopoChange to create dual of mesh. This does
// all the hard work.
dualMaker.setRefinement
(
splitAllFaces,
featureFaces,
featureEdges,
singleCellFeaturePoints,
multiCellFeaturePoints,
meshMod
);
// Create mesh, return map from old to new mesh.
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
// Update fields
mesh.updateMesh(map);
// Optionally inflate mesh
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
if (!overwrite)
{
runTime++;
mesh.setInstance(runTime.timeName());
}
Info<< "Writing dual mesh to " << runTime.timeName() << endl;
mesh.write();
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,262 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
meshDualiser
Description
Creates dual of polyMesh. Every point becomes a cell (or multiple cells
for feature points), a walk around every edge creates faces between them.
Put all points you want in the final mesh into featurePoints; all edge(mid)s
you want in the final mesh into featureEdges; all face(centre)s in
faceFaces.
Usually to preserve boundaries:
- all boundary faces are featureFaces
- all edges and points inbetween different patches are
featureEdges/points.
In same way you can also preserve internal faces (e.g. faceZones)
SourceFiles
meshDualiser.C
\*---------------------------------------------------------------------------*/
#ifndef meshDualiser_H
#define meshDualiser_H
#include "DynamicList.H"
#include "PackedList.H"
#include "boolList.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
class polyTopoChange;
/*---------------------------------------------------------------------------*\
Class meshDualiser Declaration
\*---------------------------------------------------------------------------*/
class meshDualiser
{
// Private data
const polyMesh& mesh_;
//- From point on cell to dual cell. Either single entry or
// one entry per pointCells
labelListList pointToDualCells_;
//- From point to dual point (or -1 if not feature point).
labelList pointToDualPoint_;
//- From cell to dual point. All cells become point
labelList cellToDualPoint_;
//- From face to dual point (or -1 if not feature face)
labelList faceToDualPoint_;
//- From edge to dual point (or -1 if not feature edge)
labelList edgeToDualPoint_;
// Private Member Functions
static void checkPolyTopoChange(const polyTopoChange&);
static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
//- Find dual cell given point and cell
label findDualCell(const label cellI, const label pointI) const;
//- Helper function to generate dualpoints on all boundary edges
// emanating from (boundary & feature) point
void generateDualBoundaryEdges
(
const PackedList<1>&,
const label pointI,
polyTopoChange&
);
//- Check that owner and neighbour of face have same dual cell
bool sameDualCell
(
const label faceI,
const label pointI
) const;
//- Add internal face
label addInternalFace
(
const label masterPointI,
const label masterEdgeI,
const label masterFaceI,
const bool edgeOrder,
const label dualCell0,
const label dualCell1,
const DynamicList<label>& verts,
polyTopoChange& meshMod
) const;
//- Add boundary face
label addBoundaryFace
(
const label masterPointI,
const label masterEdgeI,
const label masterFaceI,
const label dualCellI,
const label patchI,
const DynamicList<label>& verts,
polyTopoChange& meshMod
) const;
//- Create internal faces walking around edge
void createFacesAroundEdge
(
const bool splitFace,
const PackedList<1>&,
const label edgeI,
const label startFaceI,
polyTopoChange&,
boolList& doneEFaces
) const;
//- Create single internal face from internal face
void createFaceFromInternalFace
(
const label faceI,
label& fp,
polyTopoChange&
) const;
//- Creates boundary faces walking around point on patchI.
void createFacesAroundBoundaryPoint
(
const label patchI,
const label patchPointI,
const label startFaceI,
polyTopoChange&,
boolList& donePFaces // pFaces visited
) const;
//- Disallow default bitwise copy construct
meshDualiser(const meshDualiser&);
//- Disallow default bitwise assignment
void operator=(const meshDualiser&);
public:
//- Runtime type information
ClassName("meshDualiser");
// Constructors
//- Construct from mesh
meshDualiser(const polyMesh&);
// Member Functions
// Access
//- From point on cell to dual cell. Either single entry or
// one entry per pointCells.
const labelListList& pointToDualCells() const
{
return pointToDualCells_;
}
//- From point to dual point (or -1 if not feature point).
const labelList& pointToDualPoint() const
{
return pointToDualPoint_;
}
//- From cell to dual point (at cell centre). All cells become
// points.
const labelList& cellToDualPoint() const
{
return cellToDualPoint_;
}
//- From face to dual point (at face centre; or -1 if not
// feature face).
const labelList& faceToDualPoint() const
{
return faceToDualPoint_;
}
//- From edge to dual point (at edge mid; or -1 if not feature
// edge).
const labelList& edgeToDualPoint() const
{
return edgeToDualPoint_;
}
// Edit
//- Insert all changes into meshMod to convert the polyMesh into
// its dual.
// featureFaces : faces where we want a point at the face centre
// featureEdges : edges ,, edge mid
// featurePoints : points ,, point. Two variants:
// singleCellFeaturePoints : point becomes one dualcell.
// Use this for e.g. convex boundary points.
// multiCellFeaturePoints : one dualcell per original cell
// around point. Use this for e.g. concave boundary points
// since it prevents big concave boundary cells.
void setRefinement
(
const bool splitFace,
const labelList& featureFaces,
const labelList& featureEdges,
const labelList& singleCellFeaturePoints,
const labelList& multiCellFeaturePoints,
polyTopoChange& meshMod
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -292,6 +292,7 @@ meshQualityControls
minFlatness 0.5;
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;

View File

@ -109,7 +109,7 @@ Foam::label Foam::checkTopology
{
Info<< " Number of regions: " << rs.nRegions() << " (OK)."
<< endl;
}
else
{
@ -214,7 +214,7 @@ Foam::label Foam::checkTopology
const pointField& pts = pp.points();
const labelList& mp = pp.meshPoints();
boundBox bb(vector::zero, vector::zero);
boundBox bb; // zero-sized
if (returnReduce(mp.size(), sumOp<label>()) > 0)
{
bb.min() = pts[mp[0]];

View File

@ -144,7 +144,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
wordList curPointZoneNames = pointZones().names();
if (curPointZoneNames.size() > 0)
{
pointZoneNames_.setSize(2*curPointZoneNames.size());
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
forAll (curPointZoneNames, zoneI)
@ -157,7 +157,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
if (curFaceZoneNames.size() > 0)
{
faceZoneNames_.setSize(2*curFaceZoneNames.size());
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
forAll (curFaceZoneNames, zoneI)
{
@ -169,7 +169,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
if (curCellZoneNames.size() > 0)
{
cellZoneNames_.setSize(2*curCellZoneNames.size());
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
forAll (curCellZoneNames, zoneI)
{

View File

@ -354,7 +354,7 @@ bool domainDecomposition::writeDecomposition()
// Estimate size
forAll(zonePoints, zoneI)
{
zonePoints[zoneI].setSize(pz[zoneI].size() / nProcs_);
zonePoints[zoneI].setCapacity(pz[zoneI].size() / nProcs_);
}
// Use the pointToZone map to find out the single zone (if any),
@ -423,8 +423,8 @@ bool domainDecomposition::writeDecomposition()
{
label procSize = fz[zoneI].size() / nProcs_;
zoneFaces[zoneI].setSize(procSize);
zoneFaceFlips[zoneI].setSize(procSize);
zoneFaces[zoneI].setCapacity(procSize);
zoneFaceFlips[zoneI].setCapacity(procSize);
}
// Go through all the zoned faces and find out if they
@ -514,7 +514,7 @@ bool domainDecomposition::writeDecomposition()
// Estimate size
forAll(zoneCells, zoneI)
{
zoneCells[zoneI].setSize(cz[zoneI].size() / nProcs_);
zoneCells[zoneI].setCapacity(cz[zoneI].size() / nProcs_);
}
forAll (curCellLabels, celli)

View File

@ -45,8 +45,10 @@ Description
int main(int argc, char *argv[])
{
// enable -constant ... if someone really wants it
// enable -zeroTime to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true);
argList::noParallel();
timeSelector::addOptions();
# include "addRegionOption.H"
argList::validOptions.insert("fields", "\"(list of fields)\"");

View File

@ -273,7 +273,7 @@ autoPtr<mapPolyMesh> mergeSharedPoints
}
}
return map;
return map;
}
@ -418,11 +418,7 @@ int main(int argc, char *argv[])
// Read point on individual processors to determine merge tolerance
// (otherwise single cell domains might give problems)
boundBox bb
(
point(GREAT, GREAT, GREAT),
point(-GREAT, -GREAT, -GREAT)
);
boundBox bb = boundBox::invertedBox;
for (label procI = 0; procI < nProcs; procI++)
{

View File

@ -74,7 +74,9 @@ using namespace Foam;
int main(int argc, char *argv[])
{
// with -constant and -zeroTime
// enable -constant
// probably don't need -zeroTime though, since the fields are vetted
// afterwards anyhow
timeSelector::addOptions(true, false);
argList::noParallel();
argList::validOptions.insert("ascii", "");

View File

@ -617,8 +617,10 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
{
const labelList& eFaces = edgeFaces[edgeI];
if (eFaces.size() != 2)
if (eFaces.size() == 1)
{
// Note: could also do ones with > 2 faces but this gives
// too many zones for baffles
featEdge[edgeI] = true;
}
else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
Info<< "\nWall heat fluxes [W]" << endl;
forAll(patchHeatFlux, patchi)
{
if (typeid(mesh.boundary()) == typeid(wallFvPatch))
if (typeid(mesh.boundary()[patchi]) == typeid(wallFvPatch))
{
Info<< mesh.boundary()[patchi].name()
<< " "

View File

@ -0,0 +1,3 @@
foamUpgradeFvSolution.C
EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
foamUpgradeFvSolution
Description
Simple tool to upgrade the syntax of system/fvSolution::solvers
Usage
- foamUpgradeFvSolution [OPTION]
@param -test \n
Suppress writing the updated fvSolution file
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IOdictionary.H"
#include "solution.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("test", "");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary solutionDict
(
IOobject
(
"fvSolution",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
label nChanged = 0;
entry* e = solutionDict.lookupEntryPtr("solvers", false, false);
if (e && e->isDict())
{
nChanged = solution::upgradeSolverDict(e->dict(), true);
}
Info<< nChanged << " solver settings changed" << nl << endl;
if (nChanged)
{
if (args.options().found("test"))
{
Info<< "-test option: no changes made" << nl << endl;
}
else
{
mv
(
solutionDict.objectPath(),
solutionDict.objectPath() + ".old"
);
solutionDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl
<< "Write to " << solutionDict.objectPath() << nl << endl;
}
}
return 0;
}
// ************************************************************************* //

View File

@ -29,7 +29,6 @@ License
#include "GeometricField.H"
#include "meshToMesh.H"
#include "cuttingPlane.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -199,7 +199,6 @@ int main(int argc, char *argv[])
if (args.options().found("clean"))
{
surf.cleanup(true);
surf.checkOrientation(true);
}
if (fromCsys.valid())

View File

@ -104,13 +104,19 @@ int main(int argc, char *argv[])
{
triSurface surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.checkOrientation(true);
surf.writeStats(Info);
Info<< endl;
}
Info << "writing " << exportName;
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
@ -119,6 +125,8 @@ int main(int argc, char *argv[])
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
// write sorted by region
@ -128,34 +136,16 @@ int main(int argc, char *argv[])
{
UnsortedMeshedSurface<face> surf(importName);
if (args.options().found("clean"))
{
surf.cleanup(true);
surf.checkOrientation(true);
}
Info << "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
}
surf.write(exportName);
}
#if 1
else if (args.options().found("triFace"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.checkOrientation(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
@ -167,6 +157,39 @@ int main(int argc, char *argv[])
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
#if 1
else if (args.options().found("triFace"))
{
MeshedSurface<triFace> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
if (scaleFactor <= 0)
{
Info<< " without scaling" << endl;
}
else
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}
@ -175,10 +198,16 @@ int main(int argc, char *argv[])
{
MeshedSurface<face> surf(importName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
if (args.options().found("clean"))
{
Info<< "Cleaning up surface" << endl;
surf.cleanup(true);
surf.checkOrientation(true);
surf.writeStats(Info);
Info<< endl;
}
Info<< "writing " << exportName;
@ -190,6 +219,8 @@ int main(int argc, char *argv[])
{
Info<< " with scaling " << scaleFactor << endl;
surf.scalePoints(scaleFactor);
surf.writeStats(Info);
Info<< endl;
}
surf.write(exportName);
}

View File

@ -50,9 +50,9 @@ then
*/applications/solvers/*.C | */applications/utilities/*.C )
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-top.awk
;;
*/applications/solvers/*.H | */applications/utilities/*.H )
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk
;;
# */applications/solvers/*.H | */applications/utilities/*.H )
# awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk
# ;;
esac
awk -f $awkScript $1 | \

View File

@ -1,70 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# foamCheckSourceDeps
#
# Description
# Usage: foamCheckSourceDeps [dir1 .. dirN]
#
# Search for *.dep files that are without a corresponding .C or .L file.
# These could indicate a directory that has been moved.
# - print questionable directory and dep file
#------------------------------------------------------------------------------
if [ "$1" = "-h" -o "$1" = "-help" ]
then
cat <<USAGE 1>&2
Usage: ${0##*/} [dir1 .. dirN]
Search for .dep files that are without a corresponding .C or .L file.
This could indicate a directory that has been moved.
- print questionable directory and file
USAGE
exit 1
fi
if [ "$#" -eq 0 ]
then
set -- .
fi
for checkDir
do
if [ -d $checkDir ]
then
find $checkDir -name '*.dep' -print | while read depFile;
do
Cfile=$(echo $depFile | sed -e 's/\.dep$/.C/')
# also check flex files
Lfile=$(echo $depFile | sed -e 's/\.C$/.L/')
if [ ! -f $Cfile -a ! -f $Lfile ]
then
echo "$(dirname $Cfile) ${depFile##*/}"
fi
done
fi
done
# -----------------------------------------------------------------------------

View File

@ -31,19 +31,19 @@
#
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION]
options:
-case dir specify alternative case directory
-region name specify mesh region name
-touch create the .OpenFOAM file only and exit
-touch only create the .OpenFOAM file
* start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE
exit 1
exit 1
}
unset regionName touchOnly
@ -51,81 +51,83 @@ unset regionName touchOnly
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-case)
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
caseDir=$2
shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
-region)
[ "$#" -ge 2 ] || usage "'-region' option requires an argument"
regionName=$2
shift 2
;;
-touch)
touchOnly=1
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
case "$1" in
-h | -help)
usage
;;
-case)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
shift 2
;;
-region)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
regionName=$2
shift 2
;;
-touch)
touchOnly=true
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
# get a sensible caseName
caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM"
fvControls="system"
if [ -n "$regionName" ]
then
caseFile="$caseName{$regionName}.OpenFOAM"
caseFile="$caseName{$regionName}.OpenFOAM"
fvControls="$fvControls/$regionName"
fi
if [ -n "$touchOnly" ];
if [ -n "$touchOnly" ]
then
touch "$caseFile"
echo "created '$caseFile'"
exit 0
touch "$caseFile"
echo "created '$caseFile'"
exit 0
fi
# parent directory for normal or parallel results
case "$caseName" in
processor*) parentDir=".." ;;
*) parentDir="." ;;
processor*) parentDir=".." ;;
*) parentDir="." ;;
esac
# check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done
case "$ParaView_VERSION" in
2*)
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
paraview paraFoam.pvs
;;
paraview paraFoam.pvs
;;
*)
# only create/remove caseFile if it doesn't exist
[ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
echo "created temporary '$caseFile'"
}
# only create/remove caseFile if it didn't already exist
[ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
echo "created temporary '$caseFile'"
}
paraview --data="$caseFile"
;;
paraview --data="$caseFile"
;;
esac
#------------------------------------------------------------------------------

109
bin/rmdepold Executable file
View File

@ -0,0 +1,109 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# rmdepold
#
# Description
# Usage: rmdepold [dir1 .. dirN]
#
# Remove *.dep files that are without a corresponding .C or .L file.
# This often occurs when a directory has been moved.
# - print questionable directory and the *.dep file
# - optionally remove empty directories
#------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE 1>&2
Usage: ${0##*/} [OPTION] [dir1 .. dirN]
options:
-rmdir find and remove empty directories (recursively)
Remove *.dep files that are without a corresponding .C or .L file.
This often occurs when a directory has been moved.
- print questionable directory and file
- optionally remove empty directories
USAGE
exit 1
}
unset optRmdir
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-rmdir)
optRmdir=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# default is the current directory
[ "$#" -gt 0 ] || set -- .
for checkDir
do
if [ -d $checkDir ]
then
echo "searching: $checkDir"
else
echo "skipping non-dir: $checkDir"
continue
fi
find $checkDir -name '*.dep' -print | while read depFile
do
# check C++ and Flex files
if [ ! -r "${depFile%dep}C" -a ! -r "${depFile%dep}L" ];
then
echo "rm $depFile"
rm -f $depFile 2>/dev/null
fi
done
# remove empty dirs
if [ "$optRmdir" ]
then
# get subdirs ourselves so we can avoid particular directories
for dir in $(find $checkDir -mindepth 1 -maxdepth 1 -type d \( -name .git -prune -o -print \) )
do
echo "check dir: $dir"
find $dir -depth -type d -empty -exec rmdir {} \; -print
done
fi
done
# -----------------------------------------------------------------------------

View File

@ -1,2 +1,2 @@
Misc. tools for building applications, etc that are useful to have
but which don't really need to be in the PATH.
Misc. tools, scripts, templates that are useful (eg, for building applications)
but don't need to be in the PATH.

View File

@ -538,6 +538,7 @@ EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
@ -787,6 +788,10 @@ TREEVIEW_WIDTH = 250
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# Path for OpenCFD LaTeX macros
@INCLUDE_PATH = $(WM_PROJECT_DIR)/doc/Doxygen/Macros/
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
@ -824,7 +829,7 @@ PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
EXTRA_PACKAGES = $(WM_PROJECT_DIR)/doc/Doxygen/Macros/tensorOperator
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until

View File

@ -0,0 +1,129 @@
%-----------------------------------------------------------------------------
% ========= |
% \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
% \\ / O peration |
% \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
% Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
%
% LaTeX Style file
% tensorOperator.sty
%
% Description
% Standard OpenCFD LaTeX macros for typesetting tensor algebra.
%
%------------------------------------------------------------------------------
% tensor style
% ~~~~~~~~~~~~
\renewcommand{\vec}[1] {\ensuremath{\mathbf #1}}
\newcommand{\gvec}[1] {\ensuremath{\mbox{\boldmath$\bf#1$}}}
% products
% ~~~~~~~~
\newcommand{\anyprod}{\star}
\newcommand{\cprod} {\times}
\newcommand{\dprod} {\,{\scriptscriptstyle \stackrel{\bullet}{{}}}\,}
\newcommand{\ddprod} {\,{\scriptscriptstyle \stackrel{\bullet}{\bullet}}\,}
\newcommand{\tdprod} {\,{\scriptscriptstyle \stackrel{3}{\bullet}}\,}
\newcommand{\tprod} {\,{\scriptscriptstyle \stackrel{\otimes}{{}}}\,}
% operations
% ~~~~~~~~~~
\newcommand{\adj} {\ensuremath{\operatorname{adj}}}
\newcommand{\cof} {\ensuremath{\operatorname{cof}}}
\newcommand{\diag} {\ensuremath{\operatorname{diag}}}
\newcommand{\dev} {\ensuremath{\operatorname{dev}}}
\newcommand{\Hodge} {\ensuremath{\operatorname{\stackrel{\displaystyle \ast}{}}}}
\newcommand{\hyd} {\ensuremath{\operatorname{hyd}}}
\renewcommand{\max} {\ensuremath{\operatorname{max}}}
\renewcommand{\min} {\ensuremath{\operatorname{min}}}
\newcommand{\inv} {\ensuremath{\operatorname{inv}}}
\newcommand{\sym} {\ensuremath{\operatorname{symm}}} % symm ?
\newcommand{\skw} {\ensuremath{\operatorname{skew}}} % skew already defined
\newcommand{\tr} {\ensuremath{\operatorname{tr}}}
\newcommand{\trans}[1] {\ensuremath{#1^{\operatorname{T}}}}
% alternative tensor operators for hypersonics etc.
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\newcommand{\devs}[1] {\overset{\scriptscriptstyle\circ}{#1}}
%\newcommand{\trans}[1] {\ensuremath{#1^{\operatorname{T}}}}
\newcommand{\symms}[1] {\overleftrightarrow{#1}}
\newlength{\skewslength}
\newlength{\skewsheight}
\newcommand{\skews}[1]{
\settowidth{\skewslength}{#1}%
\settoheight{\skewsheight}{#1}%
\addtolength{\skewsheight}{0.4mm}%
{\overleftrightarrow{#1}\hspace{-.5\skewslength}%
\rule[\skewsheight]{.4pt}{1.4mm}
\hspace{.5\skewslength}%
}}
%\newcommand{\skew}[1] {\ensuremath{#1^{\operatorname{A}}}}
% spatial derivatives
% ~~~~~~~~~~~~~~~~~~~
\newcommand{\curl}{\ensuremath{\nabla\cprod}}
\renewcommand{\div} {\ensuremath{\nabla\dprod}}
\newcommand{\grad}{\ensuremath{\nabla}}
\newcommand{\laplacian}{\ensuremath{\nabla^{2}}}
% temporal derivatives
% ~~~~~~~~~~~~~~~~~~~~
\newcommand{\ddt}[1] {\ensuremath{\frac{\partial #1}{\partial t }}}
\newcommand{\DDt}[1] {\ensuremath{\frac{D #1}{D t}}}
\newcommand{\DpDt}[2] {\ensuremath{\frac{d_{#1} #2}{d t }}}
\newcommand{\dsdts}[1] {\ensuremath{\frac{\partial ^2 #1}{\partial t^2}}}
\newcommand{\rate}[1] {\ensuremath{\dot{#1}}}
\newcommand{\genDer}{\mathcal{L}}
% time average symbols
% ~~~~~~~~~~~~~~~~~~~~
\newcommand{\av}[1] {\ensuremath{\overline{#1}}}
\newcommand{\corrtwo}[2] {{\dwea{\dprime{#1} \dprime{#2}}}}
\newcommand{\curly}[1] {{\cal #1}}
\newcommand{\dprime}[1] {\ensuremath{{#1}^{^{\prime \prime}}}}
\newcommand{\dwea}[1] {\ensuremath{\widetilde{#1}}}
\newcommand{\dweafluc}[1] {\ensuremath{\dprime{#1}}}
\newcommand{\fluc}[1] {\ensuremath{#1^{\prime}}}
% index style
% ~~~~~~~~~~~
\newcommand{\veci}[2][i] {\ensuremath{#2_{#1}}}
\newcommand{\teni}[2][ij] {\ensuremath{#2_{#1}}}
\newcommand{\tenTi}[2][ji] {\ensuremath{#2_{#1}}}
% index operations
% ~~~~~~~~~~~~~~~~
\newcommand{\deltai}[1] {\ensuremath{\partial_{#1}}}
% Sub-subscripts
% ~~~~~~~~~~~~~~
\newcommand{\eff} {{\scriptscriptstyle e\!f\!\!f\!}}
% unknown use
% ~~~~~~~~~~~
%\font\bigtenrm=cmr12 scaled 1200
%\newcommand{\eexp}[1]{{\hbox{$\textfont1=\bigtenrm e$}}^{\raise3pt
%\hbox{$#1$}}}
% ------------------------------------------------------------------------------

View File

@ -187,7 +187,7 @@ case MPICH-GM:
setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpich-gm
breaksw
case MPICH-GM:
case HPMPI:
setenv MPI_HOME /opt/hpmpi
setenv MPI_ARCH_PATH $MPI_HOME
setenv MPICH_ROOT=$MPI_ARCH_PATH

View File

@ -2,6 +2,7 @@ signals/sigFpe.C
signals/sigSegv.C
signals/sigInt.C
signals/sigQuit.C
regExp.C
timer.C
fileStat.C
Unix.C

View File

@ -0,0 +1,196 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include <sys/types.h>
#include "regExp.H"
#include "label.H"
#include "string.H"
#include "List.H"
#include "IOstreams.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::regExp::compile(const char* pat) const
{
clear();
preg_ = new regex_t;
if (regcomp(preg_, pat, REG_EXTENDED) != 0)
{
FatalErrorIn
(
"regExp::compile(const char*)"
) << "Failed to compile regular expression '" << pat << "'"
<< exit(FatalError);
}
}
void Foam::regExp::clear() const
{
if (preg_)
{
regfree(preg_);
delete preg_;
preg_ = 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regExp::regExp()
:
preg_(0)
{}
Foam::regExp::regExp(const string& pat)
:
preg_(0)
{
compile(pat.c_str());
}
Foam::regExp::regExp(const char* pat)
:
preg_(0)
{
compile(pat);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regExp::~regExp()
{
clear();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
int Foam::regExp::ngroups() const
{
return preg_ ? preg_->re_nsub : 0;
}
bool Foam::regExp::match
(
const string& str,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = 1;
regmatch_t pmatch[1];
// match and also verify that the entire string was matched
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
return true;
}
}
return false;
}
bool Foam::regExp::match
(
const string& str,
List<string>& groups,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = ngroups() + 1;
regmatch_t pmatch[nmatch];
// match and also verify that the entire string was matched
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
groups.setSize(ngroups());
label groupI = 0;
for (size_t matchI = 1; matchI < nmatch; matchI++)
{
if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1)
{
groups[groupI] = str.substr
(
pmatch[matchI].rm_so,
pmatch[matchI].rm_eo - pmatch[matchI].rm_so
);
}
else
{
groups[groupI].clear();
}
groupI++;
}
return true;
}
}
groups.clear();
return false;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::regExp::operator=(const string& pat)
{
compile(pat.c_str());
}
void Foam::regExp::operator=(const char* pat)
{
compile(pat);
}
// ************************************************************************* //

View File

@ -23,19 +23,26 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::regularExpression
Foam::regExp
Description
Wrapper around regular expressions.
Wrapper around POSIX extended regular expressions.
The beginning-of-line (^) and the end-of-line ($) anchors are implicit
by default.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
These differ somewhat from @c Perl and @c sed regular expressions.
SourceFiles
regExp.C
\*---------------------------------------------------------------------------*/
#ifndef regularExpression_H
#define regularExpression_H
#ifndef regExp_H
#define regExp_H
#include <sys/types.h>
#include <regex.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,70 +50,81 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class string;
template<class T> class List;
/*---------------------------------------------------------------------------*\
Class regularExpression Declaration
Class regExp Declaration
\*---------------------------------------------------------------------------*/
class regularExpression
class regExp
{
// Private data
//- Precompiled regular expression
regex_t* preg_;
mutable regex_t* preg_;
// Private member functions
//- release allocated space
void clear() const;
//- compile into a regular expression
void compile(const char*) const;
//- Disallow default bitwise copy construct
regularExpression(const regularExpression&);
regExp(const regExp&);
//- Disallow default bitwise assignment
void operator=(const regularExpression&);
void operator=(const regExp&);
public:
// Constructors
//- Construct null
regExp();
//- Construct from string
inline regularExpression(const string& s)
{
preg_ = new regex_t;
if (regcomp(preg_, s.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
{
FatalErrorIn
(
"regularExpression::regularExpression(const char*)"
) << "Failed to compile regular expression " << s
<< exit(FatalError);
}
}
regExp(const string&);
//- Construct from character array
regExp(const char*);
// Destructor
//- Construct from string
inline ~regularExpression()
{
if (preg_)
{
regfree(preg_);
delete preg_;
}
}
~regExp();
// Member functions
//- Matches?
inline bool matches(const string& s) const
{
size_t nmatch = 0;
regmatch_t *pmatch = NULL;
//- Return the number of (groups)
int ngroups() const;
//- Return true if it matches, partial matches are optional
bool match
(
const string&,
bool partialMatch=false
) const;
//- Return true if it matches and sets the sub-groups matched,
// partial matches are optional
bool match
(
const string&,
List<string>& groups,
bool partialMatch=false
) const;
// Member Operators
//- Assign from a string
void operator=(const string&);
//- Assign from a character array
void operator=(const char*);
return regexec(preg_, s.c_str(), nmatch, pmatch, 0) == 0;
}
};

View File

@ -28,23 +28,23 @@ License
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// Construct from Istream
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList(Istream& is)
:
List<T>(is),
allocSize_(List<T>::size())
capacity_(List<T>::size())
{}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& DL
Ostream& os,
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
)
{
os << static_cast<const List<T>&>(DL);
os << static_cast<const List<T>&>(lst);
return os;
}
@ -52,12 +52,12 @@ Foam::Ostream& Foam::operator<<
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& DL
Istream& is,
DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
)
{
is >> static_cast<List<T>&>(DL);
DL.allocSize_ = DL.List<T>::size();
is >> static_cast<List<T>&>(lst);
lst.capacity_ = lst.List<T>::size();
return is;
}

View File

@ -32,7 +32,7 @@ Description
Internal storage is a compact array and the list can be shrunk to compact
storage. The increase of list size is controlled by three template
parameters, which allows the list storage to either increase by the given
increment or the given multiplier and divider (allowing non-integer
increment or by the given multiplier and divider (allowing non-integer
multiples).
SourceFiles
@ -81,14 +81,11 @@ class DynamicList
{
// Private data
//- Allocated size for underlying List.
label allocSize_;
//- The capacity (allocated size) of the underlying list.
label capacity_;
// Private Member Functions
// Disabled, since the usefulness and semantics are not quite clear
void setSize(const label, const T&);
public:
// Related types
@ -116,20 +113,30 @@ public:
// Access
//- Size of the underlying storage.
inline label allocSize() const;
inline label capacity() const;
// Edit
//- Alter the list size.
// When the new size is greater than the addressed list size, the
// allocated list sizes is adjusted and the
// addressed size does not change.
// Otherwise the addressed list size is just reduced and the
// allocated size does not change.
//- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched.
// Use this or reserve() in combination with append().
inline void setCapacity(const label);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
inline void setSize(const label);
//- Clear the list, i.e. set the size to zero.
//- Alter the addressed list size and fill new space with a constant.
inline void setSize(const label, const T&);
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size, use setCapacity() for that.
inline void reserve(const label);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
@ -152,6 +159,9 @@ public:
//- Append an element at the end of the list
inline void append(const T& e);
//- Append a List at the end of this list
inline void append(const UList<T>&);
//- Remove and return the top element
inline T remove();
@ -162,7 +172,7 @@ public:
inline void operator=(const T&);
//- Assignment from List<T>. Also handles assignment from DynamicList.
inline void operator=(const List<T>&);
inline void operator=(const UList<T>&);
// IOstream operators

View File

@ -30,7 +30,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
:
List<T>(SizeInc),
allocSize_(SizeInc)
capacity_(SizeInc)
{
List<T>::size(0);
}
@ -39,11 +39,11 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
(
const label s
const label nElem
)
:
List<T>(s),
allocSize_(s)
List<T>(nElem),
capacity_(nElem)
{
List<T>::size(0);
}
@ -56,39 +56,101 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
)
:
List<T>(lst),
allocSize_(lst.size())
capacity_(lst.size())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::label Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::allocSize()
inline Foam::label Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::capacity()
const
{
return allocSize_;
return capacity_;
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
(
const label nElem
)
{
label nextFree = List<T>::size();
capacity_ = nElem;
if (nextFree > capacity_)
{
// truncate addressed sizes too
nextFree = capacity_;
}
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
(
const label nElem
)
{
// allocate more capacity?
if (nElem > capacity_)
{
capacity_ = max
(
nElem,
label(SizeInc + capacity_ * SizeMult / SizeDiv)
);
// adjust allocated size, leave addressed size untouched
label nextFree = List<T>::size();
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
(
const label s
const label nElem
)
{
// allocate more capacity?
if (nElem > capacity_)
{
capacity_ = max
(
nElem,
label(SizeInc + capacity_ * SizeMult / SizeDiv)
);
List<T>::setSize(capacity_);
}
// adjust addressed size
List<T>::size(nElem);
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
(
const label nElem,
const T& t
)
{
label nextFree = List<T>::size();
if (s <= nextFree)
setSize(nElem);
// set new elements to constant value
while (nextFree < nElem)
{
// adjust addressed size, leave allocated size untouched
nextFree = s;
this->operator[](nextFree++) = t;
}
else
{
// adjust allocated size, leave addressed size untouched
allocSize_ = s;
List<T>::setSize(allocSize_);
}
List<T>::size(nextFree);
}
@ -103,7 +165,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
{
List<T>::clear();
allocSize_ = 0;
capacity_ = 0;
}
@ -111,13 +173,15 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
{
if (allocSize_ > List<T>::size())
label nextFree = List<T>::size();
if (capacity_ > nextFree)
{
allocSize_ = List<T>::size();
// force re-allocation/copying in List<T>::setSize() by temporarily
// faking a larger list size that will be truncated
List<T>::size(allocSize_+1);
List<T>::setSize(allocSize_);
// use the full list when resizing
List<T>::size(capacity_);
// the new size
capacity_ = nextFree;
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
return *this;
}
@ -127,7 +191,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst)
{
allocSize_ = lst.size();
capacity_ = lst.size();
List<T>::transfer(lst); // take over storage, clear addressing for lst.
}
@ -140,41 +204,58 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
)
{
// take over storage as-is (without shrink), clear addressing for lst.
allocSize_ = lst.allocSize_;
lst.allocSize_ = 0;
capacity_ = lst.capacity_;
lst.capacity_ = 0;
List<T>::transfer(static_cast<List<T>&>(lst));
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append(const T& e)
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const T& t
)
{
label elemI = List<T>::size();
setSize(elemI + 1);
this->operator[](elemI) = t;
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
(
const UList<T>& lst
)
{
// Work on copy free index since gets overwritten by setSize
label nextFree = List<T>::size();
nextFree++;
if (nextFree > allocSize_)
if (this == &lst)
{
allocSize_ = max
FatalErrorIn
(
nextFree,
label(SizeMult*allocSize_/SizeDiv + SizeInc)
);
List<T>::setSize(allocSize_);
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::append"
"(const UList<T>&)"
) << "attempted appending to self" << abort(FatalError);
}
List<T>::size(nextFree);
setSize(nextFree + lst.size());
this->operator[](nextFree - 1) = e;
forAll(lst, elemI)
{
this->operator[](nextFree++) = lst[elemI];
}
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
{
if (List<T>::size() == 0)
label elemI = List<T>::size() - 1;
if (elemI < 0)
{
FatalErrorIn
(
@ -182,11 +263,9 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
) << "List is empty" << abort(FatalError);
}
label nextFree = List<T>::size()-1;
const T& val = List<T>::operator[](elemI);
const T& val = List<T>::operator[](nextFree);
List<T>::size(nextFree);
List<T>::size(elemI);
return val;
}
@ -197,26 +276,15 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
(
const label i
const label elemI
)
{
label nextFree = List<T>::size();
nextFree = max(nextFree, i + 1);
if (nextFree > allocSize_)
if (elemI >= List<T>::size())
{
allocSize_ = max
(
nextFree,
label(SizeMult*allocSize_/SizeDiv + SizeInc)
);
List<T>::setSize(allocSize_);
setSize(elemI + 1);
}
List<T>::size(nextFree);
return this->operator[](i);
return this->operator[](elemI);
}
@ -226,21 +294,39 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
const T& t
)
{
List<T>::operator=(t);
UList<T>::operator=(t);
}
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
(
const List<T>& lst
const UList<T>& lst
)
{
// make the entire storage available for the copy operation:
List<T>::size(allocSize_);
if (this == &lst)
{
FatalErrorIn
(
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator="
"(const UList<T>&)"
) << "attempted assignment to self" << abort(FatalError);
}
List<T>::operator=(lst);
allocSize_ = List<T>::size();
if (capacity_ >= lst.size())
{
// can copy w/o reallocating, match initial size to avoid reallocation
List<T>::size(lst.size());
List<T>::operator=(lst);
}
else
{
// make everything available for the copy operation
List<T>::size(capacity_);
List<T>::operator=(lst);
capacity_ = List<T>::size();
}
}

View File

@ -432,14 +432,19 @@ void Foam::List<T>::transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>& a)
{
// shrink the allocated space to the number of elements used
a.shrink();
transfer(static_cast<List<T>&>(a));
a.clearStorage();
}
if (this->v_) delete[] this->v_;
this->size_ = a.size_;
this->v_ = a.v_;
a.size_ = 0;
a.v_ = 0;
a.allocSize_ = 0;
// Transfer the contents of the argument SortableList into this List
// and anull the argument list
template<class T>
void Foam::List<T>::transfer(SortableList<T>& a)
{
// shrink away the sort indices
a.shrink();
transfer(static_cast<List<T>&>(a));
}

View File

@ -63,7 +63,8 @@ template<class T, label Size> class FixedList;
template<class T> class PtrList;
template<class T> class SLList;
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
class DynamicList;
class DynamicList;
template<class T> class SortableList;
template<class T> class IndirectList;
template<class T> class BiIndirectList;
@ -173,6 +174,10 @@ public:
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
void transfer(DynamicList<T, SizeInc, SizeMult, SizeDiv>&);
//- Transfer the contents of the argument List into this List
// and annull the argument list.
void transfer(SortableList<T>&);
//- Return subscript-checked element of UList.
inline T& newElmt(const label);

View File

@ -82,6 +82,13 @@ void inplaceMapKey(const UList<label>& oldToNew, Container&);
template<class T>
void sortedOrder(const UList<T>&, labelList& order);
//- Generate (sorted) indices corresponding to duplicate list values
template<class T>
void duplicateOrder(const UList<T>&, labelList& order);
//- Generate (sorted) indices corresponding to unique list values
template<class T>
void uniqueOrder(const UList<T>&, labelList& order);
//- Extract elements of List whose region is certain value.
// Use e.g. to extract all selected elements:

View File

@ -174,16 +174,65 @@ void Foam::sortedOrder
)
{
order.setSize(lst.size());
forAll(order, elemI)
{
order[elemI] = elemI;
}
Foam::stableSort(order, typename UList<T>::less(lst));
}
template<class T>
void Foam::duplicateOrder
(
const UList<T>& lst,
labelList& order
)
{
if (lst.size() < 2)
{
order.clear();
return;
}
sortedOrder(lst, order);
label n = 0;
for (label i = 0; i < order.size() - 1; ++i)
{
if (lst[order[i]] == lst[order[i+1]])
{
order[n++] = order[i];
}
}
order.setSize(n);
}
template<class T>
void Foam::uniqueOrder
(
const UList<T>& lst,
labelList& order
)
{
sortedOrder(lst, order);
if (order.size() > 1)
{
label n = 0;
for (label i = 0; i < order.size() - 1; ++i)
{
if (lst[order[i]] != lst[order[i+1]])
{
order[n++] = order[i];
}
}
order.setSize(n);
}
}
template<class T, class ListType>
ListType Foam::subset
(

View File

@ -24,6 +24,23 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template <class Type>
void Foam::SortableList<Type>::sortIndices(List<label>& ind) const
{
// list lengths must be identical
ind.setSize(this->size());
forAll(ind, i)
{
ind[i] = i;
}
Foam::stableSort(ind, typename UList<Type>::less(*this));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class Type>
@ -73,13 +90,6 @@ Foam::SortableList<Type>::SortableList(const SortableList<Type>& lst)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type>
void Foam::SortableList<Type>::setSize(const label newSize)
{
List<Type>::setSize(newSize);
indices_.setSize(newSize, -1);
}
template <class Type>
void Foam::SortableList<Type>::clear()
@ -100,15 +110,7 @@ Foam::List<Type>& Foam::SortableList<Type>::shrink()
template <class Type>
void Foam::SortableList<Type>::sort()
{
// list lengths must be identical
indices_.setSize(this->size());
forAll(indices_, i)
{
indices_[i] = i;
}
Foam::stableSort(indices_, typename UList<Type>::less(*this));
sortIndices(indices_);
List<Type> lst(this->size());
forAll(indices_, i)
@ -120,10 +122,33 @@ void Foam::SortableList<Type>::sort()
}
template <class Type>
void Foam::SortableList<Type>::reverseSort()
{
sortIndices(indices_);
List<Type> lst(this->size());
label endI = indices_.size();
forAll(indices_, i)
{
lst[--endI] = this->operator[](indices_[i]);
}
List<Type>::transfer(lst);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template <class Type>
void Foam::SortableList<Type>::operator=(const UList<Type>& rhs)
inline void Foam::SortableList<Type>::operator=(const Type& t)
{
UList<Type>::operator=(t);
}
template <class Type>
inline void Foam::SortableList<Type>::operator=(const UList<Type>& rhs)
{
List<Type>::operator=(rhs);
indices_.clear();
@ -131,7 +156,7 @@ void Foam::SortableList<Type>::operator=(const UList<Type>& rhs)
template <class Type>
void Foam::SortableList<Type>::operator=(const SortableList<Type>& rhs)
inline void Foam::SortableList<Type>::operator=(const SortableList<Type>& rhs)
{
List<Type>::operator=(rhs);
indices_ = rhs.indices();

View File

@ -60,6 +60,9 @@ class SortableList
//- Original indices
labelList indices_;
//- Resize and sort the parameter according to the list values
void sortIndices(List<label>&) const;
public:
// Constructors
@ -99,9 +102,6 @@ public:
return indices_;
}
//- Size the list. Growing can cause undefined indices (until next sort)
void setSize(const label);
//- Clear the list and the indices
void clear();
@ -112,13 +112,19 @@ public:
// also resizes the indices as required
void sort();
//- Reverse (stable) sort the list
void reverseSort();
// Member Operators
//- Assignment of all entries to the given value
inline void operator=(const Type&);
//- Assignment from UList operator. Takes linear time.
void operator=(const UList<Type>&);
inline void operator=(const UList<Type>&);
//- Assignment operator. Takes linear time.
void operator=(const SortableList<Type>&);
inline void operator=(const SortableList<Type>&);
};

View File

@ -87,6 +87,9 @@ public:
//- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const;
//- Assignment of all entries to the given value
inline void operator=(const T&);
};

View File

@ -54,7 +54,7 @@ inline Foam::SubList<T>::SubList
# ifdef FULLDEBUG
// Artificially allowing the start of a zero-sized subList to be
// one past the end of the original list.
// one past the end of the original list.
if (subSize > 0)
{
list.checkStart(startIndex);
@ -73,7 +73,7 @@ inline Foam::SubList<T>::SubList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
const Foam::SubList<T>& Foam::SubList<T>::null()
inline const Foam::SubList<T>& Foam::SubList<T>::null()
{
SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL);
return *nullPtr;
@ -89,4 +89,11 @@ inline Foam::SubList<T>::operator const Foam::List<T>&() const
}
template<class T>
inline void Foam::SubList<T>::operator=(const T& t)
{
UList<T>::operator=(t);
}
// ************************************************************************* //

View File

@ -50,14 +50,14 @@ inline Foam::UList<T>::UList(T* __restrict__ v, label size)
template<class T>
inline Foam::label Foam::UList<T>::fcIndex(const label i) const
{
return (i == size()-1 ? 0 : i+1);
return (i == size()-1 ? 0 : i+1);
}
template<class T>
inline Foam::label Foam::UList<T>::rcIndex(const label i) const
{
return (i == 0 ? size()-1 : i-1);
return (i == 0 ? size()-1 : i-1);
}

View File

@ -45,7 +45,7 @@ void Foam::UList<T>::writeEntry(Ostream& os) const
{
os << word("List<" + word(pTraits<T>::typeName) + '>') << " ";
}
os << *this;
}

View File

@ -56,22 +56,12 @@ Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const
{
List<bool> lst(Times.size(), false);
// check ranges
forAll(Times, i)
// check ranges, avoid false positive on constant/
forAll(Times, timeI)
{
if (selected(Times[i]))
if (Times[timeI].name() != "constant" && selected(Times[timeI]))
{
lst[i] = true;
}
}
// avoid false positive on "constant"
forAll(Times, i)
{
if (Times[i].name() == "constant")
{
lst[i] = false;
break;
lst[timeI] = true;
}
}
@ -85,15 +75,15 @@ Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const
int nearestIndex = -1;
scalar nearestDiff = Foam::GREAT;
forAll(Times, timeIndex)
forAll(Times, timeI)
{
if (Times[timeIndex].name() == "constant") continue;
if (Times[timeI].name() == "constant") continue;
scalar diff = fabs(Times[timeIndex].value() - target);
scalar diff = fabs(Times[timeI].value() - target);
if (diff < nearestDiff)
{
nearestDiff = diff;
nearestIndex = timeIndex;
nearestIndex = timeI;
}
}
@ -141,7 +131,7 @@ void Foam::timeSelector::addOptions
argList::validOptions.insert("zeroTime", "");
}
argList::validOptions.insert("noZero", "");
argList::validOptions.insert("time", "time");
argList::validOptions.insert("time", "ranges");
argList::validOptions.insert("latestTime", "");
}
@ -156,35 +146,76 @@ Foam::List<Foam::instant> Foam::timeSelector::select
{
List<bool> selectTimes(timeDirs.size(), true);
// determine locations of constant/ and 0/ directories
label constantIdx = -1;
label zeroIdx = -1;
forAll(timeDirs, timeI)
{
if (timeDirs[timeI].name() == "constant")
{
constantIdx = timeI;
}
else if (timeDirs[timeI].value() == 0)
{
zeroIdx = timeI;
}
if (constantIdx >= 0 && zeroIdx >= 0)
{
break;
}
}
// determine latestTime selection (if any)
// this must appear before the -time option processing
label latestIdx = -1;
if (args.options().found("latestTime"))
{
selectTimes = false;
latestIdx = timeDirs.size() - 1;
// avoid false match on constant/
if (latestIdx == constantIdx)
{
latestIdx = -1;
}
}
if (args.options().found("time"))
{
// can match 0/, but can never match constant/
selectTimes = timeSelector
(
IStringStream(args.options()["time"])()
).selected(timeDirs);
}
else if (args.options().found("latestTime"))
{
selectTimes = false;
// avoid false match on constant/ or 0/
if (timeDirs.size() > 2)
{
selectTimes[timeDirs.size() - 1] = true;
}
// add in latestTime (if selected)
if (latestIdx >= 0)
{
selectTimes[latestIdx] = true;
}
if (timeDirs.size() > 1)
if (constantIdx >= 0)
{
selectTimes[0] = args.options().found("constant");
// only add constant/ if specifically requested
selectTimes[constantIdx] = args.options().found("constant");
}
// special treatment for 0/
if (zeroIdx >= 0)
{
if (args.options().found("noZero"))
{
selectTimes[1] = false;
// exclude 0/ if specifically requested
selectTimes[zeroIdx] = false;
}
else if (argList::validOptions.found("zeroTime"))
{
selectTimes[1] = args.options().found("zeroTime");
// with -zeroTime enabled, drop 0/ unless specifically requested
selectTimes[zeroIdx] = args.options().found("zeroTime");
}
}

View File

@ -60,8 +60,9 @@ Description
@endverbatim
The first argument avoids adding the @b -constant option. The second
argument adds an additional @b -zeroTime option and prevents the @c 0/
directory from being included in the default time range.
argument adds an additional @b -zeroTime option and also prevents the
@c 0/ directory from being included in the default time range and in the
@b -latestTime selection.
SourceFiles
timeSelector.C
@ -121,14 +122,17 @@ public:
//
// @param constant
// Add the @b -constant option to include the @c constant/ directory
//
// @param zeroTime
// Additional to the @b -noZero option (explicitly exclude the
// @c 0/ directory), add the @b -zeroTime option to include the
// @c 0/ directory. The @b -noZero option has precedence.
// Enable the @b -zeroTime option and alter the normal time selection
// behaviour (and @b -latestTime behaviour) to exclude the @c 0/
// directory. The @c 0/ directory will only be included when
// @b -zeroTime is specified.
// The @b -noZero option has precedence over the @b -zeroTime option.
static void addOptions
(
const bool constant = true,
const bool zeroTime = false
const bool constant=true,
const bool zeroTime=false
);
//- Return the set of times selected based on the argList options

View File

@ -27,6 +27,7 @@ License
#include "dictionary.H"
#include "primitiveEntry.H"
#include "dictionaryEntry.H"
#include "regExp.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
@ -42,21 +43,18 @@ bool Foam::dictionary::findInWildcards
const bool wildCardMatch,
const word& Keyword,
DLList<entry*>::const_iterator& wcLink,
DLList<autoPtr<regularExpression> >::const_iterator& reLink
DLList<autoPtr<regExp> >::const_iterator& reLink
) const
{
if (wildCardEntries_.size() > 0)
{
//wcLink = wildCardEntries_.begin();
//reLink = wildCardRegexps_.end();
while (wcLink != wildCardEntries_.end())
{
if (!wildCardMatch && wcLink()->keyword() == Keyword)
{
return true;
}
else if (wildCardMatch && reLink()->matches(Keyword))
else if (wildCardMatch && reLink()->match(Keyword))
{
return true;
}
@ -75,7 +73,7 @@ bool Foam::dictionary::findInWildcards
const bool wildCardMatch,
const word& Keyword,
DLList<entry*>::iterator& wcLink,
DLList<autoPtr<regularExpression> >::iterator& reLink
DLList<autoPtr<regExp> >::iterator& reLink
)
{
if (wildCardEntries_.size() > 0)
@ -86,7 +84,7 @@ bool Foam::dictionary::findInWildcards
{
return true;
}
else if (wildCardMatch && reLink()->matches(Keyword))
else if (wildCardMatch && reLink()->match(Keyword))
{
return true;
}
@ -132,10 +130,7 @@ Foam::dictionary::dictionary
wildCardEntries_.insert(&iter());
wildCardRegexps_.insert
(
autoPtr<regularExpression>
(
new regularExpression(iter().keyword())
)
autoPtr<regExp>(new regExp(iter().keyword()))
);
}
}
@ -165,10 +160,7 @@ Foam::dictionary::dictionary
wildCardEntries_.insert(&iter());
wildCardRegexps_.insert
(
autoPtr<regularExpression>
(
new regularExpression(iter().keyword())
)
autoPtr<regExp>(new regExp(iter().keyword()))
);
}
}
@ -228,7 +220,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
if (wildCardEntries_.size() > 0)
{
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::const_iterator reLink =
DLList<autoPtr<regExp> >::const_iterator reLink =
wildCardRegexps_.begin();
// Find in wildcards using regular expressions only
@ -265,7 +257,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
{
DLList<entry*>::const_iterator wcLink =
wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::const_iterator reLink =
DLList<autoPtr<regExp> >::const_iterator reLink =
wildCardRegexps_.begin();
// Find in wildcards using regular expressions only
@ -304,7 +296,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
{
DLList<entry*>::iterator wcLink =
wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink =
DLList<autoPtr<regExp> >::iterator reLink =
wildCardRegexps_.begin();
// Find in wildcards using regular expressions only
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
@ -486,10 +478,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
wildCardEntries_.insert(entryPtr);
wildCardRegexps_.insert
(
autoPtr<regularExpression>
(
new regularExpression(entryPtr->keyword())
)
autoPtr<regExp>(new regExp(entryPtr->keyword()))
);
}
@ -518,10 +507,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
wildCardEntries_.insert(entryPtr);
wildCardRegexps_.insert
(
autoPtr<regularExpression>
(
new regularExpression(entryPtr->keyword())
)
autoPtr<regExp>(new regExp(entryPtr->keyword()))
);
}
@ -614,8 +600,7 @@ bool Foam::dictionary::remove(const word& Keyword)
// Delete from wildcards first
DLList<entry*>::iterator wcLink =
wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink =
wildCardRegexps_.begin();
DLList<autoPtr<regExp> >::iterator reLink = wildCardRegexps_.begin();
// Find in wildcards using exact match only
if (findInWildcards(false, Keyword, wcLink, reLink))
@ -682,7 +667,7 @@ bool Foam::dictionary::changeKeyword
// Delete from wildcards first
DLList<entry*>::iterator wcLink =
wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink =
DLList<autoPtr<regExp> >::iterator reLink =
wildCardRegexps_.begin();
// Find in wildcards using exact match only
@ -696,7 +681,7 @@ bool Foam::dictionary::changeKeyword
IDLList<entry>::replace(iter2(), iter());
delete iter2();
hashedEntries_.erase(iter2);
}
else
{
@ -721,10 +706,7 @@ bool Foam::dictionary::changeKeyword
wildCardEntries_.insert(iter());
wildCardRegexps_.insert
(
autoPtr<regularExpression>
(
new regularExpression(newKeyword)
)
autoPtr<regExp>(new regExp(newKeyword))
);
}
@ -788,6 +770,8 @@ void Foam::dictionary::clear()
{
IDLList<entry>::clear();
hashedEntries_.clear();
wildCardEntries_.clear();
wildCardRegexps_.clear();
}

View File

@ -60,7 +60,6 @@ SourceFiles
#include "HashTable.H"
#include "wordList.H"
#include "className.H"
#include "regularExpression.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,7 +67,7 @@ namespace Foam
{
// Forward declaration of friend functions and operators
class regExp;
class dictionary;
Istream& operator>>(Istream&, dictionary&);
Ostream& operator<<(Ostream&, const dictionary&);
@ -96,8 +95,8 @@ class dictionary
//- Wildcard entries
DLList<entry*> wildCardEntries_;
//- Wildcard precompiled regex
DLList<autoPtr<regularExpression> > wildCardRegexps_;
//- Wildcard precompiled regular expressions
DLList<autoPtr<regExp> > wildCardRegexps_;
// Private Member Functions
@ -108,7 +107,7 @@ class dictionary
const bool wildCardMatch,
const word& Keyword,
DLList<entry*>::const_iterator& wcLink,
DLList<autoPtr<regularExpression> >::const_iterator& reLink
DLList<autoPtr<regExp> >::const_iterator& reLink
) const;
//- Search wildcard table either for exact match or for regular
@ -118,7 +117,7 @@ class dictionary
const bool wildCardMatch,
const word& Keyword,
DLList<entry*>::iterator& wcLink,
DLList<autoPtr<regularExpression> >::iterator& reLink
DLList<autoPtr<regExp> >::iterator& reLink
);
@ -164,16 +163,16 @@ public:
dictionary(Istream&);
//- Construct as copy given the parent dictionary
dictionary(const dictionary& parentDict, const dictionary& dict);
dictionary(const dictionary& parentDict, const dictionary&);
//- Construct top-level dictionary as copy
dictionary(const dictionary& dict);
dictionary(const dictionary&);
//- Construct and return clone
Foam::autoPtr<dictionary> clone() const;
//- Construct top-level dictionary on freestore from Istream
static Foam::autoPtr<dictionary> New(Istream& is);
static Foam::autoPtr<dictionary> New(Istream&);
// Destructor
@ -212,12 +211,12 @@ public:
//- Search dictionary for given keyword
// If recursive search parent dictionaries
bool found(const word& keyword, bool recursive=false) const;
bool found(const word&, bool recursive=false) const;
//- Find and return an entry data stream pointer if present
// otherwise return NULL.
// If recursive search parent dictionaries. If wildCardMatch
// use wildcards.
// If recursive search parent dictionaries.
// If wildCardMatch use wildcards.
const entry* lookupEntryPtr
(
const word&,
@ -227,8 +226,8 @@ public:
//- Find and return an entry data stream pointer for manipulation
// if present otherwise return NULL.
// If recursive search parent dictionaries. If wildCardMatch
// use wildcards.
// If recursive search parent dictionaries.
// If wildCardMatch use wildcards.
entry* lookupEntryPtr
(
const word&,
@ -237,8 +236,8 @@ public:
);
//- Find and return an entry data stream if present otherwise error.
// If recursive search parent dictionaries. If wildCardMatch
// use wildcards.
// If recursive search parent dictionaries.
// If wildCardMatch use wildcards.
const entry& lookupEntry
(
const word&,
@ -332,13 +331,13 @@ public:
//- Add a scalar entry
// optionally overwrite an existing entry
void add (const keyType&, const scalar, bool overwrite=false);
void add(const keyType&, const scalar, bool overwrite=false);
//- Add a dictionary entry
// optionally merge with an existing sub-dictionary
void add
(
const keyType& keyword,
const keyType&,
const dictionary&,
bool mergeEntry=false
);
@ -346,7 +345,7 @@ public:
//- Add a T entry
// optionally overwrite an existing entry
template<class T>
void add(const keyType& keyword, const T&, bool overwrite=false);
void add(const keyType&, const T&, bool overwrite=false);
//- Assign a new entry, overwrite any existing entry
void set(entry*);
@ -355,14 +354,14 @@ public:
void set(const entry&);
//- Assign a dictionary entry, overwrite any existing entry
void set(const keyType& keyword, const dictionary&);
void set(const keyType&, const dictionary&);
//- Assign a T entry, overwrite any existing entry
template<class T>
void set(const keyType& keyword, const T&);
void set(const keyType&, const T&);
//- Remove an entry specified by keyword
bool remove(const word& keyword);
bool remove(const word&);
//- Change the keyword for an entry,
// optionally forcing overwrite of an existing entry
@ -370,7 +369,7 @@ public:
(
const keyType& oldKeyword,
const keyType& newKeyword,
bool forceOverwrite = false
bool forceOverwrite=false
);
//- Merge entries from the given dictionary.
@ -383,7 +382,7 @@ public:
// Write
void write(Ostream& os, bool subDict = true) const;
void write(Ostream&, bool subDict=true) const;
// Member Operators

View File

@ -27,6 +27,7 @@ License
#include "dictionary.H"
#include "IFstream.H"
#include "inputModeEntry.H"
#include "regExp.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -136,9 +137,6 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
functionEntries::inputModeEntry::clear();
dict.clear();
dict.hashedEntries_.clear();
dict.wildCardEntries_.clear();
dict.wildCardRegexps_.clear();
dict.read(is);
return is;

View File

@ -26,6 +26,7 @@ License
#include "transformField.H"
#include "FieldM.H"
#include "diagTensor.H"
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
@ -75,7 +76,8 @@ void Foam::transform
{
vector T = tr.t();
if (mag(tr.r().w()) > SMALL)
// Check if any rotation
if (mag(tr.r().R() - I) > SMALL)
{
transform(rtf, tr.r(), tf);
@ -90,6 +92,10 @@ void Foam::transform
{
TFOR_ALL_F_OP_S_OP_F(vector, rtf, =, vector, T, +, vector, tf);
}
else
{
rtf = vector::zero;
}
}
}

View File

@ -37,19 +37,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
SLList<string> argList::validArgs;
HashTable<string> argList::validOptions;
HashTable<string> argList::validParOptions;
}
Foam::SLList<Foam::string> Foam::argList::validArgs;
Foam::HashTable<Foam::string> Foam::argList::validOptions;
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
bool Foam::argList::bannerEnabled(true);
Foam::argList::initValidTables::initValidTables()
{
validOptions.insert("case", "dir");
validOptions.insert("parallel", "");
validParOptions.insert("parallel", "");
validOptions.set("case", "dir");
validOptions.set("parallel", "");
validParOptions.set("parallel", "");
Pstream::addValidParOptions(validParOptions);
}
@ -138,7 +136,7 @@ void Foam::argList::getRootCase()
casePath = cwd();
// we could add this back in as '-case'?
// options_.insert("case", casePath);
// options_.set("case", casePath);
}
rootPath_ = casePath.path();
@ -285,7 +283,7 @@ Foam::argList::argList
string timeString = clock::clockTime();
// Print the banner once only for parallel runs
if (Pstream::master())
if (Pstream::master() && bannerEnabled)
{
IOobject::writeBanner(Info, true);
Info<< "Exec : " << argListString.c_str() << nl
@ -315,8 +313,6 @@ Foam::argList::argList
// For the master
if (Pstream::master())
{
fileNameList roots;
// establish rootPath_/globalCase_/case_ for master
getRootCase();
@ -333,45 +329,25 @@ Foam::argList::argList
<< exit(FatalError);
}
dictionary decompositionDict(decompDictStream);
Switch distributed(false);
if
(
decompositionDict.readIfPresent("distributed", distributed)
&& distributed
)
{
decompositionDict.lookup("roots") >> roots;
if (roots.size() != Pstream::nProcs()-1)
{
FatalError
<< "number of entries in decompositionDict::roots"
<< " is not equal to the number of slaves "
<< Pstream::nProcs()-1
<< exit(FatalError);
}
}
dictionary decompDict(decompDictStream);
label dictNProcs
(
readLabel
(
decompositionDict.lookup("numberOfSubdomains")
decompDict.lookup("numberOfSubdomains")
)
);
// Check number of processors. We have nProcs(number of
// actual processes), dictNProcs(wanted number of processes read
// from decompositionDict) and nProcDirs(number of processor
// directories - n/a when running distributed)
// Check number of processors.
// nProcs => number of actual procs
// dictNProcs => number of procs specified in decompositionDict
// nProcDirs => number of processor directories
// (n/a when running distributed)
//
// - normal running : nProcs = dictNProcs = nProcDirs
// - decomposition to more processors : nProcs = dictNProcs
// - decomposition to less processors : nProcs = nProcDirs
// - decomposition to more processors : nProcs = dictNProcs
// - decomposition to fewer processors : nProcs = nProcDirs
if (dictNProcs > Pstream::nProcs())
{
FatalError
@ -382,38 +358,23 @@ Foam::argList::argList
<< exit(FatalError);
}
if (!distributed && dictNProcs < Pstream::nProcs())
// distributed data
if (decompDict.lookupOrDefault<Switch>("distributed", false))
{
// Possibly going to fewer processors.
// Check if all procDirs are there.
label nProcDirs = 0;
while
(
dir
(
rootPath_/globalCase_/"processor"
+ name(++nProcDirs)
)
)
{}
fileNameList roots;
decompDict.lookup("roots") >> roots;
if (nProcDirs != Pstream::nProcs())
if (roots.size() != Pstream::nProcs()-1)
{
FatalError
<< "number of processor directories = "
<< nProcDirs
<< " is not equal to the number of processors = "
<< Pstream::nProcs()
<< "number of entries in decompositionDict::roots"
<< " is not equal to the number of slaves "
<< Pstream::nProcs()-1
<< exit(FatalError);
}
}
// distributed data
if (roots.size())
{
bool hadOptCase = options_.found("case");
// Distribute the master's argument list (with new root)
bool hadCaseOpt = options_.found("case");
for
(
int slave=Pstream::firstSlave();
@ -421,8 +382,7 @@ Foam::argList::argList
slave++
)
{
options_.erase("case");
options_.insert
options_.set
(
"case",
fileName(roots[slave-1])/globalCase_
@ -431,17 +391,42 @@ Foam::argList::argList
OPstream toSlave(Pstream::scheduled, slave);
toSlave << args_ << options_;
}
options_.erase("case");
// restore [-case dir]
if (hadOptCase)
if (hadCaseOpt)
{
options_.insert("case", rootPath_/globalCase_);
options_.set("case", rootPath_/globalCase_);
}
}
else
{
// Possibly going to fewer processors.
// Check if all procDirs are there.
if (dictNProcs < Pstream::nProcs())
{
label nProcDirs = 0;
while
(
dir
(
rootPath_/globalCase_/"processor"
+ name(++nProcDirs)
)
)
{}
if (nProcDirs != Pstream::nProcs())
{
FatalError
<< "number of processor directories = "
<< nProcDirs
<< " is not equal to the number of processors = "
<< Pstream::nProcs()
<< exit(FatalError);
}
}
// Distribute the master's argument list (unaltered)
for
(
@ -472,7 +457,6 @@ Foam::argList::argList
{
// establish rootPath_/globalCase_/case_
getRootCase();
case_ = globalCase_;
}
@ -510,21 +494,21 @@ Foam::argList::argList
}
if (Pstream::master())
if (Pstream::master() && bannerEnabled)
{
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
<< "nProcs : " << nProcs << endl;
}
if (parRunControl_.parRun() && Pstream::master())
{
Info<< "Slaves : " << slaveProcs << nl
<< "Pstream initialized with:" << nl
<< " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
<< endl;
if (parRunControl_.parRun())
{
Info<< "Slaves : " << slaveProcs << nl
<< "Pstream initialized with:" << nl
<< " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
<< endl;
}
}
jobInfo.add("root", rootPath_);
@ -546,7 +530,7 @@ Foam::argList::argList
sigQuit_.set();
sigSegv_.set();
if (Pstream::master())
if (Pstream::master() && bannerEnabled)
{
Info<< endl;
IOobject::writeDivider(Info);
@ -564,6 +548,12 @@ Foam::argList::~argList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::argList::noBanner()
{
bannerEnabled = false;
}
void Foam::argList::noParallel()
{
validOptions.erase("parallel");

View File

@ -92,6 +92,7 @@ namespace Foam
class argList
{
// Private data
static bool bannerEnabled;
stringList args_;
HashTable<string> options_;
@ -213,6 +214,9 @@ public:
// Edit
//- Disable emitting the banner information
static void noBanner();
//- Remove the parallel options
static void noParallel();

View File

@ -259,7 +259,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
),
(
fieldName,
@ -267,7 +267,7 @@ public:
interfaceBouCoeffs,
interfaceIntCoeffs,
interfaces,
solverData
solverControls
)
);
@ -282,7 +282,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
),
(
fieldName,
@ -290,7 +290,7 @@ public:
interfaceBouCoeffs,
interfaceIntCoeffs,
interfaces,
solverData
solverControls
)
);
@ -304,7 +304,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
);
// Selectors
@ -317,7 +317,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
);
@ -359,7 +359,7 @@ public:
//- Read and reset the solver parameters from the given stream
virtual void read(Istream& solverData);
virtual void read(const dictionary&);
virtual solverPerformance solve
(
@ -396,6 +396,9 @@ public:
public:
//- Find the smoother name (directly or from a sub-dictionary)
static word getName(const dictionary&);
//- Runtime type information
virtual const word& type() const = 0;
@ -467,7 +470,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& smootherData
const dictionary& solverControls
);
@ -531,6 +534,9 @@ public:
public:
//- Find the preconditioner name (directly or from a sub-dictionary)
static word getName(const dictionary&);
//- Runtime type information
virtual const word& type() const = 0;
@ -544,9 +550,9 @@ public:
symMatrix,
(
const solver& sol,
Istream& preconditionerData
const dictionary& solverControls
),
(sol, preconditionerData)
(sol, solverControls)
);
declareRunTimeSelectionTable
@ -556,9 +562,9 @@ public:
asymMatrix,
(
const solver& sol,
Istream& preconditionerData
const dictionary& solverControls
),
(sol, preconditionerData)
(sol, solverControls)
);
@ -579,7 +585,7 @@ public:
static autoPtr<preconditioner> New
(
const solver& sol,
Istream& preconditionerData
const dictionary& solverControls
);
@ -593,7 +599,7 @@ public:
//- Read and reset the preconditioner parameters
// from the given stream
virtual void read(Istream& preconditionerData)
virtual void read(const dictionary&)
{}
//- Return wA the preconditioned form of residual rA

View File

@ -37,29 +37,66 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word
Foam::lduMatrix::preconditioner::getName
(
const dictionary& solverControls
)
{
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
if (e.isDict())
{
e.dict().lookup("preconditioner") >> name;
}
else
{
e.stream() >> name;
}
return name;
}
Foam::autoPtr<Foam::lduMatrix::preconditioner>
Foam::lduMatrix::preconditioner::New
(
const solver& sol,
Istream& preconditionerData
const dictionary& solverControls
)
{
word preconditionerName(preconditionerData);
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
if (e.isDict())
{
e.dict().lookup("preconditioner") >> name;
}
else
{
e.stream() >> name;
}
const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
if (sol.matrix().symmetric())
{
symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(preconditionerName);
symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::preconditioner::New(const solver&, Istream&)",
preconditionerData
"lduMatrix::preconditioner::New"
"(const solver&, const dictionary&)",
controls
) << "Unknown symmetric matrix preconditioner "
<< preconditionerName << endl << endl
<< "Valid symmetric matrix preconditioners are :" << endl
<< name << nl << nl
<< "Valid symmetric matrix preconditioners :" << endl
<< symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
}
@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New
constructorIter()
(
sol,
preconditionerData
controls
)
);
}
else if (sol.matrix().asymmetric())
{
asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(preconditionerName);
asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::preconditioner::New(const solver&, Istream&)",
preconditionerData
"lduMatrix::preconditioner::New"
"(const solver&, const dictionary&)",
controls
) << "Unknown asymmetric matrix preconditioner "
<< preconditionerName << endl << endl
<< "Valid asymmetric matrix preconditioners are :" << endl
<< name << nl << nl
<< "Valid asymmetric matrix preconditioners :" << endl
<< asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
}
@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New
constructorIter()
(
sol,
preconditionerData
controls
)
);
}
@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New
{
FatalIOErrorIn
(
"lduMatrix::preconditioner::New(const solver&, Istream&)",
preconditionerData
) << "cannot preconditione incomplete matrix, "
"lduMatrix::preconditioner::New"
"(const solver&, const dictionary&)",
controls
) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient"
<< exit(FatalIOError);

View File

@ -34,9 +34,31 @@ namespace Foam
defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word
Foam::lduMatrix::smoother::getName
(
const dictionary& solverControls
)
{
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("smoother", false, false);
if (e.isDict())
{
e.dict().lookup("smoother") >> name;
}
else
{
e.stream() >> name;
}
return name;
}
Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
(
const word& fieldName,
@ -44,23 +66,37 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& smootherData
const dictionary& solverControls
)
{
word smootherName(smootherData);
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("smoother", false, false);
if (e.isDict())
{
e.dict().lookup("smoother") >> name;
}
else
{
e.stream() >> name;
}
// not (yet?) needed:
// const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
if (matrix.symmetric())
{
symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(smootherName);
symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::smoother::New", smootherData
) << "Unknown symmetric matrix smoother " << smootherName
<< endl << endl
"lduMatrix::smoother::New", solverControls
) << "Unknown symmetric matrix smoother "
<< name << nl << nl
<< "Valid symmetric matrix smoothers are :" << endl
<< symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
@ -81,15 +117,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
else if (matrix.asymmetric())
{
asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(smootherName);
asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::smoother::New", smootherData
) << "Unknown asymmetric matrix smoother " << smootherName
<< endl << endl
"lduMatrix::smoother::New", solverControls
) << "Unknown asymmetric matrix smoother "
<< name << nl << nl
<< "Valid asymmetric matrix smoothers are :" << endl
<< asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
@ -111,8 +147,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
{
FatalIOErrorIn
(
"lduMatrix::smoother::New", smootherData
) << "cannot solve incomplete matrix, no off-diagonal coefficients"
"lduMatrix::smoother::New", solverControls
) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient"
<< exit(FatalIOError);
return autoPtr<lduMatrix::smoother>(NULL);

View File

@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
)
{
word solverName(solverData);
word name(solverControls.lookup("solver"));
if (matrix.diagonal())
{
@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs,
interfaceIntCoeffs,
interfaces,
solverData
solverControls
)
);
}
else if (matrix.symmetric())
{
symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(solverName);
symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::solver::New", solverData
) << "Unknown symmetric matrix solver " << solverName
<< endl << endl
"lduMatrix::solver::New", solverControls
) << "Unknown symmetric matrix solver " << name << nl << nl
<< "Valid symmetric matrix solvers are :" << endl
<< symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs,
interfaceIntCoeffs,
interfaces,
solverData
solverControls
)
);
}
else if (matrix.asymmetric())
{
asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(solverName);
asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end())
{
FatalIOErrorIn
(
"lduMatrix::solver::New", solverData
) << "Unknown asymmetric matrix solver " << solverName
<< endl << endl
"lduMatrix::solver::New", solverControls
) << "Unknown asymmetric matrix solver " << name << nl << nl
<< "Valid asymmetric matrix solvers are :" << endl
<< asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError);
@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs,
interfaceIntCoeffs,
interfaces,
solverData
solverControls
)
);
}
@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
{
FatalIOErrorIn
(
"lduMatrix::solver::New", solverData
"lduMatrix::solver::New", solverControls
) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient"
<< exit(FatalIOError);
@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
const dictionary& solverControls
)
:
fieldName_(fieldName),
@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver
interfaceBouCoeffs_(interfaceBouCoeffs),
interfaceIntCoeffs_(interfaceIntCoeffs),
interfaces_(interfaces),
controlDict_(solverData),
maxIter_(1000),
tolerance_(1e-6),
relTol_(0)
controlDict_(solverControls)
{
readControls();
}
@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver
void Foam::lduMatrix::solver::readControls()
{
controlDict_.readIfPresent("maxIter", maxIter_);
controlDict_.readIfPresent("tolerance", tolerance_);
controlDict_.readIfPresent("relTol", relTol_);
maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000);
tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6);
relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0);
}
void Foam::lduMatrix::solver::read(Istream& solverData)
void Foam::lduMatrix::solver::read(const dictionary& solverControls)
{
word solverName(solverData);
solverData >> controlDict_;
controlDict_ = solverControls;
readControls();
}

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::DICPreconditioner::DICPreconditioner
(
const lduMatrix::solver& sol,
Istream&
const dictionary&
)
:
lduMatrix::preconditioner(sol),

View File

@ -67,11 +67,11 @@ public:
// Constructors
//- Construct from matrix components and preconditioner data stream
//- Construct from matrix components and preconditioner solver controls
DICPreconditioner
(
const lduMatrix::solver& sol,
Istream& preconditionerData
const lduMatrix::solver&,
const dictionary& solverControlsUnused
);

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::DILUPreconditioner::DILUPreconditioner
(
const lduMatrix::solver& sol,
Istream&
const dictionary&
)
:
lduMatrix::preconditioner(sol),

View File

@ -67,11 +67,11 @@ public:
// Constructors
//- Construct from matrix components and preconditioner data stream
//- Construct from matrix components and preconditioner solver controls
DILUPreconditioner
(
const lduMatrix::solver& sol,
Istream& preconditionerData
const lduMatrix::solver&,
const dictionary& solverControlsUnused
);
@ -94,8 +94,7 @@ public:
const direction cmpt=0
) const;
//- Return wT the transpose-matrix preconditioned form of
// residual rT.
//- Return wT the transpose-matrix preconditioned form of residual rT.
virtual void preconditionT
(
scalarField& wT,

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::FDICPreconditioner::FDICPreconditioner
(
const lduMatrix::solver& sol,
Istream&
const dictionary&
)
:
lduMatrix::preconditioner(sol),
@ -164,7 +164,7 @@ void Foam::FDICPreconditioner::precondition
__builtin_prefetch (&uPtr[face+96],0,0);
__builtin_prefetch (&lPtr[face+96],0,0);
__builtin_prefetch (&rDuUpperPtr[face+96],0,0);
__builtin_prefetch (&wAPtr[uPtr[face+32]],0,1);
__builtin_prefetch (&wAPtr[uPtr[face+32]],0,1);
__builtin_prefetch (&wAPtr[lPtr[face+32]],0,1);
#endif

View File

@ -80,11 +80,11 @@ public:
// Constructors
//- Construct from matrix components and preconditioner data stream
//- Construct from matrix components and preconditioner solver controls
FDICPreconditioner
(
const lduMatrix::solver& sol,
Istream& preconditionerData
const lduMatrix::solver&,
const dictionary& solverControlsUnused
);

View File

@ -45,7 +45,7 @@ namespace Foam
Foam::GAMGPreconditioner::GAMGPreconditioner
(
const lduMatrix::solver& sol,
Istream& preconditionerData
const dictionary& solverControls
)
:
GAMGSolver
@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner
sol.interfaceBouCoeffs(),
sol.interfaceIntCoeffs(),
sol.interfaces(),
preconditionerData
solverControls
),
lduMatrix::preconditioner(sol),
nVcycles_(2)
@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
void Foam::GAMGPreconditioner::readControls()
{
GAMGSolver::readControls();
controlDict_.readIfPresent("nVcycles", nVcycles_);
}
void Foam::GAMGPreconditioner::read(Istream& solverData)
{
GAMGSolver::read(solverData);
nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2);
}

Some files were not shown because too many files have changed in this diff Show More