Compare commits

...

128 Commits

Author SHA1 Message Date
7f5aae75e0 BUG: parse issues for nastran long format (closes #589) 2017-09-15 10:55:27 +02:00
ba8fa9f2ca wmake/scripts/wmakeFunctions: Add support for $WM_PROJECT_DIR being a link 2016-06-15 14:22:33 +01:00
e8885c868d BUG: incorrect fall-through in directionalPressureGradientExplicitSource (fixes #486) 2017-05-29 15:36:44 +02:00
cc676d1820 BUG: foamToEnsight fails with missing field at time 0 (fixes #473) 2017-05-16 17:53:29 +02:00
61ea8936bb BUG: Corrected compilation errors 2017-04-19 13:56:55 +01:00
e6695e7354 BUG: typo in addProfiling0 macro (fixes #446) 2017-04-07 07:46:17 +02:00
79d4e466a2 BUG: in wordRe::operator=(const keyType&)
- the regex was not being unset on assignment.
- drop unused recompile() method as being dubious
2017-03-10 13:05:35 +01:00
085ff44ea4 BUG: meshToMesh - corrected indexing of cutting patches. See #376 2017-01-10 17:04:12 +00:00
967a5c2216 BUG: turbulentDFSEMInlet BC - corrected singleProc usage for parallel runs. Fixes #374 2017-01-06 11:00:58 +00:00
983a1d1b15 Adding autoPtr clone constructors and correcting T.oldTime() 2016-12-13 13:30:42 -08:00
3d7b6bdba2 BUG: Fixing oldTime Tw and Reference Value of humidityTemperatureCoupledMixed BC 2016-12-13 09:44:25 -08:00
8d7379bc72 BUG: surfaceNoise - corrected fftWriteInterval operation 2016-12-06 16:19:01 +00:00
9d168b2b8e ENH: Changes in handling topological changes in VOF solvers
1) Using divU instead of fvc::absolute(phi,U) in TEqn as the latter uses latest time meshPhi which is inconsistent
2) Adding fvc::interpolate(U) when topo changes
3) in pEq for compressible dgdt is updated using the latest rho1 and rho2 after compressible effects are considered
2016-12-07 12:57:32 -08:00
24a6c4810d ENH: Lagrangian models - added headers to enable derived libraries to compile 2016-11-29 09:10:37 +00:00
c97b1f21e1 STYLE: porosityModel - minor cleanup of bounds output 2016-11-21 09:44:00 +00:00
c7ec42c3da BUG: Following issue 284 for particle switching processors flag 2016-11-21 11:54:31 -08:00
1497394c7a ENH: Adding writing of the motionSolver dictionary for sixDoFRigidBodyDisplacementPointPatchVectorField BC 2016-11-17 08:46:27 -08:00
b70b0bb5cb ENH: Porosity model - output cellZone bounds in the local co-ordinate system. Fixes #300 2016-11-17 13:35:35 +00:00
e661d2382f Correcting header information for IDDESDelta 2016-11-17 08:41:08 -08:00
331d24ed0c ENH: consistent output format for coupled geometry description (issue #278)
- In the corner case with few faces or points, the normal List I/O
  results in a compact list representation.

  This is less than desirable for external programs with simple
  line-based parsers.

- Write exactly the following

*Faces*
// Patch: <word-Region> <word-Patch>
<int-nFaces>
(
<int-faceSize>(<int> .. <int>)
...
)

*Points*
// Patch: <word-Region> <word-Patch>
<int-nPoints>
(
(<float-x> <float-y> <float-z>)
...
)

STYLE: only use serial form of createExternalCoupledPatchGeometry in tutorial

- less confusing for the user, who wonders why it is being done twice.
2016-11-02 17:26:25 +01:00
a79eaa2d64 ENH: provide separate geometry description per region/patch (issue #278)
- Also fixed bug noted in issue #269

- Previous implementation had all faces together, which made
  it difficult (impossible) for external applications to
  figure out which geometry was being referred to.

- Provide separate region/patches as follows:

    // Patch: <regionName> <patchName>

  For example,

    // Group: coupleGroup
    // Patch: heater minY
    8( ... )

  The region-name is always present, even if there is only one region.

- This change is a partial reversion to the behaviour in 2.4.x, except
  that we can now also handle multi-region geometries.

  Changing the leading comment from "# " to "// " facilitates parsing
  of the files with OpenFOAM itself if necessary.
2016-10-25 15:43:46 +02:00
19b5952c35 ENH: enable 'status=done' when finishing an externalCoupled FO
- This provides a mechanism for the external code to detect when
  OpenFOAM is done.

- Adjust tutorial to use the mechanism. Also test in parallel.
2016-10-25 15:43:27 +02:00
83db6f793c BUG: resolve some decomposeParDict problems (issues #60, #265).
- Cleanup/centralize handling of -decomposeParDict by relocating
  common code into argList. Ensures that all processes receive
  identical information about the -decomposeParDict opton.

- Only use alternative decomposeParDict for simpleFoam/motorBike
  tutorial so that this will be included in the test loop for snappy.

- Added Mattijs' fix for surfaceRedistributePar.
2016-10-25 18:19:19 +02:00
c9e9815b86 ENh: Adding clone member to sixDoFSolvers 2016-10-26 14:53:26 -07:00
1ff9ae9ff5 ENH: setTimeStep: adjust timestep for adjustableRunTime writeInterval. Fixes #268. 2016-10-24 13:07:51 +01:00
1f408ffd1b ENH: effectivenessHeatExchangerSource - calculate upstream average temperature by default 2016-10-26 15:54:03 +01:00
1df1f8fe20 STYLE: adjust mergePoints to ease adoption of different list types (issue #250)
- A preliminary minor adjustment only.
2016-10-19 10:42:47 +02:00
dad301d81c BUG: foamCleanPath problem if path contains @ (closes #264)
- Can occur with some user names, or mounted paths.
  Resolve by using '?' for the separation character.

  Since '?' is a shell-glob, it is highly unlikely to occur appear in
  filenames.  Additionally, it is not a meta-character in standard sed,
  nor in the GNU extension (which uses '\?').
2016-10-18 09:52:37 +02:00
779f884355 COMP: compile issue with gcc-5.2 (closes #273)
- Superfluous #include "FieldFunctions.H" provokes warnings/errors
  with newer gcc.
2016-10-17 21:50:30 +02:00
5682eb6035 BUG: snappyHexMesh: findCellZoneTopo was copying same value but still setting
changed flag which caused infinite while loop. Background info:
- findCellZoneTopo tries to find for all named surface intersections
which side of the face is in the faceZone
- i.e. it tries to make the cellZone consistent with the faceZone
(to fix small problems)
- this had some logic to assign the neighbour cellZone to the owner cellZone
- which didn't check for the neighbour being the same value as the owner
- but still set a 'changed' flag which caused the loop to never end.
2016-10-17 12:25:03 +01:00
a5e1c11a4b ENH: subTriSurfaceMesh: fixed comment 2016-10-17 12:24:11 +01:00
2b5e278ffc STYLE: Corrected typo 2016-10-19 13:20:18 +01:00
b386d8a1c2 ENH: gmshToFoam: Updated for line entries 2016-10-19 13:20:02 +01:00
9cfce48c9c ENH: noiseModel: Updated check for uniform time step size 2016-10-19 13:19:34 +01:00
8f7ad9130a ENH: wallDist - suppress calc if updateInterval is zero 2016-09-30 11:47:38 +01:00
0ceb2cd230 ENH: wallDist - added option to evaluate every XXX steps 2016-09-28 16:59:57 +01:00
025eebca13 ENH: provide direct access to raw pointer/reference from autoPtr (issue #252)
All of the access methods for autoPtr include validity checks and will
fail if the underlying point is NULL. In some cases, however, we'd
like to retain the automatic deletion mechanism, but still address a
nullptr. This is mostly for cases in which a file-stream should be
allocated, but only on the master process. For these cases we'd still
like to pass through and reference the underlying pointer (eg, to
obtain the correct method call) without tripping the pointer check
mechanism. If we attempt to use the ptr() method, the autoPtr memory
management is bypassed and we risk memory leaks.

Instead provide an alternative mechanism to obtain the raw underlying
pointers/references. Use rawPtr() and rawRef() for these potentially
useful, but also potentially dangerous, operations.
2016-10-03 16:38:19 +02:00
a5ff48870f ENH: surfaceCheck: added -outputThreshold option to manage file writing 2016-10-03 13:55:30 +01:00
59418c711a STYLE: Added header documentation to function 2016-09-29 10:30:30 +01:00
4093fcd66b ENH: provide refOrNull method for autoPtr.
- Normally use '()' to deference. This has extra safety and issues a
  fatal error if the underlying pointer is not valid.

  However, in some cases we are happy with getting a null reference.
  The refOrNull() method returns the reference without any checking.

  Usage example:

      autoPtr<OFstream> osPtr;
      if (Pstream::master())
      {
          osPtr.reset(new OFstream(...));
      }
      writeViaMaster(osPtr.refOrNull());

      - The writeViaMaster() call takes an OFstream reference,
        but this is only used directly on the master.
        The slaves will pass things through to the master.
2016-09-28 11:26:42 +02:00
85885adea8 ENH: provide list of enums for NamedEnum
- can be used to loop over all enumerations in the order of definition.
2016-09-27 12:40:17 +02:00
26b6f93b33 ENH: distributedTriSurfaceMesh: bail out if getting stuck due to precision errors 2016-09-28 12:26:23 +01:00
67970d02b6 STYLE: minor adjustment to echoed information 2016-09-26 08:02:03 +02:00
9fbb796135 Fix tensor names in foamToEnsightParts case file (fixes #243) 2016-09-26 07:41:02 +02:00
fbc1a1d82a ENH: reduce startup time for foamToVTK conversion
- Similar to ensight converters (issue #240),
  improve speed for detection of lagrangian clouds.

- provide a -noLagrangian option for symmetry
2016-09-23 18:45:06 +02:00
7d2ea92570 ENH: reduce startup time for ensight conversion (issue #240).
- Less looping when detecting lagrangian clouds and their fields.

- Avoid using Time::setTime() and IOobjectList in tight loops.
  They both kill performance immensely.

ENH: provide a -noLagrangian option to foamToEnsight and foamToEnsightParts
for even more control.
2016-09-23 17:45:47 +02:00
af13209920 STYLE: add OpenFOAM version to ensight geom file description.
- More informative than a horizonal line, can help when debugging.

STYLE: remove unused write field methods from ensightParts
2016-09-23 14:53:01 +02:00
53ed99b084 BUG: ensight output failing with dimensioned field (fixes #244)
- The new field needs initialization with a dimensioned<Type> not just
  the dimensionSet.

- The new field was also incorrectly being registered, which could
  cause issues later.
2016-09-23 13:13:12 +02:00
6f4509b938 BUG: incorrect symmTensor order for some ensight output (fixes #243)
- affects foamToEnsightParts, sampled surfaces

- Use ensightPTraits mechanism throughout to avoid this issue
2016-09-23 09:10:57 +02:00
4e5d2d8e04 ENH: improve startup time for foamToEnsight conversion (issue #240).
Old code:
    Found 10990 time steps
    Search for moving mesh ... no moving mesh detected.
    Startup in 329.09 s

Updated:
    Found 10990 time steps
    Search for moving mesh ... no moving mesh detected.
    Startup in 1.6 s

- Cause was checking "polyMesh/points" via an IOobject.
  Short-circuit with a check for a polyMesh/ directory first.

  Limit the check to the master-node as well to further reduce
  load on the file-system.

------------------------------

ENH: improve per-step conversion times for foamToEnsight.

Old code:
    Converting 11001 time steps
    Time [0] = 0       Wrote in 1.53 s
    Time [1] = 1       Wrote in 1.52 s
    ...
    Time [100] = 100   Elapsed time 205.35 s

Updated:
    Converting 11001 time steps
    Time [0] = 0       Wrote in 1.4 s
    Time [1] = 1       Wrote in 0.07 s
    ...
    Time [100] = 100   Elapsed time 42.4 s

- Speedup by hashing test results from the first conversion step
  instead of checking each time.

  Check data on all nodes to avoid problems with incomplete writes.

------------------------------

BUG: moving mesh detection failed for foamToEnsightParts

- adjusted to agree with updated foamToEnsight

------------------------------

Note:

- foamToEnsightParts (serial) still has about twice the throughput of
  foamToEnsight.
2016-09-21 18:15:19 +02:00
b0d1deeb69 ENH: fvc: instantiating 2D volVectorField 2016-09-20 17:07:30 +01:00
008a583992 BUG: output field name instead of field (fixes #224) 2016-09-20 15:15:19 +05:30
b4f050ad52 ENH: more flexible selection/naming for ddt2 FO (issue #224)
- bugfix (empty patches), and added detection of steady-state
  scheme.

Caveat: when called via execFlowFunctionObjects will always produce a
  zero field, since the oldTime field is not available for this mode.
2016-09-16 14:49:47 +02:00
a5fbb36d73 ENH: runTime calculation of zeroGradient volume fields (issue #235)
Extrapolate internal field to walls for post-processing.
Uses as new syntax for handling the naming of multiple fields.

The input fields are selected via a wordReList.
For example,

    fields      (U "(T|k|epsilon|omega)");

The names of the resulting output fields use placeholder tokens for
flexibility. For example,

    result      zeroGradient(@@);

The '@@' placeholder is replaced by the name of the input field.
Eg,
    fields      (U T);
    result      zeroGradient(@@);
->  zeroGradient(U), zeroGradient(T)

Or,
    fields      (U T);
    result      @@nearWall;
->  UnearWall, TnearWall

NOTE:
    The function object will skip over fields that only have
    processor, empty, zeroGradient patches. The operation does not
    make much sense for these, and it avoids inadvertently
    re-processing fields twice.
2016-09-16 21:33:40 +02:00
3aa54d114d ENH: runTime calculation of (dp/dt)^2 - issue #224
- implemented using magSqr() instead of sqr().
  For scalar fields they are the same, but can be useful
  if this function object is extended for more field types.
2016-09-14 14:02:40 +02:00
a70e4ef8fe ENH: expand data mask for foamToEnsight (issue #231)
- Default is a width of 8 characters, but this can be extended up to 31
  characters via the '-width' command-line option.

- Now use a similar structure as foamToEnsightParts for the masking.
  This reduces the clutter within the directory, makes it easier to
  selectively delete some time steps (using shell commands).

- Added in a "time" information data in each sub-directory to
  make it possible to reconstruct the case file with an external
  script.

- Conversion of cloud data should now also work in parallel
  (may need more testing).

- Support binary output for cloud data.

- Better avoidance of illegal ensight variable names.
  But still partially incomplete (due to patch fields).

==================================================
Example of NEW file structure:

    EnSight/verticalChannel.case        # case name
    EnSight/geometry                    # for non-moving geometry

    EnSight/data/                       # time-varying data
    EnSight/data/00000000/
    EnSight/data/00000001/
    ...

  Fields are stored by name within the data/********/ directories:

    EnSight/data/00000001/time          # human-readable time info
    EnSight/data/00000001/U
    EnSight/data/00000001/p
    ...
    EnSight/data/00000001/geometry      # for moving geometry

  Clouds are stored at the next sub-directory level:

    EnSight/data/00000001/lagrangian/<cloudName>/positions
    EnSight/data/00000001/lagrangian/<cloudName>/U
    ...

==================================================
The old structure was significantly more cluttered:

    EnSight/verticalChannel.case
    EnSight/verticalChannel.0000.mesh
    EnSight/verticalChannel.0001.p
    EnSight/verticalChannel.0001.<cloudName>
    EnSight/verticalChannel.0001.<cloudName>.U

==================================================
2016-09-13 18:26:00 +02:00
2bbbcf60de COMP: CGAL rules should use lib64/ (fixes #234)
- 64-bit builds of gcc/mpfr/gmp use lib64/ for their installation path.
  Use this for the wmake rules as well.
2016-09-13 08:58:00 +02:00
a32c043944 BUG: metisDecomp compile failure for WM_DP (closes #232)
- spurious use of floatScalar instead of scalar for processor weights.

STYLE: partially updated dummy metis.h to reflect metis-5.1.0 API
2016-09-13 08:51:03 +02:00
0e5054c3c7 STYLE: PrimitivePatch: undefined function 2016-09-07 12:40:35 +01:00
b74cf47bc3 ENH: snappyHexMesh: combine previous zone based algorithm with v3+ one.
Fixes #66.
2016-09-07 12:38:59 +01:00
0d9fc569c5 BUG: Non-const dereferencing of tmp in fvc:dt2dt2 (closes #227) 2016-09-07 09:33:26 +02:00
7110aa8236 STYLE: propogate WM_CC for CMake (fixes #226)
- reported by Bruno
2016-09-06 16:17:20 +02:00
b5231f2ec1 BUG: triSurface IO operators are asymmetrical (fixed #225)
- Also reported as http://bugs.openfoam.org/view.php?id=2188
2016-09-06 14:57:40 +02:00
fa2ae8e7b4 ENH: add stream operators for MeshedSurface, UnsortedMeshedSurface
- add corrsponding testing into surfaceMeshConvertTesting too
2016-09-06 14:45:44 +02:00
86c214de81 ENH: minor adjustments to surfZoneIdentifier
- gearing to make it more reusable in triSurface
2016-08-12 10:05:01 +02:00
71e1f300c8 ENH: surfaceCheck: survive triangles with duplicate vertices. Fixes #222 2016-08-31 16:47:36 +01:00
4e1ce0241a ENH: snappyHexMesh: added -region option (fixes #223) 2016-08-31 09:44:34 +01:00
ef4ae3063b BUG: snappyHexMesh: patch intersections of mesh was using cell zone information.
This was going wrong in a fair few cases where you would get regions which
were delimited by a combination of intersections with unnamed surfaces (wall)
and named surfaces (faceZone surface) but not with either of these sets
individually. This would cause there to be unvisited cells (zone = -2)
next to a visited cells but separated by a named surface only (and not an
unnamed surface). Fixed by using direct surface intersection in the removal
part. Related to #66.
2016-08-19 10:48:35 +01:00
d716c59f57 COMP: foamDebugSwitches: support for missing randomProcesses. Fixes #213. 2016-08-19 10:46:53 +01:00
b12b50548b BUG: singleCellMesh: writes constant mesh to 0 directory instead.
Fixes partially #93.
2016-08-10 15:49:09 +01:00
8524c72854 CONFIG: allow static or dynamic linkage for optional conversion utility 2016-08-08 11:58:52 +02:00
ce1abf5b42 CONFIG: use src/conversion/Allwmake when building source
- existed, but was not being called
2016-08-08 11:38:38 +02:00
ea1c9a1559 For issue #202, re-adjust commit 08412ddfd3f to use zero-gradient instead
- consistent with approach used elsewhere. Generates smaller files.
2016-08-02 21:56:40 +02:00
feed30d63c BUG: runParallel ignores presence of log file (closes #203)
- was a small typo
2016-08-02 18:31:50 +02:00
9e766b8bc5 ENH: decomposePar -cellDist misses patches (issue #202)
- Propagate cellDist information from internal to patch fields too

NOTE: uses C++11 'auto' and a range-based for loop
2016-08-02 16:39:20 +02:00
616cb0f137 BUG: 'processor' in directory name causes issues (issue #199)
- previously just detected the presence of "processor" in the case
  path name. Restrict to checking the final portion.
  Does not solve all problems, but solves ones like this:

      test-new-processor-generation/....
2016-08-01 14:11:05 +02:00
ed2017aa21 ENH: group info about particle output with "{}" etc
- The only reasonable means of mirroring the data layout.

  The '{}' delimiters mark the extent of the binary writes.

  The primitives 'label' and 'scalar' are directly supported and correspond
  to known byte widths.

  Using "List<scalar>" was a bad choice, since this triggers unpleasant
  tokenizing behaviour. Instead use 'scalars' as a provisional placeholder
  to indicates a list of scalar values. However, there is currently no
  support for actually handling lists of scalars, for several reasons:

   * The information is not available at compile-time.
     The cloud or parcel must be queried. And it must be guaranteed
     that this value is consistent for the entire cloud.

   * Binary output of lists is currently not great for determining the
     the encoded width:
        - A zero-size list is a single '0'.
        - The leading size is a non-constant number of digits.
        - There are prefix/suffix newlines need to be tagged and
          skipped.

  The special '*' (glob) token indicates that the remaining content
  has a dynamic variable length and nothing reasonable can be known
  about their sizes. This is exemplified by the collision records.
2016-06-02 17:39:19 +02:00
215f9a8555 BUG: incorrect face order/orientation in boundBox (issue #196)
- was fortunately not used anywhere previously
2016-07-28 07:00:33 +02:00
e219399d93 ENH: sampledSets: warn for no fields (fixes #206) 2016-08-10 13:32:47 +01:00
d6e15499b8 BUG: snappyHexMesh: compacting list w/o checking for aliasing. Fixes #197 2016-07-27 13:06:01 +01:00
267409dc62 ENH: Changing radiation correct in YEEq.H in fireFoam.
Adding clone member functions to motion solvers
2016-10-26 11:45:57 -07:00
7241e7ddd0 ENH: Adding autoMap and rMap tp greyDiffusiveViewFactorFixedValueFvPatchScalarField 2016-09-30 11:03:10 -07:00
571fc94077 BUG: runTimePostProcessing - corrected surface visualisation caused by regression update/bug 2016-09-07 10:02:02 +01:00
2b40688ebd ENH: Adding iso-plane histogram to regionSizeDistribution 2016-09-02 12:28:20 -07:00
b548540589 BUG: buoyantPimpleFoam - div term should be present for both compressible and incompressible 2016-09-02 08:14:10 +01:00
3fbd69b9e7 Adding area weighted average to U mean calculation for uniformJump option in fan BC 2016-09-02 11:51:59 -07:00
633c0fcc37 STYLE: Corrected spelling error 2016-08-25 17:28:50 +01:00
0e13a0462f BUG: Corrected Doxygen style sheet - patch contributed by Bruno Santos. Fixes #217 2016-08-25 13:36:43 +01:00
57e36b5252 BUG: incompressible/icoFoam/cavityMappingTest - renamed Allrun-serial->Allrun. Fixes #220 2016-08-25 13:34:17 +01:00
ec478c9636 BUG: mesh/filter case - corrected Allrun script. Fixes #219 2016-08-25 13:32:45 +01:00
4302ddf47e BUG: ensightSurfaceReader - enabled reading of data from sub-directory and updated field mask (See #215) 2016-08-18 15:29:56 +01:00
28c15a6ec1 ENH: noise functionality robustness improvements 2016-08-18 15:24:13 +01:00
42325c9cf1 BUG: Corrected FFTW_ARCH_PATH - patch contributed by Bruno Santos. Fixes #210 2016-08-18 11:22:25 +01:00
b34b7fab82 ENH: tetOverlapVolume - improved robustness. Fixes #207 2016-08-11 12:14:43 +01:00
8af962c7b2 ENH: plane - updated construct from components to optionally normalise the normal vector 2016-08-11 12:14:34 +01:00
03f552aa6e BUG: blendingFactor function object updated to handle bounded schemes. Fixes #205 2016-08-09 15:38:40 +01:00
a985c5520b ENH: boundedConvection scheme - added access function to the underlying scheme 2016-08-09 15:33:46 +01:00
93119a478a BUG: maxDeltaxyz LES delta - updated calculation. Fixes #200 2016-08-01 12:59:24 +01:00
d57867da1d STYLE: fanFvPatchField - updated example usage to reflect change in CSV specification. Fixes #177 2016-07-27 13:06:22 +01:00
5ad923bf50 STYLE: externalCoupledFunctionObject: typo 2016-07-27 10:38:58 +01:00
4076d9c9d4 ENH: distinguish OpenFOAM version for user-coding (fixes #195)
The pre-processor macro 'OPENFOAM_PLUS' is defined with a numerical
value equal to the currently compatible version number.

This can be used judiciously within user coding to help with minor
differences between OpenFOAM versions. For example,

    #ifdef OPENFOAM_PLUS
        #if (OPENFOAM_PLUS >= 1612)
        ...
        #endif
    #endif

or simply

    #if (OPENFOAM_PLUS >= 1612)
    ...
    #endif
2016-07-26 14:02:40 +02:00
9b848b64e0 ENH: provide a vfork/exec version of system (issue #185)
The normal library system() command uses 'fork', which causes
problems on IB+OPENMPI.

STYLE: add Foam:: qualifier to system calls to make them easier to spot.
2016-07-18 13:37:39 +02:00
7a3f0f3feb ENH: adapter for a list of C++ strings <-> a list of C-style strings
- Translate a list of C++ strings into C-style (argc, argv) pair.
- Translate C-style (argc, argv) pair to list of C++ strings.

Useful when interfacing to external C-code and some libraries
2016-06-16 08:22:53 +02:00
3772e2ea44 ENH: OSspecific - softlink handling (fixes #164)
Links are followed in most cases, with some notable exceptions:

- mv, mvBak:
  renames the link, not the underlying file/directory

- rmDir:
  remove the symlink to a directory, does not recurse into the
  underlying directory
2014-04-23 15:00:00 +02:00
0c1962ca06 ENH: regIOobject: use reverse order scatter for dictionary
Fixes #192
2016-07-25 14:14:05 +01:00
9317ca55dc STYLE: codedBase: indentation 2016-07-18 15:18:40 +01:00
9b052de408 STYLE: missing include in codeStream test dictionary 2016-07-15 09:05:44 +02:00
e340c86b62 STYLE/ENH: reduce code duplication for coded boundary conditions (issue #184)
- relocate common dictionary output into codedBase class
2016-06-09 16:13:04 +01:00
8f2a40a960 ENH: provide access to the underlying patch types of generic patches (issue #188) 2016-07-15 16:24:46 +02:00
0c28b34833 BUG: polyMesh::movePoints: clear cellTree since gets constructed using current geometry
so will be out of date (w.r.t bounding box, subdivisions) when the mesh moves.
Only when all cells stays in all the same boxes can you skip rebuilding it
so this was not deemed worthwhile. Fixes #172
2016-07-18 16:07:15 +01:00
2df891993c ENH: avoid deprecated resource xml when building paraview plugins (fixes #181)
- remove old VTK_CONVEX_POINT_SET code, since VTK_POLYHEDRON exists
  since several years

ENH: improve robustness of paraFoam script

- only check the relevant plugin types,
  fallback to native reader if needed/possible.
2016-07-12 11:17:57 +02:00
daf86f8b7d CONFIG: remove engridFoam start script
- no engrid development since 2013
2016-07-12 08:19:54 +02:00
211754795b BUG: incorrect wmakePrintBuild -check behaviour when outside of git (issue #174)
- return 0 if not under git, since nothing particular can be said
  about the build number.

- explicitly define which git-dir is to be used.
  This ensure we don't accidentally get some values from some unrelated
  project in the parent directory.
2016-07-12 17:37:30 +02:00
3aa32c4830 STYLE: documentation typo in EulerCoordinateRotation, add external reference 2016-07-06 11:47:10 +02:00
803871ae48 STYLE: mention suppression of banner for surfaceMeshInfo, ... (issue #125) 2016-07-06 07:43:05 +02:00
ecbe31d210 BUG: config.csh: wrong variable. Fixes #176 2016-07-06 09:23:55 +01:00
3637024d45 BUG: Turbulence DFSEM - protect sigFpe for reconstruct - see #194 2016-07-26 15:33:10 +01:00
a17c282104 BUG: mapFields function object - evaluate constraint patches after mapping. Fixes #190 2016-07-26 12:05:15 +01:00
b062ca29e7 BUG: runTimePostProcessing - correct the glyph behaviour when dealing with cell data. Fixes #186 2016-07-22 15:32:17 +01:00
18842a7069 ENH: Adding optional uniform jump switch to fan BC 2016-07-27 08:55:52 -07:00
acd51c8d7e COMP: fftw needs int (not long) for its dimensionality (issue #175)
- explicitly use List<int> instead List<label> for API compatibility,
  even when 64-bit labels are in use.
2016-07-07 11:20:28 +02:00
758900bf39 COMP: template ambiguity for 64-bit labels (issue #175) 2016-07-07 11:17:09 +02:00
06aa7205d0 CONFIG: rename config file to avoid premature filtering of its name 2016-07-06 08:11:42 +02:00
8ab25d7d31 CONFIG: use ThirdParty boost, FFTW instead of system versions
- many systems may not have boost or FFTW installed, or in an older
  version. Using ThirdParty for them should lead to a more robust
  build process.
2016-07-05 16:15:03 +02:00
c4511687c4 BUG: randomProcesses/Allwmake not being called (fixes #171) 2016-07-05 14:43:59 +02:00
b2c5e66699 BUG: need 'unset -f' to unset functions (issue #170)
- triggered by dash.
2016-07-01 17:55:03 +02:00
b1a419d576 BUG: Taken out mesh flux from the hEqn for Solid to Gas reactions 2016-07-19 10:51:50 -07:00
e120a7698e ENH: Adding support to moving mesh to activePressureForceBaffle 2016-07-07 10:19:56 -07:00
275 changed files with 6762 additions and 2939 deletions

View File

@ -53,6 +53,8 @@ tmp<fv::convectionScheme<scalar>> mvConvection
Y[inertIndex] = scalar(1) - Yt; Y[inertIndex] = scalar(1) - Yt;
Y[inertIndex].max(0.0); Y[inertIndex].max(0.0);
radiation->correct();
volScalarField& he = thermo.he(); volScalarField& he = thermo.he();
fvScalarMatrix EEqn fvScalarMatrix EEqn

View File

@ -41,7 +41,6 @@
p_rghDDtEqn = p_rghDDtEqn =
( (
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh)) fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
+ fvc::div(phiHbyA)
== ==
fvOptions(psi, p_rgh, rho.name()) fvOptions(psi, p_rgh, rho.name())
); );
@ -52,6 +51,7 @@
fvScalarMatrix p_rghEqn fvScalarMatrix p_rghEqn
( (
p_rghDDtEqn() p_rghDDtEqn()
+ fvc::div(phiHbyA)
- fvm::laplacian(rhorAUf, p_rgh) - fvm::laplacian(rhorAUf, p_rgh)
); );

View File

@ -5,8 +5,8 @@
+ fvm::div(rhoPhi, T) + fvm::div(rhoPhi, T)
- fvm::laplacian(mixture.alphaEff(turbulence->mut()), T) - fvm::laplacian(mixture.alphaEff(turbulence->mut()), T)
+ ( + (
fvc::div(fvc::absolute(phi, U), p) divU*p
+ fvc::ddt(rho, K) + fvc::div(rhoPhi, K) + fvc::ddt(rho, K) + fvc::div(rhoPhi, K)
) )
*( *(
alpha1/mixture.thermo1().Cv() alpha1/mixture.thermo1().Cv()
@ -20,4 +20,4 @@
mixture.correct(); mixture.correct();
Info<< "min(T) " << min(T).value() << endl; Info<< "min(T) " << min(T).value() << endl;
} }

View File

@ -70,6 +70,21 @@ int main(int argc, char *argv[])
turbulence->validate(); turbulence->validate();
volScalarField rAU
(
IOobject
(
"rAU",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("rAU", dimTime/rho.dimensions(), 1.0)
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl; Info<< "\nStarting time loop\n" << endl;
@ -77,45 +92,17 @@ int main(int argc, char *argv[])
{ {
#include "readControls.H" #include "readControls.H"
{ // Store divU from the previous mesh so that it can be mapped
// Store divU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the
// and used in correctPhi to ensure the corrected phi has the // same divergence
// same divergence volScalarField divU("divU0",fvc::div(fvc::absolute(phi, U)));
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
#include "CourantNo.H" #include "CourantNo.H"
#include "setDeltaT.H" #include "setDeltaT.H"
runTime++; runTime++;
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() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
}
if (mesh.changing() && correctPhi)
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
}
}
if (mesh.changing() && checkMeshCourantNo) if (mesh.changing() && checkMeshCourantNo)
{ {
@ -127,6 +114,46 @@ int main(int argc, char *argv[])
// --- Pressure-velocity PIMPLE corrector loop // --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop()) while (pimple.loop())
{ {
if (pimple.firstIter())
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
mesh.update();
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
}
if ((correctPhi && mesh.changing()) || mesh.topoChanging())
{
// Calculate absolute flux from the mapped surface velocity
// SAF: temporary fix until mapped Uf is assessed
Uf = fvc::interpolate(U);
phi = mesh.Sf() & Uf;
#include "correctPhi.H"
fvc::makeRelative(phi, U);
mixture.correct();
mesh.topoChanging(false);
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaEqnsSubCycle.H" #include "alphaEqnsSubCycle.H"
// correct interface on first PIMPLE corrector // correct interface on first PIMPLE corrector
@ -145,6 +172,11 @@ int main(int argc, char *argv[])
{ {
#include "pEqn.H" #include "pEqn.H"
} }
if (pimple.turbCorr())
{
turbulence->correct();
}
} }
rho = alpha1*rho1 + alpha2*rho2; rho = alpha1*rho1 + alpha2*rho2;

View File

@ -87,15 +87,6 @@
if (pimple.finalNonOrthogonalIter()) if (pimple.finalNonOrthogonalIter())
{ {
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
phi = phiHbyA + p_rghEqnIncomp.flux(); phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA U = HbyA
@ -116,8 +107,19 @@
rho = alpha1*rho1 + alpha2*rho2; rho = alpha1*rho1 + alpha2*rho2;
p = max(p_rgh + rho*gh, pMin);
p_rgh = p - rho*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
K = 0.5*magSqr(U); K = 0.5*magSqr(U);
Info<< "max(U) " << max(mag(U)).value() << endl; Info<< "max(U) " << max(mag(U)).value() << endl;
Info<< "min(p_rgh) " << min(p_rgh).value() << endl; Info<< "min(p_rgh) " << min(p_rgh).value() << endl;
} }

View File

@ -93,6 +93,7 @@ int main(int argc, char *argv[])
solve(fvm::ddt(rho) + fvc::div(rhoPhi)); solve(fvm::ddt(rho) + fvc::div(rhoPhi));
#include "UEqn.H" #include "UEqn.H"
volScalarField divU(fvc::div(fvc::absolute(phi, U)));
#include "TEqn.H" #include "TEqn.H"
// --- Pressure corrector loop // --- Pressure corrector loop

View File

@ -84,15 +84,6 @@
if (pimple.finalNonOrthogonalIter()) if (pimple.finalNonOrthogonalIter())
{ {
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
phi = phiHbyA + p_rghEqnIncomp.flux(); phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA U = HbyA
@ -101,14 +92,21 @@
} }
} }
// p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
// Update densities from change in p_rgh // Update densities from change in p_rgh
rho1 += psi1*(p_rgh - p_rgh_0); rho1 += psi1*(p_rgh - p_rgh_0);
rho2 += psi2*(p_rgh - p_rgh_0); rho2 += psi2*(p_rgh - p_rgh_0);
rho = alpha1*rho1 + alpha2*rho2; rho = alpha1*rho1 + alpha2*rho2;
p = max(p_rgh + rho*gh, pMin);
p_rgh = p - rho*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
K = 0.5*magSqr(U); K = 0.5*magSqr(U);
Info<< "max(U) " << max(mag(U)).value() << endl; Info<< "max(U) " << max(mag(U)).value() << endl;

View File

@ -133,9 +133,12 @@ int main(int argc, char *argv[])
ghf = (g & mesh.Cf()) - ghRef; ghf = (g & mesh.Cf()) - ghRef;
} }
if (mesh.changing() && correctPhi) if ((mesh.changing() && correctPhi) || mesh.topoChanging())
{ {
// Calculate absolute flux from the mapped surface velocity // Calculate absolute flux from the mapped surface velocity
// SAF: temporary fix until mapped Uf is assessed
Uf = fvc::interpolate(U);
phi = mesh.Sf() & Uf; phi = mesh.Sf() & Uf;
#include "correctPhi.H" #include "correctPhi.H"
@ -144,6 +147,8 @@ int main(int argc, char *argv[])
fvc::makeRelative(phi, U); fvc::makeRelative(phi, U);
mixture.correct(); mixture.correct();
mesh.topoChanging(false);
} }
if (mesh.changing() && checkMeshCourantNo) if (mesh.changing() && checkMeshCourantNo)

View File

@ -1,3 +1,3 @@
Test-namedEnum.C Test-NamedEnum.C
EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "NamedEnum.H"
#include "IOstreams.H"
using namespace Foam;
class namedEnumTest
{
public:
enum option
{
a,
b,
c,
d
};
static const Foam::NamedEnum<option, 4> namedEnum;
};
template<>
const char* Foam::NamedEnum<namedEnumTest::option, 4>::names[] =
{
"a",
"b",
"c",
"d"
};
const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
const List<namedEnumTest::option> options
= namedEnumTest::namedEnum.enums();
Info<< "enums: " << options << nl;
Info<< "loop over enums (as list):" << nl;
forAll(options, i)
{
const namedEnumTest::option& opt = options[i];
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
#if __cplusplus > 201100L
// C++11
Info<< "loop over enums (C++11 for range):" << nl;
for (auto const& opt : options)
{
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
#else
Info<< "loop over enums (via iterator):" << nl;
forAllConstIter(List<namedEnumTest::option>, options, iter)
{
const namedEnumTest::option& opt = *iter;
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
#endif
Info<< nl
<< namedEnumTest::namedEnum["a"] << nl
<< namedEnumTest::namedEnum[namedEnumTest::a] << nl;
Info<< "--- test read construction ---" << endl;
namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin));
Info<< namedEnumTest::namedEnum[dummy] << endl;
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,38 +22,28 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description Description
Test bounding box behaviour
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "NamedEnum.H" #include "argList.H"
#include "IOstreams.H" #include "Time.H"
#include "polyMesh.H"
#include "boundBox.H"
#include "treeBoundBox.H"
#include "cellModeller.H"
using namespace Foam; using namespace Foam;
class namedEnumTest //- simple helper to create a cube
boundBox cube(scalar start, scalar width)
{ {
public: return boundBox
(
enum options point(start, start, start),
{ point(start + width, start + width, start + width)
a, );
b, }
c
};
static const Foam::NamedEnum<options, 3> namedEnum;
};
template<>
const char* Foam::NamedEnum<namedEnumTest::options, 3>::names[] =
{
"a",
"b",
"c"
};
const Foam::NamedEnum<namedEnumTest::options, 3> namedEnumTest::namedEnum;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,13 +51,14 @@ const Foam::NamedEnum<namedEnumTest::options, 3> namedEnumTest::namedEnum;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Info<< namedEnumTest::namedEnum["a"] << endl; #include "setRootCase.H"
Info<< namedEnumTest::namedEnum[namedEnumTest::a] << endl; // #include "createTime.H"
// #include "createMesh.H"
namedEnumTest::options hmm(namedEnumTest::namedEnum.read(Sin)); const cellModel& hex = *(cellModeller::lookup("hex"));
Info<< namedEnumTest::namedEnum[hmm] << endl;
Info<< "End\n" << endl; Info<<"boundBox faces: " << boundBox::faces << endl;
Info<<"hex faces: " << hex.modelFaces() << endl;
return 0; return 0;
} }

View File

@ -30,7 +30,8 @@ writeInterval #codeStream
codeOptions codeOptions
#{ #{
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#}; #};
localCode localCode

View File

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

View File

@ -0,0 +1,2 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Test some string functionality
\*---------------------------------------------------------------------------*/
#include "CStringList.H"
#include "DynamicList.H"
#include "IOstreams.H"
#include "fileNameList.H"
#include "stringList.H"
#include "wordList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int print(int argc, char *argv[])
{
Info<< "argc=" << argc << endl;
for (int i=0; i<argc; ++i)
{
Info<< " argv[" << i << "] = \"" << argv[i] << "\"" << endl;
}
return argc;
}
int print(const CStringList& cstrLst)
{
return print(cstrLst.size(), cstrLst.strings());
}
// Main program:
int main(int argc, char *argv[])
{
DynamicList<string> dynlst;
dynlst.reserve(16);
dynlst.append("string1 with content");
dynlst.append("string2 other content");
dynlst.append("string3 done");
{
CStringList inC(dynlst);
Info<< "input: " << dynlst << endl;
print(inC);
}
Info<<"command-line with " << CStringList::count(argv) << " items"<< endl;
print(argc, argv);
{
dynlst.clear();
for (int i=0; i<argc; ++i)
{
dynlst.append(argv[i]);
}
Info<< "input: " << dynlst << endl;
CStringList inC(dynlst);
inC.reset(dynlst);
print(inC);
Info<< "length: " << inC.length() << endl;
std::cout.write(inC.data(), inC.length());
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,6 +34,7 @@ Description
#include "IOobject.H" #include "IOobject.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "POSIX.H"
using namespace Foam; using namespace Foam;
@ -99,6 +100,98 @@ int main()
} }
// Test some copying and deletion
{
const fileName dirA("dirA");
const fileName lnA("lnA");
const fileName lnB("lnB");
const fileName dirB("dirB");
Foam::rmDir(dirA);
Foam::rm(lnA);
Foam::rm(lnB);
Foam::rmDir(dirB);
Info<< "Creating directory " << dirA << endl;
Foam::mkDir(dirA);
const int oldPosix = POSIX::debug;
POSIX::debug = 1;
// Create link and test it
Info<< "Creating softlink " << lnA << endl;
Foam::ln(dirA, lnA);
fileName::Type lnAType = lnA.type(false);
if (lnAType != fileName::LINK)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnA
<< " should be " << fileName::LINK
<< " but is " << lnAType << exit(FatalError);
}
fileName::Type dirAType = lnA.type(true);
if (dirAType != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of what softlink " << lnA
<< " points to should be " << fileName::DIRECTORY
<< " but is " << dirAType << exit(FatalError);
}
// Copy link only
{
Info<< "Copying (non-follow) softlink " << lnA << " to " << lnB
<< endl;
Foam::cp(lnA, lnB, false);
if (lnB.type(false) != fileName::LINK)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::LINK
<< " but is " << lnB.type(false) << exit(FatalError);
}
if (lnB.type(true) != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::DIRECTORY
<< " but is " << lnB.type(true) << exit(FatalError);
}
// Delete
Foam::rm(lnB);
}
// Copy contents of link
{
Info<< "Copying (contents of) softlink " << lnA << " to " << lnB
<< endl;
Foam::cp(lnA, lnB, true);
if (lnB.type(false) != fileName::DIRECTORY)
{
FatalErrorIn("Test-fileName") << "Type of softlink " << lnB
<< " should be " << fileName::DIRECTORY
<< " but is " << lnB.type(false) << exit(FatalError);
}
// Delete
Foam::rm(lnB);
}
POSIX::debug = oldPosix;
Foam::rmDir(dirA);
Foam::rm(lnA);
}
// test findEtcFile // test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl << " controlDict => " << findEtcFile("controlDict") << nl

View File

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

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
test
Description
Finite volume method test code.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "vector2D.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef GeometricField<vector2D, fvPatchField, volMesh> volVector2DField;
defineTemplate2TypeNameAndDebug
(
volVector2DField::DimensionedInternalField,
0
);
defineTemplateTypeNameAndDebug(volVector2DField, 0);
typedef fvPatchField<vector2D> fvPatchVector2DField;
makeFvPatchField(fvPatchVector2DField)
}
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
GeometricField<vector2D, fvPatchField, volMesh> fld
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "end" << endl;
}
// ************************************************************************* //

View File

@ -75,8 +75,8 @@ int main(int argc, char *argv[])
wre.info(Info) << " after DETECT" << endl; wre.info(Info) << " after DETECT" << endl;
wre.uncompile(); wre.uncompile();
wre.info(Info) << " uncompiled" << endl; wre.info(Info) << " uncompiled" << endl;
wre.recompile(); wre.compile();
wre.info(Info) << " recompiled" << endl; wre.info(Info) << " re-compiled" << endl;
wre.set("something .* value", wordRe::LITERAL); wre.set("something .* value", wordRe::LITERAL);
wre.info(Info) << " set as LITERAL" << endl; wre.info(Info) << " set as LITERAL" << endl;

View File

@ -8,15 +8,15 @@ cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
# Get version info and arch-path # Get version info and arch-path
. $WM_PROJECT_DIR/etc/config.sh/functions . $WM_PROJECT_DIR/etc/config.sh/functions
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/libccmio) _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
set -x set -x
# Build libccmio (.so) # Build libccmio (.a|.so)
$WM_THIRD_PARTY_DIR/makeCCMIO $WM_THIRD_PARTY_DIR/makeCCMIO lib # libso
if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \ if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \
-a -e $FOAM_EXT_LIBBIN/libccmio.so ] -a \( -e $CCMIO_ARCH_PATH/lib/libccmio.a -o $FOAM_EXT_LIBBIN/libccmio.so \) ]
then then
wmake ccm26ToFoam wmake ccm26ToFoam
fi fi

View File

@ -6,4 +6,4 @@ EXE_INC = \
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-L$(FOAM_EXT_LIBBIN) -lccmio -L$(CCMIO_ARCH_PATH)/lib -L$(FOAM_EXT_LIBBIN) -lccmio

View File

@ -63,12 +63,17 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Element type numbers // Element type numbers
static label MSHLINE = 1;
static label MSHTRI = 2; static label MSHTRI = 2;
static label MSHQUAD = 3; static label MSHQUAD = 3;
static label MSHTET = 4; static label MSHTET = 4;
static label MSHPYR = 7;
static label MSHPRISM = 6;
static label MSHHEX = 5; static label MSHHEX = 5;
static label MSHPRISM = 6;
static label MSHPYR = 7;
// Skips till end of section. Returns false if end of file. // Skips till end of section. Returns false if end of file.
@ -424,6 +429,11 @@ void readCells
List<DynamicList<label>>& zoneCells List<DynamicList<label>>& zoneCells
) )
{ {
//$Elements
//number-of-elements
//elm-number elm-type number-of-tags < tag > \u2026 node-number-list
Info<< "Starting to read cells at line " << inFile.lineNumber() << endl; Info<< "Starting to read cells at line " << inFile.lineNumber() << endl;
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = *(cellModeller::lookup("hex"));
@ -473,13 +483,12 @@ void readCells
IStringStream lineStr(line); IStringStream lineStr(line);
label elmNumber, elmType, regPhys; label elmNumber, elmType, regPhys;
if (versionFormat >= 2) if (versionFormat >= 2)
{ {
lineStr >> elmNumber >> elmType; lineStr >> elmNumber >> elmType;
label nTags; label nTags;
lineStr>> nTags; lineStr >> nTags;
if (nTags > 0) if (nTags > 0)
{ {
@ -488,7 +497,7 @@ void readCells
for (label i = 1; i < nTags; i++) for (label i = 1; i < nTags; i++)
{ {
label dummy; label dummy;
lineStr>> dummy; lineStr >> dummy;
} }
} }
} }
@ -499,8 +508,12 @@ void readCells
} }
// regPhys on surface elements is region number. // regPhys on surface elements is region number.
if (elmType == MSHLINE)
if (elmType == MSHTRI) {
label meshPti;
lineStr >> meshPti >> meshPti;
}
else if (elmType == MSHTRI)
{ {
lineStr >> triPoints[0] >> triPoints[1] >> triPoints[2]; lineStr >> triPoints[0] >> triPoints[1] >> triPoints[2];

View File

@ -107,16 +107,12 @@ int main(int argc, char *argv[])
fileName dictPath; fileName dictPath;
// Check if the dictionary is specified on the command-line // Check if the dictionary is specified on the command-line
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath))
{ {
dictPath = args["dict"]; if (isDir(dictPath))
{
dictPath = dictPath = dictPath / dictName;
( }
isDir(dictPath)
? dictPath/dictName
: dictPath
);
} }
// Check if dictionary is present in the constant directory // Check if dictionary is present in the constant directory
else if else if

View File

@ -62,7 +62,7 @@ Foam::tmp<Foam::Field<Type>> filterFarPoints
) )
{ {
tmp<Field<Type>> tNewField(new Field<Type>(field.size())); tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
Field<Type>& newField = tNewField(); Field<Type>& newField = tNewField.ref();
label added = 0; label added = 0;
label count = 0; label count = 0;

View File

@ -35,7 +35,7 @@ Foam::tmp<Foam::Field<Type>> Foam::smoothAlignmentSolver::filterFarPoints
) )
{ {
tmp<Field<Type>> tNewField(new Field<Type>(field.size())); tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
Field<Type>& newField = tNewField(); Field<Type>& newField = tNewField.ref();
label added = 0; label added = 0;
label count = 0; label count = 0;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,14 +67,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
IOdictionary foamyHexMeshDict IOdictionary foamyHexMeshDict
( (

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -524,13 +524,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
labelList decomp = decompositionModel::New labelList decomp = decompositionModel::New
( (

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -613,6 +613,7 @@ void writeMesh
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "addRegionOption.H"
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
Foam::argList::addBoolOption Foam::argList::addBoolOption
( (
@ -762,20 +763,29 @@ int main(int argc, char *argv[])
// } // }
// else // else
{ {
Foam::Info word regionName;
<< "Create mesh for time = " if (args.optionReadIfPresent("region", regionName))
<< runTime.timeName() << Foam::nl << Foam::endl; {
Info<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << nl << endl;
}
else
{
regionName = fvMesh::defaultRegion;
Info<< "Create mesh for time = "
<< runTime.timeName() << nl << endl;
}
meshPtr.set meshPtr.set
( (
new fvMesh new fvMesh
( (
Foam::IOobject IOobject
( (
Foam::fvMesh::defaultRegion, regionName,
runTime.timeName(), runTime.timeName(),
runTime, runTime,
Foam::IOobject::MUST_READ IOobject::MUST_READ
) )
) )
); );
@ -827,13 +837,7 @@ int main(int argc, char *argv[])
if (Pstream::parRun()) if (Pstream::parRun())
{ {
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
decomposeDict = IOdictionary decomposeDict = IOdictionary
( (

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
IOobject IOobject
( (
singleCellName, singleCellName,
mesh.polyMesh::instance(), mesh.pointsInstance(),
runTime, runTime,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
@ -108,6 +108,8 @@ int main(int argc, char *argv[])
mesh mesh
) )
); );
scMesh().setInstance(mesh.pointsInstance());
// For convenience create any fv* files // For convenience create any fv* files
if (!exists(scMesh().fvSolution::objectPath())) if (!exists(scMesh().fvSolution::objectPath()))
{ {
@ -140,7 +142,7 @@ int main(int argc, char *argv[])
IOobject IOobject
( (
singleCellName, singleCellName,
mesh.polyMesh::instance(), mesh.pointsInstance(),
runTime, runTime,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE

View File

@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
if [ -f "$FFTW_ARCH_PATH/include/fftw3.h" ] || \
[ "${FFTW_ARCH_PATH##*-}" = system -a -f "/usr/include/fftw3.h" ]
then
export LINK_FLAGS="-lrandomProcesses"
fi
wmake
#------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
EXE_LIBS = \ EXE_LIBS = \
$(LINK_FLAGS) \
-lsnappyHexMesh \ -lsnappyHexMesh \
-lbarotropicCompressibilityModel \ -lbarotropicCompressibilityModel \
-lsolidThermo \ -lsolidThermo \
@ -41,7 +42,6 @@ EXE_LIBS = \
-lOpenFOAM \ -lOpenFOAM \
-lpotential \ -lpotential \
-lradiationModels \ -lradiationModels \
-lrandomProcesses \
-lreactionThermophysicalModels \ -lreactionThermophysicalModels \
-lreconstruct \ -lreconstruct \
-lsampling \ -lsampling \

View File

@ -151,7 +151,7 @@ void Foam::helpType::displayDoc
Info<< "Source file: " << classDirectory.c_str() << classFile << nl Info<< "Source file: " << classDirectory.c_str() << classFile << nl
<< endl; << endl;
system(docBrowser); Foam::system(docBrowser);
} }
else else
{ {

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -23,6 +23,8 @@ License
Application Application
foamInfoExec foamInfoExec
To simplify parsing of the output, The normal banner information
is suppressed.
Group Group
grpMiscUtilities grpMiscUtilities

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -211,14 +211,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
wordList regionNames; wordList regionNames;
wordList regionDirs; wordList regionDirs;
@ -301,7 +294,6 @@ int main(int argc, char *argv[])
), ),
decompDictFile decompDictFile
) )
).lookup("numberOfSubdomains") ).lookup("numberOfSubdomains")
); );
@ -425,7 +417,8 @@ int main(int argc, char *argv[])
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
mesh, mesh,
dimensionedScalar("cellDist", dimless, 0) dimensionedScalar("cellDist", dimless, -1),
zeroGradientFvPatchScalarField::typeName
); );
forAll(procIds, celli) forAll(procIds, celli)
@ -433,6 +426,7 @@ int main(int argc, char *argv[])
cellDist[celli] = procIds[celli]; cellDist[celli] = procIds[celli];
} }
cellDist.correctBoundaryConditions();
cellDist.write(); cellDist.write();
Info<< nl << "Wrote decomposition as volScalarField to " Info<< nl << "Wrote decomposition as volScalarField to "

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,6 +64,7 @@ Usage
#include "fvMeshTools.H" #include "fvMeshTools.H"
#include "fvMeshDistribute.H" #include "fvMeshDistribute.H"
#include "decompositionMethod.H" #include "decompositionMethod.H"
#include "decompositionModel.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
#include "volFields.H" #include "volFields.H"
@ -74,7 +75,6 @@ Usage
#include "loadOrCreateMesh.H" #include "loadOrCreateMesh.H"
#include "processorFvPatchField.H" #include "processorFvPatchField.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "decompositionModel.H"
#include "parFvFieldReconstructor.H" #include "parFvFieldReconstructor.H"
#include "parLagrangianRedistributor.H" #include "parLagrangianRedistributor.H"
@ -2153,7 +2153,6 @@ int main(int argc, char *argv[])
bool newTimes = args.optionFound("newTimes"); bool newTimes = args.optionFound("newTimes");
if (env("FOAM_SIGFPE")) if (env("FOAM_SIGFPE"))
{ {
WarningInFunction WarningInFunction
@ -2246,8 +2245,6 @@ int main(int argc, char *argv[])
Pstream::scatter(decompose); Pstream::scatter(decompose);
// If running distributed we have problem of new processors not finding // If running distributed we have problem of new processors not finding
// a system/controlDict. However if we switch on the master-only reading // a system/controlDict. However if we switch on the master-only reading
// the problem becomes that the time directories are differing sizes and // the problem becomes that the time directories are differing sizes and
@ -2331,7 +2328,6 @@ int main(int argc, char *argv[])
// Determine any region // Determine any region
word regionName = polyMesh::defaultRegion; word regionName = polyMesh::defaultRegion;
fileName meshSubDir; fileName meshSubDir;
if (args.optionReadIfPresent("region", regionName)) if (args.optionReadIfPresent("region", regionName))
{ {
meshSubDir = regionName/polyMesh::meshSubDir; meshSubDir = regionName/polyMesh::meshSubDir;
@ -2775,13 +2771,7 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location // Allow override of decomposeParDict location
fileName decompDictFile; fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile)) args.optionReadIfPresent("decomposeParDict", decompDictFile);
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
// Determine decomposition // Determine decomposition

View File

@ -1,6 +1,5 @@
itoa.C
ensightMesh.C ensightMesh.C
ensightParticlePositions.C ensightCloud.C
foamToEnsight.C foamToEnsight.C
EXE = $(FOAM_APPBIN)/foamToEnsight EXE = $(FOAM_APPBIN)/foamToEnsight

View File

@ -5,7 +5,8 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
@ -13,5 +14,5 @@ EXE_LIBS = \
-lfileFormats \ -lfileFormats \
-lsampling \ -lsampling \
-lgenericPatchFields \ -lgenericPatchFields \
-llagrangian -llagrangian \
-lconversion

View File

@ -1,21 +1,33 @@
// ignore special fields or fields that we don't handle // ignore special fields (_0 fields),
// // ignore fields we don't handle,
bool variableGood = true; // ignore fields that are not available for all time-steps
for (label n1=0; n1<Times.size() && variableGood; ++n1)
// hash by field-name in fieldsToUse
if (!fieldsToUse.found(fieldName))
{ {
// ignore _0 fields bool variableGood = false;
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
forAll(timeDirs, n1)
{ {
variableGood = false; variableGood =
}
else
{
variableGood = IOobject
( (
fieldName, fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0"
Times[n1].name(), ? false
mesh, : IOobject
IOobject::NO_READ (
).typeHeaderOk<volScalarField>(false); fieldName,
timeDirs[n1].name(),
mesh,
IOobject::NO_READ
).typeHeaderOk<volScalarField>(false)
);
if (!variableGood)
{
break;
}
} }
reduce(variableGood, andOp<bool>());
fieldsToUse.set(fieldName, variableGood);
} }

View File

@ -1,27 +1,50 @@
// check for "points" in any of the result directories // check for "points" in any of the result directories
bool meshMoving = false; bool meshMoving = false;
if (Times.size() > 1)
if (timeDirs.size() > 1 && Pstream::master())
{ {
// We already loaded a mesh (usually from constant). See if any other // We already loaded a mesh (usually from constant).
// points files // See if any other "polyMesh/points" files exist too.
forAll(Times, timeI)
const fileName& baseDir = mesh.time().path();
Info<< "Search for moving mesh ... " << flush;
forAll(timeDirs, timeI)
{ {
if (Times[timeI].name() != mesh.pointsInstance()) const word& timeName = timeDirs[timeI].name();
{
IOobject io meshMoving =
(
timeName != mesh.pointsInstance()
&& isDir(baseDir/timeName/polyMesh::meshSubDir)
&& IOobject
( (
"points", "points",
Times[timeI].name(), timeName,
polyMesh::meshSubDir, polyMesh::meshSubDir,
mesh, mesh,
IOobject::NO_READ IOobject::NO_READ,
); IOobject::NO_WRITE,
if (io.typeHeaderOk<pointIOField>(true)) false // no register
{ ).typeHeaderOk<pointIOField>(true)
meshMoving = true; );
break;
} if (meshMoving)
{
break;
} }
} }
if (meshMoving)
{
Info<< "found." << nl
<< " Writing meshes for every timestep." << endl;
}
else
{
Info<< "none detected." << endl;
}
} }
reduce(meshMoving, orOp<bool>());

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -52,17 +52,17 @@ class ensightAsciiStream
{ {
// Private data // Private data
//- Description of data_ //- Output file stream
OFstream str_; OFstream str_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ensightAsciiStream(const ensightAsciiStream&); ensightAsciiStream(const ensightAsciiStream&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ensightAsciiStream&); void operator=(const ensightAsciiStream&) = delete;
public: public:
@ -70,14 +70,14 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
ensightAsciiStream(const fileName& f, const Time& runTime) ensightAsciiStream(const fileName& f)
: :
ensightStream(f), ensightStream(f),
str_ str_
( (
f, f,
runTime.writeFormat(), IOstream::ASCII,
runTime.writeVersion(), IOstream::currentVersion,
IOstream::UNCOMPRESSED IOstream::UNCOMPRESSED
) )
{ {
@ -139,14 +139,6 @@ public:
<< setw(10) << partI << nl; << setw(10) << partI << nl;
} }
// Member Operators
// Friend Functions
// Friend Operators
// IOstream Operators
}; };

View File

@ -51,17 +51,17 @@ class ensightBinaryStream
{ {
// Private data // Private data
//- Description of data_ //- Output file stream
autoPtr<std::ofstream> str_; autoPtr<std::ofstream> str_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ensightBinaryStream(const ensightBinaryStream&); ensightBinaryStream(const ensightBinaryStream&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ensightBinaryStream&); void operator=(const ensightBinaryStream&) = delete;
public: public:
@ -69,7 +69,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
ensightBinaryStream(const fileName& f, const Time&) ensightBinaryStream(const fileName& f)
: :
ensightStream(f), ensightStream(f),
str_ str_
@ -90,11 +90,6 @@ public:
// Member Functions // Member Functions
virtual bool ascii() const
{
return false;
}
virtual void write(const char* val) virtual void write(const char* val)
{ {
char buffer[80]; char buffer[80];
@ -141,14 +136,6 @@ public:
write(partI); write(partI);
} }
// Member Operators
// Friend Functions
// Friend Operators
// IOstream Operators
}; };

View File

@ -1,5 +1,8 @@
if (Pstream::master()) if (Pstream::master())
{ {
ensightCaseFile.setf(ios_base::scientific, ios_base::floatfield);
ensightCaseFile.precision(5);
ensightCaseFile << nl << "TIME" << nl ensightCaseFile << nl << "TIME" << nl
<< "time set: " << 1 << nl << "time set: " << 1 << nl
<< "number of steps: " << nTimeSteps << nl << "number of steps: " << nTimeSteps << nl
@ -8,20 +11,17 @@ if (Pstream::master())
ensightCaseFile << "time values:" << nl; ensightCaseFile << "time values:" << nl;
ensightCaseFile.setf(ios_base::scientific, ios_base::floatfield);
ensightCaseFile.precision(5);
label count = 0; label count = 0;
scalar Tcorr = 0.0; scalar Tcorr = 0.0;
if (Times[0].value() < 0) if (timeDirs[0].value() < 0)
{ {
Tcorr = - Times[0].value(); Tcorr = -timeDirs[0].value();
Info<< "Correcting time values. Adding " << Tcorr << endl; Info<< "Correcting time values. Adding " << Tcorr << endl;
} }
forAll(Times, n) forAll(timeDirs, n)
{ {
ensightCaseFile << setw(12) << Times[n].value() + Tcorr << " "; ensightCaseFile << setw(12) << timeDirs[n].value() + Tcorr << " ";
if (++count % 6 == 0) if (++count % 6 == 0)
{ {

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightCloud.H"
#include "ensightFile.H"
#include "fvMesh.H"
#include "passiveParticle.H"
#include "Cloud.H"
#include "pointList.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::ensightParticlePositions
(
const fvMesh& mesh,
const fileName& dataDir,
const label timeIndex,
const word& cloudName,
const bool dataExists,
IOstream::streamFormat format
)
{
if (dataExists)
{
Info<< " positions";
}
else
{
Info<< " positions{0}";
}
// Total number of parcels on all processes
label nTotParcels = 0;
autoPtr<Cloud<passiveParticle>> cloudPtr;
if (dataExists)
{
cloudPtr.reset(new Cloud<passiveParticle>(mesh, cloudName, false));
nTotParcels = cloudPtr().size();
}
reduce(nTotParcels, sumOp<label>());
if (Pstream::master())
{
const fileName postFileName =
ensightFile::subDir(timeIndex)/cloud::prefix/cloudName/"positions";
// the ITER/lagrangian subdirectory must exist
mkDir(dataDir/postFileName.path());
ensightFile os(dataDir, postFileName, format);
// tag binary format (just like geometry files)
os.writeBinaryHeader();
os.write(postFileName); // description
os.newline();
os.write("particle coordinates");
os.newline();
os.write(nTotParcels, 8); // unusual width
os.newline();
if (!nTotParcels)
{
return; // DONE
}
if (format == IOstream::BINARY)
{
// binary write is Ensight6 - first ids, then positions
// 1-index
for (label parcelId = 0; parcelId < nTotParcels; ++parcelId)
{
os.write(parcelId+1);
}
// Master
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
{
const point& p = elmnt().position();
os.write(p.x());
os.write(p.y());
os.write(p.z());
}
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
pointList points(fromSlave);
forAll(points, pti)
{
const point& p = points[pti];
os.write(p.x());
os.write(p.y());
os.write(p.z());
}
}
}
else
{
// ASCII id + position together
label parcelId = 0;
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
{
const point& p = elmnt().position();
os.write(++parcelId, 8); // unusual width
os.write(p.x());
os.write(p.y());
os.write(p.z());
os.newline();
}
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
pointList points(fromSlave);
forAll(points, pti)
{
const point& p = points[pti];
os.write(++parcelId, 8); // unusual width
os.write(p.x());
os.write(p.y());
os.write(p.z());
os.newline();
}
}
}
}
else if (nTotParcels)
{
// SLAVE, and data exist
pointList points(cloudPtr().size());
label pti = 0;
forAllConstIter(Cloud<passiveParticle>, cloudPtr(), elmnt)
{
const point& p = elmnt().position();
points[pti++] = p;
}
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< points;
}
}
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,35 +27,62 @@ InApplication
Description Description
SourceFiles SourceFiles
ensightCloudField.C ensightCloud.C
ensightCloudTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ensightCloudField_H #ifndef ensightCloud_H
#define ensightCloudField_H #define ensightCloud_H
#include "ensightFile.H"
#include "fvMesh.H"
#include "Cloud.H" #include "Cloud.H"
#include "IOobject.H" #include "IOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
void ensightParticlePositions
(
const fvMesh& mesh,
const fileName& dataDir,
const label timeIndex,
const word& cloudName,
const bool dataExists,
const IOstream::streamFormat format
);
template<class Type> template<class Type>
void ensightCloudField void ensightCloudField
( (
const IOobject& fieldObject, const IOobject& fieldObject,
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const word& timeFile,
const word& cloudName, const word& cloudName,
const label cloudNo,
Ostream& ensightCaseFile, Ostream& ensightCaseFile,
const bool dataExists const bool dataExists,
const IOstream::streamFormat format
); );
template<class Type>
void writeCloudField
(
const IOField<Type>& field,
ensightFile& os
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "ensightCloudField.C" #include "ensightCloudTemplates.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightCloudField.H"
#include "Time.H"
#include "IOField.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "ensightPTraits.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type>
void ensightCloudField
(
const IOobject& fieldObject,
const fileName& postProcPath,
const word& prepend,
const label timeIndex,
const word& cloudName,
Ostream& ensightCaseFile,
const bool dataExists
)
{
if (dataExists)
{
Info<< "Converting cloud " << cloudName
<< " field " << fieldObject.name() << endl;
}
else
{
Info<< "Creating empty cloud " << cloudName
<< " field " << fieldObject.name() << endl;
}
word timeFile = prepend + itoa(timeIndex);
const Time& runTime = fieldObject.time();
if (timeIndex == 0 && Pstream::master())
{
ensightCaseFile
<< pTraits<Type>::typeName << " per measured node: 1 ";
ensightCaseFile.width(15);
ensightCaseFile.setf(ios_base::left);
ensightCaseFile
<< ("c" + fieldObject.name()).c_str()
<< (' ' + prepend + "****." + cloudName
+ "." + fieldObject.name()).c_str()
<< nl;
}
fileName ensightFileName
(
timeFile + "." + cloudName +"." + fieldObject.name()
);
OFstream ensightFile
(
postProcPath/ensightFileName,
runTime.writeFormat(),
runTime.writeVersion(),
runTime.writeCompression()
);
ensightFile<< pTraits<Type>::typeName << " values" << nl;
if (dataExists)
{
IOField<Type> vf(fieldObject);
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
ensightFile.precision(5);
label count = 0;
forAll(vf, i)
{
Type v = vf[i];
if (mag(v) < 1.0e-90)
{
v = Zero;
}
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{
label cmpt = ensightPTraits<Type>::componentOrder[i];
ensightFile << setw(12) << component(v, cmpt);
if (++count % 6 == 0)
{
ensightFile << nl;
}
}
}
if ((count % 6 != 0) || (count==0))
{
ensightFile << nl;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightCloud.H"
#include "ensightFile.H"
#include "Time.H"
#include "IOField.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "ensightPTraits.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::writeCloudField
(
const Foam::IOField<Type>& field,
Foam::ensightFile& os
)
{
if (returnReduce(field.size(), sumOp<label>()) > 0)
{
if (Pstream::master())
{
// 6 values per line
label count = 0;
// Master
forAll(field, i)
{
Type val = field[i];
if (mag(val) < 1e-90)
{
val = Zero;
}
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
label cmpt = ensightPTraits<Type>::componentOrder[d];
os.write(component(val, cmpt));
if (++count % 6 == 0)
{
os.newline();
}
}
}
// Slaves
for (int slave=1; slave<Pstream::nProcs(); ++slave)
{
IPstream fromSlave(Pstream::scheduled, slave);
Field<Type> slaveData(fromSlave);
forAll(slaveData, i)
{
Type val = slaveData[i];
if (mag(val) < 1e-90)
{
val = Zero;
}
for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{
label cmpt = ensightPTraits<Type>::componentOrder[d];
os.write(component(val, cmpt));
if (++count % 6 == 0)
{
os.newline();
}
}
}
}
// add final newline if required
if (count % 6)
{
os.newline();
}
}
else
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< field;
}
}
}
template<class Type>
void Foam::ensightCloudField
(
const Foam::IOobject& fieldObject,
const Foam::fileName& dataDir,
const Foam::label timeIndex,
const Foam::word& cloudName,
const Foam::label cloudNo,
Foam::Ostream& ensightCaseFile,
const bool dataExists,
Foam::IOstream::streamFormat format
)
{
const ensight::VarName varName(fieldObject.name());
if (dataExists)
{
Info<< ' ' << fieldObject.name();
}
else
{
Info<< ' ' << fieldObject.name() << "{0}"; // ie, empty field
}
ensightFile* filePtr(nullptr);
if (Pstream::master())
{
const fileName postFileName =
ensightFile::subDir(timeIndex)/cloud::prefix/cloudName/varName;
// the ITER/lagrangian subdirectory must exist
// the ITER/lagrangian subdirectory was already created
// when writing positions
mkDir(dataDir/postFileName.path());
if (timeIndex == 0)
{
const fileName dirName =
dataDir.name()/ensightFile::mask()/cloud::prefix/cloudName;
ensightCaseFile.setf(ios_base::left);
// prefix variables with 'c' (cloud)
ensightCaseFile
<< ensightPTraits<Type>::typeName << " per "
<< setw(20)
<< "measured node:"
<< " 1 "
<< setw(15)
<< ("c" + Foam::name(cloudNo) + varName).c_str() << ' '
<< (dirName/varName).c_str()
<< nl;
}
filePtr = new ensightFile(dataDir, postFileName, format);
// description
filePtr->write
(
string(postFileName + " <" + pTraits<Type>::typeName + ">")
);
filePtr->newline();
}
if (dataExists)
{
IOField<Type> field(fieldObject);
writeCloudField(field, *filePtr);
}
if (filePtr) // on master only
{
delete filePtr;
}
}
// ************************************************************************* //

View File

@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ensightFile.H"
#include "ensightField.H" #include "ensightField.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "volFields.H" #include "volFields.H"
#include "OFstream.H" #include "OFstream.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "itoa.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "ensightBinaryStream.H" #include "ensightBinaryStream.H"
#include "ensightAsciiStream.H" #include "ensightAsciiStream.H"
@ -81,7 +81,9 @@ volField
// Construct volField (with zeroGradient) from dimensioned field // Construct volField (with zeroGradient) from dimensioned field
IOobject io(df); IOobject io(df);
io.readOpt() = IOobject::NO_READ; io.readOpt() = IOobject::NO_READ;
io.writeOpt() = IOobject::NO_WRITE;
io.registerObject() = false;
tmp<GeometricField<Type, fvPatchField, volMesh>> tvf tmp<GeometricField<Type, fvPatchField, volMesh>> tvf
( (
@ -89,16 +91,17 @@ volField
( (
io, io,
df.mesh(), df.mesh(),
df.dimensions(), dimensioned<Type>("0", df.dimensions(), Zero),
zeroGradientFvPatchField<scalar>::typeName zeroGradientFvPatchField<Type>::typeName
) )
); );
tvf.ref().internalField() = df; tvf.ref().internalField() = df;
tvf.ref().correctBoundaryConditions(); tvf.ref().correctBoundaryConditions();
const GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
if (meshSubsetter.hasSubMesh()) if (meshSubsetter.hasSubMesh())
{ {
const GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
tmp<GeometricField<Type, fvPatchField, volMesh>> tfld tmp<GeometricField<Type, fvPatchField, volMesh>> tfld
( (
meshSubsetter.interpolate(vf) meshSubsetter.interpolate(vf)
@ -121,10 +124,8 @@ volField
// const IOobject& io, // const IOobject& io,
// const fvMesh& mesh, // const fvMesh& mesh,
// const ensightMesh& eMesh, // const ensightMesh& eMesh,
// const fileName& postProcPath, // const fileName& dataDir,
// const word& prepend,
// const label timeIndex, // const label timeIndex,
// const bool binary,
// const bool nodeValues, // const bool nodeValues,
// Ostream& ensightCaseFile // Ostream& ensightCaseFile
//) //)
@ -134,10 +135,8 @@ volField
// ( // (
// volField<typename Container::value_type>(meshSubsetter, fld), // volField<typename Container::value_type>(meshSubsetter, fld),
// eMesh, // eMesh,
// postProcPath, // dataDir,
// prepend,
// timeIndex, // timeIndex,
// binary,
// nodeValues, // nodeValues,
// ensightCaseFile // ensightCaseFile
// ); // );
@ -175,26 +174,26 @@ void writeField
( (
const char* key, const char* key,
const Field<Type>& vf, const Field<Type>& vf,
ensightStream& ensightFile ensightStream& os
) )
{ {
if (returnReduce(vf.size(), sumOp<label>()) > 0) if (returnReduce(vf.size(), sumOp<label>()) > 0)
{ {
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.write(key); os.write(key);
for (direction i=0; i < pTraits<Type>::nComponents; ++i) for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i]; label cmpt = ensightPTraits<Type>::componentOrder[i];
ensightFile.write(vf.component(cmpt)); os.write(vf.component(cmpt));
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
IPstream fromSlave(Pstream::scheduled, slave); IPstream fromSlave(Pstream::scheduled, slave);
scalarField slaveData(fromSlave); scalarField slaveData(fromSlave);
ensightFile.write(slaveData); os.write(slaveData);
} }
} }
} }
@ -220,35 +219,35 @@ bool writePatchField
const label ensightPatchI, const label ensightPatchI,
const faceSets& boundaryFaceSet, const faceSets& boundaryFaceSet,
const ensightMesh::nFacePrimitives& nfp, const ensightMesh::nFacePrimitives& nfp,
ensightStream& ensightFile ensightStream& os
) )
{ {
if (nfp.nTris || nfp.nQuads || nfp.nPolys) if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{ {
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.writePartHeader(ensightPatchI); os.writePartHeader(ensightPatchI);
} }
writeField writeField
( (
"tria3", "tria3",
Field<Type>(pf, boundaryFaceSet.tris), Field<Type>(pf, boundaryFaceSet.tris),
ensightFile os
); );
writeField writeField
( (
"quad4", "quad4",
Field<Type>(pf, boundaryFaceSet.quads), Field<Type>(pf, boundaryFaceSet.quads),
ensightFile os
); );
writeField writeField
( (
"nsided", "nsided",
Field<Type>(pf, boundaryFaceSet.polys), Field<Type>(pf, boundaryFaceSet.polys),
ensightFile os
); );
return true; return true;
@ -267,15 +266,11 @@ void writePatchField
const Field<Type>& pf, const Field<Type>& pf,
const word& patchName, const word& patchName,
const ensightMesh& eMesh, const ensightMesh& eMesh,
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool binary,
Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
const Time& runTime = eMesh.mesh().time();
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets(); const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
const wordList& allPatchNames = eMesh.allPatchNames(); const wordList& allPatchNames = eMesh.allPatchNames();
const HashTable<ensightMesh::nFacePrimitives>& const HashTable<ensightMesh::nFacePrimitives>&
@ -295,53 +290,51 @@ void writePatchField
ensightPatchI++; ensightPatchI++;
} }
ensightStream* filePtr(nullptr);
word pfName = patchName + '.' + fieldName;
word timeFile = prepend + itoa(timeIndex);
ensightStream* ensightFilePtr = NULL;
if (Pstream::master()) if (Pstream::master())
{ {
// TODO: verify that these are indeed valid ensight variable names
const word varName = patchName + '.' + fieldName;
const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
// the data/ITER subdirectory must exist
mkDir(dataDir/postFileName.path());
if (timeIndex == 0) if (timeIndex == 0)
{ {
ensightCaseFile.setf(ios_base::left); const fileName dirName = dataDir.name()/ensightFile::mask();
ensightCaseFile.setf(ios_base::left);
ensightCaseFile ensightCaseFile
<< ensightPTraits<Type>::typeName << ensightPTraits<Type>::typeName << " per "
<< " per element: 1 " << setw(20)
<< setw(15) << pfName << "element:"
<< (' ' + prepend + "****." + pfName).c_str() << " 1 "
<< setw(15)
<< varName.c_str() << ' '
<< (dirName/varName).c_str()
<< nl; << nl;
} }
// set the filename of the ensight file if (eMesh.format() == IOstream::BINARY)
fileName ensightFileName(timeFile + "." + pfName);
if (binary)
{ {
ensightFilePtr = new ensightBinaryStream filePtr = new ensightBinaryStream
( (
postProcPath/ensightFileName, dataDir/postFileName
runTime
); );
} }
else else
{ {
ensightFilePtr = new ensightAsciiStream filePtr = new ensightAsciiStream
( (
postProcPath/ensightFileName, dataDir/postFileName
runTime
); );
} }
filePtr->write(ensightPTraits<Type>::typeName);
} }
ensightStream& ensightFile = *ensightFilePtr; ensightStream& os = *filePtr;
if (Pstream::master())
{
ensightFile.write(ensightPTraits<Type>::typeName);
}
if (patchi >= 0) if (patchi >= 0)
{ {
@ -352,7 +345,7 @@ void writePatchField
ensightPatchI, ensightPatchI,
boundaryFaceSets[patchi], boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(), nPatchPrims.find(patchName)(),
ensightFile os
); );
} }
else else
@ -366,13 +359,13 @@ void writePatchField
ensightPatchI, ensightPatchI,
nullFaceSets, nullFaceSets,
nPatchPrims.find(patchName)(), nPatchPrims.find(patchName)(),
ensightFile os
); );
} }
if (Pstream::master()) if (filePtr) // on master only
{ {
delete ensightFilePtr; delete filePtr;
} }
} }
@ -382,19 +375,14 @@ void ensightField
( (
const GeometricField<Type, fvPatchField, volMesh>& vf, const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& eMesh, const ensightMesh& eMesh,
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool binary,
Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
Info<< "Converting field " << vf.name() << endl; Info<< ' ' << vf.name();
word timeFile = prepend + itoa(timeIndex);
const fvMesh& mesh = eMesh.mesh(); const fvMesh& mesh = eMesh.mesh();
const Time& runTime = mesh.time();
const cellSets& meshCellSets = eMesh.meshCellSets(); const cellSets& meshCellSets = eMesh.meshCellSets();
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets(); const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
@ -414,48 +402,48 @@ void ensightField
const labelList& hexes = meshCellSets.hexes; const labelList& hexes = meshCellSets.hexes;
const labelList& polys = meshCellSets.polys; const labelList& polys = meshCellSets.polys;
ensightStream* ensightFilePtr = NULL; ensightStream* filePtr(nullptr);
if (Pstream::master()) if (Pstream::master())
{ {
// set the filename of the ensight file const ensight::VarName varName(vf.name());
fileName ensightFileName(timeFile + "." + vf.name()); const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
if (binary) // the data/ITER subdirectory must exist
mkDir(dataDir/postFileName.path());
if (timeIndex == 0)
{ {
ensightFilePtr = new ensightBinaryStream const fileName dirName = dataDir.name()/ensightFile::mask();
ensightCaseFile.setf(ios_base::left);
ensightCaseFile
<< ensightPTraits<Type>::typeName
<< " per element: 1 "
<< setw(15)
<< varName.c_str() << ' '
<< (dirName/varName).c_str()
<< nl;
}
if (eMesh.format() == IOstream::BINARY)
{
filePtr = new ensightBinaryStream
( (
postProcPath/ensightFileName, dataDir/postFileName
runTime
); );
} }
else else
{ {
ensightFilePtr = new ensightAsciiStream filePtr = new ensightAsciiStream
( (
postProcPath/ensightFileName, dataDir/postFileName
runTime
); );
} }
filePtr->write(ensightPTraits<Type>::typeName);
} }
ensightStream& ensightFile = *ensightFilePtr; ensightStream& os = *filePtr;
if (Pstream::master())
{
if (timeIndex == 0)
{
ensightCaseFile.setf(ios_base::left);
ensightCaseFile
<< ensightPTraits<Type>::typeName
<< " per element: 1 "
<< setw(15) << vf.name()
<< (' ' + prepend + "****." + vf.name()).c_str()
<< nl;
}
ensightFile.write(ensightPTraits<Type>::typeName);
}
if (patchNames.empty()) if (patchNames.empty())
{ {
@ -463,42 +451,42 @@ void ensightField
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.writePartHeader(1); os.writePartHeader(1);
} }
writeField writeField
( (
"hexa8", "hexa8",
map(vf, hexes, wedges), map(vf, hexes, wedges),
ensightFile os
); );
writeField writeField
( (
"penta6", "penta6",
Field<Type>(vf, prisms), Field<Type>(vf, prisms),
ensightFile os
); );
writeField writeField
( (
"pyramid5", "pyramid5",
Field<Type>(vf, pyrs), Field<Type>(vf, pyrs),
ensightFile os
); );
writeField writeField
( (
"tetra4", "tetra4",
Field<Type>(vf, tets), Field<Type>(vf, tets),
ensightFile os
); );
writeField writeField
( (
"nfaced", "nfaced",
Field<Type>(vf, polys), Field<Type>(vf, polys),
ensightFile os
); );
} }
@ -521,7 +509,7 @@ void ensightField
ensightPatchI, ensightPatchI,
boundaryFaceSets[patchi], boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(), nPatchPrims.find(patchName)(),
ensightFile os
) )
) )
{ {
@ -546,8 +534,7 @@ void ensightField
eMesh.barrier(); eMesh.barrier();
label zoneID = mesh.faceZones().findZoneID(faceZoneName); const label zoneID = mesh.faceZones().findZoneID(faceZoneName);
const faceZone& fz = mesh.faceZones()[zoneID]; const faceZone& fz = mesh.faceZones()[zoneID];
// Prepare data to write // Prepare data to write
@ -595,7 +582,7 @@ void ensightField
ensightPatchI, ensightPatchI,
faceZoneFaceSets[zoneID], faceZoneFaceSets[zoneID],
nFaceZonePrims.find(faceZoneName)(), nFaceZonePrims.find(faceZoneName)(),
ensightFile os
) )
) )
{ {
@ -603,9 +590,10 @@ void ensightField
} }
} }
} }
if (Pstream::master())
if (filePtr) // on master only
{ {
delete ensightFilePtr; delete filePtr;
} }
} }
@ -615,65 +603,63 @@ void ensightPointField
( (
const GeometricField<Type, pointPatchField, pointMesh>& pf, const GeometricField<Type, pointPatchField, pointMesh>& pf,
const ensightMesh& eMesh, const ensightMesh& eMesh,
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool binary,
Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
Info<< "Converting field " << pf.name() << endl; Info<< ' ' << pf.name();
word timeFile = prepend + itoa(timeIndex);
const fvMesh& mesh = eMesh.mesh(); const fvMesh& mesh = eMesh.mesh();
const wordList& allPatchNames = eMesh.allPatchNames(); const wordList& allPatchNames = eMesh.allPatchNames();
const wordHashSet& patchNames = eMesh.patchNames(); const wordHashSet& patchNames = eMesh.patchNames();
const wordHashSet& faceZoneNames = eMesh.faceZoneNames(); const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
ensightStream* filePtr(nullptr);
ensightStream* ensightFilePtr = NULL;
if (Pstream::master()) if (Pstream::master())
{ {
// set the filename of the ensight file const ensight::VarName varName(pf.name());
fileName ensightFileName(timeFile + "." + pf.name()); const fileName postFileName = ensightFile::subDir(timeIndex)/varName;
if (binary) // the data/ITER subdirectory must exist
mkDir(dataDir/postFileName.path());
if (timeIndex == 0)
{ {
ensightFilePtr = new ensightBinaryStream const fileName dirName = dataDir.name()/ensightFile::mask();
ensightCaseFile.setf(ios_base::left);
ensightCaseFile
<< ensightPTraits<Type>::typeName
<< " per "
<< setw(20)
<< " node:"
<< " 1 "
<< setw(15)
<< varName.c_str() << ' '
<< (dirName/varName).c_str()
<< nl;
}
if (eMesh.format() == IOstream::BINARY)
{
filePtr = new ensightBinaryStream
( (
postProcPath/ensightFileName, dataDir/postFileName
mesh.time()
); );
} }
else else
{ {
ensightFilePtr = new ensightAsciiStream filePtr = new ensightAsciiStream
( (
postProcPath/ensightFileName, dataDir/postFileName
mesh.time()
); );
} }
filePtr->write(ensightPTraits<Type>::typeName);
} }
ensightStream& ensightFile = *ensightFilePtr; ensightStream& os = *filePtr;
if (Pstream::master())
{
if (timeIndex == 0)
{
ensightCaseFile.setf(ios_base::left);
ensightCaseFile
<< ensightPTraits<Type>::typeName
<< " per node: 1 "
<< setw(15) << pf.name()
<< (' ' + prepend + "****." + pf.name()).c_str()
<< nl;
}
ensightFile.write(ensightPTraits<Type>::typeName);
}
if (eMesh.patchNames().empty()) if (eMesh.patchNames().empty())
{ {
@ -681,14 +667,14 @@ void ensightPointField
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.writePartHeader(1); os.writePartHeader(1);
} }
writeField writeField
( (
"coordinates", "coordinates",
Field<Type>(pf.internalField(), eMesh.uniquePointMap()), Field<Type>(pf.internalField(), eMesh.uniquePointMap()),
ensightFile os
); );
} }
@ -704,11 +690,8 @@ void ensightPointField
if (patchNames.empty() || patchNames.found(patchName)) if (patchNames.empty() || patchNames.found(patchName))
{ {
const fvPatch& p = mesh.boundary()[patchi]; const fvPatch& p = mesh.boundary()[patchi];
if
( if (returnReduce(p.size(), sumOp<label>()) > 0)
returnReduce(p.size(), sumOp<label>())
> 0
)
{ {
// Renumber the patch points/faces into unique points // Renumber the patch points/faces into unique points
labelList pointToGlobal; labelList pointToGlobal;
@ -724,14 +707,14 @@ void ensightPointField
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.writePartHeader(ensightPatchI); os.writePartHeader(ensightPatchI);
} }
writeField writeField
( (
"coordinates", "coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels), Field<Type>(pf.internalField(), uniqueMeshPointLabels),
ensightFile os
); );
ensightPatchI++; ensightPatchI++;
@ -748,8 +731,7 @@ void ensightPointField
eMesh.barrier(); eMesh.barrier();
label zoneID = mesh.faceZones().findZoneID(faceZoneName); const label zoneID = mesh.faceZones().findZoneID(faceZoneName);
const faceZone& fz = mesh.faceZones()[zoneID]; const faceZone& fz = mesh.faceZones()[zoneID];
if (returnReduce(fz().nPoints(), sumOp<label>()) > 0) if (returnReduce(fz().nPoints(), sumOp<label>()) > 0)
@ -768,7 +750,7 @@ void ensightPointField
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.writePartHeader(ensightPatchI); os.writePartHeader(ensightPatchI);
} }
writeField writeField
@ -779,7 +761,7 @@ void ensightPointField
pf.internalField(), pf.internalField(),
uniqueMeshPointLabels uniqueMeshPointLabels
), ),
ensightFile os
); );
ensightPatchI++; ensightPatchI++;
@ -787,9 +769,9 @@ void ensightPointField
} }
} }
if (Pstream::master()) if (filePtr) // on master only
{ {
delete ensightFilePtr; delete filePtr;
} }
} }
@ -799,10 +781,8 @@ void ensightField
( (
const GeometricField<Type, fvPatchField, volMesh>& vf, const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& eMesh, const ensightMesh& eMesh,
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool binary,
const bool nodeValues, const bool nodeValues,
Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
@ -819,10 +799,8 @@ void ensightField
( (
pfld, pfld,
eMesh, eMesh,
postProcPath, dataDir,
prepend,
timeIndex, timeIndex,
binary,
ensightCaseFile ensightCaseFile
); );
} }
@ -832,10 +810,8 @@ void ensightField
( (
vf, vf,
eMesh, eMesh,
postProcPath, dataDir,
prepend,
timeIndex, timeIndex,
binary,
ensightCaseFile ensightCaseFile
); );
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,10 +69,8 @@ void ensightField
( (
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf, const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
const Foam::ensightMesh& eMesh, const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath, const Foam::fileName& dataDir,
const Foam::word& prepend,
const Foam::label timeIndex, const Foam::label timeIndex,
const bool binary,
const bool nodeValues, const bool nodeValues,
Foam::Ostream& ensightCaseFile Foam::Ostream& ensightCaseFile
); );
@ -85,8 +83,7 @@ void writePatchField
const Foam::Field<Type>& pf, const Foam::Field<Type>& pf,
const Foam::word& patchName, const Foam::word& patchName,
const Foam::ensightMesh& eMesh, const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath, const Foam::fileName& dataDir,
const Foam::word& prepend,
const Foam::label timeIndex, const Foam::label timeIndex,
Foam::Ostream& ensightCaseFile Foam::Ostream& ensightCaseFile
); );

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,16 +32,21 @@ License
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "cellModeller.H" #include "cellModeller.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "itoa.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "mapDistribute.H" #include "mapDistribute.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "ensightFile.H"
#include "ensightBinaryStream.H" #include "ensightBinaryStream.H"
#include "ensightAsciiStream.H" #include "ensightAsciiStream.H"
#include <fstream> #include <fstream>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* Foam::ensightMesh::geometryName = "geometry";
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
void Foam::ensightMesh::correct() void Foam::ensightMesh::correct()
@ -403,7 +408,7 @@ Foam::ensightMesh::ensightMesh
const bool faceZones, const bool faceZones,
const wordReList& faceZonePatterns, const wordReList& faceZonePatterns,
const bool binary const IOstream::streamFormat format
) )
: :
mesh_(mesh), mesh_(mesh),
@ -412,7 +417,7 @@ Foam::ensightMesh::ensightMesh
patchPatterns_(patchPatterns), patchPatterns_(patchPatterns),
faceZones_(faceZones), faceZones_(faceZones),
faceZonePatterns_(faceZonePatterns), faceZonePatterns_(faceZonePatterns),
binary_(binary), format_(format),
meshCellSets_(mesh.nCells()) meshCellSets_(mesh.nCells())
{ {
correct(); correct();
@ -521,7 +526,7 @@ void Foam::ensightMesh::writePrims
// Create a temp int array // Create a temp int array
if (cellShapes.size()) if (cellShapes.size())
{ {
if (ensightGeometryFile.ascii()) if (format_ == IOstream::ASCII)
{ {
// Workaround for paraview issue : write one cell per line // Workaround for paraview issue : write one cell per line
@ -1018,63 +1023,55 @@ void Foam::ensightMesh::writeAllPoints
void Foam::ensightMesh::write void Foam::ensightMesh::write
( (
const fileName& postProcPath, const fileName& dataDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool meshMoving, const bool meshMoving,
Ostream& ensightCaseFile Ostream& ensightCaseFile
) const ) const
{ {
const Time& runTime = mesh_.time();
const cellShapeList& cellShapes = mesh_.cellShapes(); const cellShapeList& cellShapes = mesh_.cellShapes();
ensightStream* filePtr(nullptr);
word timeFile = prepend;
if (timeIndex == 0)
{
timeFile += "0000.";
}
else if (meshMoving)
{
timeFile += itoa(timeIndex) + '.';
}
// set the filename of the ensight file
fileName ensightGeometryFileName = timeFile + "mesh";
ensightStream* ensightGeometryFilePtr = NULL;
if (Pstream::master()) if (Pstream::master())
{ {
if (binary_) // set the filename of the ensight file
fileName geoFileName = dataDir.path()/ensightMesh::geometryName;
if (meshMoving)
{ {
ensightGeometryFilePtr = new ensightBinaryStream geoFileName =
dataDir/ensightFile::subDir(timeIndex)/ensightMesh::geometryName;
mkDir(geoFileName.path());
}
if (format_ == IOstream::BINARY)
{
filePtr = new ensightBinaryStream
( (
postProcPath/ensightGeometryFileName, geoFileName
runTime
); );
ensightGeometryFilePtr->write("C binary"); filePtr->write("C binary");
} }
else else
{ {
ensightGeometryFilePtr = new ensightAsciiStream filePtr = new ensightAsciiStream
( (
postProcPath/ensightGeometryFileName, geoFileName
runTime
); );
} }
} }
ensightStream& ensightGeometryFile = *ensightGeometryFilePtr; ensightStream& os = *filePtr;
if (Pstream::master()) if (Pstream::master())
{ {
string desc = string("written by OpenFOAM-") + Foam::FOAMversion; string desc = string("written by OpenFOAM-") + Foam::FOAMversion;
ensightGeometryFile.write("EnSight Geometry File"); os.write("EnSight Geometry File");
ensightGeometryFile.write(desc.c_str()); os.write(desc.c_str());
ensightGeometryFile.write("node id assign"); os.write("node id assign");
ensightGeometryFile.write("element id assign"); os.write("element id assign");
} }
if (patchNames_.empty()) if (patchNames_.empty())
@ -1089,7 +1086,7 @@ void Foam::ensightMesh::write
"internalMesh", "internalMesh",
uniquePoints, uniquePoints,
nPoints, nPoints,
ensightGeometryFile os
); );
writeAllPrims writeAllPrims
@ -1103,7 +1100,7 @@ void Foam::ensightMesh::write
meshCellSets_.wedges, meshCellSets_.wedges,
pointToGlobal_ pointToGlobal_
), ),
ensightGeometryFile os
); );
writeAllPrims writeAllPrims
@ -1111,7 +1108,7 @@ void Foam::ensightMesh::write
"penta6", "penta6",
meshCellSets_.nPrisms, meshCellSets_.nPrisms,
map(cellShapes, meshCellSets_.prisms, pointToGlobal_), map(cellShapes, meshCellSets_.prisms, pointToGlobal_),
ensightGeometryFile os
); );
writeAllPrims writeAllPrims
@ -1119,7 +1116,7 @@ void Foam::ensightMesh::write
"pyramid5", "pyramid5",
meshCellSets_.nPyrs, meshCellSets_.nPyrs,
map(cellShapes, meshCellSets_.pyrs, pointToGlobal_), map(cellShapes, meshCellSets_.pyrs, pointToGlobal_),
ensightGeometryFile os
); );
writeAllPrims writeAllPrims
@ -1127,13 +1124,13 @@ void Foam::ensightMesh::write
"tetra4", "tetra4",
meshCellSets_.nTets, meshCellSets_.nTets,
map(cellShapes, meshCellSets_.tets, pointToGlobal_), map(cellShapes, meshCellSets_.tets, pointToGlobal_),
ensightGeometryFile os
); );
writeAllPolys writeAllPolys
( (
pointToGlobal_, pointToGlobal_,
ensightGeometryFile os
); );
} }
@ -1182,7 +1179,7 @@ void Foam::ensightMesh::write
patchName, patchName,
uniquePoints, uniquePoints,
globalPointsPtr().size(), globalPointsPtr().size(),
ensightGeometryFile os
); );
writeAllFacePrims writeAllFacePrims
@ -1191,7 +1188,7 @@ void Foam::ensightMesh::write
tris, tris,
nfp.nTris, nfp.nTris,
patchFaces, patchFaces,
ensightGeometryFile os
); );
writeAllFacePrims writeAllFacePrims
@ -1200,7 +1197,7 @@ void Foam::ensightMesh::write
quads, quads,
nfp.nQuads, nfp.nQuads,
patchFaces, patchFaces,
ensightGeometryFile os
); );
writeAllNSided writeAllNSided
@ -1208,7 +1205,7 @@ void Foam::ensightMesh::write
polys, polys,
nfp.nPolys, nfp.nPolys,
patchFaces, patchFaces,
ensightGeometryFile os
); );
} }
} }
@ -1287,7 +1284,7 @@ void Foam::ensightMesh::write
faceZoneName, faceZoneName,
uniquePoints, uniquePoints,
globalPointsPtr().size(), globalPointsPtr().size(),
ensightGeometryFile os
); );
writeAllFacePrims writeAllFacePrims
@ -1296,7 +1293,7 @@ void Foam::ensightMesh::write
tris, tris,
nfp.nTris, nfp.nTris,
faceZoneMasterFaces, faceZoneMasterFaces,
ensightGeometryFile os
); );
writeAllFacePrims writeAllFacePrims
@ -1305,7 +1302,7 @@ void Foam::ensightMesh::write
quads, quads,
nfp.nQuads, nfp.nQuads,
faceZoneMasterFaces, faceZoneMasterFaces,
ensightGeometryFile os
); );
writeAllNSided writeAllNSided
@ -1313,14 +1310,14 @@ void Foam::ensightMesh::write
polys, polys,
nfp.nPolys, nfp.nPolys,
faceZoneMasterFaces, faceZoneMasterFaces,
ensightGeometryFile os
); );
} }
} }
if (Pstream::master()) if (filePtr) // only on master
{ {
delete ensightGeometryFilePtr; delete filePtr;
} }
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -63,6 +63,11 @@ class ensightStream;
class ensightMesh class ensightMesh
{ {
public: public:
//- The name for geometry files
static const char* geometryName;
//- Helper class for managing face primitives
class nFacePrimitives class nFacePrimitives
{ {
public: public:
@ -97,8 +102,8 @@ private:
const bool faceZones_; const bool faceZones_;
const wordReList faceZonePatterns_; const wordReList faceZonePatterns_;
//- Set binary file output //- Ascii/Binary file output
const bool binary_; const IOstream::streamFormat format_;
//- The ensight part id for the first patch //- The ensight part id for the first patch
label patchPartOffset_; label patchPartOffset_;
@ -140,10 +145,10 @@ private:
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ensightMesh(const ensightMesh&); ensightMesh(const ensightMesh&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ensightMesh&); void operator=(const ensightMesh&) = delete;
void writePoints void writePoints
( (
@ -267,7 +272,7 @@ public:
const wordReList& patchPatterns, const wordReList& patchPatterns,
const bool faceZones, const bool faceZones,
const wordReList& faceZonePatterns, const wordReList& faceZonePatterns,
const bool binary const IOstream::streamFormat format = IOstream::BINARY
); );
@ -284,6 +289,11 @@ public:
return mesh_; return mesh_;
} }
IOstream::streamFormat format() const
{
return format_;
}
const cellSets& meshCellSets() const const cellSets& meshCellSets() const
{ {
return meshCellSets_; return meshCellSets_;
@ -352,8 +362,6 @@ public:
} }
// Other // Other
//- Update for new mesh //- Update for new mesh
@ -371,8 +379,7 @@ public:
void write void write
( (
const fileName& postProcPath, const fileName& ensightDir,
const word& prepend,
const label timeIndex, const label timeIndex,
const bool meshMoving, const bool meshMoving,
Ostream& ensightCaseFile Ostream& ensightCaseFile

View File

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ensightParticlePositions.H"
#include "fvMesh.H"
#include "passiveParticle.H"
#include "Cloud.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "itoa.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void ensightParticlePositions
(
const fvMesh& mesh,
const fileName& postProcPath,
const word& timeFile,
const word& cloudName,
const bool dataExists
)
{
if (dataExists)
{
Info<< "Converting cloud " << cloudName << " positions" << endl;
}
else
{
Info<< "Creating empty cloud " << cloudName << " positions" << endl;
}
const Time& runTime = mesh.time();
fileName ensightFileName(timeFile + "." + cloudName);
OFstream ensightFile
(
postProcPath/ensightFileName,
runTime.writeFormat(),
runTime.writeVersion(),
runTime.writeCompression()
);
// Output header
ensightFile
<< cloudName.c_str() << nl
<< "particle coordinates" << nl;
if (dataExists)
{
Cloud<passiveParticle> parcels(mesh, cloudName, false);
// Set Format
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
ensightFile.precision(5);
ensightFile<< setw(8) << parcels.size() << nl;
label nParcels = 0;
// Output positions
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
{
const vector& p = elmnt().position();
ensightFile
<< setw(8) << ++nParcels
<< setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
<< nl;
}
}
else
{
label nParcels = 0;
ensightFile<< setw(8) << nParcels << nl;
}
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,10 +57,10 @@ class ensightStream
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
ensightStream(const ensightStream&); ensightStream(const ensightStream&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ensightStream&); void operator=(const ensightStream&) = delete;
public: public:
@ -86,8 +86,6 @@ public:
return name_; return name_;
} }
virtual bool ascii() const = 0;
virtual void write(const char*) = 0; virtual void write(const char*) = 0;
virtual void write(const int) = 0; virtual void write(const int) = 0;
@ -98,8 +96,6 @@ public:
virtual void writePartHeader(const label) = 0; virtual void writePartHeader(const label) = 0;
}; };

View File

@ -0,0 +1,93 @@
// check all time directories for the following:
// The fields for each cloud:
HashTable<HashTable<word>> cloudFields;
// Identify if lagrangian data exist at any time step.
if (timeDirs.size() && !noLagrangian)
{
const fileName& baseDir = mesh.time().path();
const fileName& cloudPrefix = regionPrefix/cloud::prefix;
Info<< "Searching for lagrangian ... " << flush;
forAll(timeDirs, timeI)
{
const word& timeName = timeDirs[timeI].name();
// DO NOT USE -->> runTime.setTime(timeDirs[timeI], timeI); <<--
// It incurs a large overhead when done so frequently.
fileNameList cloudDirs = readDir
(
baseDir/timeName/cloudPrefix,
fileName::DIRECTORY
);
forAll(cloudDirs, cloudI)
{
const word& cloudName = cloudDirs[cloudI];
IOobjectList cloudObjs
(
mesh,
timeName,
cloudPrefix/cloudName
);
// clouds always require "positions"
if (cloudObjs.found("positions"))
{
HashTable<HashTable<word>>::iterator cloudIter =
cloudFields.find(cloudName);
if (cloudIter == cloudFields.end())
{
// A newly discovered cloud
cloudFields.insert(cloudName, HashTable<word>());
cloudIter = cloudFields.find(cloudName);
}
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
{
const IOobject obj = *fieldIter();
// Add field and field type
cloudIter().insert
(
obj.name(),
obj.headerClassName()
);
}
}
}
}
// prune out "positions" again since it gets treated specially
forAllIter(HashTable<HashTable<word>>, cloudFields, cloudIter)
{
cloudIter().erase("positions");
}
if (cloudFields.empty())
{
Info<< "none detected." << endl;
}
}
// sorted list of cloud names
const wordList cloudNames(cloudFields.sortedToc());
if (cloudNames.size())
{
// complete the echo information
Info<< "(";
forAll(cloudNames, cloudNo)
{
Info<< ' ' << cloudNames[cloudNo];
}
Info<< " ) " << endl;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,24 +34,33 @@ Description
Usage Usage
- foamToEnsight [OPTION] \n - foamToEnsight [OPTION] \n
Translates OpenFOAM data to Ensight format Translates OpenFOAM data to EnSight format
\param -ascii \n \param -ascii \n
Write Ensight data in ASCII format instead of "C Binary" Write Ensight data in ASCII format instead of "C Binary"
\param -patches patchList \n \param -noZero \n
Specify particular patches to write. Exclude the often incomplete initial conditions.
Specifying an empty list suppresses writing the internalMesh.
\param -noLagrangian \n
Suppress writing lagrangian positions and fields.
\param -noPatches \n \param -noPatches \n
Suppress writing any patches. Suppress writing any patches.
\param -patches patchList \n
Specify particular patches to write.
Specifying an empty list suppresses writing the internalMesh.
\param -faceZones zoneList \n \param -faceZones zoneList \n
Specify faceZones to write, with wildcards Specify faceZones to write, with wildcards
\param -cellZone zoneName \n \param -cellZone zoneName \n
Specify single cellZone to write (not lagrangian) Specify single cellZone to write (not lagrangian)
\param -width \<n\>\n
Width of EnSight data subdir (default: 8)
Note Note
Parallel support for cloud data is not supported Parallel support for cloud data is not supported
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts - writes to \a EnSight directory to avoid collisions with foamToEnsightParts
@ -70,14 +79,12 @@ Note
#include "scalarIOField.H" #include "scalarIOField.H"
#include "tensorIOField.H" #include "tensorIOField.H"
#include "ensightFile.H"
#include "ensightMesh.H" #include "ensightMesh.H"
#include "ensightField.H" #include "ensightField.H"
#include "ensightCloud.H"
#include "ensightParticlePositions.H"
#include "ensightCloudField.H"
#include "fvc.H" #include "fvc.H"
#include "cellSet.H" #include "cellSet.H"
#include "fvMeshSubset.H" #include "fvMeshSubset.H"
@ -122,6 +129,11 @@ int main(int argc, char *argv[])
"write values in nodes" "write values in nodes"
); );
argList::addBoolOption argList::addBoolOption
(
"noLagrangian",
"suppress writing lagrangian positions and fields"
);
argList::addBoolOption
( (
"noPatches", "noPatches",
"suppress writing any patches" "suppress writing any patches"
@ -151,32 +163,21 @@ int main(int argc, char *argv[])
"word", "word",
"specify cellZone to write" "specify cellZone to write"
); );
argList::addOption
(
"name",
"subdir",
"define sub-directory name to use for ensight data "
"(default: 'EnSight')"
);
argList::addOption
(
"width",
"n",
"width of ensight data subdir"
);
#include "setRootCase.H" // the volume field types that we handle
// Check options
const bool binary = !args.optionFound("ascii");
const bool nodeValues = args.optionFound("nodeValues");
cpuTime timer;
memInfo mem;
Info<< "Initial memory "
<< mem.update().size() << " kB" << endl;
#include "createTime.H"
instantList Times = timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
// Mesh instance (region0 gets filtered out)
fileName regionPrefix = "";
if (regionName != polyMesh::defaultRegion)
{
regionPrefix = regionName;
}
const label nVolFieldTypes = 10; const label nVolFieldTypes = 10;
const word volFieldTypes[] = const word volFieldTypes[] =
{ {
@ -193,38 +194,90 @@ int main(int argc, char *argv[])
volTensorField::DimensionedInternalField::typeName volTensorField::DimensionedInternalField::typeName
}; };
#include "setRootCase.H"
// default to binary output, unless otherwise specified
const IOstream::streamFormat format =
(
args.optionFound("ascii")
? IOstream::ASCII
: IOstream::BINARY
);
const bool nodeValues = args.optionFound("nodeValues");
cpuTime timer;
memInfo mem;
Info<< "Initial memory "
<< mem.update().size() << " kB" << endl;
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
// adjust output width
if (args.optionFound("width"))
{
ensightFile::subDirWidth(args.optionRead<label>("width"));
}
// define sub-directory name to use for EnSight data
fileName ensightDir = "EnSight";
args.optionReadIfPresent("name", ensightDir);
// Path to EnSight directory at case level only // Path to EnSight directory at case level only
// - For parallel cases, data only written from master // - For parallel cases, data only written from master
fileName ensightDir = args.rootPath()/args.globalCaseName()/"EnSight"; if (!ensightDir.isAbsolute())
{
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
}
const fileName dataDir = ensightDir/"data";
const fileName dataMask = dataDir.name()/ensightFile::mask();
if (Pstream::master()) if (Pstream::master())
{ {
// EnSight and EnSight/data directories must exist
// - remove old data for a clean conversion of everything
if (isDir(ensightDir)) if (isDir(ensightDir))
{ {
rmDir(ensightDir); rmDir(ensightDir);
} }
mkDir(ensightDir); mkDir(dataDir);
}
#include "createNamedMesh.H"
// Mesh instance (region0 gets filtered out)
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion)
{
regionPrefix = regionName;
} }
// Start of case file header output // Start of case file header output
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const word prepend = args.globalCaseName() + '.'; OFstream *ensightCaseFilePtr(nullptr);
OFstream *ensightCaseFilePtr = NULL;
if (Pstream::master()) if (Pstream::master())
{ {
fileName caseFileName = prepend + "case"; fileName caseFileName = args.globalCaseName() + ".case";
Info<< nl << "write case: " << caseFileName.c_str() << endl;
// the case file is always ASCII Info<< "Converting " << timeDirs.size() << " time steps" << nl
<< "Ensight case: " << caseFileName.c_str() << endl;
// The case file is always ASCII
ensightCaseFilePtr = new OFstream ensightCaseFilePtr = new OFstream
( (
ensightDir/caseFileName, ensightDir/caseFileName,
IOstream::ASCII IOstream::ASCII
); );
ensightCaseFilePtr->setf(ios_base::left);
ensightCaseFilePtr->setf(ios_base::scientific, ios_base::floatfield);
ensightCaseFilePtr->precision(5);
*ensightCaseFilePtr *ensightCaseFilePtr
<< "FORMAT" << nl << "FORMAT" << nl
<< "type: ensight gold" << nl << nl; << "type: ensight gold" << nl << nl;
@ -253,6 +306,8 @@ int main(int argc, char *argv[])
fieldPatterns = wordReList(args.optionLookup("fields")()); fieldPatterns = wordReList(args.optionLookup("fields")());
} }
const bool noLagrangian = args.optionFound("noLagrangian");
word cellZoneName; word cellZoneName;
const bool doCellZone = args.optionReadIfPresent("cellZone", cellZoneName); const bool doCellZone = args.optionReadIfPresent("cellZone", cellZoneName);
@ -280,133 +335,84 @@ int main(int argc, char *argv[])
patchPatterns, patchPatterns,
selectedZones, selectedZones,
zonePatterns, zonePatterns,
binary format
); );
// Set Time to the last time before looking for the lagrangian objects // Set Time to the last time before looking for the lagrangian objects
runTime.setTime(Times.last(), Times.size()-1); runTime.setTime(timeDirs.last(), timeDirs.size()-1);
IOobjectList objects(mesh, runTime.timeName()); IOobjectList objects(mesh, runTime.timeName());
#include "checkMeshMoving.H" #include "checkMeshMoving.H"
#include "findCloudFields.H"
if (meshMoving)
{
Info<< "Detected a moving mesh (multiple polyMesh/points files)."
<< " Writing meshes for every timestep." << endl;
}
wordHashSet allCloudNames;
if (Pstream::master()) if (Pstream::master())
{ {
word geomFileName = prepend + "0000"; // test the pre-check variable if there is a moving mesh
// time-set for geometries
// TODO: split off into separate time-set,
// but need to verify ensight spec
// test pre check variable if there is a moving mesh
if (meshMoving) if (meshMoving)
{ {
geomFileName = prepend + "****"; ensightCaseFile
<< "GEOMETRY" << nl
<< setw(16) << "model: 1"
<< (dataMask/ensightMesh::geometryName).c_str() << nl;
} }
else
ensightCaseFile
<< "GEOMETRY" << nl
<< "model: 1 "
<< (geomFileName + ".mesh").c_str() << nl;
}
// Identify if lagrangian data exists at each time, and add clouds
// to the 'allCloudNames' hash set
forAll(Times, timeI)
{
runTime.setTime(Times[timeI], timeI);
fileNameList cloudDirs = readDir
(
runTime.timePath()/regionPrefix/cloud::prefix,
fileName::DIRECTORY
);
forAll(cloudDirs, cloudI)
{
IOobjectList cloudObjs
(
mesh,
runTime.timeName(),
cloud::prefix/cloudDirs[cloudI]
);
IOobject* positionsPtr = cloudObjs.lookup(word("positions"));
if (positionsPtr)
{
allCloudNames.insert(cloudDirs[cloudI]);
}
}
}
HashTable<HashTable<word>> allCloudFields;
forAllConstIter(wordHashSet, allCloudNames, cloudIter)
{
// Add the name of the cloud(s) to the case file header
if (Pstream::master())
{ {
ensightCaseFile ensightCaseFile
<< ( << "GEOMETRY" << nl
"measured: 1 " << setw(16) << "model:"
+ prepend << ensightMesh::geometryName << nl;
+ "****."
+ cloudIter.key()
).c_str()
<< nl;
} }
// Create a new hash table for each cloud
allCloudFields.insert(cloudIter.key(), HashTable<word>());
// Identify the new cloud in the hash table // Add the name of the cloud(s) to the case file header
HashTable<HashTable<word>>::iterator newCloudIter = forAll(cloudNames, cloudNo)
allCloudFields.find(cloudIter.key());
// Loop over all times to build list of fields and field types
// for each cloud
forAll(Times, timeI)
{ {
runTime.setTime(Times[timeI], timeI); const word& cloudName = cloudNames[cloudNo];
IOobjectList cloudObjs ensightCaseFile
( << setw(16) << "measured: 1"
mesh, << fileName
runTime.timeName(), (
cloud::prefix/cloudIter.key() dataMask/cloud::prefix/cloudName/"positions"
); ).c_str() << nl;
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
{
const IOobject obj = *fieldIter();
if (obj.name() != "positions")
{
// Add field and field type
newCloudIter().insert
(
obj.name(),
obj.headerClassName()
);
}
}
} }
} }
Info<< "Startup in "
<< timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << nl << endl;
// ignore special fields (_0 fields),
// ignore fields we don't handle,
// ignore fields that are not available for all time-steps
HashTable<bool> fieldsToUse;
label nTimeSteps = 0; label nTimeSteps = 0;
forAll(Times, timeIndex) forAll(timeDirs, timeIndex)
{ {
nTimeSteps++; ++nTimeSteps;
runTime.setTime(Times[timeIndex], timeIndex); runTime.setTime(timeDirs[timeIndex], timeIndex);
word timeName = itoa(timeIndex); Info<< "Time [" << timeIndex << "] = " << runTime.timeName() << nl;
word timeFile = prepend + timeName;
Info<< "Translating time = " << runTime.timeName() << nl; if (Pstream::master())
{
// the data/ITER subdirectory must exist
// Note that data/ITER is indeed a valid ensight::FileName
const fileName subDir = ensightFile::subDir(timeIndex);
mkDir(dataDir/subDir);
// place a timestamp in the directory for future reference
OFstream timeStamp(dataDir/subDir/"time");
timeStamp
<< "# timestep time" << nl
<< subDir.c_str() << " " << runTime.timeName() << nl;
}
polyMesh::readUpdateState meshState = mesh.readUpdate(); polyMesh::readUpdateState meshState = mesh.readUpdate();
if (timeIndex != 0 && meshSubsetter.hasSubMesh()) if (timeIndex != 0 && meshSubsetter.hasSubMesh())
@ -420,7 +426,6 @@ int main(int argc, char *argv[])
meshSubsetter.setLargeCellSubset(c0, 0); meshSubsetter.setLargeCellSubset(c0, 0);
} }
if (meshState != polyMesh::UNCHANGED) if (meshState != polyMesh::UNCHANGED)
{ {
eMesh.correct(); eMesh.correct();
@ -430,8 +435,7 @@ int main(int argc, char *argv[])
{ {
eMesh.write eMesh.write
( (
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
meshMoving, meshMoving,
ensightCaseFile ensightCaseFile
@ -450,8 +454,9 @@ int main(int argc, char *argv[])
// Cell field data output // Cell field data output
// ~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~
Info<< "Write volume field (";
for (label i=0; i<nVolFieldTypes; i++) for (label i=0; i<nVolFieldTypes; ++i)
{ {
wordList fieldNames = objects.names(volFieldTypes[i]); wordList fieldNames = objects.names(volFieldTypes[i]);
@ -470,7 +475,7 @@ int main(int argc, char *argv[])
#include "checkData.H" #include "checkData.H"
if (!variableGood) if (!fieldsToUse[fieldName])
{ {
continue; continue;
} }
@ -491,10 +496,8 @@ int main(int argc, char *argv[])
( (
volField(meshSubsetter, vf), volField(meshSubsetter, vf),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -506,10 +509,8 @@ int main(int argc, char *argv[])
( (
volField(meshSubsetter, vf), volField(meshSubsetter, vf),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -521,10 +522,8 @@ int main(int argc, char *argv[])
( (
volField(meshSubsetter, vf), volField(meshSubsetter, vf),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -536,10 +535,8 @@ int main(int argc, char *argv[])
( (
volField(meshSubsetter, vf), volField(meshSubsetter, vf),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -551,10 +548,8 @@ int main(int argc, char *argv[])
( (
volField(meshSubsetter, vf), volField(meshSubsetter, vf),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -575,10 +570,8 @@ int main(int argc, char *argv[])
( (
volField<scalar>(meshSubsetter, df), volField<scalar>(meshSubsetter, df),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -598,10 +591,8 @@ int main(int argc, char *argv[])
( (
volField<vector>(meshSubsetter, df), volField<vector>(meshSubsetter, df),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -621,10 +612,8 @@ int main(int argc, char *argv[])
( (
volField<sphericalTensor>(meshSubsetter, df), volField<sphericalTensor>(meshSubsetter, df),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -644,10 +633,8 @@ int main(int argc, char *argv[])
( (
volField<symmTensor>(meshSubsetter, df), volField<symmTensor>(meshSubsetter, df),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
@ -667,24 +654,29 @@ int main(int argc, char *argv[])
( (
volField<tensor>(meshSubsetter, df), volField<tensor>(meshSubsetter, df),
eMesh, eMesh,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
binary,
nodeValues, nodeValues,
ensightCaseFile ensightCaseFile
); );
} }
else
{
// Do not currently handle this type - blacklist for the future.
fieldsToUse.set(fieldName, false);
}
} }
} }
Info<< " )" << nl;
// Cloud field data output // Cloud field data output
// ~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~
forAllConstIter(HashTable<HashTable<word>>, allCloudFields, cloudIter) forAll(cloudNames, cloudNo)
{ {
const word& cloudName = cloudIter.key(); const word& cloudName = cloudNames[cloudNo];
const HashTable<word>& theseCloudFields = cloudFields[cloudName];
fileNameList currentCloudDirs = readDir fileNameList currentCloudDirs = readDir
( (
@ -692,17 +684,22 @@ int main(int argc, char *argv[])
fileName::DIRECTORY fileName::DIRECTORY
); );
Info<< "Write " << cloudName << " (";
bool cloudExists = inFileNameList(currentCloudDirs, cloudName); bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
reduce(cloudExists, orOp<bool>());
ensightParticlePositions ensightParticlePositions
( (
mesh, mesh,
ensightDir, dataDir,
timeFile, timeIndex,
cloudName, cloudName,
cloudExists cloudExists,
format
); );
forAllConstIter(HashTable<word>, cloudIter(), fieldIter) forAllConstIter(HashTable<word>, theseCloudFields, fieldIter)
{ {
const word& fieldName = fieldIter.key(); const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter(); const word& fieldType = fieldIter();
@ -720,17 +717,20 @@ int main(int argc, char *argv[])
( (
false false
); );
reduce(fieldExists, orOp<bool>());
if (fieldType == scalarIOField::typeName) if (fieldType == scalarIOField::typeName)
{ {
ensightCloudField<scalar> ensightCloudField<scalar>
( (
fieldObject, fieldObject,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
cloudName, cloudName,
cloudNo,
ensightCaseFile, ensightCaseFile,
fieldExists fieldExists,
format
); );
} }
else if (fieldType == vectorIOField::typeName) else if (fieldType == vectorIOField::typeName)
@ -738,37 +738,34 @@ int main(int argc, char *argv[])
ensightCloudField<vector> ensightCloudField<vector>
( (
fieldObject, fieldObject,
ensightDir, dataDir,
prepend,
timeIndex, timeIndex,
cloudName, cloudName,
cloudNo,
ensightCaseFile, ensightCaseFile,
fieldExists fieldExists,
format
); );
} }
else
{
Info<< "Unable to convert field type " << fieldType
<< " for field " << fieldName << endl;
}
} }
Info<< " )" << nl;
} }
Info<< "Wrote in " Info<< "Wrote in "
<< timer.cpuTimeIncrement() << " s, " << timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << endl; << mem.update().size() << " kB" << nl << nl;
} }
#include "ensightCaseTail.H" #include "ensightCaseTail.H"
if (Pstream::master()) if (ensightCaseFilePtr) // on master only
{ {
delete ensightCaseFilePtr; delete ensightCaseFilePtr;
} }
Info<< "\nEnd: " Info<< "End: "
<< timer.elapsedCpuTime() << " s, " << timer.elapsedCpuTime() << " s, "
<< mem.update().peak() << " kB (peak)\n" << endl; << mem.update().peak() << " kB (peak)" << nl << endl;
return 0; return 0;
} }

View File

@ -2,18 +2,47 @@
// - could restrict to the selected times // - could restrict to the selected times
bool hasMovingMesh = false; bool hasMovingMesh = false;
if (timeDirs.size() > 1)
if (timeDirs.size() > 1 && Pstream::master())
{ {
hasMovingMesh = true; // We already loaded a mesh (usually from constant).
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i) // See if any other "polyMesh/points" files exist too.
const fileName& baseDir = mesh.time().path();
Info<< "Search for moving mesh ... " << flush;
forAll(timeDirs, timeI)
{ {
hasMovingMesh = IOobject hasMovingMesh =
( (
"points", isDir(baseDir/timeDirs[timeI].name()/polyMesh::meshSubDir)
timeDirs[i].name(), && IOobject
polyMesh::meshSubDir, (
mesh, "points",
IOobject::NO_READ timeDirs[timeI].name(),
).typeHeaderOk<pointIOField>(true); polyMesh::meshSubDir,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false // no register
).typeHeaderOk<pointIOField>(true)
);
if (hasMovingMesh)
{
break;
}
}
if (hasMovingMesh)
{
Info<< "found." << nl
<< " Writing meshes for every timestep." << endl;
}
else
{
Info<< "none detected." << endl;
} }
} }
reduce(hasMovingMesh, orOp<bool>());

View File

@ -58,35 +58,36 @@ forAllConstIter(HashTable<word>, volumeFields, fieldIter)
if (fieldType == volScalarField::typeName) if (fieldType == volScalarField::typeName)
{ {
ensightType = "scalar"; ensightType = ensightPTraits<scalar>::typeName;
} }
else if (fieldType == volVectorField::typeName) else if (fieldType == volVectorField::typeName)
{ {
ensightType = "vector"; ensightType = ensightPTraits<vector>::typeName;
} }
else if (fieldType == volSphericalTensorField::typeName) else if (fieldType == volSphericalTensorField::typeName)
{ {
ensightType = "tensor symm"; ensightType = ensightPTraits<sphericalTensor>::typeName;
} }
else if (fieldType == volSymmTensorField::typeName) else if (fieldType == volSymmTensorField::typeName)
{ {
ensightType = "tensor symm"; ensightType = ensightPTraits<symmTensor>::typeName;
} }
else if (fieldType == volTensorField::typeName) else if (fieldType == volTensorField::typeName)
{ {
ensightType = "tensor asym"; ensightType = ensightPTraits<tensor>::typeName;
}
else
{
continue;
} }
if (ensightType.size()) ensightCaseEntry
{ (
ensightCaseEntry caseFile,
( ensightType,
caseFile, fieldName,
ensightType, dataMask
fieldName, );
dataMask
);
}
} }
@ -104,30 +105,31 @@ forAllConstIter(HashTable<HashTable<word>>, cloudFields, cloudIter)
if (fieldType == scalarIOField::typeName) if (fieldType == scalarIOField::typeName)
{ {
ensightType = "scalar"; ensightType = ensightPTraits<scalar>::typeName;
} }
else if (fieldType == vectorIOField::typeName) else if (fieldType == vectorIOField::typeName)
{ {
ensightType = "vector"; ensightType = ensightPTraits<vector>::typeName;
} }
else if (fieldType == tensorIOField::typeName) else if (fieldType == tensorIOField::typeName)
{ {
ensightType = "tensor"; ensightType = ensightPTraits<tensor>::typeName;
}
else
{
continue;
} }
if (ensightType.size()) ensightCaseEntry
{ (
ensightCaseEntry caseFile,
( ensightType,
caseFile, fieldName,
ensightType, dataMask,
fieldName, cloud::prefix/cloudName,
dataMask, cloudNo,
cloud::prefix/cloudName, 2
cloudNo, );
2
);
}
} }
cloudNo++; cloudNo++;
} }
@ -162,7 +164,7 @@ if (fieldTimesUsed.size())
count = 0; count = 0;
forAll(fieldTimesUsed, i) forAll(fieldTimesUsed, i)
{ {
const label& index = fieldTimesUsed[i]; const label index = fieldTimesUsed[i];
caseFile caseFile
<< " " << setw(12) << timeIndices[index] + timeCorrection; << " " << setw(12) << timeIndices[index] + timeCorrection;
@ -203,7 +205,7 @@ if (geometryTimesUsed.size())
count = 0; count = 0;
forAll(geometryTimesUsed, i) forAll(geometryTimesUsed, i)
{ {
const label& index = geometryTimesUsed[i]; const label index = geometryTimesUsed[i];
caseFile caseFile
<< " " << setw(12) << timeIndices[index] + timeCorrection; << " " << setw(12) << timeIndices[index] + timeCorrection;
@ -249,7 +251,7 @@ forAllConstIter(HashTable<DynamicList<label>>, cloudTimesUsed, cloudIter)
count = 0; count = 0;
forAll(timesUsed, i) forAll(timesUsed, i)
{ {
const label& index = timesUsed[i]; const label index = timesUsed[i];
caseFile caseFile
<< " " << setw(12) << timeIndices[index] + timeCorrection; << " " << setw(12) << timeIndices[index] + timeCorrection;

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ensightOutputFunctions.H" #include "ensightOutputFunctions.H"
#include "ensightPTraits.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "IOField.H" #include "IOField.H"
@ -171,11 +172,8 @@ void Foam::ensightLagrangianField
// when writing positions // when writing positions
ensightFile os(dataDir, postFileName, format); ensightFile os(dataDir, postFileName, format);
os.write // description
( os.write(string(postFileName + " <" + pTraits<Type>::typeName + ">"));
// description
string(postFileName + " with " + pTraits<Type>::typeName + " values")
);
os.newline(); os.newline();
IOField<Type> field(fieldObject); IOField<Type> field(fieldObject);
@ -187,21 +185,20 @@ void Foam::ensightLagrangianField
{ {
Type val = field[i]; Type val = field[i];
if (mag(val) < 1.0e-90) if (mag(val) < 1e-90)
{ {
val = Zero; val = Zero;
} }
for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++) for (direction d=0; d < pTraits<Type>::nComponents; ++d)
{ {
os.write( component(val, cmpt) ); label cmpt = ensightPTraits<Type>::componentOrder[d];
} os.write(component(val, cmpt));
count += pTraits<Type>::nComponents; if (++count % 6 == 0)
{
if (count % 6 == 0) os.newline();
{ }
os.newline();
} }
} }

View File

@ -8,7 +8,10 @@ HashTable<HashTable<word>> cloudFields;
if (timeDirs.size()) if (timeDirs.size())
{ {
IOobjectList objs(mesh, timeDirs.last().name()); const fileName& cloudPrefix = regionPrefix/cloud::prefix;
const word& lastTimeName = timeDirs.last().name();
IOobjectList objs(mesh, lastTimeName);
forAllConstIter(IOobjectList, objs, fieldIter) forAllConstIter(IOobjectList, objs, fieldIter)
{ {
@ -31,14 +34,17 @@ if (timeDirs.size())
// //
// now check for lagrangian/<cloudName> // now check for lagrangian/<cloudName>
// //
fileNameList cloudDirs = readDir fileNameList cloudDirs;
( if (!noLagrangian)
runTime.path() {
/ timeDirs.last().name() cloudDirs = readDir
/ regionPrefix (
/ cloud::prefix, runTime.path()
fileName::DIRECTORY / lastTimeName
); / cloudPrefix,
fileName::DIRECTORY
);
}
forAll(cloudDirs, cloudI) forAll(cloudDirs, cloudI)
{ {
@ -54,8 +60,8 @@ if (timeDirs.size())
IOobjectList objs IOobjectList objs
( (
mesh, mesh,
timeDirs.last().name(), lastTimeName,
cloud::prefix/cloudName cloudPrefix/cloudName
); );
bool hasPositions = false; bool hasPositions = false;
@ -89,17 +95,27 @@ if (timeDirs.size())
// //
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i) for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
{ {
IOobjectList objs(mesh, timeDirs[i].name()); const word& timeName = timeDirs[i].name();
forAllIter(HashTable<word>, volumeFields, fieldIter) // Everything is potentially missing, unless we discover otherwise
wordHashSet missing(volumeFields);
// Avoid -->> IOobjectList objs(mesh, timeName); <<--
// Too much overhead when done so frequently.
fileNameList contents = readDir
(
runTime.path()
/ timeName,
fileName::FILE
);
forAll(contents, fileI)
{ {
const word& fieldName = fieldIter.key(); missing.erase(contents[fileI].name());
if (!objs.found(fieldName))
{
volumeFields.erase(fieldIter);
}
} }
volumeFields.erase(missing);
} }
} }

View File

@ -44,6 +44,9 @@ Usage
\param -noZero \n \param -noZero \n
Exclude the often incomplete initial conditions. Exclude the often incomplete initial conditions.
\param -noLagrangian \n
Suppress writing lagrangian positions and fields.
\param -index \<start\>\n \param -index \<start\>\n
Ignore the time index contained in the time file and use a Ignore the time index contained in the time file and use a
simple indexing when creating the \c Ensight/data/######## files. simple indexing when creating the \c Ensight/data/######## files.
@ -101,6 +104,11 @@ int main(int argc, char *argv[])
"and use simple indexing when creating the files" "and use simple indexing when creating the files"
); );
argList::addBoolOption argList::addBoolOption
(
"noLagrangian",
"suppress writing lagrangian positions and fields"
);
argList::addBoolOption
( (
"noMesh", "noMesh",
"suppress writing the geometry. " "suppress writing the geometry. "
@ -149,15 +157,17 @@ int main(int argc, char *argv[])
instantList timeDirs = timeSelector::select0(runTime, args); instantList timeDirs = timeSelector::select0(runTime, args);
// default to binary output, unless otherwise specified // default to binary output, unless otherwise specified
IOstream::streamFormat format = IOstream::BINARY; const IOstream::streamFormat format =
if (args.optionFound("ascii")) (
{ args.optionFound("ascii")
format = IOstream::ASCII; ? IOstream::ASCII
} : IOstream::BINARY
);
// control for renumbering iterations // control for renumbering iterations
label indexingNumber = 0; label indexingNumber = 0;
bool optIndex = args.optionReadIfPresent("index", indexingNumber); const bool optIndex = args.optionReadIfPresent("index", indexingNumber);
const bool noLagrangian = args.optionFound("noLagrangian");
// always write the geometry, unless the -noMesh option is specified // always write the geometry, unless the -noMesh option is specified
bool optNoMesh = args.optionFound("noMesh"); bool optNoMesh = args.optionFound("noMesh");
@ -204,6 +214,11 @@ int main(int argc, char *argv[])
regionPrefix = regionName; regionPrefix = regionName;
} }
if (Pstream::master())
{
Info<< "Converting " << timeDirs.size() << " time steps" << endl;
}
// Construct the list of ensight parts for the entire mesh // Construct the list of ensight parts for the entire mesh
ensightParts partsList(mesh); ensightParts partsList(mesh);
@ -244,6 +259,9 @@ int main(int argc, char *argv[])
cloudTimesUsed.insert(cloudIter.key(), DynamicList<label>()); cloudTimesUsed.insert(cloudIter.key(), DynamicList<label>());
} }
Info<< "Startup in "
<< timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << nl << endl;
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
{ {
@ -294,7 +312,7 @@ int main(int argc, char *argv[])
} }
} }
Info<< "write volume field (" << flush; Info<< "Write volume field (" << flush;
forAllConstIter(HashTable<word>, volumeFields, fieldIter) forAllConstIter(HashTable<word>, volumeFields, fieldIter)
{ {
@ -380,15 +398,9 @@ int main(int argc, char *argv[])
forAllConstIter(HashTable<HashTable<word>>, cloudFields, cloudIter) forAllConstIter(HashTable<HashTable<word>>, cloudFields, cloudIter)
{ {
const word& cloudName = cloudIter.key(); const word& cloudName = cloudIter.key();
const fileName& cloudPrefix = regionPrefix/cloud::prefix;
if if (!isDir(runTime.timePath()/cloudPrefix/cloudName))
(
!isDir
(
runTime.timePath()/regionPrefix/
cloud::prefix/cloudName
)
)
{ {
continue; continue;
} }
@ -397,28 +409,25 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
cloud::prefix/cloudName cloudPrefix/cloudName
); );
// check that the positions field is present for this time // check that the positions field is present for this time
IOobject* positionPtr = cloudObjs.lookup(word("positions")); if (!cloudObjs.found("positions"))
if (positionPtr != NULL)
{
ensightParticlePositions
(
mesh,
dataDir,
subDir,
cloudName,
format
);
}
else
{ {
continue; continue;
} }
Info<< "write " << cloudName << " (" << flush; Info<< "Write " << cloudName << " ( positions" << flush;
ensightParticlePositions
(
mesh,
dataDir,
subDir,
cloudName,
format
);
forAllConstIter(HashTable<word>, cloudIter(), fieldIter) forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
{ {
@ -430,7 +439,7 @@ int main(int argc, char *argv[])
if (!fieldObject) if (!fieldObject)
{ {
Info<< "missing " Info<< "missing "
<< runTime.timeName()/cloud::prefix/cloudName << runTime.timeName()/cloudPrefix/cloudName
/ fieldName / fieldName
<< endl; << endl;
continue; continue;

View File

@ -39,5 +39,5 @@
} }
timeIndices.insert(timeIndex, timeDirs[timeI].value()); timeIndices.insert(timeIndex, timeDirs[timeI].value());
Info<< "\nTime [" << timeIndex << "] = " << runTime.timeName() << nl; Info<< nl << "Time [" << timeIndex << "] = " << runTime.timeName() << nl;

View File

@ -93,7 +93,7 @@ Foam::tmp<Field<Type>> Foam::tecplotWriter::getFaceField
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh(); const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
tmp<Field<Type>> tfld(new Field<Type>(faceLabels.size())); tmp<Field<Type>> tfld(new Field<Type>(faceLabels.size()));
Field<Type>& fld = tfld(); Field<Type>& fld = tfld.ref();
forAll(faceLabels, i) forAll(faceLabels, i)
{ {

View File

@ -0,0 +1,71 @@
// check all time directories for the following:
// Any cloud names:
HashSet<fileName> allCloudDirs;
if (timeDirs.size() && !noLagrangian)
{
const fileName& baseDir = mesh.time().path();
const fileName& cloudPrefix = regionPrefix/cloud::prefix;
Info<< "Searching for lagrangian ... " << flush;
forAll(timeDirs, timeI)
{
const word& timeName = timeDirs[timeI].name();
// DO NOT USE -->> runTime.setTime(timeDirs[timeI], timeI); <<--
// It incurs a large overhead when done so frequently.
fileNameList cloudDirs = readDir
(
baseDir/timeName/cloudPrefix,
fileName::DIRECTORY
);
forAll(cloudDirs, cloudI)
{
const word& cloudName = cloudDirs[cloudI];
IOobjectList cloudObjs
(
mesh,
timeName,
cloudPrefix/cloudName
);
// clouds always require "positions"
if (cloudObjs.found("positions"))
{
if (allCloudDirs.insert(cloudName))
{
Info<< "At time: " << timeName
<< " detected cloud directory : " << cloudName
<< endl;
}
}
}
}
if (allCloudDirs.empty())
{
Info<< "none detected." << endl;
}
}
// sorted list of cloud names
const fileNameList cloudNames(allCloudDirs.sortedToc());
if (cloudNames.size())
{
// complete the echo information
Info<< "(";
forAll(cloudNames, cloudNo)
{
Info<< ' ' << cloudNames[cloudNo];
}
Info<< " ) " << endl;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -71,6 +71,9 @@ Usage
\param -noInternal \n \param -noInternal \n
Do not generate file for mesh, only for patches Do not generate file for mesh, only for patches
\param -noLagrangian \n
Suppress writing lagrangian positions and fields.
\param -noPointValues \n \param -noPointValues \n
No pointFields No pointFields
@ -290,6 +293,12 @@ int main(int argc, char *argv[])
"noInternal", "noInternal",
"do not generate file for mesh, only for patches" "do not generate file for mesh, only for patches"
); );
argList::addBoolOption
(
"noLagrangian",
"suppress writing lagrangian positions and fields"
);
argList::addBoolOption argList::addBoolOption
( (
"noPointValues", "noPointValues",
@ -336,6 +345,7 @@ int main(int argc, char *argv[])
const bool doLinks = !args.optionFound("noLinks"); const bool doLinks = !args.optionFound("noLinks");
bool binary = !args.optionFound("ascii"); bool binary = !args.optionFound("ascii");
const bool useTimeName = args.optionFound("useTimeName"); const bool useTimeName = args.optionFound("useTimeName");
const bool noLagrangian = args.optionFound("noLagrangian");
// Decomposition of polyhedral cells into tets/pyramids cells // Decomposition of polyhedral cells into tets/pyramids cells
vtkTopo::decomposePoly = !args.optionFound("poly"); vtkTopo::decomposePoly = !args.optionFound("poly");
@ -406,9 +416,9 @@ int main(int argc, char *argv[])
// VTK/ directory in the case // VTK/ directory in the case
fileName fvPath(runTime.path()/"VTK"); fileName fvPath(runTime.path()/"VTK");
// Directory of mesh (region0 gets filtered out)
fileName regionPrefix = "";
// Directory of mesh (region0 gets filtered out)
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion) if (regionName != polyMesh::defaultRegion)
{ {
fvPath = fvPath/regionName; fvPath = fvPath/regionName;
@ -446,43 +456,7 @@ int main(int argc, char *argv[])
<< timer.cpuTimeIncrement() << " s, " << timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << endl; << mem.update().size() << " kB" << endl;
#include "findClouds.H"
// Scan for all possible lagrangian clouds
HashSet<fileName> allCloudDirs;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
fileNameList cloudDirs
(
readDir
(
runTime.timePath()/regionPrefix/cloud::prefix,
fileName::DIRECTORY
)
);
forAll(cloudDirs, i)
{
IOobjectList sprayObjs
(
mesh,
runTime.timeName(),
cloud::prefix/cloudDirs[i]
);
IOobject* positionsPtr = sprayObjs.lookup(word("positions"));
if (positionsPtr)
{
if (allCloudDirs.insert(cloudDirs[i]))
{
Info<< "At time: " << runTime.timeName()
<< " detected cloud directory : " << cloudDirs[i]
<< endl;
}
}
}
}
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
{ {
@ -490,7 +464,7 @@ int main(int argc, char *argv[])
Info<< "Time: " << runTime.timeName() << endl; Info<< "Time: " << runTime.timeName() << endl;
word timeDesc = const word timeDesc =
useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex()); useTimeName ? runTime.timeName() : Foam::name(runTime.timeIndex());
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell // Check for new polyMesh/ and update mesh, fvMeshSubset and cell
@ -662,7 +636,7 @@ int main(int argc, char *argv[])
+ dtf.size(); + dtf.size();
// Construct pointMesh only if nessecary since constructs edge // Construct pointMesh only if necessary since constructs edge
// addressing (expensive on polyhedral meshes) // addressing (expensive on polyhedral meshes)
if (noPointValues) if (noPointValues)
{ {
@ -1149,9 +1123,9 @@ int main(int argc, char *argv[])
// //
//--------------------------------------------------------------------- //---------------------------------------------------------------------
forAllConstIter(HashSet<fileName>, allCloudDirs, iter) forAll(cloudNames, cloudNo)
{ {
const fileName& cloudName = iter.key(); const fileName& cloudName = cloudNames[cloudNo];
// Always create the cloud directory. // Always create the cloud directory.
mkDir(fvPath/cloud::prefix/cloudName); mkDir(fvPath/cloud::prefix/cloudName);
@ -1172,9 +1146,7 @@ int main(int argc, char *argv[])
cloud::prefix/cloudName cloud::prefix/cloudName
); );
IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (sprayObjs.found("positions"))
if (positionsPtr)
{ {
wordList labelNames(sprayObjs.names(labelIOField::typeName)); wordList labelNames(sprayObjs.names(labelIOField::typeName));
Info<< " labels :"; Info<< " labels :";
@ -1309,7 +1281,7 @@ int main(int argc, char *argv[])
+ "_" + "_"
+ procFile.name() + procFile.name()
); );
if (system(cmd.c_str()) == -1) if (Foam::system(cmd.c_str()) == -1)
{ {
WarningInFunction WarningInFunction
<< "Could not execute command " << cmd << endl; << "Could not execute command " << cmd << endl;

View File

@ -47,7 +47,8 @@ case "$ParaView_VERSION" in
if canBuildPlugin if canBuildPlugin
then then
( (
# C++ compiler for CMake # ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
wmake $targetType vtkPV3Readers wmake $targetType vtkPV3Readers

View File

@ -47,7 +47,8 @@ case "$ParaView_VERSION" in
if canBuildPlugin if canBuildPlugin
then then
( (
# C++ compiler for CMake # ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
wmake $targetType vtkPVReaders wmake $targetType vtkPVReaders

View File

@ -8,7 +8,8 @@ targetType=libso
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
# C++ compiler for CMake # ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
set -x set -x

View File

@ -47,11 +47,14 @@ QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVFoamReaderPanel CLASS_NAME pqPVFoamReaderPanel
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources XML_GROUP sources
) )
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0) # Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN( ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0" PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -61,7 +64,7 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVFoamReader.xml GUI_RESOURCE_FILES PVFoamReader.xml
) )
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ELSE()
ADD_PARAVIEW_PLUGIN( ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0" PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -70,7 +73,7 @@ ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
GUI_SOURCES pqPVFoamReaderPanel.cxx GUI_SOURCES pqPVFoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
) )
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ENDIF()
TARGET_LINK_LIBRARIES( TARGET_LINK_LIBRARIES(
PVFoamReader_SM PVFoamReader_SM

View File

@ -1,4 +1,5 @@
<ParaViewReaders> <ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVFoamReader" <Reader name="PVFoamReader"
extensions="OpenFOAM" extensions="OpenFOAM"
file_description="OpenFOAM Reader"> file_description="OpenFOAM Reader">

View File

@ -1,18 +1,12 @@
/* Note: enable vtkPolyhedron when available */
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I../../vtkPVReaders/lnInclude \
-I../PVFoamReader \
-I$(ParaView_INCLUDE_DIR) \ -I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \ -I$(ParaView_INCLUDE_DIR)/vtkkwiml \
$(shell \ -I../../vtkPVReaders/lnInclude \
test -f $(ParaView_INCLUDE_DIR)/vtkPolyhedron.h && \ -I../PVFoamReader
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
)
LIB_LIBS = \ LIB_LIBS = \
-lmeshTools \ -lmeshTools \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -275,7 +275,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// Polyhedral cell - use VTK_POLYHEDRON // Polyhedral cell - use VTK_POLYHEDRON
const labelList& cFaces = mesh.cells()[cellI]; const labelList& cFaces = mesh.cells()[cellI];
#ifdef HAS_VTK_POLYHEDRON
vtkIdType nFaces = cFaces.size(); vtkIdType nFaces = cFaces.size();
vtkIdType nLabels = nFaces; vtkIdType nLabels = nFaces;
@ -320,33 +319,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
} }
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data()); vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data());
#else
// this is a horrible substitute
// but avoids crashes when there is no vtkPolyhedron support
// establish unique node ids used
HashSet<vtkIdType, Hash<label>> hashUniqId(2*256);
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
forAll(f, fp)
{
hashUniqId.insert(f[fp]);
}
}
// use face stream to store unique node ids:
faceStream = hashUniqId.sortedToc();
vtkmesh->InsertNextCell
(
VTK_CONVEX_POINT_SET,
vtkIdType(faceStream.size()),
faceStream.data()
);
#endif
} }
else else
{ {

View File

@ -8,7 +8,8 @@ targetType=libso
# Source the wmake functions # Source the wmake functions
. $WM_DIR/scripts/wmakeFunctions . $WM_DIR/scripts/wmakeFunctions
# C++ compiler for CMake # ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX" [ -n "$WM_CXX" ] && export CXX="$WM_CXX"
set -x set -x

View File

@ -46,13 +46,16 @@ QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVblockMeshReaderPanel CLASS_NAME pqPVblockMeshReaderPanel
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_GROUP sources XML_GROUP sources
) )
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0) # Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
ADD_PARAVIEW_PLUGIN( # so check if version < 4.4
PVblockMeshReader_SM "1.0"
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES} GUI_INTERFACES ${IFACES}
@ -60,16 +63,16 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVblockMeshReader.xml GUI_RESOURCE_FILES PVblockMeshReader.xml
) )
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ELSE()
ADD_PARAVIEW_PLUGIN( ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0" PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES} GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPVblockMeshReaderPanel.cxx GUI_SOURCES pqPVblockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
) )
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0) ENDIF()
# Build the client-side plugin # Build the client-side plugin

View File

@ -1,4 +1,5 @@
<ParaViewReaders> <ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVblockMeshReader" <Reader name="PVblockMeshReader"
extensions="blockMesh" extensions="blockMesh"
file_description="OpenFOAM blockMesh reader"> file_description="OpenFOAM blockMesh reader">

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,6 +29,8 @@ Group
Description Description
List times using timeSelector. List times using timeSelector.
To simplify parsing of the output, the normal banner information
is suppressed.
Usage Usage

View File

@ -51,13 +51,11 @@ int readNumProcs
const Time& runTime const Time& runTime
) )
{ {
const word dictName = "decomposeParDict";
fileName dictFile; fileName dictFile;
if (args.optionReadIfPresent(optionName, dictFile)) if (args.optionReadIfPresent(optionName, dictFile) && isDir(dictFile))
{ {
if (isDir(dictFile)) dictFile = dictFile / dictName;
{
dictFile = dictFile/"decomposeParDict";
}
} }
return readInt return readInt
@ -68,7 +66,7 @@ int readNumProcs
( (
IOobject IOobject
( (
"decomposeParDict", dictName,
runTime.system(), runTime.system(),
runTime, runTime,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
@ -376,7 +374,7 @@ int main(int argc, char *argv[])
if (parallelSource && !parallelTarget) if (parallelSource && !parallelTarget)
{ {
int nProcs = readNumProcs const int nProcs = readNumProcs
( (
args, args,
"sourceDecomposeParDict", "sourceDecomposeParDict",
@ -448,7 +446,7 @@ int main(int argc, char *argv[])
} }
else if (!parallelSource && parallelTarget) else if (!parallelSource && parallelTarget)
{ {
int nProcs = readNumProcs const int nProcs = readNumProcs
( (
args, args,
"targetDecomposeParDict", "targetDecomposeParDict",
@ -521,13 +519,13 @@ int main(int argc, char *argv[])
} }
else if (parallelSource && parallelTarget) else if (parallelSource && parallelTarget)
{ {
int nProcsSource = readNumProcs const int nProcsSource = readNumProcs
( (
args, args,
"sourceDecomposeParDict", "sourceDecomposeParDict",
runTimeSource runTimeSource
); );
int nProcsTarget = readNumProcs const int nProcsTarget = readNumProcs
( (
args, args,
"targetDecomposeParDict", "targetDecomposeParDict",

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -191,9 +191,15 @@ void writeRays
str << "l " << vertI-1 << ' ' << vertI << nl; str << "l " << vertI-1 << ' ' << vertI << nl;
} }
} }
string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk"); str.flush();
Pout<< "cmd:" << cmd << endl;
system(cmd); DynamicList<string> cmd(3);
cmd.append("objToVTK");
cmd.append(fName);
cmd.append(fName.lessExt() + ".vtk");
Pout<< "cmd: objToVTK " << fName.c_str() << endl;
Foam::system(cmd);
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,6 +30,26 @@ Group
Description Description
Checks geometric and topological quality of a surface. Checks geometric and topological quality of a surface.
Usage
- surfaceCheck surfaceFile [OPTION]
\param -checkSelfIntersection \n
Check for self-intersection.
\param -splitNonManifold \n
Split surface along non-manifold edges.
\param -verbose \n
Extra verbosity.
\param -blockMesh \n
Write vertices/blocks for tight-fitting 1 cell blockMeshDict.
\param -outputThreshold \<num files\> \n
Specifies upper limit for the number of files written. This is useful to
prevent surfaces with lots of disconnected parts to write lots of files.
Default is 10. A special case is 0 which prevents writing any files.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "triangle.H" #include "triangle.H"
@ -265,6 +285,63 @@ void writeParts
} }
void syncEdges(const triSurface& p, labelHashSet& markedEdges)
{
// See comment below about having duplicate edges
const edgeList& edges = p.edges();
HashSet<edge, Hash<edge>> edgeSet(2*markedEdges.size());
forAllConstIter(labelHashSet, markedEdges, iter)
{
edgeSet.insert(edges[iter.key()]);
}
forAll(edges, edgeI)
{
if (edgeSet.found(edges[edgeI]))
{
markedEdges.insert(edgeI);
}
}
}
void syncEdges(const triSurface& p, boolList& isMarkedEdge)
{
// See comment below about having duplicate edges
const edgeList& edges = p.edges();
label n = 0;
forAll(isMarkedEdge, edgeI)
{
if (isMarkedEdge[edgeI])
{
n++;
}
}
HashSet<edge, Hash<edge>> edgeSet(2*n);
forAll(isMarkedEdge, edgeI)
{
if (isMarkedEdge[edgeI])
{
edgeSet.insert(edges[edgeI]);
}
}
forAll(edges, edgeI)
{
if (edgeSet.found(edges[edgeI]))
{
isMarkedEdge[edgeI] = true;
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -299,6 +376,8 @@ int main(int argc, char *argv[])
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection"); const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
const bool verbose = args.optionFound("verbose"); const bool verbose = args.optionFound("verbose");
const bool splitNonManifold = args.optionFound("splitNonManifold"); const bool splitNonManifold = args.optionFound("splitNonManifold");
label outputThreshold = 10;
args.optionReadIfPresent("outputThreshold", outputThreshold);
Info<< "Reading surface from " << surfFileName << " ..." << nl << endl; Info<< "Reading surface from " << surfFileName << " ..." << nl << endl;
@ -408,10 +487,14 @@ int main(int argc, char *argv[])
Info<< "Surface has " << illegalFaces.size() Info<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl; << " illegal triangles." << endl;
OFstream str("illegalFaces"); if (outputThreshold > 0)
Info<< "Dumping conflicting face labels to " << str.name() << endl {
<< "Paste this into the input for surfaceSubset" << endl; OFstream str("illegalFaces");
str << illegalFaces; Info<< "Dumping conflicting face labels to " << str.name()
<< endl
<< "Paste this into the input for surfaceSubset" << endl;
str << illegalFaces;
}
} }
else else
{ {
@ -486,6 +569,7 @@ int main(int argc, char *argv[])
} }
// Dump for subsetting // Dump for subsetting
if (outputThreshold > 0)
{ {
DynamicList<label> problemFaces(surf.size()/100+1); DynamicList<label> problemFaces(surf.size()/100+1);
@ -666,12 +750,15 @@ int main(int argc, char *argv[])
Info<< "Conflicting face labels:" << problemFaces.size() << endl; Info<< "Conflicting face labels:" << problemFaces.size() << endl;
OFstream str("problemFaces"); if (outputThreshold > 0)
{
OFstream str("problemFaces");
Info<< "Dumping conflicting face labels to " << str.name() << endl Info<< "Dumping conflicting face labels to " << str.name() << endl
<< "Paste this into the input for surfaceSubset" << endl; << "Paste this into the input for surfaceSubset" << endl;
str << problemFaces; str << problemFaces;
}
} }
else else
{ {
@ -695,6 +782,7 @@ int main(int argc, char *argv[])
borderEdge[edgeI] = true; borderEdge[edgeI] = true;
} }
} }
syncEdges(surf, borderEdge);
} }
labelList faceZone; labelList faceZone;
@ -702,7 +790,7 @@ int main(int argc, char *argv[])
Info<< "Number of unconnected parts : " << numZones << endl; Info<< "Number of unconnected parts : " << numZones << endl;
if (numZones > 1) if (numZones > 1 && outputThreshold > 0)
{ {
Info<< "Splitting surface into parts ..." << endl << endl; Info<< "Splitting surface into parts ..." << endl << endl;
@ -710,7 +798,7 @@ int main(int argc, char *argv[])
writeParts writeParts
( (
surf, surf,
numZones, min(outputThreshold, numZones),
faceZone, faceZone,
surfFilePath, surfFilePath,
surfFileNameBase surfFileNameBase
@ -726,6 +814,17 @@ int main(int argc, char *argv[])
labelHashSet borderEdge(surf.size()/1000); labelHashSet borderEdge(surf.size()/1000);
PatchTools::checkOrientation(surf, false, &borderEdge); PatchTools::checkOrientation(surf, false, &borderEdge);
// Bit strange: if a triangle has two same vertices (illegal!) it will
// still have three distinct edges (two of which have the same vertices).
// In this case the faceEdges addressing is not symmetric, i.e. a
// neighbouring, valid, triangle will have correct addressing so 3 distinct
// edges so it will miss one of those two identical edges.
// - we don't want to fix this in PrimitivePatch since it is too specific
// - instead just make sure we mark all identical edges consistently
// when we use them for marking.
syncEdges(surf, borderEdge);
// //
// Colour all faces into zones using borderEdge // Colour all faces into zones using borderEdge
// //
@ -739,15 +838,26 @@ int main(int argc, char *argv[])
if (numNormalZones > 1) if (numNormalZones > 1)
{ {
Info<< "More than one normal orientation." << endl; Info<< "More than one normal orientation." << endl;
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
writeParts if (outputThreshold > 0)
( {
surf, writeZoning
numNormalZones, (
normalZone, surf,
surfFilePath, normalZone,
surfFileNameBase + "_normal" "normal",
); surfFilePath,
surfFileNameBase
);
writeParts
(
surf,
min(outputThreshold, numNormalZones),
normalZone,
surfFilePath,
surfFileNameBase + "_normal"
);
}
} }
Info<< endl; Info<< endl;
@ -764,7 +874,11 @@ int main(int argc, char *argv[])
const indexedOctree<treeDataTriSurface>& tree = querySurf.tree(); const indexedOctree<treeDataTriSurface>& tree = querySurf.tree();
OBJstream intStream("selfInterPoints.obj"); autoPtr<OBJstream> intStreamPtr;
if (outputThreshold > 0)
{
intStreamPtr.reset(new OBJstream("selfInterPoints.obj"));
}
label nInt = 0; label nInt = 0;
@ -786,9 +900,9 @@ int main(int argc, char *argv[])
) )
); );
if (hitInfo.hit()) if (hitInfo.hit() && intStreamPtr.valid())
{ {
intStream.write(hitInfo.hitPoint()); intStreamPtr().write(hitInfo.hitPoint());
nInt++; nInt++;
} }
} }
@ -801,36 +915,13 @@ int main(int argc, char *argv[])
{ {
Info<< "Surface is self-intersecting at " << nInt Info<< "Surface is self-intersecting at " << nInt
<< " locations." << endl; << " locations." << endl;
Info<< "Writing intersection points to " << intStream.name()
<< endl;
}
//surfaceIntersection inter(querySurf); if (intStreamPtr.valid())
// {
//if (inter.cutEdges().empty() && inter.cutPoints().empty()) Info<< "Writing intersection points to "
//{ << intStreamPtr().name() << endl;
// Info<< "Surface is not self-intersecting" << endl; }
//} }
//else
//{
// Info<< "Surface is self-intersecting" << endl;
// Info<< "Writing edges of intersection to selfInter.obj" << endl;
//
// OFstream intStream("selfInter.obj");
// forAll(inter.cutPoints(), cutPointI)
// {
// const point& pt = inter.cutPoints()[cutPointI];
//
// intStream << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z()
// << endl;
// }
// forAll(inter.cutEdges(), cutEdgeI)
// {
// const edge& e = inter.cutEdges()[cutEdgeI];
//
// intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
// }
//}
Info<< endl; Info<< endl;
} }

View File

@ -156,14 +156,10 @@ int main(int argc, char *argv[])
// Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary // Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary
// is in constant // is in constant
fileName dictPath = ""; fileName dictPath;
if (args.optionFound("dict")) if (args.optionReadIfPresent("dict", dictPath) && isDir(dictPath))
{ {
dictPath = args["dict"]; dictPath = dictPath / dictName;
if (isDir(dictPath))
{
dictPath = dictPath / dictName;
}
} }
if (dictPath.size()) if (dictPath.size())

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -66,6 +66,9 @@ Note
#include "MeshedSurfaces.H" #include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H" #include "UnsortedMeshedSurfaces.H"
#include "IStringStream.H"
#include "OStringStream.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -84,11 +87,37 @@ int main(int argc, char *argv[])
argList::validArgs.append("outputFile"); argList::validArgs.append("outputFile");
argList::addBoolOption("clean"); argList::addBoolOption("clean");
argList::addBoolOption("orient"); argList::addBoolOption
argList::addBoolOption("surfMesh"); (
argList::addBoolOption("triSurface"); "orient",
argList::addBoolOption("unsorted"); "check surface orientation"
argList::addBoolOption("triFace"); );
argList::addBoolOption
(
"surfMesh",
"test surfMesh output"
);
argList::addBoolOption
(
"triSurface",
"use triSurface for read/write"
);
argList::addBoolOption
(
"unsorted",
"use UnsortedMeshedSurface instead of MeshedSurface, "
"or unsorted output (with -triSurface option)"
);
argList::addBoolOption
(
"triFace",
"use triFace instead of face"
);
argList::addBoolOption
(
"stdout",
"ignore output filename and write to stdout"
);
argList::addOption argList::addOption
( (
@ -99,10 +128,11 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const bool optStdout = args.optionFound("stdout");
const scalar scaleFactor = args.optionLookupOrDefault("scale", 0.0); const scalar scaleFactor = args.optionLookupOrDefault("scale", 0.0);
const fileName importName = args[1]; const fileName importName = args[1];
const fileName exportName = args[2]; const fileName exportName = optStdout ? "-stdout" : args[2];
if (importName == exportName) if (importName == exportName)
{ {
@ -114,7 +144,11 @@ int main(int argc, char *argv[])
if if
( (
!MeshedSurface<face>::canRead(importName, true) !MeshedSurface<face>::canRead(importName, true)
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true) ||
(
!optStdout
&& !MeshedSurface<face>::canWriteType(exportName.ext(), true)
)
) )
{ {
return 1; return 1;
@ -128,6 +162,23 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
// check: output to ostream, construct from istream
{
OStringStream os;
os << surf;
IStringStream is(os.str());
// both work:
triSurface surf2(is);
// OR
// is.rewind();
// triSurface surf2;
// is >> surf2;
// surf2.read(is); // FAIL: private method
}
if (args.optionFound("orient")) if (args.optionFound("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
@ -156,8 +207,15 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
// write sorted by region if (optStdout)
surf.write(exportName, true); {
Info<< surf;
}
else
{
// normally write sorted (looks nicer)
surf.write(exportName, !args.optionFound("unsorted"));
}
} }
else if (args.optionFound("unsorted")) else if (args.optionFound("unsorted"))
{ {
@ -167,6 +225,23 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
// check: output to ostream, construct from istream
{
OStringStream os;
os << surf;
IStringStream is(os.str());
// both work:
UnsortedMeshedSurface<face> surf2(is);
// OR
// is.rewind();
// UnsortedMeshedSurface<face> surf2;
// is >> surf2;
// surf2.read(is); // FAIL: private method
}
if (args.optionFound("orient")) if (args.optionFound("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
@ -194,9 +269,16 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
} }
surf.write(exportName);
if (optStdout)
{
Info<< surf;
}
else
{
surf.write(exportName);
}
} }
#if 1
else if (args.optionFound("triFace")) else if (args.optionFound("triFace"))
{ {
MeshedSurface<triFace> surf(importName); MeshedSurface<triFace> surf(importName);
@ -205,6 +287,23 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
// check: output to ostream, construct from istream
{
OStringStream os;
os << surf;
IStringStream is(os.str());
// both work:
MeshedSurface<face> surf2(is);
// OR
// is.rewind();
// MeshedSurface<face> surf2;
// is >> surf2;
// surf2.read(is); // FAIL: private method
}
if (args.optionFound("orient")) if (args.optionFound("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
@ -232,9 +331,16 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
} }
surf.write(exportName);
if (optStdout)
{
Info<< surf;
}
else
{
surf.write(exportName);
}
} }
#endif
else else
{ {
MeshedSurface<face> surf(importName); MeshedSurface<face> surf(importName);
@ -243,6 +349,23 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
// check: output to ostream, construct from istream
{
OStringStream os;
os << surf;
IStringStream is(os.str());
// both work:
MeshedSurface<face> surf2(is);
// OR
// is.rewind();
// MeshedSurface<face> surf2;
// is >> surf2;
// surf2.read(is); // FAIL: private method
}
if (args.optionFound("orient")) if (args.optionFound("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
@ -258,7 +381,6 @@ int main(int argc, char *argv[])
Info<< endl; Info<< endl;
} }
Info<< "writing " << exportName; Info<< "writing " << exportName;
if (scaleFactor <= 0) if (scaleFactor <= 0)
{ {
@ -271,7 +393,15 @@ int main(int argc, char *argv[])
surf.writeStats(Info); surf.writeStats(Info);
Info<< endl; Info<< endl;
} }
surf.write(exportName);
if (optStdout)
{
Info<< surf;
}
else
{
surf.write(exportName);
}
if (args.optionFound("surfMesh")) if (args.optionFound("surfMesh"))
{ {
@ -287,7 +417,6 @@ int main(int argc, char *argv[])
Info<< "runTime.instance() = " << runTime.instance() << endl; Info<< "runTime.instance() = " << runTime.instance() << endl;
Info<< "runTime.timeName() = " << runTime.timeName() << endl; Info<< "runTime.timeName() = " << runTime.timeName() << endl;
Info<< "write MeshedSurface 'yetAnother' via proxy as surfMesh" Info<< "write MeshedSurface 'yetAnother' via proxy as surfMesh"
<< endl; << endl;
surf.write surf.write
@ -312,14 +441,11 @@ int main(int argc, char *argv[])
MeshedSurface<face> surfIn2(runTime, "foobar"); MeshedSurface<face> surfIn2(runTime, "foobar");
Info<<"surfIn2 = " << surfIn2.size() << endl; Info<<"surfIn2 = " << surfIn2.size() << endl;
Info<< "surfIn = " << surfIn.size() << endl; Info<< "surfIn = " << surfIn.size() << endl;
Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl; Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl;
surfIn.write("oldSurfIn.obj"); surfIn.write("oldSurfIn.obj");
Info<< "runTime.instance() = " << runTime.instance() << endl; Info<< "runTime.instance() = " << runTime.instance() << endl;
surfMesh surfOut surfMesh surfOut

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,6 +29,8 @@ Group
Description Description
Miscellaneous information about surface meshes. Miscellaneous information about surface meshes.
To simplify parsing of the output, the normal banner information
is suppressed.
Usage Usage
- surfaceMeshInfo surfaceFile [OPTION] - surfaceMeshInfo surfaceFile [OPTION]

View File

@ -1,9 +1,12 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/distributed/lnInclude -I$(LIB_SRC)/parallel/distributed/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-ldistributed \ -ldistributed \
-lmeshTools \ -lmeshTools \
-ltriSurface -ltriSurface \
-ldecompose

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,6 +46,7 @@ Note
#include "distributedTriSurfaceMesh.H" #include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H" #include "mapDistribute.H"
#include "localIOdictionary.H" #include "localIOdictionary.H"
#include "decompositionModel.H"
using namespace Foam; using namespace Foam;
@ -103,7 +104,8 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"redistribute a triSurface" "Redistribute a triSurface. "
"The specified surface must be located in the constant/triSurface directory"
); );
argList::validArgs.append("triSurfaceMesh"); argList::validArgs.append("triSurfaceMesh");
@ -127,7 +129,7 @@ int main(int argc, char *argv[])
<< "Using distribution method " << "Using distribution method "
<< distTypeName << nl << endl; << distTypeName << nl << endl;
const bool keepNonMapped = args.options().found("keepNonMapped"); const bool keepNonMapped = args.optionFound("keepNonMapped");
if (keepNonMapped) if (keepNonMapped)
{ {
@ -151,6 +153,37 @@ int main(int argc, char *argv[])
Random rndGen(653213); Random rndGen(653213);
// For independent decomposition, ensure that distributedTriSurfaceMesh
// can find the alternative decomposeParDict specified via the
// -decomposeParDict option.
if (distType == distributedTriSurfaceMesh::INDEPENDENT)
{
fileName decompDictFile;
args.optionReadIfPresent("decomposeParDict", decompDictFile);
IOdictionary* dict = new IOdictionary
(
decompositionModel::selectIO
(
IOobject
(
"decomposeParDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
),
decompDictFile
)
);
// The object must have the expected "decomposeParDict" name.
// This also implies that it cannot be changed during the run.
dict->rename("decomposeParDict");
runTime.store(dict);
}
// Determine mesh bounding boxes: // Determine mesh bounding boxes:
List<List<treeBoundBox>> meshBb(Pstream::nProcs()); List<List<treeBoundBox>> meshBb(Pstream::nProcs());
if (distType == distributedTriSurfaceMesh::FOLLOW) if (distType == distributedTriSurfaceMesh::FOLLOW)

View File

@ -1,61 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# engridFoam
#
# Description
# start engrid using the paraview libraries from OpenFOAM
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION]
options:
-help
* start engrid using the paraview-$ParaView_MAJOR libraries
passes through engrid options unmodified
USAGE
exit 1
}
# report usage
[ "$1" = "-h" -o "$1" = "-help" ] && usage
bindir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/engrid
libdir="$ParaView_DIR/lib/paraview-${ParaView_MAJOR:-unknown}"
[ -x $bindir/engrid ] || usage "engrid executable not found in $bindir"
[ -d $libdir ] || usage "paraview libraries not found"
export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
echo "starting $bindir/engrid $@"
eval "exec $bindir/engrid $@ &"
#------------------------------------------------------------------------------

View File

@ -99,7 +99,7 @@ IFS=': '
# or may contain ':' separators # or may contain ':' separators
set -- $* set -- $*
# strip out wildcards via sed # Strip out wildcards via sed. Path and wildcard cannot contain '?'.
while [ "$#" -ge 1 ] while [ "$#" -ge 1 ]
do do
wildcard=$1 wildcard=$1
@ -107,7 +107,7 @@ do
##DEBUG echo "remove>$wildcard<" 1>&2 ##DEBUG echo "remove>$wildcard<" 1>&2
if [ -n "$wildcard" ] if [ -n "$wildcard" ]
then then
dirList=$(echo "$dirList:" | sed -e "s@${wildcard}[^:]*:@@g") dirList=$(echo "$dirList:" | sed -e "s?${wildcard}[^:]*:??g")
fi fi
done done

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
@ -40,17 +40,18 @@ usage() {
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION] Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
options: options:
-block use blockMesh reader (uses .blockMesh extension) -block use blockMesh reader (uses .blockMesh extension)
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-case <dir> specify alternative case directory, default is the cwd -case <dir> specify alternative case directory, default is the cwd
-region <name> specify alternative mesh region -region <name> specify alternative mesh region
-touch only create the file (eg, .blockMesh, .OpenFOAM, etc) -touch only create the file (eg, .blockMesh, .OpenFOAM, etc)
-touchAll create .blockMesh, .OpenFOAM files (and for all regions) -touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-help print the usage -help print the usage
Paraview options start with a double dashes.
paraview options start with a double dashes * start paraview with the OpenFOAM libraries
* start paraview $ParaView_VERSION with the OpenFOAM libraries paraview=$(command -v paraview)
USAGE USAGE
exit 1 exit 1
@ -67,10 +68,9 @@ unset regionName optTouch
# already 2010-07) # already 2010-07)
export LC_ALL=C export LC_ALL=C
# Reader extension # Reader extension and plugin
extension=OpenFOAM extension=OpenFOAM
plugin=PVFoamReader
requirePV=1
# Parse options # Parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
@ -81,11 +81,12 @@ do
;; ;;
-block | -blockMesh) -block | -blockMesh)
extension=blockMesh extension=blockMesh
plugin=PVblockMeshReader
shift shift
;; ;;
-builtin) -builtin | -vtk)
extension=foam extension=foam
requirePV=0 unset plugin
shift shift
;; ;;
-case) -case)
@ -100,12 +101,12 @@ do
;; ;;
-touch) -touch)
optTouch=true optTouch=true
requirePV=0 unset plugin
shift shift
;; ;;
-touchAll) -touchAll)
optTouch=all optTouch=all
requirePV=0 unset plugin
shift shift
;; ;;
--) --)
@ -116,26 +117,34 @@ do
break # Stop here, treat this and balance as paraview options break # Stop here, treat this and balance as paraview options
;; ;;
*) *)
usage "unknown option/argument: '$*'" usage "unknown option/argument: '$1'"
;; ;;
esac esac
done done
# Check that reader module has been built # If a reader module is needed, check that it exists
if [ $requirePV -eq 1 -a ! -f $PV_PLUGIN_PATH/libPVFoamReader_SM.so ] [ -z "$plugin" -o -f $PV_PLUGIN_PATH/lib${plugin}_SM.so ] || {
then cat<< BUILDREADER 1>&2
cat<< BUILDREADER
FATAL ERROR: ParaView reader module libraries do not exist
ERROR: ParaView reader module library ($plugin) does not exist
Please build the reader module before continuing: Please build the reader module before continuing:
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwclean cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwmake ./Allwclean
./Allwmake
BUILDREADER BUILDREADER
exit 1
fi # Fallback to native reader, if possible
if [ "$extension" = OpenFOAM ]
then
extension=foam
echo "Using the native VTK/OpenFOAM reader instead" 1>&2
else
exit 1
fi
}
# Check for --data=... argument # Check for --data=... argument
hasDataArg() hasDataArg()
@ -165,7 +174,7 @@ if [ -n "$regionName" ]
then then
if [ ! -d constant/$regionName ] if [ ! -d constant/$regionName ]
then then
echo "FATAL ERROR: Region $regionName does not exist" echo "FATAL ERROR: Region $regionName does not exist" 1>&2
exit 1 exit 1
else else
caseFile="$caseName{$regionName}.$extension" caseFile="$caseName{$regionName}.$extension"
@ -179,10 +188,10 @@ all)
if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ] if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ]
then then
touch "$caseName.blockMesh" touch "$caseName.blockMesh"
echo "Created '$caseName.blockMesh'" echo "Created '$caseName.blockMesh'" 1>&2
fi fi
touch "$caseName.$extension" touch "$caseName.$extension"
echo "Created '$caseName.$extension'" echo "Created '$caseName.$extension'" 1>&2
# Discover probable regions # Discover probable regions
for region in constant/* for region in constant/*
do do
@ -190,14 +199,14 @@ all)
then then
regionName=${region##*/} regionName=${region##*/}
touch "$caseName{$regionName}.$extension" touch "$caseName{$regionName}.$extension"
echo "Created '$caseName{$regionName}.$extension'" echo "Created '$caseName{$regionName}.$extension'" 1>&2
fi fi
done done
exit 0 exit 0
;; ;;
true) true)
touch "$caseFile" touch "$caseFile"
echo "Created '$caseFile'" echo "Created '$caseFile'" 1>&2
exit 0 exit 0
;; ;;
esac esac
@ -222,14 +231,14 @@ else
warn="WARN file does not exist:" warn="WARN file does not exist:"
case $extension in case $extension in
blockMesh) blockMesh)
blockMeshDictDir=system/blockMeshDict blockMeshDict=system/blockMeshDict
if [ -f constant/polyMesh/blockMeshDict ] if [ -f constant/polyMesh/blockMeshDict ]
then then
blockMeshDictDir=constant/polyMesh/blockMeshDict blockMeshDict=constant/polyMesh/blockMeshDict
fi fi
for check in \ for check in \
system/controlDict \ system/controlDict \
$blockMeshDictDir \ $blockMeshDict \
; ;
do do
[ -s "$parentDir/$check" ] || { [ -s "$parentDir/$check" ] || {
@ -240,7 +249,7 @@ else
done done
;; ;;
builtin | OpenFOAM) OpenFOAM)
for check in \ for check in \
system/controlDict \ system/controlDict \
$fvControls/fvSchemes \ $fvControls/fvSchemes \
@ -268,7 +277,7 @@ else
[ -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'" 1>&2
} }
# For now filter out any ld.so errors. Caused by non-system compiler? # For now filter out any ld.so errors. Caused by non-system compiler?

