mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' into molecularDynamics
This commit is contained in:
@ -23,12 +23,42 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
basicSubGrid
|
Foam::XiEqModels::basicSubGrid
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Basic sub-grid obstacle flame-wrinking enhancement factor model.
|
Basic sub-grid obstacle flame-wrinking enhancement factor model.
|
||||||
Details supplied by J Puttock 2/7/06.
|
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
|
SourceFiles
|
||||||
basicSubGrid.C
|
basicSubGrid.C
|
||||||
|
|
||||||
|
|||||||
@ -23,12 +23,30 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
basicSubGrid
|
Foam::XiGModel::basicSubGrid
|
||||||
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
Basic sub-grid obstacle flame-wrinking generation rate coefficient model.
|
Basic sub-grid obstacle flame-wrinking generation rate coefficient model.
|
||||||
Details supplied by J Puttock 2/7/06.
|
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
|
SourceFiles
|
||||||
basicSubGrid.C
|
basicSubGrid.C
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
PDRDragModel
|
Foam::PDRDragModel
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base-class for sub-grid obstacle drag models.
|
Base-class for sub-grid obstacle drag models.
|
||||||
|
|||||||
@ -23,12 +23,56 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
basic
|
Foam::PDRDragModels::basic
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Basic sub-grid obstacle drag model.
|
Basic sub-grid obstacle drag model.
|
||||||
Details supplied by J Puttock 2/7/06.
|
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
|
SourceFiles
|
||||||
basic.C
|
basic.C
|
||||||
|
|
||||||
@ -40,7 +84,6 @@ SourceFiles
|
|||||||
#include "PDRDragModel.H"
|
#include "PDRDragModel.H"
|
||||||
#include "XiEqModel.H"
|
#include "XiEqModel.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,10 +23,20 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
PDRkEpsilon
|
Foam::compressible::RASModels::PDRkEpsilon
|
||||||
|
|
||||||
Description
|
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
|
SourceFiles
|
||||||
PDRkEpsilon.C
|
PDRkEpsilon.C
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Gulder
|
Foam::XiEqModels::Gulder
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Simple Gulder model for XiEq based on Gulders correlation
|
Simple Gulder model for XiEq based on Gulders correlation
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
SCOPEBlend
|
Foam::XiEqModels::SCOPEBlend
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
SCOPEXiEq
|
Foam::XiEqModel::SCOPEXiEq
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation
|
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
XiEqModel
|
Foam::XiEqModel
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base-class for all XiEq models used by the b-XiEq combustion model.
|
Base-class for all XiEq models used by the b-XiEq combustion model.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
instability
|
Foam::XiEqModels::instability
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
KTS
|
Foam::XiGModels::KTS
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Simple Kolmogorov time-scale model for the flame-wrinling generation rate.
|
Simple Kolmogorov time-scale model for the flame-wrinling generation rate.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
XiGModel
|
Foam::XiGModel
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base-class for all Xi generation models used by the b-Xi combustion model.
|
Base-class for all Xi generation models used by the b-Xi combustion model.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
instabilityG
|
Foam::XiGModels::instabilityG
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Flame-surface instabilityG flame-wrinking generation rate coefficient model.
|
Flame-surface instabilityG flame-wrinking generation rate coefficient model.
|
||||||
|
|||||||
@ -23,10 +23,61 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
XiModel
|
Foam::XiModel
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base-class for all Xi models used by the b-Xi combustion model.
|
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
|
SourceFiles
|
||||||
XiModel.C
|
XiModel.C
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
algebraic
|
Foam::XiModels::algebraic
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Simple algebraic model for Xi based on Gulders correlation
|
Simple algebraic model for Xi based on Gulders correlation
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
fixed
|
Foam::XiModels::fixed
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Fixed value model for Xi.
|
Fixed value model for Xi.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
transport
|
Foam::XiModels::transport
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Simple transport model for Xi based on Gulders correlation
|
Simple transport model for Xi based on Gulders correlation
|
||||||
|
|||||||
@ -23,11 +23,38 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
SCOPE
|
Foam::laminarFlameSpeedModels::SCOPE
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Laminar flame speed obtained from the SCOPE correlation.
|
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
|
SourceFiles
|
||||||
SCOPELaminarFlameSpeed.C
|
SCOPELaminarFlameSpeed.C
|
||||||
|
|
||||||
|
|||||||
@ -74,24 +74,26 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
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() = "
|
// Store divU from the previous mesh for the correctPhi
|
||||||
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
|
volScalarField divU = fvc::div(phi);
|
||||||
<< " s" << endl;
|
|
||||||
|
|
||||||
gh = g & mesh.C();
|
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
|
||||||
ghf = g & mesh.Cf();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mesh.changing() && correctPhi)
|
// Do any mesh changes
|
||||||
{
|
mesh.update();
|
||||||
//***HGW#include "correctPhi.H"
|
|
||||||
|
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
|
// Make the fluxes relative to the mesh motion
|
||||||
@ -102,6 +104,12 @@ int main(int argc, char *argv[])
|
|||||||
#include "meshCourantNo.H"
|
#include "meshCourantNo.H"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mesh.changing())
|
||||||
|
{
|
||||||
|
gh = g & mesh.C();
|
||||||
|
ghf = g & mesh.Cf();
|
||||||
|
}
|
||||||
|
|
||||||
turbulence->correct();
|
turbulence->correct();
|
||||||
|
|
||||||
// --- Outer-corrector loop
|
// --- Outer-corrector loop
|
||||||
|
|||||||
@ -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"
|
||||||
|
}
|
||||||
@ -150,3 +150,14 @@
|
|||||||
(
|
(
|
||||||
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -43,16 +43,21 @@ int main(int argc, char *argv[])
|
|||||||
ldl[0](3) = 3;
|
ldl[0](3) = 3;
|
||||||
ldl[0](1) = 1;
|
ldl[0](1) = 1;
|
||||||
|
|
||||||
ldl[0].setSize(5); // increase allocated size
|
ldl[0].setCapacity(5); // increase allocated size
|
||||||
ldl[1].setSize(10); // increase allocated size
|
ldl[1].setCapacity(10); // increase allocated size
|
||||||
ldl[1](2) = 2;
|
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;
|
ldl[1] = 3;
|
||||||
|
|
||||||
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
|
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
|
||||||
forAll(ldl, i)
|
forAll(ldl, i)
|
||||||
{
|
{
|
||||||
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
|
Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
|
||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
@ -63,7 +68,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
|
Info<< "<ldl>" << ldl << "</ldl>" << nl << "sizes: ";
|
||||||
forAll(ldl, i)
|
forAll(ldl, i)
|
||||||
{
|
{
|
||||||
Info<< " " << ldl[i].size() << "/" << ldl[i].allocSize();
|
Info<< " " << ldl[i].size() << "/" << ldl[i].capacity();
|
||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
@ -78,10 +83,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
dlA.append(i);
|
dlA.append(i);
|
||||||
}
|
}
|
||||||
dlA.setSize(10);
|
dlA.setCapacity(10);
|
||||||
|
|
||||||
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
|
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
|
||||||
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
|
<< " " << dlA.size() << "/" << dlA.capacity() << endl;
|
||||||
|
|
||||||
dlB.transfer(dlA);
|
dlB.transfer(dlA);
|
||||||
|
|
||||||
@ -91,10 +96,54 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Transferred to dlB" << endl;
|
Info<< "Transferred to dlB" << endl;
|
||||||
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
|
Info<< "<dlA>" << dlA << "</dlA>" << nl << "sizes: "
|
||||||
<< " " << dlA.size() << "/" << dlA.allocSize() << endl;
|
<< " " << dlA.size() << "/" << dlA.capacity() << endl;
|
||||||
Info<< "<dlB>" << dlB << "</dlB>" << nl << "sizes: "
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
namedEnumTest.C
|
namedEnumTest.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/NamedEnum
|
EXE = $(FOAM_USER_APPBIN)/NamedEnum
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
callbackTest.C
|
callbackTest.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/callbackTest
|
EXE = $(FOAM_USER_APPBIN)/callbackTest
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
testDataEntry.C
|
testDataEntry.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/testDataEntry
|
EXE = $(FOAM_USER_APPBIN)/testDataEntry
|
||||||
|
|||||||
@ -30,6 +30,7 @@ Description
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "IOobject.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
|
||||||
@ -40,10 +41,37 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
IFstream dictStream("testDict");
|
Info<< dictionary(IFstream("testDict")()) << endl;
|
||||||
dictionary testDict(dictStream);
|
|
||||||
|
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
34
applications/test/dictionary/testDictRegex
Normal file
34
applications/test/dictionary/testDictRegex
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -28,6 +28,7 @@ Description
|
|||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
#include "timeSelector.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -36,13 +37,19 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
argList::noParallel();
|
||||||
|
// timeSelector::addOptions();
|
||||||
|
timeSelector::addOptions(true, true);
|
||||||
|
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
# include "createTime.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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
3
applications/test/regex/Make/files
Normal file
3
applications/test/regex/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
regexTest.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/regexTest
|
||||||
3
applications/test/regex/Make/options
Normal file
3
applications/test/regex/Make/options
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
EXE_LIBS = \
|
||||||
|
$(FOAM_LIBBIN)/libOSspecific.o
|
||||||
|
|
||||||
@ -22,55 +22,61 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Application
|
|
||||||
polyDualMesh
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Calculate the dual of a polyMesh. Adheres to all the feature&patch edges
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "argList.H"
|
#include "IOstreams.H"
|
||||||
#include "Time.H"
|
#include "IOobject.H"
|
||||||
#include "polyDualMesh.H"
|
#include "IFstream.H"
|
||||||
#include "mathematicalConstants.H"
|
#include "regExp.H"
|
||||||
|
#include "List.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::noParallel();
|
|
||||||
argList::validArgs.append("feature angle[0-180]");
|
|
||||||
argList::validOptions.insert("overwrite", "");
|
|
||||||
|
|
||||||
# include "setRootCase.H"
|
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
|
||||||
# include "createTime.H"
|
Info<< "input list:" << rawList << endl;
|
||||||
runTime.functionObjects().off();
|
IOobject::writeDivider(Info);
|
||||||
# include "createPolyMesh.H"
|
Info<< endl;
|
||||||
|
|
||||||
scalar featureAngle(readScalar(IStringStream(args.additionalArgs()[0])()));
|
List<string> groups;
|
||||||
bool overwrite = args.options().found("overwrite");
|
|
||||||
|
|
||||||
scalar minCos = Foam::cos(featureAngle * mathematicalConstant::pi/180.0);
|
// report matches:
|
||||||
|
forAll(rawList, elemI)
|
||||||
Info<< "Feature:" << featureAngle << endl
|
|
||||||
<< "minCos :" << minCos << endl
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
polyDualMesh dualMesh(mesh, minCos);
|
|
||||||
|
|
||||||
if (!overwrite)
|
|
||||||
{
|
{
|
||||||
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;
|
Info<< endl;
|
||||||
|
|
||||||
dualMesh.write();
|
|
||||||
|
|
||||||
Info << "End\n" << endl;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
20
applications/test/regex/testRegexps
Normal file
20
applications/test/regex/testRegexps
Normal 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" )
|
||||||
|
)
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -27,6 +27,7 @@ Description
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "SortableList.H"
|
#include "SortableList.H"
|
||||||
|
#include "ListOps.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -35,42 +36,101 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
labelList orig(5);
|
labelList orig(8);
|
||||||
orig[0] = 7;
|
orig[0] = 7;
|
||||||
orig[1] = 4;
|
orig[1] = 9;
|
||||||
orig[2] = 1;
|
orig[2] = 1;
|
||||||
orig[3] = 2;
|
orig[3] = 2;
|
||||||
orig[4] = 9;
|
orig[4] = 4;
|
||||||
|
orig[5] = 7;
|
||||||
|
orig[6] = 4;
|
||||||
|
orig[7] = 0;
|
||||||
|
|
||||||
|
labelList order;
|
||||||
|
|
||||||
labelList a(orig);
|
labelList a(orig);
|
||||||
Info << "before: " << a << endl;
|
sortedOrder(a, order);
|
||||||
|
|
||||||
|
Info<< "unsorted: " << a << endl;
|
||||||
sort(a);
|
sort(a);
|
||||||
Info << "after: " << a << endl;
|
Info<< "sorted: " << a << endl;
|
||||||
|
Info<< "indices: " << order << endl;
|
||||||
|
|
||||||
SortableList<label> b(orig);
|
SortableList<label> b(orig);
|
||||||
Info << "sorted: " << b << endl;
|
Info<< "unsorted: " << orig << endl;
|
||||||
Info << "indices: " << b.indices() << endl;
|
Info<< "sorted: " << b << endl;
|
||||||
|
Info<< "indices: " << b.indices() << endl;
|
||||||
|
|
||||||
Info << "shrunk: " << b.shrink() << endl;
|
Info<< "shrunk: " << b.shrink() << endl;
|
||||||
Info << "indices: " << b.indices() << endl;
|
Info<< "indices: " << b.indices() << endl;
|
||||||
|
|
||||||
// repeat by assignment
|
// repeat by assignment
|
||||||
b = orig;
|
b = orig;
|
||||||
Info << "unsorted: " << b << endl;
|
Info<< "unsorted: " << b << endl;
|
||||||
b.sort();
|
b.sort();
|
||||||
|
|
||||||
Info << "sorted: " << b << endl;
|
Info<< "sorted: " << b << endl;
|
||||||
Info << "indices: " << b.indices() << 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
|
// transfer assignment
|
||||||
b.transfer(orig);
|
a = orig;
|
||||||
Info << "unsorted: " << b << endl;
|
b.transfer(a);
|
||||||
|
Info<< "unsorted: " << b << endl;
|
||||||
b.sort();
|
b.sort();
|
||||||
|
|
||||||
Info << "sorted: " << b << endl;
|
Info<< "sorted: " << b << endl;
|
||||||
Info << "indices: " << b.indices() << 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,7 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "stringList.H"
|
#include "stringListOps.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
xferListTest.C
|
xferListTest.C
|
||||||
|
|
||||||
/* EXE = $(FOAM_USER_APPBIN)/xferListTest */
|
EXE = $(FOAM_USER_APPBIN)/xferListTest
|
||||||
EXE = ./xferListTest
|
|
||||||
|
|||||||
@ -108,13 +108,13 @@ int main(int argc, char *argv[])
|
|||||||
face f1(dl);
|
face f1(dl);
|
||||||
face f2(xferCopy<labelList>(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<< "f1: " << f1 << endl;
|
||||||
Info<< "f2: " << f2 << endl;
|
Info<< "f2: " << f2 << endl;
|
||||||
|
|
||||||
// note: using xferMoveTo to ensure the correct transfer() method is called
|
// note: using xferMoveTo to ensure the correct transfer() method is called
|
||||||
face f3( xferMoveTo<labelList>(dl) );
|
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;
|
Info<< "f3: " << f3 << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
polyDualMeshApp.C
|
meshDualiser.C
|
||||||
|
makePolyDualMesh.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/polyDualMesh
|
EXE = $(FOAM_APPBIN)/polyDualMesh
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
-I$(LIB_SRC)/conversion/lnInclude
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lmeshTools -lconversion
|
-lfiniteVolume \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-lmeshTools
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
1489
applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C
Normal file
1489
applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -292,6 +292,7 @@ meshQualityControls
|
|||||||
minFlatness 0.5;
|
minFlatness 0.5;
|
||||||
|
|
||||||
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
|
//- 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.
|
// Set to very negative number (e.g. -1E30) to disable.
|
||||||
minVol 1e-13;
|
minVol 1e-13;
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,7 @@ Foam::label Foam::checkTopology
|
|||||||
const pointField& pts = pp.points();
|
const pointField& pts = pp.points();
|
||||||
const labelList& mp = pp.meshPoints();
|
const labelList& mp = pp.meshPoints();
|
||||||
|
|
||||||
boundBox bb(vector::zero, vector::zero);
|
boundBox bb; // zero-sized
|
||||||
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
||||||
{
|
{
|
||||||
bb.min() = pts[mp[0]];
|
bb.min() = pts[mp[0]];
|
||||||
|
|||||||
@ -144,7 +144,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
|
|||||||
wordList curPointZoneNames = pointZones().names();
|
wordList curPointZoneNames = pointZones().names();
|
||||||
if (curPointZoneNames.size() > 0)
|
if (curPointZoneNames.size() > 0)
|
||||||
{
|
{
|
||||||
pointZoneNames_.setSize(2*curPointZoneNames.size());
|
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll (curPointZoneNames, zoneI)
|
forAll (curPointZoneNames, zoneI)
|
||||||
@ -157,7 +157,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
|
|||||||
|
|
||||||
if (curFaceZoneNames.size() > 0)
|
if (curFaceZoneNames.size() > 0)
|
||||||
{
|
{
|
||||||
faceZoneNames_.setSize(2*curFaceZoneNames.size());
|
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
|
||||||
}
|
}
|
||||||
forAll (curFaceZoneNames, zoneI)
|
forAll (curFaceZoneNames, zoneI)
|
||||||
{
|
{
|
||||||
@ -169,7 +169,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
|
|||||||
|
|
||||||
if (curCellZoneNames.size() > 0)
|
if (curCellZoneNames.size() > 0)
|
||||||
{
|
{
|
||||||
cellZoneNames_.setSize(2*curCellZoneNames.size());
|
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
|
||||||
}
|
}
|
||||||
forAll (curCellZoneNames, zoneI)
|
forAll (curCellZoneNames, zoneI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -354,7 +354,7 @@ bool domainDecomposition::writeDecomposition()
|
|||||||
// Estimate size
|
// Estimate size
|
||||||
forAll(zonePoints, zoneI)
|
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),
|
// 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_;
|
label procSize = fz[zoneI].size() / nProcs_;
|
||||||
|
|
||||||
zoneFaces[zoneI].setSize(procSize);
|
zoneFaces[zoneI].setCapacity(procSize);
|
||||||
zoneFaceFlips[zoneI].setSize(procSize);
|
zoneFaceFlips[zoneI].setCapacity(procSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through all the zoned faces and find out if they
|
// Go through all the zoned faces and find out if they
|
||||||
@ -514,7 +514,7 @@ bool domainDecomposition::writeDecomposition()
|
|||||||
// Estimate size
|
// Estimate size
|
||||||
forAll(zoneCells, zoneI)
|
forAll(zoneCells, zoneI)
|
||||||
{
|
{
|
||||||
zoneCells[zoneI].setSize(cz[zoneI].size() / nProcs_);
|
zoneCells[zoneI].setCapacity(cz[zoneI].size() / nProcs_);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll (curCellLabels, celli)
|
forAll (curCellLabels, celli)
|
||||||
|
|||||||
@ -45,8 +45,10 @@ Description
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
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();
|
argList::noParallel();
|
||||||
timeSelector::addOptions();
|
|
||||||
# include "addRegionOption.H"
|
# include "addRegionOption.H"
|
||||||
argList::validOptions.insert("fields", "\"(list of fields)\"");
|
argList::validOptions.insert("fields", "\"(list of fields)\"");
|
||||||
|
|
||||||
|
|||||||
@ -418,11 +418,7 @@ int main(int argc, char *argv[])
|
|||||||
// Read point on individual processors to determine merge tolerance
|
// Read point on individual processors to determine merge tolerance
|
||||||
// (otherwise single cell domains might give problems)
|
// (otherwise single cell domains might give problems)
|
||||||
|
|
||||||
boundBox bb
|
boundBox bb = boundBox::invertedBox;
|
||||||
(
|
|
||||||
point(GREAT, GREAT, GREAT),
|
|
||||||
point(-GREAT, -GREAT, -GREAT)
|
|
||||||
);
|
|
||||||
|
|
||||||
for (label procI = 0; procI < nProcs; procI++)
|
for (label procI = 0; procI < nProcs; procI++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -74,7 +74,9 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
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);
|
timeSelector::addOptions(true, false);
|
||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
argList::validOptions.insert("ascii", "");
|
argList::validOptions.insert("ascii", "");
|
||||||
|
|||||||
@ -617,8 +617,10 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer)
|
|||||||
{
|
{
|
||||||
const labelList& eFaces = edgeFaces[edgeI];
|
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;
|
featEdge[edgeI] = true;
|
||||||
}
|
}
|
||||||
else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
|
else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5)
|
||||||
|
|||||||
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "\nWall heat fluxes [W]" << endl;
|
Info<< "\nWall heat fluxes [W]" << endl;
|
||||||
forAll(patchHeatFlux, patchi)
|
forAll(patchHeatFlux, patchi)
|
||||||
{
|
{
|
||||||
if (typeid(mesh.boundary()) == typeid(wallFvPatch))
|
if (typeid(mesh.boundary()[patchi]) == typeid(wallFvPatch))
|
||||||
{
|
{
|
||||||
Info<< mesh.boundary()[patchi].name()
|
Info<< mesh.boundary()[patchi].name()
|
||||||
<< " "
|
<< " "
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
foamUpgradeFvSolution.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -29,7 +29,6 @@ License
|
|||||||
|
|
||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
#include "meshToMesh.H"
|
#include "meshToMesh.H"
|
||||||
#include "cuttingPlane.H"
|
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -199,7 +199,6 @@ int main(int argc, char *argv[])
|
|||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
surf.cleanup(true);
|
surf.cleanup(true);
|
||||||
surf.checkOrientation(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromCsys.valid())
|
if (fromCsys.valid())
|
||||||
|
|||||||
@ -104,13 +104,19 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
triSurface surf(importName);
|
triSurface surf(importName);
|
||||||
|
|
||||||
|
Info<< "Read surface:" << endl;
|
||||||
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
|
Info<< "Cleaning up surface" << endl;
|
||||||
surf.cleanup(true);
|
surf.cleanup(true);
|
||||||
surf.checkOrientation(true);
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info << "writing " << exportName;
|
Info<< "writing " << exportName;
|
||||||
if (scaleFactor <= 0)
|
if (scaleFactor <= 0)
|
||||||
{
|
{
|
||||||
Info<< " without scaling" << endl;
|
Info<< " without scaling" << endl;
|
||||||
@ -119,6 +125,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< " with scaling " << scaleFactor << endl;
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
surf.scalePoints(scaleFactor);
|
surf.scalePoints(scaleFactor);
|
||||||
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write sorted by region
|
// write sorted by region
|
||||||
@ -128,34 +136,16 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
UnsortedMeshedSurface<face> surf(importName);
|
UnsortedMeshedSurface<face> surf(importName);
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
Info<< "Read surface:" << endl;
|
||||||
{
|
surf.writeStats(Info);
|
||||||
surf.cleanup(true);
|
Info<< endl;
|
||||||
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);
|
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
|
Info<< "Cleaning up surface" << endl;
|
||||||
surf.cleanup(true);
|
surf.cleanup(true);
|
||||||
surf.checkOrientation(true);
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "writing " << exportName;
|
Info<< "writing " << exportName;
|
||||||
@ -167,6 +157,39 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< " with scaling " << scaleFactor << endl;
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
surf.scalePoints(scaleFactor);
|
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);
|
surf.write(exportName);
|
||||||
}
|
}
|
||||||
@ -175,10 +198,16 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
MeshedSurface<face> surf(importName);
|
MeshedSurface<face> surf(importName);
|
||||||
|
|
||||||
|
Info<< "Read surface:" << endl;
|
||||||
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
|
Info<< "Cleaning up surface" << endl;
|
||||||
surf.cleanup(true);
|
surf.cleanup(true);
|
||||||
surf.checkOrientation(true);
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "writing " << exportName;
|
Info<< "writing " << exportName;
|
||||||
@ -190,6 +219,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< " with scaling " << scaleFactor << endl;
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
surf.scalePoints(scaleFactor);
|
surf.scalePoints(scaleFactor);
|
||||||
|
surf.writeStats(Info);
|
||||||
|
Info<< endl;
|
||||||
}
|
}
|
||||||
surf.write(exportName);
|
surf.write(exportName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,9 +50,9 @@ then
|
|||||||
*/applications/solvers/*.C | */applications/utilities/*.C )
|
*/applications/solvers/*.C | */applications/utilities/*.C )
|
||||||
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-top.awk
|
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-top.awk
|
||||||
;;
|
;;
|
||||||
*/applications/solvers/*.H | */applications/utilities/*.H )
|
# */applications/solvers/*.H | */applications/utilities/*.H )
|
||||||
awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk
|
# awkScript=$WM_PROJECT_DIR/bin/tools/doxyFilt-ignore.awk
|
||||||
;;
|
# ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
awk -f $awkScript $1 | \
|
awk -f $awkScript $1 | \
|
||||||
|
|||||||
@ -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
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
104
bin/paraFoam
104
bin/paraFoam
@ -31,19 +31,19 @@
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
usage() {
|
usage() {
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
cat<<USAGE
|
cat<<USAGE
|
||||||
|
|
||||||
usage: ${0##*/} [OPTION]
|
usage: ${0##*/} [OPTION]
|
||||||
options:
|
options:
|
||||||
-case dir specify alternative case directory
|
-case dir specify alternative case directory
|
||||||
-region name specify mesh region name
|
-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
|
* start paraview $ParaView_VERSION with the OpenFOAM libraries
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
unset regionName touchOnly
|
unset regionName touchOnly
|
||||||
@ -51,81 +51,83 @@ unset regionName touchOnly
|
|||||||
# parse options
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help)
|
-h | -help)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
-case)
|
-case)
|
||||||
[ "$#" -ge 2 ] || usage "'-case' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
caseDir=$2
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||||
shift 2
|
shift 2
|
||||||
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
|
;;
|
||||||
;;
|
-region)
|
||||||
-region)
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
[ "$#" -ge 2 ] || usage "'-region' option requires an argument"
|
regionName=$2
|
||||||
regionName=$2
|
shift 2
|
||||||
shift 2
|
;;
|
||||||
;;
|
-touch)
|
||||||
-touch)
|
touchOnly=true
|
||||||
touchOnly=1
|
shift
|
||||||
shift
|
;;
|
||||||
;;
|
*)
|
||||||
*)
|
usage "unknown option/argument: '$*'"
|
||||||
usage "unknown option/argument: '$*'"
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# get a sensible caseName
|
# get a sensible caseName
|
||||||
caseName=${PWD##*/}
|
caseName=${PWD##*/}
|
||||||
caseFile="$caseName.OpenFOAM"
|
caseFile="$caseName.OpenFOAM"
|
||||||
|
fvControls="system"
|
||||||
|
|
||||||
if [ -n "$regionName" ]
|
if [ -n "$regionName" ]
|
||||||
then
|
then
|
||||||
caseFile="$caseName{$regionName}.OpenFOAM"
|
caseFile="$caseName{$regionName}.OpenFOAM"
|
||||||
|
fvControls="$fvControls/$regionName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$touchOnly" ];
|
if [ -n "$touchOnly" ]
|
||||||
then
|
then
|
||||||
touch "$caseFile"
|
touch "$caseFile"
|
||||||
echo "created '$caseFile'"
|
echo "created '$caseFile'"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# parent directory for normal or parallel results
|
# parent directory for normal or parallel results
|
||||||
case "$caseName" in
|
case "$caseName" in
|
||||||
processor*) parentDir=".." ;;
|
processor*) parentDir=".." ;;
|
||||||
*) parentDir="." ;;
|
*) parentDir="." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# check existence of essential files
|
# check existence of essential files
|
||||||
for check in system/controlDict system/fvSchemes system/fvSolution
|
for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
|
||||||
do
|
do
|
||||||
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
|
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
case "$ParaView_VERSION" in
|
case "$ParaView_VERSION" in
|
||||||
2*)
|
2*)
|
||||||
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
||||||
touch $caseFile
|
touch "$caseFile"
|
||||||
|
|
||||||
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
|
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
|
||||||
sed -e s@%CASE%@$PWD/$caseFile@g \
|
sed -e s@%CASE%@$PWD/$caseFile@g \
|
||||||
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs
|
$WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
|
||||||
|
|
||||||
paraview paraFoam.pvs
|
paraview paraFoam.pvs
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
# only create/remove caseFile if it doesn't exist
|
# only create/remove caseFile if it didn't already exist
|
||||||
[ -e $caseFile ] || {
|
[ -e $caseFile ] || {
|
||||||
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
|
||||||
touch "$caseFile"
|
touch "$caseFile"
|
||||||
echo "created temporary '$caseFile'"
|
echo "created temporary '$caseFile'"
|
||||||
}
|
}
|
||||||
|
|
||||||
paraview --data="$caseFile"
|
paraview --data="$caseFile"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
109
bin/rmdepold
Executable file
109
bin/rmdepold
Executable 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
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
@ -1,2 +1,2 @@
|
|||||||
Misc. tools for building applications, etc that are useful to have
|
Misc. tools, scripts, templates that are useful (eg, for building applications)
|
||||||
but which don't really need to be in the PATH.
|
but don't need to be in the PATH.
|
||||||
|
|||||||
@ -538,6 +538,7 @@ EXCLUDE_SYMBOLS =
|
|||||||
|
|
||||||
EXAMPLE_PATH =
|
EXAMPLE_PATH =
|
||||||
|
|
||||||
|
|
||||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
# 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
|
# 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
|
# 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
|
# 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
|
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
|
||||||
# generate Latex output.
|
# generate Latex output.
|
||||||
|
|
||||||
@ -824,7 +829,7 @@ PAPER_TYPE = a4wide
|
|||||||
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
|
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
|
||||||
# packages that should be included in the LaTeX output.
|
# 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 LATEX_HEADER tag can be used to specify a personal LaTeX header for
|
||||||
# the generated latex document. The header should contain everything until
|
# the generated latex document. The header should contain everything until
|
||||||
|
|||||||
129
doc/Doxygen/Macros/tensorOperator.sty
Normal file
129
doc/Doxygen/Macros/tensorOperator.sty
Normal 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$}}}
|
||||||
|
|
||||||
|
|
||||||
|
% ------------------------------------------------------------------------------
|
||||||
@ -187,7 +187,7 @@ case MPICH-GM:
|
|||||||
setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpich-gm
|
setenv FOAM_MPI_LIBBIN $FOAM_LIBBIN/mpich-gm
|
||||||
breaksw
|
breaksw
|
||||||
|
|
||||||
case MPICH-GM:
|
case HPMPI:
|
||||||
setenv MPI_HOME /opt/hpmpi
|
setenv MPI_HOME /opt/hpmpi
|
||||||
setenv MPI_ARCH_PATH $MPI_HOME
|
setenv MPI_ARCH_PATH $MPI_HOME
|
||||||
setenv MPICH_ROOT=$MPI_ARCH_PATH
|
setenv MPICH_ROOT=$MPI_ARCH_PATH
|
||||||
|
|||||||
@ -2,6 +2,7 @@ signals/sigFpe.C
|
|||||||
signals/sigSegv.C
|
signals/sigSegv.C
|
||||||
signals/sigInt.C
|
signals/sigInt.C
|
||||||
signals/sigQuit.C
|
signals/sigQuit.C
|
||||||
|
regExp.C
|
||||||
timer.C
|
timer.C
|
||||||
fileStat.C
|
fileStat.C
|
||||||
Unix.C
|
Unix.C
|
||||||
|
|||||||
196
src/OSspecific/Unix/regExp.C
Normal file
196
src/OSspecific/Unix/regExp.C
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -23,19 +23,26 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::regularExpression
|
Foam::regExp
|
||||||
|
|
||||||
Description
|
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
|
SourceFiles
|
||||||
|
regExp.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef regularExpression_H
|
#ifndef regExp_H
|
||||||
#define regularExpression_H
|
#define regExp_H
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -43,70 +50,81 @@ SourceFiles
|
|||||||
namespace Foam
|
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
|
// Private data
|
||||||
|
|
||||||
//- Precompiled regular expression
|
//- Precompiled regular expression
|
||||||
regex_t* preg_;
|
mutable regex_t* preg_;
|
||||||
|
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
|
|
||||||
|
//- release allocated space
|
||||||
|
void clear() const;
|
||||||
|
|
||||||
|
//- compile into a regular expression
|
||||||
|
void compile(const char*) const;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
regularExpression(const regularExpression&);
|
regExp(const regExp&);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const regularExpression&);
|
void operator=(const regExp&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
regExp();
|
||||||
|
|
||||||
//- Construct from string
|
//- Construct from string
|
||||||
inline regularExpression(const string& s)
|
regExp(const string&);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//- Construct from character array
|
||||||
|
regExp(const char*);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
||||||
//- Construct from string
|
~regExp();
|
||||||
inline ~regularExpression()
|
|
||||||
{
|
|
||||||
if (preg_)
|
|
||||||
{
|
|
||||||
regfree(preg_);
|
|
||||||
delete preg_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
//- Matches?
|
//- Return the number of (groups)
|
||||||
inline bool matches(const string& s) const
|
int ngroups() const;
|
||||||
{
|
|
||||||
size_t nmatch = 0;
|
//- Return true if it matches, partial matches are optional
|
||||||
regmatch_t *pmatch = NULL;
|
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;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -28,23 +28,23 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Construct from Istream
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList(Istream& is)
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList(Istream& is)
|
||||||
:
|
:
|
||||||
List<T>(is),
|
List<T>(is),
|
||||||
allocSize_(List<T>::size())
|
capacity_(List<T>::size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Foam::Ostream& os,
|
Ostream& os,
|
||||||
const Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& DL
|
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
os << static_cast<const List<T>&>(DL);
|
os << static_cast<const List<T>&>(lst);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,12 +52,12 @@ Foam::Ostream& Foam::operator<<
|
|||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
Foam::Istream& Foam::operator>>
|
Foam::Istream& Foam::operator>>
|
||||||
(
|
(
|
||||||
Foam::Istream& is,
|
Istream& is,
|
||||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>& DL
|
DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
is >> static_cast<List<T>&>(DL);
|
is >> static_cast<List<T>&>(lst);
|
||||||
DL.allocSize_ = DL.List<T>::size();
|
lst.capacity_ = lst.List<T>::size();
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@ Description
|
|||||||
Internal storage is a compact array and the list can be shrunk to compact
|
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
|
storage. The increase of list size is controlled by three template
|
||||||
parameters, which allows the list storage to either increase by the given
|
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).
|
multiples).
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -81,14 +81,11 @@ class DynamicList
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Allocated size for underlying List.
|
//- The capacity (allocated size) of the underlying list.
|
||||||
label allocSize_;
|
label capacity_;
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
// Disabled, since the usefulness and semantics are not quite clear
|
|
||||||
void setSize(const label, const T&);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Related types
|
// Related types
|
||||||
@ -116,20 +113,30 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Size of the underlying storage.
|
//- Size of the underlying storage.
|
||||||
inline label allocSize() const;
|
inline label capacity() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Alter the list size.
|
//- Alter the size of the underlying storage.
|
||||||
// When the new size is greater than the addressed list size, the
|
// The addressed size will be truncated if needed to fit, but will
|
||||||
// allocated list sizes is adjusted and the
|
// remain otherwise untouched.
|
||||||
// addressed size does not change.
|
// Use this or reserve() in combination with append().
|
||||||
// Otherwise the addressed list size is just reduced and the
|
inline void setCapacity(const label);
|
||||||
// allocated size does not change.
|
|
||||||
|
//- 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);
|
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
|
// Allocated size does not change
|
||||||
inline void clear();
|
inline void clear();
|
||||||
|
|
||||||
@ -152,6 +159,9 @@ public:
|
|||||||
//- Append an element at the end of the list
|
//- Append an element at the end of the list
|
||||||
inline void append(const T& e);
|
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
|
//- Remove and return the top element
|
||||||
inline T remove();
|
inline T remove();
|
||||||
|
|
||||||
@ -162,7 +172,7 @@ public:
|
|||||||
inline void operator=(const T&);
|
inline void operator=(const T&);
|
||||||
|
|
||||||
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
||||||
inline void operator=(const List<T>&);
|
inline void operator=(const UList<T>&);
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
// IOstream operators
|
||||||
|
|||||||
@ -30,7 +30,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
|||||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList()
|
||||||
:
|
:
|
||||||
List<T>(SizeInc),
|
List<T>(SizeInc),
|
||||||
allocSize_(SizeInc)
|
capacity_(SizeInc)
|
||||||
{
|
{
|
||||||
List<T>::size(0);
|
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>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||||
(
|
(
|
||||||
const label s
|
const label nElem
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
List<T>(s),
|
List<T>(nElem),
|
||||||
allocSize_(s)
|
capacity_(nElem)
|
||||||
{
|
{
|
||||||
List<T>::size(0);
|
List<T>::size(0);
|
||||||
}
|
}
|
||||||
@ -56,39 +56,101 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
List<T>(lst),
|
List<T>(lst),
|
||||||
allocSize_(lst.size())
|
capacity_(lst.size())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
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
|
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>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
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();
|
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
|
this->operator[](nextFree++) = t;
|
||||||
nextFree = s;
|
|
||||||
}
|
}
|
||||||
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()
|
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clearStorage()
|
||||||
{
|
{
|
||||||
List<T>::clear();
|
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>&
|
inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
|
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
|
||||||
{
|
{
|
||||||
if (allocSize_ > List<T>::size())
|
label nextFree = List<T>::size();
|
||||||
|
if (capacity_ > nextFree)
|
||||||
{
|
{
|
||||||
allocSize_ = List<T>::size();
|
// use the full list when resizing
|
||||||
// force re-allocation/copying in List<T>::setSize() by temporarily
|
List<T>::size(capacity_);
|
||||||
// faking a larger list size that will be truncated
|
// the new size
|
||||||
List<T>::size(allocSize_+1);
|
capacity_ = nextFree;
|
||||||
List<T>::setSize(allocSize_);
|
List<T>::setSize(capacity_);
|
||||||
|
List<T>::size(nextFree);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -127,7 +191,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
|||||||
inline void
|
inline void
|
||||||
Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer(List<T>& lst)
|
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.
|
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.
|
// take over storage as-is (without shrink), clear addressing for lst.
|
||||||
allocSize_ = lst.allocSize_;
|
capacity_ = lst.capacity_;
|
||||||
lst.allocSize_ = 0;
|
lst.capacity_ = 0;
|
||||||
|
|
||||||
List<T>::transfer(static_cast<List<T>&>(lst));
|
List<T>::transfer(static_cast<List<T>&>(lst));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append(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();
|
label nextFree = List<T>::size();
|
||||||
|
|
||||||
nextFree++;
|
if (this == &lst)
|
||||||
|
|
||||||
if (nextFree > allocSize_)
|
|
||||||
{
|
{
|
||||||
allocSize_ = max
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
nextFree,
|
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::append"
|
||||||
label(SizeMult*allocSize_/SizeDiv + SizeInc)
|
"(const UList<T>&)"
|
||||||
);
|
) << "attempted appending to self" << abort(FatalError);
|
||||||
List<T>::setSize(allocSize_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
|
inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
|
||||||
{
|
{
|
||||||
if (List<T>::size() == 0)
|
label elemI = List<T>::size() - 1;
|
||||||
|
|
||||||
|
if (elemI < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -182,11 +263,9 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
|
|||||||
) << "List is empty" << abort(FatalError);
|
) << "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(elemI);
|
||||||
|
|
||||||
List<T>::size(nextFree);
|
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -197,26 +276,15 @@ inline T Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::remove()
|
|||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
|
inline T& Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator()
|
||||||
(
|
(
|
||||||
const label i
|
const label elemI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label nextFree = List<T>::size();
|
if (elemI >= List<T>::size())
|
||||||
|
|
||||||
nextFree = max(nextFree, i + 1);
|
|
||||||
|
|
||||||
if (nextFree > allocSize_)
|
|
||||||
{
|
{
|
||||||
allocSize_ = max
|
setSize(elemI + 1);
|
||||||
(
|
|
||||||
nextFree,
|
|
||||||
label(SizeMult*allocSize_/SizeDiv + SizeInc)
|
|
||||||
);
|
|
||||||
List<T>::setSize(allocSize_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T>::size(nextFree);
|
return this->operator[](elemI);
|
||||||
|
|
||||||
return this->operator[](i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,21 +294,39 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
|||||||
const T& t
|
const T& t
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
List<T>::operator=(t);
|
UList<T>::operator=(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
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:
|
if (this == &lst)
|
||||||
List<T>::size(allocSize_);
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator="
|
||||||
|
"(const UList<T>&)"
|
||||||
|
) << "attempted assignment to self" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
List<T>::operator=(lst);
|
if (capacity_ >= lst.size())
|
||||||
allocSize_ = List<T>::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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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
|
// shrink the allocated space to the number of elements used
|
||||||
a.shrink();
|
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;
|
// Transfer the contents of the argument SortableList into this List
|
||||||
a.v_ = 0;
|
// and anull the argument list
|
||||||
a.allocSize_ = 0;
|
template<class T>
|
||||||
|
void Foam::List<T>::transfer(SortableList<T>& a)
|
||||||
|
{
|
||||||
|
// shrink away the sort indices
|
||||||
|
a.shrink();
|
||||||
|
transfer(static_cast<List<T>&>(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,8 @@ template<class T, label Size> class FixedList;
|
|||||||
template<class T> class PtrList;
|
template<class T> class PtrList;
|
||||||
template<class T> class SLList;
|
template<class T> class SLList;
|
||||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
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 IndirectList;
|
||||||
template<class T> class BiIndirectList;
|
template<class T> class BiIndirectList;
|
||||||
|
|
||||||
@ -173,6 +174,10 @@ public:
|
|||||||
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
void transfer(DynamicList<T, SizeInc, SizeMult, 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.
|
//- Return subscript-checked element of UList.
|
||||||
inline T& newElmt(const label);
|
inline T& newElmt(const label);
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,13 @@ void inplaceMapKey(const UList<label>& oldToNew, Container&);
|
|||||||
template<class T>
|
template<class T>
|
||||||
void sortedOrder(const UList<T>&, labelList& order);
|
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.
|
//- Extract elements of List whose region is certain value.
|
||||||
// Use e.g. to extract all selected elements:
|
// Use e.g. to extract all selected elements:
|
||||||
|
|||||||
@ -174,16 +174,65 @@ void Foam::sortedOrder
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
order.setSize(lst.size());
|
order.setSize(lst.size());
|
||||||
|
|
||||||
forAll(order, elemI)
|
forAll(order, elemI)
|
||||||
{
|
{
|
||||||
order[elemI] = elemI;
|
order[elemI] = elemI;
|
||||||
}
|
}
|
||||||
|
|
||||||
Foam::stableSort(order, typename UList<T>::less(lst));
|
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>
|
template<class T, class ListType>
|
||||||
ListType Foam::subset
|
ListType Foam::subset
|
||||||
(
|
(
|
||||||
|
|||||||
@ -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 * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
@ -73,13 +90,6 @@ Foam::SortableList<Type>::SortableList(const SortableList<Type>& lst)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
|
||||||
void Foam::SortableList<Type>::setSize(const label newSize)
|
|
||||||
{
|
|
||||||
List<Type>::setSize(newSize);
|
|
||||||
indices_.setSize(newSize, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void Foam::SortableList<Type>::clear()
|
void Foam::SortableList<Type>::clear()
|
||||||
@ -100,15 +110,7 @@ Foam::List<Type>& Foam::SortableList<Type>::shrink()
|
|||||||
template <class Type>
|
template <class Type>
|
||||||
void Foam::SortableList<Type>::sort()
|
void Foam::SortableList<Type>::sort()
|
||||||
{
|
{
|
||||||
// list lengths must be identical
|
sortIndices(indices_);
|
||||||
indices_.setSize(this->size());
|
|
||||||
|
|
||||||
forAll(indices_, i)
|
|
||||||
{
|
|
||||||
indices_[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
Foam::stableSort(indices_, typename UList<Type>::less(*this));
|
|
||||||
|
|
||||||
List<Type> lst(this->size());
|
List<Type> lst(this->size());
|
||||||
forAll(indices_, i)
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template <class Type>
|
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);
|
List<Type>::operator=(rhs);
|
||||||
indices_.clear();
|
indices_.clear();
|
||||||
@ -131,7 +156,7 @@ void Foam::SortableList<Type>::operator=(const UList<Type>& rhs)
|
|||||||
|
|
||||||
|
|
||||||
template <class Type>
|
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);
|
List<Type>::operator=(rhs);
|
||||||
indices_ = rhs.indices();
|
indices_ = rhs.indices();
|
||||||
|
|||||||
@ -60,6 +60,9 @@ class SortableList
|
|||||||
//- Original indices
|
//- Original indices
|
||||||
labelList indices_;
|
labelList indices_;
|
||||||
|
|
||||||
|
//- Resize and sort the parameter according to the list values
|
||||||
|
void sortIndices(List<label>&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -99,9 +102,6 @@ public:
|
|||||||
return indices_;
|
return indices_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Size the list. Growing can cause undefined indices (until next sort)
|
|
||||||
void setSize(const label);
|
|
||||||
|
|
||||||
//- Clear the list and the indices
|
//- Clear the list and the indices
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
@ -112,13 +112,19 @@ public:
|
|||||||
// also resizes the indices as required
|
// also resizes the indices as required
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
|
//- Reverse (stable) sort the list
|
||||||
|
void reverseSort();
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
//- Assignment of all entries to the given value
|
||||||
|
inline void operator=(const Type&);
|
||||||
|
|
||||||
//- Assignment from UList operator. Takes linear time.
|
//- Assignment from UList operator. Takes linear time.
|
||||||
void operator=(const UList<Type>&);
|
inline void operator=(const UList<Type>&);
|
||||||
|
|
||||||
//- Assignment operator. Takes linear time.
|
//- Assignment operator. Takes linear time.
|
||||||
void operator=(const SortableList<Type>&);
|
inline void operator=(const SortableList<Type>&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -87,6 +87,9 @@ public:
|
|||||||
|
|
||||||
//- Allow cast to a const List<T>&
|
//- Allow cast to a const List<T>&
|
||||||
inline operator const Foam::List<T>&() const;
|
inline operator const Foam::List<T>&() const;
|
||||||
|
|
||||||
|
//- Assignment of all entries to the given value
|
||||||
|
inline void operator=(const T&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ inline Foam::SubList<T>::SubList
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
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);
|
SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL);
|
||||||
return *nullPtr;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -56,22 +56,12 @@ Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const
|
|||||||
{
|
{
|
||||||
List<bool> lst(Times.size(), false);
|
List<bool> lst(Times.size(), false);
|
||||||
|
|
||||||
// check ranges
|
// check ranges, avoid false positive on constant/
|
||||||
forAll(Times, i)
|
forAll(Times, timeI)
|
||||||
{
|
{
|
||||||
if (selected(Times[i]))
|
if (Times[timeI].name() != "constant" && selected(Times[timeI]))
|
||||||
{
|
{
|
||||||
lst[i] = true;
|
lst[timeI] = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// avoid false positive on "constant"
|
|
||||||
forAll(Times, i)
|
|
||||||
{
|
|
||||||
if (Times[i].name() == "constant")
|
|
||||||
{
|
|
||||||
lst[i] = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,15 +75,15 @@ Foam::List<bool> Foam::timeSelector::selected(const List<instant>& Times) const
|
|||||||
int nearestIndex = -1;
|
int nearestIndex = -1;
|
||||||
scalar nearestDiff = Foam::GREAT;
|
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)
|
if (diff < nearestDiff)
|
||||||
{
|
{
|
||||||
nearestDiff = diff;
|
nearestDiff = diff;
|
||||||
nearestIndex = timeIndex;
|
nearestIndex = timeI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +131,7 @@ void Foam::timeSelector::addOptions
|
|||||||
argList::validOptions.insert("zeroTime", "");
|
argList::validOptions.insert("zeroTime", "");
|
||||||
}
|
}
|
||||||
argList::validOptions.insert("noZero", "");
|
argList::validOptions.insert("noZero", "");
|
||||||
argList::validOptions.insert("time", "time");
|
argList::validOptions.insert("time", "ranges");
|
||||||
argList::validOptions.insert("latestTime", "");
|
argList::validOptions.insert("latestTime", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,35 +146,76 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
{
|
{
|
||||||
List<bool> selectTimes(timeDirs.size(), true);
|
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"))
|
if (args.options().found("time"))
|
||||||
{
|
{
|
||||||
|
// can match 0/, but can never match constant/
|
||||||
selectTimes = timeSelector
|
selectTimes = timeSelector
|
||||||
(
|
(
|
||||||
IStringStream(args.options()["time"])()
|
IStringStream(args.options()["time"])()
|
||||||
).selected(timeDirs);
|
).selected(timeDirs);
|
||||||
}
|
}
|
||||||
else if (args.options().found("latestTime"))
|
|
||||||
{
|
|
||||||
selectTimes = false;
|
|
||||||
|
|
||||||
// avoid false match on constant/ or 0/
|
|
||||||
if (timeDirs.size() > 2)
|
// add in latestTime (if selected)
|
||||||
{
|
if (latestIdx >= 0)
|
||||||
selectTimes[timeDirs.size() - 1] = true;
|
{
|
||||||
}
|
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"))
|
if (args.options().found("noZero"))
|
||||||
{
|
{
|
||||||
selectTimes[1] = false;
|
// exclude 0/ if specifically requested
|
||||||
|
selectTimes[zeroIdx] = false;
|
||||||
}
|
}
|
||||||
else if (argList::validOptions.found("zeroTime"))
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,8 +60,9 @@ Description
|
|||||||
@endverbatim
|
@endverbatim
|
||||||
|
|
||||||
The first argument avoids adding the @b -constant option. The second
|
The first argument avoids adding the @b -constant option. The second
|
||||||
argument adds an additional @b -zeroTime option and prevents the @c 0/
|
argument adds an additional @b -zeroTime option and also prevents the
|
||||||
directory from being included in the default time range.
|
@c 0/ directory from being included in the default time range and in the
|
||||||
|
@b -latestTime selection.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
timeSelector.C
|
timeSelector.C
|
||||||
@ -121,14 +122,17 @@ public:
|
|||||||
//
|
//
|
||||||
// @param constant
|
// @param constant
|
||||||
// Add the @b -constant option to include the @c constant/ directory
|
// Add the @b -constant option to include the @c constant/ directory
|
||||||
|
//
|
||||||
// @param zeroTime
|
// @param zeroTime
|
||||||
// Additional to the @b -noZero option (explicitly exclude the
|
// Enable the @b -zeroTime option and alter the normal time selection
|
||||||
// @c 0/ directory), add the @b -zeroTime option to include the
|
// behaviour (and @b -latestTime behaviour) to exclude the @c 0/
|
||||||
// @c 0/ directory. The @b -noZero option has precedence.
|
// 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
|
static void addOptions
|
||||||
(
|
(
|
||||||
const bool constant = true,
|
const bool constant=true,
|
||||||
const bool zeroTime = false
|
const bool zeroTime=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return the set of times selected based on the argList options
|
//- Return the set of times selected based on the argList options
|
||||||
|
|||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "primitiveEntry.H"
|
#include "primitiveEntry.H"
|
||||||
#include "dictionaryEntry.H"
|
#include "dictionaryEntry.H"
|
||||||
|
#include "regExp.H"
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||||
|
|
||||||
@ -42,21 +43,18 @@ bool Foam::dictionary::findInWildcards
|
|||||||
const bool wildCardMatch,
|
const bool wildCardMatch,
|
||||||
const word& Keyword,
|
const word& Keyword,
|
||||||
DLList<entry*>::const_iterator& wcLink,
|
DLList<entry*>::const_iterator& wcLink,
|
||||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
DLList<autoPtr<regExp> >::const_iterator& reLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (wildCardEntries_.size() > 0)
|
if (wildCardEntries_.size() > 0)
|
||||||
{
|
{
|
||||||
//wcLink = wildCardEntries_.begin();
|
|
||||||
//reLink = wildCardRegexps_.end();
|
|
||||||
|
|
||||||
while (wcLink != wildCardEntries_.end())
|
while (wcLink != wildCardEntries_.end())
|
||||||
{
|
{
|
||||||
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
else if (wildCardMatch && reLink()->match(Keyword))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,7 +73,7 @@ bool Foam::dictionary::findInWildcards
|
|||||||
const bool wildCardMatch,
|
const bool wildCardMatch,
|
||||||
const word& Keyword,
|
const word& Keyword,
|
||||||
DLList<entry*>::iterator& wcLink,
|
DLList<entry*>::iterator& wcLink,
|
||||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
DLList<autoPtr<regExp> >::iterator& reLink
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (wildCardEntries_.size() > 0)
|
if (wildCardEntries_.size() > 0)
|
||||||
@ -86,7 +84,7 @@ bool Foam::dictionary::findInWildcards
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
else if (wildCardMatch && reLink()->match(Keyword))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -132,10 +130,7 @@ Foam::dictionary::dictionary
|
|||||||
wildCardEntries_.insert(&iter());
|
wildCardEntries_.insert(&iter());
|
||||||
wildCardRegexps_.insert
|
wildCardRegexps_.insert
|
||||||
(
|
(
|
||||||
autoPtr<regularExpression>
|
autoPtr<regExp>(new regExp(iter().keyword()))
|
||||||
(
|
|
||||||
new regularExpression(iter().keyword())
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,10 +160,7 @@ Foam::dictionary::dictionary
|
|||||||
wildCardEntries_.insert(&iter());
|
wildCardEntries_.insert(&iter());
|
||||||
wildCardRegexps_.insert
|
wildCardRegexps_.insert
|
||||||
(
|
(
|
||||||
autoPtr<regularExpression>
|
autoPtr<regExp>(new regExp(iter().keyword()))
|
||||||
(
|
|
||||||
new regularExpression(iter().keyword())
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,7 +220,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
|
|||||||
if (wildCardEntries_.size() > 0)
|
if (wildCardEntries_.size() > 0)
|
||||||
{
|
{
|
||||||
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
|
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
|
||||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
DLList<autoPtr<regExp> >::const_iterator reLink =
|
||||||
wildCardRegexps_.begin();
|
wildCardRegexps_.begin();
|
||||||
|
|
||||||
// Find in wildcards using regular expressions only
|
// Find in wildcards using regular expressions only
|
||||||
@ -265,7 +257,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
|
|||||||
{
|
{
|
||||||
DLList<entry*>::const_iterator wcLink =
|
DLList<entry*>::const_iterator wcLink =
|
||||||
wildCardEntries_.begin();
|
wildCardEntries_.begin();
|
||||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
DLList<autoPtr<regExp> >::const_iterator reLink =
|
||||||
wildCardRegexps_.begin();
|
wildCardRegexps_.begin();
|
||||||
|
|
||||||
// Find in wildcards using regular expressions only
|
// Find in wildcards using regular expressions only
|
||||||
@ -304,7 +296,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
|
|||||||
{
|
{
|
||||||
DLList<entry*>::iterator wcLink =
|
DLList<entry*>::iterator wcLink =
|
||||||
wildCardEntries_.begin();
|
wildCardEntries_.begin();
|
||||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
DLList<autoPtr<regExp> >::iterator reLink =
|
||||||
wildCardRegexps_.begin();
|
wildCardRegexps_.begin();
|
||||||
// Find in wildcards using regular expressions only
|
// Find in wildcards using regular expressions only
|
||||||
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
||||||
@ -486,10 +478,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
wildCardEntries_.insert(entryPtr);
|
wildCardEntries_.insert(entryPtr);
|
||||||
wildCardRegexps_.insert
|
wildCardRegexps_.insert
|
||||||
(
|
(
|
||||||
autoPtr<regularExpression>
|
autoPtr<regExp>(new regExp(entryPtr->keyword()))
|
||||||
(
|
|
||||||
new regularExpression(entryPtr->keyword())
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,10 +507,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
wildCardEntries_.insert(entryPtr);
|
wildCardEntries_.insert(entryPtr);
|
||||||
wildCardRegexps_.insert
|
wildCardRegexps_.insert
|
||||||
(
|
(
|
||||||
autoPtr<regularExpression>
|
autoPtr<regExp>(new regExp(entryPtr->keyword()))
|
||||||
(
|
|
||||||
new regularExpression(entryPtr->keyword())
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,8 +600,7 @@ bool Foam::dictionary::remove(const word& Keyword)
|
|||||||
// Delete from wildcards first
|
// Delete from wildcards first
|
||||||
DLList<entry*>::iterator wcLink =
|
DLList<entry*>::iterator wcLink =
|
||||||
wildCardEntries_.begin();
|
wildCardEntries_.begin();
|
||||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
DLList<autoPtr<regExp> >::iterator reLink = wildCardRegexps_.begin();
|
||||||
wildCardRegexps_.begin();
|
|
||||||
|
|
||||||
// Find in wildcards using exact match only
|
// Find in wildcards using exact match only
|
||||||
if (findInWildcards(false, Keyword, wcLink, reLink))
|
if (findInWildcards(false, Keyword, wcLink, reLink))
|
||||||
@ -682,7 +667,7 @@ bool Foam::dictionary::changeKeyword
|
|||||||
// Delete from wildcards first
|
// Delete from wildcards first
|
||||||
DLList<entry*>::iterator wcLink =
|
DLList<entry*>::iterator wcLink =
|
||||||
wildCardEntries_.begin();
|
wildCardEntries_.begin();
|
||||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
DLList<autoPtr<regExp> >::iterator reLink =
|
||||||
wildCardRegexps_.begin();
|
wildCardRegexps_.begin();
|
||||||
|
|
||||||
// Find in wildcards using exact match only
|
// Find in wildcards using exact match only
|
||||||
@ -721,10 +706,7 @@ bool Foam::dictionary::changeKeyword
|
|||||||
wildCardEntries_.insert(iter());
|
wildCardEntries_.insert(iter());
|
||||||
wildCardRegexps_.insert
|
wildCardRegexps_.insert
|
||||||
(
|
(
|
||||||
autoPtr<regularExpression>
|
autoPtr<regExp>(new regExp(newKeyword))
|
||||||
(
|
|
||||||
new regularExpression(newKeyword)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,6 +770,8 @@ void Foam::dictionary::clear()
|
|||||||
{
|
{
|
||||||
IDLList<entry>::clear();
|
IDLList<entry>::clear();
|
||||||
hashedEntries_.clear();
|
hashedEntries_.clear();
|
||||||
|
wildCardEntries_.clear();
|
||||||
|
wildCardRegexps_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,6 @@ SourceFiles
|
|||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "wordList.H"
|
#include "wordList.H"
|
||||||
#include "className.H"
|
#include "className.H"
|
||||||
#include "regularExpression.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
class regExp;
|
||||||
class dictionary;
|
class dictionary;
|
||||||
Istream& operator>>(Istream&, dictionary&);
|
Istream& operator>>(Istream&, dictionary&);
|
||||||
Ostream& operator<<(Ostream&, const dictionary&);
|
Ostream& operator<<(Ostream&, const dictionary&);
|
||||||
@ -96,8 +95,8 @@ class dictionary
|
|||||||
//- Wildcard entries
|
//- Wildcard entries
|
||||||
DLList<entry*> wildCardEntries_;
|
DLList<entry*> wildCardEntries_;
|
||||||
|
|
||||||
//- Wildcard precompiled regex
|
//- Wildcard precompiled regular expressions
|
||||||
DLList<autoPtr<regularExpression> > wildCardRegexps_;
|
DLList<autoPtr<regExp> > wildCardRegexps_;
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ class dictionary
|
|||||||
const bool wildCardMatch,
|
const bool wildCardMatch,
|
||||||
const word& Keyword,
|
const word& Keyword,
|
||||||
DLList<entry*>::const_iterator& wcLink,
|
DLList<entry*>::const_iterator& wcLink,
|
||||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
DLList<autoPtr<regExp> >::const_iterator& reLink
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Search wildcard table either for exact match or for regular
|
//- Search wildcard table either for exact match or for regular
|
||||||
@ -118,7 +117,7 @@ class dictionary
|
|||||||
const bool wildCardMatch,
|
const bool wildCardMatch,
|
||||||
const word& Keyword,
|
const word& Keyword,
|
||||||
DLList<entry*>::iterator& wcLink,
|
DLList<entry*>::iterator& wcLink,
|
||||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
DLList<autoPtr<regExp> >::iterator& reLink
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -164,16 +163,16 @@ public:
|
|||||||
dictionary(Istream&);
|
dictionary(Istream&);
|
||||||
|
|
||||||
//- Construct as copy given the parent dictionary
|
//- 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
|
//- Construct top-level dictionary as copy
|
||||||
dictionary(const dictionary& dict);
|
dictionary(const dictionary&);
|
||||||
|
|
||||||
//- Construct and return clone
|
//- Construct and return clone
|
||||||
Foam::autoPtr<dictionary> clone() const;
|
Foam::autoPtr<dictionary> clone() const;
|
||||||
|
|
||||||
//- Construct top-level dictionary on freestore from Istream
|
//- Construct top-level dictionary on freestore from Istream
|
||||||
static Foam::autoPtr<dictionary> New(Istream& is);
|
static Foam::autoPtr<dictionary> New(Istream&);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@ -212,12 +211,12 @@ public:
|
|||||||
|
|
||||||
//- Search dictionary for given keyword
|
//- Search dictionary for given keyword
|
||||||
// If recursive search parent dictionaries
|
// 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
|
//- Find and return an entry data stream pointer if present
|
||||||
// otherwise return NULL.
|
// otherwise return NULL.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
const entry* lookupEntryPtr
|
const entry* lookupEntryPtr
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -227,8 +226,8 @@ public:
|
|||||||
|
|
||||||
//- Find and return an entry data stream pointer for manipulation
|
//- Find and return an entry data stream pointer for manipulation
|
||||||
// if present otherwise return NULL.
|
// if present otherwise return NULL.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
entry* lookupEntryPtr
|
entry* lookupEntryPtr
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -237,8 +236,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Find and return an entry data stream if present otherwise error.
|
//- Find and return an entry data stream if present otherwise error.
|
||||||
// If recursive search parent dictionaries. If wildCardMatch
|
// If recursive search parent dictionaries.
|
||||||
// use wildcards.
|
// If wildCardMatch use wildcards.
|
||||||
const entry& lookupEntry
|
const entry& lookupEntry
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -332,13 +331,13 @@ public:
|
|||||||
|
|
||||||
//- Add a scalar entry
|
//- Add a scalar entry
|
||||||
// optionally overwrite an existing 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
|
//- Add a dictionary entry
|
||||||
// optionally merge with an existing sub-dictionary
|
// optionally merge with an existing sub-dictionary
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const keyType& keyword,
|
const keyType&,
|
||||||
const dictionary&,
|
const dictionary&,
|
||||||
bool mergeEntry=false
|
bool mergeEntry=false
|
||||||
);
|
);
|
||||||
@ -346,7 +345,7 @@ public:
|
|||||||
//- Add a T entry
|
//- Add a T entry
|
||||||
// optionally overwrite an existing entry
|
// optionally overwrite an existing entry
|
||||||
template<class T>
|
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
|
//- Assign a new entry, overwrite any existing entry
|
||||||
void set(entry*);
|
void set(entry*);
|
||||||
@ -355,14 +354,14 @@ public:
|
|||||||
void set(const entry&);
|
void set(const entry&);
|
||||||
|
|
||||||
//- Assign a dictionary entry, overwrite any existing 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
|
//- Assign a T entry, overwrite any existing entry
|
||||||
template<class T>
|
template<class T>
|
||||||
void set(const keyType& keyword, const T&);
|
void set(const keyType&, const T&);
|
||||||
|
|
||||||
//- Remove an entry specified by keyword
|
//- Remove an entry specified by keyword
|
||||||
bool remove(const word& keyword);
|
bool remove(const word&);
|
||||||
|
|
||||||
//- Change the keyword for an entry,
|
//- Change the keyword for an entry,
|
||||||
// optionally forcing overwrite of an existing entry
|
// optionally forcing overwrite of an existing entry
|
||||||
@ -370,7 +369,7 @@ public:
|
|||||||
(
|
(
|
||||||
const keyType& oldKeyword,
|
const keyType& oldKeyword,
|
||||||
const keyType& newKeyword,
|
const keyType& newKeyword,
|
||||||
bool forceOverwrite = false
|
bool forceOverwrite=false
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Merge entries from the given dictionary.
|
//- Merge entries from the given dictionary.
|
||||||
@ -383,7 +382,7 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
void write(Ostream& os, bool subDict = true) const;
|
void write(Ostream&, bool subDict=true) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "inputModeEntry.H"
|
#include "inputModeEntry.H"
|
||||||
|
#include "regExp.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -136,9 +137,6 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
|
|||||||
functionEntries::inputModeEntry::clear();
|
functionEntries::inputModeEntry::clear();
|
||||||
|
|
||||||
dict.clear();
|
dict.clear();
|
||||||
dict.hashedEntries_.clear();
|
|
||||||
dict.wildCardEntries_.clear();
|
|
||||||
dict.wildCardRegexps_.clear();
|
|
||||||
dict.read(is);
|
dict.read(is);
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ License
|
|||||||
|
|
||||||
#include "transformField.H"
|
#include "transformField.H"
|
||||||
#include "FieldM.H"
|
#include "FieldM.H"
|
||||||
|
#include "diagTensor.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -75,7 +76,8 @@ void Foam::transform
|
|||||||
{
|
{
|
||||||
vector T = tr.t();
|
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);
|
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);
|
TFOR_ALL_F_OP_S_OP_F(vector, rtf, =, vector, T, +, vector, tf);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rtf = vector::zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,19 +37,17 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||||
{
|
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||||
SLList<string> argList::validArgs;
|
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
|
||||||
HashTable<string> argList::validOptions;
|
bool Foam::argList::bannerEnabled(true);
|
||||||
HashTable<string> argList::validParOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::argList::initValidTables::initValidTables()
|
Foam::argList::initValidTables::initValidTables()
|
||||||
{
|
{
|
||||||
validOptions.insert("case", "dir");
|
validOptions.set("case", "dir");
|
||||||
validOptions.insert("parallel", "");
|
validOptions.set("parallel", "");
|
||||||
validParOptions.insert("parallel", "");
|
validParOptions.set("parallel", "");
|
||||||
|
|
||||||
Pstream::addValidParOptions(validParOptions);
|
Pstream::addValidParOptions(validParOptions);
|
||||||
}
|
}
|
||||||
@ -138,7 +136,7 @@ void Foam::argList::getRootCase()
|
|||||||
casePath = cwd();
|
casePath = cwd();
|
||||||
|
|
||||||
// we could add this back in as '-case'?
|
// we could add this back in as '-case'?
|
||||||
// options_.insert("case", casePath);
|
// options_.set("case", casePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
rootPath_ = casePath.path();
|
rootPath_ = casePath.path();
|
||||||
@ -285,7 +283,7 @@ Foam::argList::argList
|
|||||||
string timeString = clock::clockTime();
|
string timeString = clock::clockTime();
|
||||||
|
|
||||||
// Print the banner once only for parallel runs
|
// Print the banner once only for parallel runs
|
||||||
if (Pstream::master())
|
if (Pstream::master() && bannerEnabled)
|
||||||
{
|
{
|
||||||
IOobject::writeBanner(Info, true);
|
IOobject::writeBanner(Info, true);
|
||||||
Info<< "Exec : " << argListString.c_str() << nl
|
Info<< "Exec : " << argListString.c_str() << nl
|
||||||
@ -315,8 +313,6 @@ Foam::argList::argList
|
|||||||
// For the master
|
// For the master
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
fileNameList roots;
|
|
||||||
|
|
||||||
// establish rootPath_/globalCase_/case_ for master
|
// establish rootPath_/globalCase_/case_ for master
|
||||||
getRootCase();
|
getRootCase();
|
||||||
|
|
||||||
@ -333,45 +329,25 @@ Foam::argList::argList
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
dictionary decompositionDict(decompDictStream);
|
dictionary decompDict(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
label dictNProcs
|
label dictNProcs
|
||||||
(
|
(
|
||||||
readLabel
|
readLabel
|
||||||
(
|
(
|
||||||
decompositionDict.lookup("numberOfSubdomains")
|
decompDict.lookup("numberOfSubdomains")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check number of processors. We have nProcs(number of
|
// Check number of processors.
|
||||||
// actual processes), dictNProcs(wanted number of processes read
|
// nProcs => number of actual procs
|
||||||
// from decompositionDict) and nProcDirs(number of processor
|
// dictNProcs => number of procs specified in decompositionDict
|
||||||
// directories - n/a when running distributed)
|
// nProcDirs => number of processor directories
|
||||||
|
// (n/a when running distributed)
|
||||||
//
|
//
|
||||||
// - normal running : nProcs = dictNProcs = nProcDirs
|
// - normal running : nProcs = dictNProcs = nProcDirs
|
||||||
// - decomposition to more processors : nProcs = dictNProcs
|
// - decomposition to more processors : nProcs = dictNProcs
|
||||||
// - decomposition to less processors : nProcs = nProcDirs
|
// - decomposition to fewer processors : nProcs = nProcDirs
|
||||||
if (dictNProcs > Pstream::nProcs())
|
if (dictNProcs > Pstream::nProcs())
|
||||||
{
|
{
|
||||||
FatalError
|
FatalError
|
||||||
@ -382,38 +358,23 @@ Foam::argList::argList
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!distributed && dictNProcs < Pstream::nProcs())
|
// distributed data
|
||||||
|
if (decompDict.lookupOrDefault<Switch>("distributed", false))
|
||||||
{
|
{
|
||||||
// Possibly going to fewer processors.
|
fileNameList roots;
|
||||||
// Check if all procDirs are there.
|
decompDict.lookup("roots") >> roots;
|
||||||
label nProcDirs = 0;
|
|
||||||
while
|
|
||||||
(
|
|
||||||
dir
|
|
||||||
(
|
|
||||||
rootPath_/globalCase_/"processor"
|
|
||||||
+ name(++nProcDirs)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{}
|
|
||||||
|
|
||||||
if (nProcDirs != Pstream::nProcs())
|
if (roots.size() != Pstream::nProcs()-1)
|
||||||
{
|
{
|
||||||
FatalError
|
FatalError
|
||||||
<< "number of processor directories = "
|
<< "number of entries in decompositionDict::roots"
|
||||||
<< nProcDirs
|
<< " is not equal to the number of slaves "
|
||||||
<< " is not equal to the number of processors = "
|
<< Pstream::nProcs()-1
|
||||||
<< Pstream::nProcs()
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// distributed data
|
|
||||||
if (roots.size())
|
|
||||||
{
|
|
||||||
bool hadOptCase = options_.found("case");
|
|
||||||
|
|
||||||
// Distribute the master's argument list (with new root)
|
// Distribute the master's argument list (with new root)
|
||||||
|
bool hadCaseOpt = options_.found("case");
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
int slave=Pstream::firstSlave();
|
int slave=Pstream::firstSlave();
|
||||||
@ -421,8 +382,7 @@ Foam::argList::argList
|
|||||||
slave++
|
slave++
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
options_.erase("case");
|
options_.set
|
||||||
options_.insert
|
|
||||||
(
|
(
|
||||||
"case",
|
"case",
|
||||||
fileName(roots[slave-1])/globalCase_
|
fileName(roots[slave-1])/globalCase_
|
||||||
@ -431,17 +391,42 @@ Foam::argList::argList
|
|||||||
OPstream toSlave(Pstream::scheduled, slave);
|
OPstream toSlave(Pstream::scheduled, slave);
|
||||||
toSlave << args_ << options_;
|
toSlave << args_ << options_;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_.erase("case");
|
options_.erase("case");
|
||||||
|
|
||||||
// restore [-case dir]
|
// restore [-case dir]
|
||||||
if (hadOptCase)
|
if (hadCaseOpt)
|
||||||
{
|
{
|
||||||
options_.insert("case", rootPath_/globalCase_);
|
options_.set("case", rootPath_/globalCase_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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)
|
// Distribute the master's argument list (unaltered)
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -472,7 +457,6 @@ Foam::argList::argList
|
|||||||
{
|
{
|
||||||
// establish rootPath_/globalCase_/case_
|
// establish rootPath_/globalCase_/case_
|
||||||
getRootCase();
|
getRootCase();
|
||||||
|
|
||||||
case_ = globalCase_;
|
case_ = globalCase_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,21 +494,21 @@ Foam::argList::argList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master() && bannerEnabled)
|
||||||
{
|
{
|
||||||
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
|
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
|
||||||
<< "nProcs : " << nProcs << endl;
|
<< "nProcs : " << nProcs << endl;
|
||||||
}
|
|
||||||
|
|
||||||
if (parRunControl_.parRun() && Pstream::master())
|
if (parRunControl_.parRun())
|
||||||
{
|
{
|
||||||
Info<< "Slaves : " << slaveProcs << nl
|
Info<< "Slaves : " << slaveProcs << nl
|
||||||
<< "Pstream initialized with:" << nl
|
<< "Pstream initialized with:" << nl
|
||||||
<< " floatTransfer : " << Pstream::floatTransfer << nl
|
<< " floatTransfer : " << Pstream::floatTransfer << nl
|
||||||
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
|
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
|
||||||
<< " commsType : "
|
<< " commsType : "
|
||||||
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
<< Pstream::commsTypeNames[Pstream::defaultCommsType]
|
||||||
<< endl;
|
<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jobInfo.add("root", rootPath_);
|
jobInfo.add("root", rootPath_);
|
||||||
@ -546,7 +530,7 @@ Foam::argList::argList
|
|||||||
sigQuit_.set();
|
sigQuit_.set();
|
||||||
sigSegv_.set();
|
sigSegv_.set();
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master() && bannerEnabled)
|
||||||
{
|
{
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
IOobject::writeDivider(Info);
|
IOobject::writeDivider(Info);
|
||||||
@ -564,6 +548,12 @@ Foam::argList::~argList()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::argList::noBanner()
|
||||||
|
{
|
||||||
|
bannerEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::argList::noParallel()
|
void Foam::argList::noParallel()
|
||||||
{
|
{
|
||||||
validOptions.erase("parallel");
|
validOptions.erase("parallel");
|
||||||
|
|||||||
@ -92,6 +92,7 @@ namespace Foam
|
|||||||
class argList
|
class argList
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
static bool bannerEnabled;
|
||||||
|
|
||||||
stringList args_;
|
stringList args_;
|
||||||
HashTable<string> options_;
|
HashTable<string> options_;
|
||||||
@ -213,6 +214,9 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
//- Disable emitting the banner information
|
||||||
|
static void noBanner();
|
||||||
|
|
||||||
//- Remove the parallel options
|
//- Remove the parallel options
|
||||||
static void noParallel();
|
static void noParallel();
|
||||||
|
|
||||||
|
|||||||
@ -259,7 +259,7 @@ public:
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
@ -267,7 +267,7 @@ public:
|
|||||||
interfaceBouCoeffs,
|
interfaceBouCoeffs,
|
||||||
interfaceIntCoeffs,
|
interfaceIntCoeffs,
|
||||||
interfaces,
|
interfaces,
|
||||||
solverData
|
solverControls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ public:
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
@ -290,7 +290,7 @@ public:
|
|||||||
interfaceBouCoeffs,
|
interfaceBouCoeffs,
|
||||||
interfaceIntCoeffs,
|
interfaceIntCoeffs,
|
||||||
interfaces,
|
interfaces,
|
||||||
solverData
|
solverControls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ public:
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
);
|
);
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
@ -317,7 +317,7 @@ public:
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Read and reset the solver parameters from the given stream
|
//- Read and reset the solver parameters from the given stream
|
||||||
virtual void read(Istream& solverData);
|
virtual void read(const dictionary&);
|
||||||
|
|
||||||
virtual solverPerformance solve
|
virtual solverPerformance solve
|
||||||
(
|
(
|
||||||
@ -396,6 +396,9 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- Find the smoother name (directly or from a sub-dictionary)
|
||||||
|
static word getName(const dictionary&);
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
virtual const word& type() const = 0;
|
virtual const word& type() const = 0;
|
||||||
|
|
||||||
@ -467,7 +470,7 @@ public:
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& smootherData
|
const dictionary& solverControls
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -531,6 +534,9 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
//- Find the preconditioner name (directly or from a sub-dictionary)
|
||||||
|
static word getName(const dictionary&);
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
virtual const word& type() const = 0;
|
virtual const word& type() const = 0;
|
||||||
|
|
||||||
@ -544,9 +550,9 @@ public:
|
|||||||
symMatrix,
|
symMatrix,
|
||||||
(
|
(
|
||||||
const solver& sol,
|
const solver& sol,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControls
|
||||||
),
|
),
|
||||||
(sol, preconditionerData)
|
(sol, solverControls)
|
||||||
);
|
);
|
||||||
|
|
||||||
declareRunTimeSelectionTable
|
declareRunTimeSelectionTable
|
||||||
@ -556,9 +562,9 @@ public:
|
|||||||
asymMatrix,
|
asymMatrix,
|
||||||
(
|
(
|
||||||
const solver& sol,
|
const solver& sol,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControls
|
||||||
),
|
),
|
||||||
(sol, preconditionerData)
|
(sol, solverControls)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -579,7 +585,7 @@ public:
|
|||||||
static autoPtr<preconditioner> New
|
static autoPtr<preconditioner> New
|
||||||
(
|
(
|
||||||
const solver& sol,
|
const solver& sol,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControls
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -593,7 +599,7 @@ public:
|
|||||||
|
|
||||||
//- Read and reset the preconditioner parameters
|
//- Read and reset the preconditioner parameters
|
||||||
// from the given stream
|
// from the given stream
|
||||||
virtual void read(Istream& preconditionerData)
|
virtual void read(const dictionary&)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Return wA the preconditioned form of residual rA
|
//- Return wA the preconditioned form of residual rA
|
||||||
|
|||||||
@ -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::autoPtr<Foam::lduMatrix::preconditioner>
|
||||||
Foam::lduMatrix::preconditioner::New
|
Foam::lduMatrix::preconditioner::New
|
||||||
(
|
(
|
||||||
const solver& sol,
|
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())
|
if (sol.matrix().symmetric())
|
||||||
{
|
{
|
||||||
symMatrixConstructorTable::iterator constructorIter =
|
symMatrixConstructorTable::iterator constructorIter =
|
||||||
symMatrixConstructorTablePtr_->find(preconditionerName);
|
symMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
"lduMatrix::preconditioner::New"
|
||||||
preconditionerData
|
"(const solver&, const dictionary&)",
|
||||||
|
controls
|
||||||
) << "Unknown symmetric matrix preconditioner "
|
) << "Unknown symmetric matrix preconditioner "
|
||||||
<< preconditionerName << endl << endl
|
<< name << nl << nl
|
||||||
<< "Valid symmetric matrix preconditioners are :" << endl
|
<< "Valid symmetric matrix preconditioners :" << endl
|
||||||
<< symMatrixConstructorTablePtr_->toc()
|
<< symMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New
|
|||||||
constructorIter()
|
constructorIter()
|
||||||
(
|
(
|
||||||
sol,
|
sol,
|
||||||
preconditionerData
|
controls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (sol.matrix().asymmetric())
|
else if (sol.matrix().asymmetric())
|
||||||
{
|
{
|
||||||
asymMatrixConstructorTable::iterator constructorIter =
|
asymMatrixConstructorTable::iterator constructorIter =
|
||||||
asymMatrixConstructorTablePtr_->find(preconditionerName);
|
asymMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
"lduMatrix::preconditioner::New"
|
||||||
preconditionerData
|
"(const solver&, const dictionary&)",
|
||||||
|
controls
|
||||||
) << "Unknown asymmetric matrix preconditioner "
|
) << "Unknown asymmetric matrix preconditioner "
|
||||||
<< preconditionerName << endl << endl
|
<< name << nl << nl
|
||||||
<< "Valid asymmetric matrix preconditioners are :" << endl
|
<< "Valid asymmetric matrix preconditioners :" << endl
|
||||||
<< asymMatrixConstructorTablePtr_->toc()
|
<< asymMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New
|
|||||||
constructorIter()
|
constructorIter()
|
||||||
(
|
(
|
||||||
sol,
|
sol,
|
||||||
preconditionerData
|
controls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::preconditioner::New(const solver&, Istream&)",
|
"lduMatrix::preconditioner::New"
|
||||||
preconditionerData
|
"(const solver&, const dictionary&)",
|
||||||
) << "cannot preconditione incomplete matrix, "
|
controls
|
||||||
|
) << "cannot solve incomplete matrix, "
|
||||||
"no diagonal or off-diagonal coefficient"
|
"no diagonal or off-diagonal coefficient"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
|
|||||||
@ -34,9 +34,31 @@ namespace Foam
|
|||||||
defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
|
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
|
Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
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>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
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())
|
if (matrix.symmetric())
|
||||||
{
|
{
|
||||||
symMatrixConstructorTable::iterator constructorIter =
|
symMatrixConstructorTable::iterator constructorIter =
|
||||||
symMatrixConstructorTablePtr_->find(smootherName);
|
symMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::smoother::New", smootherData
|
"lduMatrix::smoother::New", solverControls
|
||||||
) << "Unknown symmetric matrix smoother " << smootherName
|
) << "Unknown symmetric matrix smoother "
|
||||||
<< endl << endl
|
<< name << nl << nl
|
||||||
<< "Valid symmetric matrix smoothers are :" << endl
|
<< "Valid symmetric matrix smoothers are :" << endl
|
||||||
<< symMatrixConstructorTablePtr_->toc()
|
<< symMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -81,15 +117,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
|||||||
else if (matrix.asymmetric())
|
else if (matrix.asymmetric())
|
||||||
{
|
{
|
||||||
asymMatrixConstructorTable::iterator constructorIter =
|
asymMatrixConstructorTable::iterator constructorIter =
|
||||||
asymMatrixConstructorTablePtr_->find(smootherName);
|
asymMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::smoother::New", smootherData
|
"lduMatrix::smoother::New", solverControls
|
||||||
) << "Unknown asymmetric matrix smoother " << smootherName
|
) << "Unknown asymmetric matrix smoother "
|
||||||
<< endl << endl
|
<< name << nl << nl
|
||||||
<< "Valid asymmetric matrix smoothers are :" << endl
|
<< "Valid asymmetric matrix smoothers are :" << endl
|
||||||
<< asymMatrixConstructorTablePtr_->toc()
|
<< asymMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -111,8 +147,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::smoother::New", smootherData
|
"lduMatrix::smoother::New", solverControls
|
||||||
) << "cannot solve incomplete matrix, no off-diagonal coefficients"
|
) << "cannot solve incomplete matrix, "
|
||||||
|
"no diagonal or off-diagonal coefficient"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return autoPtr<lduMatrix::smoother>(NULL);
|
return autoPtr<lduMatrix::smoother>(NULL);
|
||||||
|
|||||||
@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
word solverName(solverData);
|
word name(solverControls.lookup("solver"));
|
||||||
|
|
||||||
if (matrix.diagonal())
|
if (matrix.diagonal())
|
||||||
{
|
{
|
||||||
@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
|||||||
interfaceBouCoeffs,
|
interfaceBouCoeffs,
|
||||||
interfaceIntCoeffs,
|
interfaceIntCoeffs,
|
||||||
interfaces,
|
interfaces,
|
||||||
solverData
|
solverControls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (matrix.symmetric())
|
else if (matrix.symmetric())
|
||||||
{
|
{
|
||||||
symMatrixConstructorTable::iterator constructorIter =
|
symMatrixConstructorTable::iterator constructorIter =
|
||||||
symMatrixConstructorTablePtr_->find(solverName);
|
symMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
if (constructorIter == symMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::solver::New", solverData
|
"lduMatrix::solver::New", solverControls
|
||||||
) << "Unknown symmetric matrix solver " << solverName
|
) << "Unknown symmetric matrix solver " << name << nl << nl
|
||||||
<< endl << endl
|
|
||||||
<< "Valid symmetric matrix solvers are :" << endl
|
<< "Valid symmetric matrix solvers are :" << endl
|
||||||
<< symMatrixConstructorTablePtr_->toc()
|
<< symMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
|||||||
interfaceBouCoeffs,
|
interfaceBouCoeffs,
|
||||||
interfaceIntCoeffs,
|
interfaceIntCoeffs,
|
||||||
interfaces,
|
interfaces,
|
||||||
solverData
|
solverControls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (matrix.asymmetric())
|
else if (matrix.asymmetric())
|
||||||
{
|
{
|
||||||
asymMatrixConstructorTable::iterator constructorIter =
|
asymMatrixConstructorTable::iterator constructorIter =
|
||||||
asymMatrixConstructorTablePtr_->find(solverName);
|
asymMatrixConstructorTablePtr_->find(name);
|
||||||
|
|
||||||
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
if (constructorIter == asymMatrixConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::solver::New", solverData
|
"lduMatrix::solver::New", solverControls
|
||||||
) << "Unknown asymmetric matrix solver " << solverName
|
) << "Unknown asymmetric matrix solver " << name << nl << nl
|
||||||
<< endl << endl
|
|
||||||
<< "Valid asymmetric matrix solvers are :" << endl
|
<< "Valid asymmetric matrix solvers are :" << endl
|
||||||
<< asymMatrixConstructorTablePtr_->toc()
|
<< asymMatrixConstructorTablePtr_->toc()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
|||||||
interfaceBouCoeffs,
|
interfaceBouCoeffs,
|
||||||
interfaceIntCoeffs,
|
interfaceIntCoeffs,
|
||||||
interfaces,
|
interfaces,
|
||||||
solverData
|
solverControls
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
|
|||||||
{
|
{
|
||||||
FatalIOErrorIn
|
FatalIOErrorIn
|
||||||
(
|
(
|
||||||
"lduMatrix::solver::New", solverData
|
"lduMatrix::solver::New", solverControls
|
||||||
) << "cannot solve incomplete matrix, "
|
) << "cannot solve incomplete matrix, "
|
||||||
"no diagonal or off-diagonal coefficient"
|
"no diagonal or off-diagonal coefficient"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver
|
|||||||
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
const FieldField<Field, scalar>& interfaceBouCoeffs,
|
||||||
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
const FieldField<Field, scalar>& interfaceIntCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaces,
|
const lduInterfaceFieldPtrsList& interfaces,
|
||||||
Istream& solverData
|
const dictionary& solverControls
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
fieldName_(fieldName),
|
fieldName_(fieldName),
|
||||||
@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver
|
|||||||
interfaceBouCoeffs_(interfaceBouCoeffs),
|
interfaceBouCoeffs_(interfaceBouCoeffs),
|
||||||
interfaceIntCoeffs_(interfaceIntCoeffs),
|
interfaceIntCoeffs_(interfaceIntCoeffs),
|
||||||
interfaces_(interfaces),
|
interfaces_(interfaces),
|
||||||
|
controlDict_(solverControls)
|
||||||
controlDict_(solverData),
|
|
||||||
|
|
||||||
maxIter_(1000),
|
|
||||||
tolerance_(1e-6),
|
|
||||||
relTol_(0)
|
|
||||||
{
|
{
|
||||||
readControls();
|
readControls();
|
||||||
}
|
}
|
||||||
@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver
|
|||||||
|
|
||||||
void Foam::lduMatrix::solver::readControls()
|
void Foam::lduMatrix::solver::readControls()
|
||||||
{
|
{
|
||||||
controlDict_.readIfPresent("maxIter", maxIter_);
|
maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000);
|
||||||
controlDict_.readIfPresent("tolerance", tolerance_);
|
tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6);
|
||||||
controlDict_.readIfPresent("relTol", relTol_);
|
relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::lduMatrix::solver::read(Istream& solverData)
|
void Foam::lduMatrix::solver::read(const dictionary& solverControls)
|
||||||
{
|
{
|
||||||
word solverName(solverData);
|
controlDict_ = solverControls;
|
||||||
solverData >> controlDict_;
|
|
||||||
readControls();
|
readControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace Foam
|
|||||||
Foam::DICPreconditioner::DICPreconditioner
|
Foam::DICPreconditioner::DICPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver& sol,
|
||||||
Istream&
|
const dictionary&
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
lduMatrix::preconditioner(sol),
|
lduMatrix::preconditioner(sol),
|
||||||
|
|||||||
@ -67,11 +67,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from matrix components and preconditioner data stream
|
//- Construct from matrix components and preconditioner solver controls
|
||||||
DICPreconditioner
|
DICPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver&,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControlsUnused
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace Foam
|
|||||||
Foam::DILUPreconditioner::DILUPreconditioner
|
Foam::DILUPreconditioner::DILUPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver& sol,
|
||||||
Istream&
|
const dictionary&
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
lduMatrix::preconditioner(sol),
|
lduMatrix::preconditioner(sol),
|
||||||
|
|||||||
@ -67,11 +67,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from matrix components and preconditioner data stream
|
//- Construct from matrix components and preconditioner solver controls
|
||||||
DILUPreconditioner
|
DILUPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver&,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControlsUnused
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -94,8 +94,7 @@ public:
|
|||||||
const direction cmpt=0
|
const direction cmpt=0
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return wT the transpose-matrix preconditioned form of
|
//- Return wT the transpose-matrix preconditioned form of residual rT.
|
||||||
// residual rT.
|
|
||||||
virtual void preconditionT
|
virtual void preconditionT
|
||||||
(
|
(
|
||||||
scalarField& wT,
|
scalarField& wT,
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace Foam
|
|||||||
Foam::FDICPreconditioner::FDICPreconditioner
|
Foam::FDICPreconditioner::FDICPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver& sol,
|
||||||
Istream&
|
const dictionary&
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
lduMatrix::preconditioner(sol),
|
lduMatrix::preconditioner(sol),
|
||||||
|
|||||||
@ -80,11 +80,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from matrix components and preconditioner data stream
|
//- Construct from matrix components and preconditioner solver controls
|
||||||
FDICPreconditioner
|
FDICPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver&,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControlsUnused
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace Foam
|
|||||||
Foam::GAMGPreconditioner::GAMGPreconditioner
|
Foam::GAMGPreconditioner::GAMGPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver& sol,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControls
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
GAMGSolver
|
GAMGSolver
|
||||||
@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner
|
|||||||
sol.interfaceBouCoeffs(),
|
sol.interfaceBouCoeffs(),
|
||||||
sol.interfaceIntCoeffs(),
|
sol.interfaceIntCoeffs(),
|
||||||
sol.interfaces(),
|
sol.interfaces(),
|
||||||
preconditionerData
|
solverControls
|
||||||
),
|
),
|
||||||
lduMatrix::preconditioner(sol),
|
lduMatrix::preconditioner(sol),
|
||||||
nVcycles_(2)
|
nVcycles_(2)
|
||||||
@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
|
|||||||
void Foam::GAMGPreconditioner::readControls()
|
void Foam::GAMGPreconditioner::readControls()
|
||||||
{
|
{
|
||||||
GAMGSolver::readControls();
|
GAMGSolver::readControls();
|
||||||
controlDict_.readIfPresent("nVcycles", nVcycles_);
|
nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::GAMGPreconditioner::read(Istream& solverData)
|
|
||||||
{
|
|
||||||
GAMGSolver::read(solverData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -55,17 +55,14 @@ class GAMGPreconditioner
|
|||||||
public GAMGSolver,
|
public GAMGSolver,
|
||||||
public lduMatrix::preconditioner
|
public lduMatrix::preconditioner
|
||||||
{
|
{
|
||||||
// Private data
|
protected:
|
||||||
|
// Protected data
|
||||||
|
|
||||||
//- Number of V-cycles to perform
|
//- Number of V-cycles to perform
|
||||||
label nVcycles_;
|
label nVcycles_;
|
||||||
|
|
||||||
|
//- Read the control parameters from the controlDict_
|
||||||
// Private member functions
|
virtual void readControls();
|
||||||
|
|
||||||
//- Read control parameters from the control dictionary
|
|
||||||
void readControls();
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -75,11 +72,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct for given solver and preconditioner data stream
|
//- Construct from matrix components and preconditioner solver controls
|
||||||
GAMGPreconditioner
|
GAMGPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver&,
|
||||||
Istream& preconditionerData
|
const dictionary& solverControls
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -90,9 +87,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read and reset the preconditioner parameters from the given stream
|
|
||||||
virtual void read(Istream& preconditionerData);
|
|
||||||
|
|
||||||
//- Return wA the preconditioned form of residual rA
|
//- Return wA the preconditioned form of residual rA
|
||||||
virtual void precondition
|
virtual void precondition
|
||||||
(
|
(
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Foam
|
|||||||
Foam::diagonalPreconditioner::diagonalPreconditioner
|
Foam::diagonalPreconditioner::diagonalPreconditioner
|
||||||
(
|
(
|
||||||
const lduMatrix::solver& sol,
|
const lduMatrix::solver& sol,
|
||||||
Istream&
|
const dictionary&
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
lduMatrix::preconditioner(sol),
|
lduMatrix::preconditioner(sol),
|
||||||
@ -77,10 +77,6 @@ Foam::diagonalPreconditioner::diagonalPreconditioner
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::diagonalPreconditioner::read(Istream&)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::diagonalPreconditioner::precondition
|
void Foam::diagonalPreconditioner::precondition
|
||||||
(
|
(
|
||||||
scalarField& wA,
|
scalarField& wA,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user