diff --git a/applications/utilities/miscellaneous/foamRestoreFields/foamRestoreFields.C b/applications/utilities/miscellaneous/foamRestoreFields/foamRestoreFields.C index a8205f625b..9a7b3927c2 100644 --- a/applications/utilities/miscellaneous/foamRestoreFields/foamRestoreFields.C +++ b/applications/utilities/miscellaneous/foamRestoreFields/foamRestoreFields.C @@ -144,13 +144,9 @@ label restoreFields } } - if (dryrun) + if (verbose) { - Info<< "dry-run: " << dirName << nl; - } - else if (verbose) - { - Info<< "directory " << dirName << nl; + Info<< "directory " << dirName.name() << nl; } // Count of files moved, including backups @@ -296,7 +292,7 @@ int main(int argc, char *argv[]) // command-line options label nProcs = 0; - instantList times; + wordList timeDirs; if (args.found("processor") && !Pstream::parRun()) { @@ -310,41 +306,47 @@ int main(int argc, char *argv[]) << exit(FatalError); } - // Obtain times from "processor0/" only - times = timeSelector::select + // Obtain time directory names from "processor0/" only + + timeDirs = ListOps::create ( - Time + timeSelector::select ( - Time::controlDictName, - args.rootPath(), - args.caseName()/"processor0" - ).times(), - args + Time + ( + Time::controlDictName, + args.rootPath(), + args.caseName()/"processor0" + ).times(), + args + ), + [](const instant& t){ return t.name(); } ); } else { - if (Pstream::master()) - { - times = timeSelector::select + timeDirs = ListOps::create + ( + timeSelector::select ( Time(Time::controlDictName, args).times(), args - ); - } + ), + [](const instant& t){ return t.name(); } + ); - Pstream::scatter(times); + Pstream::scatter(timeDirs); } - if (times.empty()) + if (timeDirs.empty()) { Info<< "no times selected" << nl; } - for (const instant& inst : times) + for (const word& dirName : timeDirs) { - Info<< "\nTime = " << inst.name() << nl; + Info<< "\nTime = " << dirName << nl; label count = 0; @@ -352,7 +354,7 @@ int main(int argc, char *argv[]) { const wordHashSet files ( - getFiles(args.path()/"processor0", inst.name()) + getFiles(args.path()/"processor0", dirName) ); for (label proci=0; proci < nProcs; ++proci) @@ -360,7 +362,7 @@ int main(int argc, char *argv[]) count += restoreFields ( method, - args.path()/("processor" + Foam::name(proci))/inst.name(), + args.path()/("processor" + Foam::name(proci))/dirName, files, targetNames ); @@ -371,14 +373,14 @@ int main(int argc, char *argv[]) wordList files; if (Pstream::master()) { - files = getFiles(args.path(), inst.name()); + files = getFiles(args.path(), dirName); } Pstream::scatter(files); count += restoreFields ( method, - args.path()/inst.name(), + args.path()/dirName, wordHashSet(files), targetNames ); diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 6c0842006e..948f2ce349 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -94,7 +94,7 @@ getNumberOfProcessors() getApplication() { # Re-use positional parameters for automatic whitespace elimination - set -- $(foamDictionary -disableFunctionEntries -entry application -value system/controlDict) + set -- $(foamDictionary -disableFunctionEntries -entry application -value system/controlDict 2>/dev/null) if [ "$#" -eq 1 ] then diff --git a/etc/bashrc b/etc/bashrc index 50df795c08..658883d95c 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -158,6 +158,7 @@ _foamEtc -config vtk _foamEtc -config ensight _foamEtc -config gperftools ## _foamEtc -config ADIOS +## _foamEtc -config ADIOS2 _foamEtc -config CGAL _foamEtc -config scotch _foamEtc -config FFTW diff --git a/etc/config.csh/ADIOS2 b/etc/config.csh/ADIOS2 index b375cd8ea4..917999f51d 100644 --- a/etc/config.csh/ADIOS2 +++ b/etc/config.csh/ADIOS2 @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -28,16 +28,12 @@ if ($?FOAM_VERBOSE && $?prompt) then echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" endif -# If *_ARCH_PATH does not end with '-system' or '-none', -# it is located within ThirdParty, or a central installation -# outside of ThirdParty and should be added to the path. - -set ending="${ADIOS2_ARCH_PATH:t}" -if ( "$ending" != "adios-none" && "$ending" != "adios-system" ) then - # PATH was already cleaned by etc/cshrc caller +# - only add if the directory really exists +_foamAddLibAuto $ADIOS2_ARCH_PATH +if ($status == 0) then _foamAddPath $ADIOS2_ARCH_PATH/bin endif -unset adios_version ending +unset adios2_version #------------------------------------------------------------------------------ diff --git a/etc/config.sh/ADIOS2 b/etc/config.sh/ADIOS2 index 8fe60b0a11..b77593e9a5 100644 --- a/etc/config.sh/ADIOS2 +++ b/etc/config.sh/ADIOS2 @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -16,6 +16,7 @@ # Description # Setup for ADIOS2 include/libraries (usually ThirdParty installation). # +# Use with -force when sourcing directly from the command-line #------------------------------------------------------------------------------ # USER EDITABLE PART: Changes made here may be lost with the next upgrade @@ -29,21 +30,30 @@ then echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" 1>&2 fi -if command -v _foamAddPath >/dev/null 2>&1 # Normal sourcing +if command -v _foamAddLibAuto > /dev/null 2>&1 then - # If *_ARCH_PATH does not end with '-system' or '-none', - # it is located within ThirdParty, or a central installation - # outside of ThirdParty and should be added to the path. + # Normal sourcing (not makeADIOS) + # - but only add if the directory really exists - ending="${ADIOS2_ARCH_PATH##*-}" - if [ "$ending" != none -a "$ending" != system ] + if _foamAddLibAuto $ADIOS2_ARCH_PATH then - # PATH was already cleaned by etc/bashrc caller _foamAddPath $ADIOS2_ARCH_PATH/bin fi - unset adios2_version ending + unset adios2_version +elif [ "$1" = "-force" ] +then + # Forced command-line sourcing + + if output="$($WM_PROJECT_DIR/bin/tools/lib-dir -sh $ADIOS2_ARCH_PATH 2>/dev/null)" + then + eval "$output" + PATH="$ADIOS2_ARCH_PATH/bin:$PATH" + fi + + unset adios2_version output fi + #------------------------------------------------------------------------------ diff --git a/etc/cshrc b/etc/cshrc index 1792541cdb..8a95894abf 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -200,6 +200,7 @@ _foamEtc -config paraview -- "$FOAM_SETTINGS" # Pass through for evaluation _foamEtc -config vtk _foamEtc -config ensight ## _foamEtc -config ADIOS +## _foamEtc -config ADIOS2 _foamEtc -config CGAL _foamEtc -config FFTW diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C index b2f0d191da..26981fceea 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C @@ -330,7 +330,6 @@ Foam::functionObjects::vtkCloud::vtkCloud fvMeshFunctionObject(name, runTime, dict), writeOpts_(vtk::formatType::INLINE_BASE64), printf_(), - useTimeName_(false), useVerts_(false), selectClouds_(), selectFields_(), @@ -394,7 +393,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict) printf_ = "%0" + std::to_string(padWidth) + "d"; } - useTimeName_ = dict.lookupOrDefault("timeName", false); + // useTimeName_ = dict.lookupOrDefault("useTimeName", false); useVerts_ = dict.lookupOrDefault("cellData", false); @@ -436,11 +435,18 @@ bool Foam::functionObjects::vtkCloud::write() return true; // skip - not available } +// const word timeDesc = +// ( +// useTimeName_ +// ? time_.timeName() +// : printf_.empty() +// ? Foam::name(time_.timeIndex()) +// : word::printf(printf_, time_.timeIndex()) +// ); + const word timeDesc = ( - useTimeName_ - ? time_.timeName() - : printf_.empty() + printf_.empty() ? Foam::name(time_.timeIndex()) : word::printf(printf_, time_.timeIndex()) ); diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.H b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.H index 6ead433ff8..498df102e3 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.H +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.H @@ -28,7 +28,8 @@ Group grpUtilitiesFunctionObjects Description - This functionObject writes cloud(s) in VTK format. + This functionObject writes cloud(s) in VTK PolyData format + (.vtp extension) with the time information saved in a '.series' file. Example of function object specification: \verbatim @@ -38,11 +39,11 @@ Description libs ("liblagrangianFunctionObjects.so"); writeControl writeTime; writeInterval 1; - format binary; + format ascii; cloud myCloud; - width 12; fields (T U rho); + width 4; // file-padding } \endverbatim @@ -57,20 +58,19 @@ Usage cellData | Emit cellData instead of pointData | no | false directory | The output directory name | no | VTK width | Padding width for file name | no | 8 - timeName | Use time-name instead of time-index | no | false format | ascii or binary format | no | binary writePrecision | write precision in ascii | no | same as IOstream \endtable - The output filename and fields are added to the cloud's \c OutputProperties - dictionary. For the previous example specification: + The output filename and fields are added to the functionObjectProperties + information. For the previous example specification: \verbatim cloudWrite1 { myCloud { - file "/VTK/myCloud_00001.vtp"; + file "/VTK/myCloud_0001.vtp"; fields (T U rho); } } @@ -122,9 +122,6 @@ class vtkCloud //- The printf format for zero-padding names string printf_; - //- Use time-name instead of time-index - bool useTimeName_; - //- Write lagrangian as cell data (verts) instead of point data bool useVerts_; diff --git a/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleFoam/system/ensightWrite b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleFoam/system/ensightWrite index 302957f59e..699be75719 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleFoam/system/ensightWrite +++ b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_pimpleFoam/system/ensightWrite @@ -1,4 +1,10 @@ -// -*- C++ -*- +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ ensightWrite { diff --git a/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/controlDict b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/controlDict index 0a339e6c42..3de6809d9e 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/controlDict @@ -47,19 +47,7 @@ runTimeModifiable true; functions { - forces - { - type forces; - libs ("libforces.so"); - writeControl timeStep; - writeInterval 10; - patches (wing); - rho rhoInf; - log true; - rhoInf 1; - CofR (0.4974612746 -0.01671895744 0.125); - } + #include "forces" } - // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/forces b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/forces new file mode 100644 index 0000000000..618cbcc8a3 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/RAS/wingMotion/wingMotion2D_simpleFoam/system/forces @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +forces +{ + type forces; + libs ("libforces.so"); + + writeControl timeStep; + writeInterval 10; + log false; + + patches (wing); + rho rhoInf; + rhoInf 1; + CofR (0.4974612746 -0.01671895744 0.125); +} + +// ************************************************************************* // diff --git a/wmake/scripts/have_adios2 b/wmake/scripts/have_adios2 new file mode 100644 index 0000000000..81055812a0 --- /dev/null +++ b/wmake/scripts/have_adios2 @@ -0,0 +1,143 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# . +# +# Script +# have_adios2 +# +# Description +# Detection/setup of ADIOS2 +# +# Requires +# ADIOS2_ARCH_PATH +# +# Functions provided +# have_adios2, no_adios2, echo_adios2 +# +# Variables set on success +# HAVE_ADIOS2 +# ADIOS2_ARCH_PATH +# ADIOS2_INC_DIR +# ADIOS2_LIB_DIR +# +#------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions + +#------------------------------------------------------------------------------ + +# Reset variables +no_adios2() +{ + unset HAVE_ADIOS2 ADIOS2_INC_DIR ADIOS2_LIB_DIR + return 0 +} + + +# Report +echo_adios2() +{ + echo "adios2=${HAVE_ADIOS2:-false}" + echo "root=$ADIOS2_ARCH_PATH" + echo "include=$ADIOS2_INC_DIR" + echo "library=$ADIOS2_LIB_DIR" +} + + +# On success, return 0 and export variables +# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR +have_adios2() +{ + local header library static label settings warn + # warn="==> skip adios2" + + # Basic setup/checks + settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS2) || { + [ -n "$warn" ] && echo "$warn (no config.sh/ADIOS2 settings)" + return 1 + } + . $settings + if isNone "$ADIOS2_ARCH_PATH" + then + [ -n "$warn" ] && echo "$warn (not available)" + return 1 + fi + + + # Header/library names + header="adios2.h" + library="libadios2$extLibso" + + + if hasAbsdir "$ADIOS2_ARCH_PATH" + then + header=$(findFirstFile $ADIOS2_ARCH_PATH/include/$header) + + # FOAM_EXT_LIBBIN is allowed to be unset + library=$(findFirstFile \ + $FOAM_EXT_LIBBIN/$library \ + $ADIOS2_ARCH_PATH/lib/$library \ + $ADIOS2_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + elif isSystem "$ADIOS2_ARCH_PATH" + then + header=$(findFirstFile /usr/local/include/$header /usr/include/$header) + + case "$header" in + /usr/local/*) + library=$(findFirstFile \ + /usr/local/lib/$library \ + /usr/local/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + ;; + + *) + library=$(findFirstFile \ + /usr/lib/$library \ + /usr/lib$WM_COMPILER_LIB_ARCH/$library \ + ) + ;; + esac + else + unset header library + fi + + + # Header found? + [ -n "$header" ] || { + [ -n "$warn" ] && echo "$warn (no header)" + return 2 + } + + # Library found? + [ -n "$library" ] || { + [ -n "$warn" ] && echo "$warn (missing library)" + return 2 + } + + header="${header%/*}" # Strip one-level (include/adios2/...) + + export HAVE_ADIOS2=true + export ADIOS2_ARCH_PATH + export ADIOS2_INC_DIR="${header%/*}" # Basename + export ADIOS2_LIB_DIR="${library%/*}" # Basename +} + + +# Force reset of old variables +no_adios2 + +# Testing +if [ "$1" = "-test" ] +then + have_adios2 + echo_adios2 +fi + +#------------------------------------------------------------------------------