View File

@ -54,7 +54,6 @@ getApplication()
runApplication() runApplication()
{ {
LOG_NAME=
APP_RUN= APP_RUN=
LOG_IGNORE=false LOG_IGNORE=false
LOG_APPEND=false LOG_APPEND=false
@ -100,18 +99,18 @@ runApplication()
runParallel() runParallel()
{ {
LOG_NAME=
APP_RUN= APP_RUN=
# Store any parsed additional arguments e.g. decomposeParDict
APP_PARARGS=
LOG_IGNORE=false LOG_IGNORE=false
LOG_APPEND=false LOG_APPEND=false
LOG_SUFFIX= LOG_SUFFIX=
# Store any parsed additional arguments e.g. decomposeParDict
APP_PARARGS=
# Check the default decomposeParDict if available # Check the default decomposeParDict if available
nProcs=$(getNumberOfProcessors "system/decomposeParDict") nProcs=$(getNumberOfProcessors system/decomposeParDict)
# Parse options and executable # Parse options and executable
while [ $# -gt 0 ] && [ -z "$APP_RUN" ] ; do while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
key="$1" key="$1"
case "$key" in case "$key" in
-append|-a) -append|-a)
@ -144,7 +143,7 @@ runParallel()
shift shift
done done
if [ -f log.$SUFFIX ] && [ "$LOG_IGNORE" = "false" ] if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
then then
echo "$APP_NAME already run on $PWD:" \ echo "$APP_NAME already run on $PWD:" \
"remove log file 'log.$LOG_SUFFIX' to re-run" "remove log file 'log.$LOG_SUFFIX' to re-run"

View File

@ -39,15 +39,15 @@
if [ "$#" -gt 0 ] if [ "$#" -gt 0 ]
then then
realFilePath=$(echo $1 | sed -e s@^$WM_PROJECT_DIR@../../..@ ) realFilePath=$(echo "$1" | sed -e "s?^$WM_PROJECT_DIR?../../..?" )
if [ -n "$FOAM_ONLINE_REPO" ] if [ -n "$FOAM_ONLINE_REPO" ]
then then
filePath=$(echo $1 | sed -e s@^$WM_PROJECT_DIR@$FOAM_ONLINE_REPO@ ) filePath=$(echo "$1" | sed -e "s?^$WM_PROJECT_DIR?$FOAM_ONLINE_REPO?" )
else else
filePath=$realFilePath filePath=$realFilePath
fi fi
# dirName=$(echo "$filePath" | sed -e 's@/[^/]*$@@' ) # dirName=$(echo "$filePath" | sed -e 's?/[^/]*$??' )
dirName=${filePath%/[^/]*} dirName=${filePath%/[^/]*}
fileName=${filePath##*/} fileName=${filePath##*/}
@ -62,7 +62,7 @@ then
# ;; # ;;
esac esac
awk -f $WM_PROJECT_DIR/bin/tools/doxyFilter-table.awk $1 | \ awk -f $WM_PROJECT_DIR/bin/tools/doxyFilter-table.awk "$1" | \
awk -f $awkScript | \ awk -f $awkScript | \
sed -f $WM_PROJECT_DIR/bin/tools/doxyFilter.sed \ sed -f $WM_PROJECT_DIR/bin/tools/doxyFilter.sed \
-e s@%realFilePath%@$realFilePath@g \ -e s@%realFilePath%@$realFilePath@g \

View File

@ -118,6 +118,8 @@ tr.memlist
.OFPlainTable tr td { .OFPlainTable tr td {
height: 20px; height: 20px;
padding-left: 5px; padding-left: 5px;
}
div.line, div.line,
span.comment, span.comment,
span.keyword, span.keyword,

View File

@ -50,7 +50,7 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
set boost_version=boost-system set boost_version=boost_1_61_0
set cgal_version=CGAL-4.8 set cgal_version=CGAL-4.8
setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version

View File

@ -48,7 +48,7 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
set fftw_version=fftw-system set fftw_version=fftw-3.3.4
setenv FFTW_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version setenv FFTW_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version

View File

@ -208,7 +208,7 @@ unsetenv GMP_ARCH_PATH MPFR_ARCH_PATH
# Location of compiler installation # Location of compiler installation
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( ! $?WM_COMPILER_TYPE ) then if ( ! $?WM_COMPILER_TYPE ) then
set WM_COMPILER_TYPE=system setenv WM_COMPILER_TYPE system
echo "Warning in $WM_PROJECT_DIR/etc/config.csh/settings:" echo "Warning in $WM_PROJECT_DIR/etc/config.csh/settings:"
echo " WM_COMPILER_TYPE not set, using '$WM_COMPILER_TYPE'" echo " WM_COMPILER_TYPE not set, using '$WM_COMPILER_TYPE'"
endif endif

View File

@ -49,7 +49,7 @@
# - the LD_LIBRARY_PATH is not adjusted. # - the LD_LIBRARY_PATH is not adjusted.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
boost_version=boost-system boost_version=boost_1_61_0
cgal_version=CGAL-4.8 cgal_version=CGAL-4.8
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version

View File

@ -47,7 +47,7 @@
# - the LD_LIBRARY_PATH is not adjusted. # - the LD_LIBRARY_PATH is not adjusted.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
fftw_version=fftw-system fftw_version=fftw-3.3.4
export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version
@ -64,7 +64,7 @@ then
# it is either located within ThirdParty, or a central installation # it is either located within ThirdParty, or a central installation
# outside of ThirdParty and must be added to the lib-path. # outside of ThirdParty and must be added to the lib-path.
ending="${FFTW_ARCH_PATH_PATH##*-}" ending="${FFTW_ARCH_PATH##*-}"
if [ "$ending" != none -a "$ending" != system ] if [ "$ending" != none -a "$ending" != system ]
then then
_foamAddLib $FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH _foamAddLib $FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH

View File

@ -22,7 +22,7 @@
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/libccmio # etc/config.sh/ccmio
# #
# Description # Description
# Setup file for libccmio include/libraries. # Setup file for libccmio include/libraries.

View File

@ -116,7 +116,7 @@ else
# Cleanup environment: # Cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~
unset WM_BASH_FUNCTIONS unset WM_BASH_FUNCTIONS
unset _foamAddPath _foamAddLib _foamAddMan unset -f _foamAddPath _foamAddLib _foamAddMan
unset _foamSource _foamEval unset -f _foamSource _foamEval
fi fi

View File

@ -48,7 +48,7 @@ wmake $targetType lagrangian/basic
wmake $targetType lagrangian/distributionModels wmake $targetType lagrangian/distributionModels
wmake $targetType genericPatchFields wmake $targetType genericPatchFields
wmake $targetType conversion conversion/Allwmake $targetType $*
wmake $targetType mesh/extrudeModel wmake $targetType mesh/extrudeModel
wmake $targetType dynamicMesh wmake $targetType dynamicMesh
wmake $targetType dynamicFvMesh wmake $targetType dynamicFvMesh
@ -58,10 +58,9 @@ wmake $targetType sampling
# Compile scotchDecomp, metisDecomp etc. # Compile scotchDecomp, metisDecomp etc.
parallel/Allwmake $targetType $* parallel/Allwmake $targetType $*
randomProcesses/Allwmake $targetType $*
wmake $targetType ODE wmake $targetType ODE
wmake $targetType randomProcesses
wmake $targetType fvMotionSolver wmake $targetType fvMotionSolver
transportModels/Allwmake $targetType $* transportModels/Allwmake $targetType $*

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,6 +38,8 @@ Description
#include "timer.H" #include "timer.H"
#include "IFstream.H" #include "IFstream.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "CStringList.H"
#include "SubList.H"
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
@ -49,6 +51,7 @@ Description
#include <pwd.h> #include <pwd.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
@ -593,9 +596,9 @@ bool Foam::chMod(const fileName& name, const mode_t m)
} }
mode_t Foam::mode(const fileName& name) mode_t Foam::mode(const fileName& name, const bool followLink)
{ {
fileStat fileStatus(name); fileStat fileStatus(name, followLink);
if (fileStatus.isValid()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_mode; return fileStatus.status().st_mode;
@ -607,14 +610,18 @@ mode_t Foam::mode(const fileName& name)
} }
Foam::fileName::Type Foam::type(const fileName& name) Foam::fileName::Type Foam::type(const fileName& name, const bool followLink)
{ {
mode_t m = mode(name); mode_t m = mode(name, followLink);
if (S_ISREG(m)) if (S_ISREG(m))
{ {
return fileName::FILE; return fileName::FILE;
} }
else if (S_ISLNK(m))
{
return fileName::LINK;
}
else if (S_ISDIR(m)) else if (S_ISDIR(m))
{ {
return fileName::DIRECTORY; return fileName::DIRECTORY;
@ -626,27 +633,39 @@ Foam::fileName::Type Foam::type(const fileName& name)
} }
bool Foam::exists(const fileName& name, const bool checkGzip) bool Foam::exists
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{ {
return mode(name) || isFile(name, checkGzip); return mode(name, followLink) || isFile(name, checkGzip, followLink);
} }
bool Foam::isDir(const fileName& name) bool Foam::isDir(const fileName& name, const bool followLink)
{ {
return S_ISDIR(mode(name)); return S_ISDIR(mode(name, followLink));
} }
bool Foam::isFile(const fileName& name, const bool checkGzip) bool Foam::isFile
(
const fileName& name,
const bool checkGzip,
const bool followLink
)
{ {
return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz"))); return
S_ISREG(mode(name, followLink))
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)));
} }
off_t Foam::fileSize(const fileName& name) off_t Foam::fileSize(const fileName& name, const bool followLink)
{ {
fileStat fileStatus(name); fileStat fileStatus(name, followLink);
if (fileStatus.isValid()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_size; return fileStatus.status().st_size;
@ -658,9 +677,9 @@ off_t Foam::fileSize(const fileName& name)
} }
time_t Foam::lastModified(const fileName& name) time_t Foam::lastModified(const fileName& name, const bool followLink)
{ {
fileStat fileStatus(name); fileStat fileStatus(name, followLink);
if (fileStatus.isValid()) if (fileStatus.isValid())
{ {
return fileStatus.status().st_mtime; return fileStatus.status().st_mtime;
@ -676,7 +695,8 @@ Foam::fileNameList Foam::readDir
( (
const fileName& directory, const fileName& directory,
const fileName::Type type, const fileName::Type type,
const bool filtergz const bool filtergz,
const bool followLink
) )
{ {
// Initial filename list size // Initial filename list size
@ -717,10 +737,10 @@ Foam::fileNameList Foam::readDir
{ {
fileName fName(list->d_name); fileName fName(list->d_name);
// ignore files begining with ., i.e. '.', '..' and '.*' // ignore files beginning with ., i.e. '.', '..' and '.*'
if (fName.size() && fName[0] != '.') if (fName.size() && fName[0] != '.')
{ {
word fExt = fName.ext(); const word fExt = fName.ext();
if if
( (
@ -736,7 +756,7 @@ Foam::fileNameList Foam::readDir
) )
) )
{ {
if ((directory/fName).type() == type) if ((directory/fName).type(followLink) == type)
{ {
if (nEntries >= dirEntries.size()) if (nEntries >= dirEntries.size())
{ {
@ -766,7 +786,7 @@ Foam::fileNameList Foam::readDir
} }
bool Foam::cp(const fileName& src, const fileName& dest) bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
{ {
// Make sure source exists. // Make sure source exists.
if (!exists(src)) if (!exists(src))
@ -777,7 +797,8 @@ bool Foam::cp(const fileName& src, const fileName& dest)
fileName destFile(dest); fileName destFile(dest);
// Check type of source file. // Check type of source file.
if (src.type() == fileName::FILE) const fileName::Type srcType = src.type(followLink);
if (srcType == fileName::FILE)
{ {
// If dest is a directory, create the destination file name. // If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY) if (destFile.type() == fileName::DIRECTORY)
@ -817,7 +838,23 @@ bool Foam::cp(const fileName& src, const fileName& dest)
return false; return false;
} }
} }
else if (src.type() == fileName::DIRECTORY) else if (srcType == fileName::LINK)
{
// If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY)
{
destFile = destFile/src.name();
}
// Make sure the destination directory exists.
if (!isDir(destFile.path()) && !mkDir(destFile.path()))
{
return false;
}
ln(src, destFile);
}
else if (srcType == fileName::DIRECTORY)
{ {
// If dest is a directory, create the destination file name. // If dest is a directory, create the destination file name.
if (destFile.type() == fileName::DIRECTORY) if (destFile.type() == fileName::DIRECTORY)
@ -832,7 +869,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// Copy files // Copy files
fileNameList contents = readDir(src, fileName::FILE, false); fileNameList contents = readDir(src, fileName::FILE, false, followLink);
forAll(contents, i) forAll(contents, i)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -843,11 +880,17 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// File to file. // File to file.
cp(src/contents[i], destFile/contents[i]); cp(src/contents[i], destFile/contents[i], followLink);
} }
// Copy sub directories. // Copy sub directories.
fileNameList subdirs = readDir(src, fileName::DIRECTORY); fileNameList subdirs = readDir
(
src,
fileName::DIRECTORY,
false,
followLink
);
forAll(subdirs, i) forAll(subdirs, i)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -858,9 +901,13 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// Dir to Dir. // Dir to Dir.
cp(src/subdirs[i], destFile); cp(src/subdirs[i], destFile, followLink);
} }
} }
else
{
return false;
}
return true; return true;
} }
@ -903,7 +950,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
} }
bool Foam::mv(const fileName& src, const fileName& dst) bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
{ {
if (POSIX::debug) if (POSIX::debug)
{ {
@ -914,7 +961,7 @@ bool Foam::mv(const fileName& src, const fileName& dst)
if if
( (
dst.type() == fileName::DIRECTORY dst.type() == fileName::DIRECTORY
&& src.type() != fileName::DIRECTORY && src.type(followLink) != fileName::DIRECTORY
) )
{ {
const fileName dstName(dst/src.name()); const fileName dstName(dst/src.name());
@ -1016,7 +1063,7 @@ bool Foam::rmDir(const fileName& directory)
{ {
fileName path = directory/fName; fileName path = directory/fName;
if (path.type() == fileName::DIRECTORY) if (path.type(false) == fileName::DIRECTORY)
{ {
if (!rmDir(path)) if (!rmDir(path))
{ {
@ -1166,9 +1213,153 @@ bool Foam::ping(const string& hostname, const label timeOut)
} }
namespace Foam
{
//! \cond fileScope
static int waitpid(const pid_t pid)
{
// child status, return code from the exec etc.
int status = 0;
// in parent - blocking wait
// modest treatment of signals (in child)
// treat 'stopped' like exit (suspend/continue)
while (true)
{
pid_t wpid = ::waitpid(pid, &status, WUNTRACED);
if (wpid == -1)
{
FatalErrorInFunction
<< "some error occurred in child"
<< exit(FatalError);
break;
}
if (WIFEXITED(status))
{
// child exited, get its return status
return WEXITSTATUS(status);
}
if (WIFSIGNALED(status))
{
// child terminated by some signal
return WTERMSIG(status);
}
if (WIFSTOPPED(status))
{
// child stopped by some signal
return WSTOPSIG(status);
}
FatalErrorInFunction
<< "programming error, status from waitpid() not handled: "
<< status
<< exit(FatalError);
}
return -1; // should not happen
}
//! \endcond
}
int Foam::system(const std::string& command) int Foam::system(const std::string& command)
{ {
return ::system(command.c_str()); if (command.empty())
{
// Treat an empty command as a successful no-op.
// From 'man sh' POSIX (man sh):
// "If the command_string operand is an empty string,
// sh shall exit with a zero exit status."
return 0;
}
pid_t child_pid = ::vfork(); // NB: vfork, not fork!
if (child_pid == -1)
{
FatalErrorInFunction
<< "vfork() failed for system command " << command
<< exit(FatalError);
}
if (child_pid == 0)
{
// in child
// execl uses the current environ
(void) ::execl
(
"/bin/sh", // Path of the shell
"sh", // Command-name (name for the shell)
"-c", // Read commands from the command_string operand.
command.c_str(), // Command string
reinterpret_cast<char *>(0)
);
// obviously failed, since exec should not return at all
FatalErrorInFunction
<< "exec failed: " << command
<< exit(FatalError);
}
// in parent - blocking wait
return waitpid(child_pid);
}
int Foam::system(const Foam::UList<Foam::string>& command)
{
const int argc = command.size();
if (!argc)
{
// Treat an empty command as a successful no-op.
// For consistency with POSIX (man sh) behaviour for (sh -c command),
// which is what is mostly being replicated here.
return 0;
}
// NB: use vfork, not fork!
// vfork behaves more like a thread and avoids copy-on-write problems
// triggered by fork.
// The normal system() command has a fork buried in it that causes
// issues with infiniband and openmpi etc.
pid_t child_pid = ::vfork();
if (child_pid == -1)
{
FatalErrorInFunction
<< "vfork() failed for system command " << command[0]
<< exit(FatalError);
}
if (child_pid == 0)
{
// in child:
// Need command and arguments separately.
// args is a NULL-terminated list of c-strings
CStringList args(SubList<string>(command, 0));
if (argc > 1)
{
args.reset(SubList<string>(command, argc-1, 1));
}
// execvp uses the current environ
(void) ::execvp(command[0].c_str(), args.strings());
// obviously failed, since exec should not return at all
FatalErrorInFunction
<< "exec(" << command[0] << ", ...) failed"
<< exit(FatalError);
}
// in parent - blocking wait
return waitpid(child_pid);
} }

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