From f3474dad1d4780d36badb6b6e15adbe2c811b93a Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Jun 2018 14:55:20 +0100 Subject: [PATCH 1/3] BUG: rigidBodyMotionState: not readable in binary. Fixes #871. --- .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 3 ++- .../rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 428ff83c0f..38408510cc 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -357,7 +357,8 @@ bool Foam::rigidBodyMeshMotion::writeObject ); model_.state().write(dict); - return dict.regIOobject::write(); + // Force ascii writing + return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid); } diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C index 4746876226..3351c068a7 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotionSolver/rigidBodyMeshMotionSolver.C @@ -301,7 +301,8 @@ bool Foam::rigidBodyMeshMotionSolver::writeObject ); model_.state().write(dict); - return dict.regIOobject::write(); + // Force ascii writing + return dict.regIOobject::writeObject(IOstream::ASCII, ver, cmp, valid); } From 5390c48b2d2c72ea199b7ecfaf1122c76dd85c5e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 16 Jun 2018 00:29:41 +0200 Subject: [PATCH 2/3] BUG: dictionary lookup of embedded coordinateSystem fails (fixes #879) - also fix incorrect documentation in forces functionObject and interRegionExplicitPorositySource fvOption. --- src/functionObjects/forces/forces/forces.H | 16 +++++++++----- .../interRegionExplicitPorositySource.H | 9 ++++++-- .../coordinateSystems/coordinateSystem.C | 22 +++++++++++++------ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/functionObjects/forces/forces/forces.H b/src/functionObjects/forces/forces/forces.H index 41d4aa6b6f..4a27514c6a 100644 --- a/src/functionObjects/forces/forces/forces.H +++ b/src/functionObjects/forces/forces/forces.H @@ -111,8 +111,12 @@ Note coordinateSystem { origin (0 0 0); - e3 (0 0 1); - e1 (1 0 0); + coordinateRotation + { + type axesRotation; + e3 (0 0 1); + e1 (1 0 0); + } } \endverbatim @@ -346,11 +350,11 @@ protected: //- Write binned data void writeBins(); - //- Disallow default bitwise copy construct - forces(const forces&); + //- No copy construct + forces(const forces&) = delete; - //- Disallow default bitwise assignment - void operator=(const forces&); + //- No copy assignment + void operator=(const forces&) = delete; public: diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H index e42e29d3db..1b0c33b95b 100644 --- a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H +++ b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.H @@ -43,8 +43,13 @@ Description coordinateSystem { - e1 (0.70710678 0.70710678 0); - e2 (0 0 1); + origin (0 0 0); + coordinateRotation + { + type axesRotation; + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } } } } diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C index b4a9e78820..484f410c5e 100644 --- a/src/meshTools/coordinateSystems/coordinateSystem.C +++ b/src/meshTools/coordinateSystems/coordinateSystem.C @@ -129,9 +129,21 @@ Foam::coordinateSystem::coordinateSystem { const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false); - // non-dictionary entry is a lookup into global coordinateSystems - if (entryPtr && !entryPtr->isDict()) + if (!entryPtr) { + // No 'coordinateSystem' entry + init(dict, obr); + } + else if (entryPtr->isDict()) + { + // 'coordinateSystem' as dictionary entry - use it + init(entryPtr->dict(), obr); + } + else + { + // 'coordinateSystem' as non-dictionary entry + // - this is a lookup into global coordinateSystems + keyType key(entryPtr->stream()); const coordinateSystems& lst = coordinateSystems::New(obr); @@ -152,15 +164,11 @@ Foam::coordinateSystem::coordinateSystem << exit(FatalError); } - // copy coordinateSystem, but assign the name as the typeName + // Copy from coordinateSystem, but assign the name as the typeName // to avoid strange things in writeDict() operator=(lst[index]); name_ = typeName_(); } - else - { - init(dict, obr); - } } From 5754405bfb6547965d8057fbdcb4e70543ea5930 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 18 Jun 2018 08:42:55 +0200 Subject: [PATCH 3/3] CONFIG: cannot pass additional arguments to foamEtcFile (closes #880) - add support by using updated foamEtcFile from 1806, which also add the '-config' short-cut option. --- bin/foamEtcFile | 170 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 50 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index e61279b591..195b91bdbe 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM, licensed under GNU General Public License @@ -46,7 +46,7 @@ printHelp() { cat<&2 # done - -# Save the essential bits of information -# silently remove leading ~OpenFOAM/ (used in Foam::findEtcFile) -nArgs=$# -fileName="${1#~OpenFOAM/}" - # Define the various places to be searched: unset dirList case "$optMode" in (*u*) # (U)ser @@ -309,27 +335,61 @@ case "$optMode" in (*o*) # (O)ther == shipped esac set -- $dirList +[ "$#" -ge 1 ] || die "No directories to scan. Programming error?" +exitCode=2 # Fallback is a FileNotFound error + + +# +# Preliminaries +# + +# Special handling of config.sh/ , config.csh/ directories +if [ -n "$optConfig" -a -n "$shellOutput" -a -n "$fileName" ] +then + case "$shellOutput" in + csh*) + optConfig="config.csh/" + ;; + sh*) + optConfig="config.sh/" + ;; + *) + unset optConfig + ;; + esac + + if [ -n "$optConfig" ] + then + case "$fileName" in + /* | config.csh* | config.sh*) + # Does not need or cannot add a prefix + unset optConfig + ;; + *) + fileName="$optConfig$fileName" + ;; + esac + fi +fi + # # The main routine # -exitCode=0 if [ -n "$optList" ] then # List directories, or potential file locations [ "$nArgs" -le 1 ] || \ - die "-list expects 0 or 1 filename, but $nArgs provided" + die "-list options expect 0 or 1 filename, but $nArgs provided" - # A silly combination, but -quiet does have precedence + # A silly combination, but -quiet has absolute precedence [ -n "$optQuiet" ] && exit 0 # Test for directory or file too? if [ "$optList" = "test" ] then - exitCode=2 # Fallback to a general error (file not found) - if [ "$nArgs" -eq 1 ] then for dir @@ -352,6 +412,7 @@ then done fi else + exitCode=0 # OK, already verified that $# != 0 for dir do echo "$dir${fileName:+/}$fileName" @@ -362,35 +423,44 @@ else [ "$nArgs" -eq 1 ] || die "One filename expected - $nArgs provided" - exitCode=2 # Fallback to a general error (file not found) + # Output for sourcing files ("source" for csh, "." for POSIX shell) + # Only allow sourcing a single file (disallow combination with -all) + case "$shellOutput" in + csh*) + shellOutput="source " # eg, "source FILE" + ;; + sh*) + shellOutput=". " # eg, ". FILE" + ;; + esac + + # Anti-pattern: -all disables shell commands + if [ -n "$optAll" ] + then + unset shellOutput verboseOutput + fi for dir do - if [ -f "$dir/$fileName" ] + resolved="$dir/$fileName" + if [ -f "$resolved" ] then - exitCode=0 - [ -n "$optQuiet" ] && break - - case "$optShell" in - (*verbose) - echo "Using: $dir/$fileName" 1>&2 - ;; - esac - - case "$optShell" in - csh*) - echo "source $dir/$fileName" + exitCode=0 # OK + if [ -n "$optQuiet" ] + then break - ;; - sh*) - echo ". $dir/$fileName" - break - ;; - *) - echo "$dir/$fileName" - [ -n "$optAll" ] || break - ;; - esac + elif [ -n "$verboseOutput" ] + then + echo "$verboseOutput$resolved" 1>&2 + fi + + if [ -n "$shellOutput" ] + then + echo "$shellOutput$resolved $evalArgs" + else + echo "$resolved" + fi + [ -n "$optAll" ] || break fi done