View Issue Details

IDProjectCategoryView StatusLast Update
0000012OpenFOAM[All Projects] Bugpublic2010-08-31 10:30
ReporterbgschaidAssigned Touser2 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version 
Fixed in Version 
Summary0000012: sample silently fails to write data if filenames are too long
DescriptionWhen specifying too many fields (or too long field names) the filename (which is constructed from the fields) becomes too long and OFstream does not create a file. sample continues anyway (but no data gets written)
Steps To ReproduceObvious. Sample a lot of fields (all species for a large chemical system for instance)
Additional InformationI attached a patch that emits a warning if the stream is not valid. Did not let it fail as it might still write the vectors in a separete file (if the file that is too long is the one with the scalars) and as I understand it the code is also used for function objects (and we don't want them to fail, do we)

I also included in the patch my personal workaround for the situation: make the sampleDict selectable from the command line with the sample-utility
TagsInput/output, Post-processing, Utility

Activities

bgschaid

2010-08-27 09:04

reporter   ~0000005

Could not upload the patch. Got this error message:

Not Acceptable

An appropriate representation of the requested resource /mantisbt/bug_file_add.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I will copy/paste the patch below:

# HG changeset patch
# Parent 87056e22824fbb36e200f177ae231edcca508a9b

diff --git a/applications/utilities/postProcessing/sampling/sample/sample.C b/applications/utilities/postProcessing/sampling/sample/sample.C
--- a/applications/utilities/postProcessing/sampling/sample/sample.C
+++ b/applications/utilities/postProcessing/sampling/sample/sample.C
@@ -95,6 +95,8 @@
 
 int main(int argc, char *argv[])
 {
+ argList::validOptions.insert("sampleDict","sample dictionary");
+
     timeSelector::addOptions();
 # include "addRegionOption.H"
 # include "setRootCase.H"
@@ -102,11 +104,17 @@
     instantList timeDirs = timeSelector::select0(runTime, args);
 # include "createNamedMesh.H"
 
+ word sampleDict="sampleDict";
+ if(args.options().found("sampleDict"))
+ {
+ sampleDict=args.options()["sampleDict"];
+ }
+
     IOsampledSets sSets
     (
         sampledSets::typeName,
         mesh,
- "sampleDict",
+ sampleDict,
         IOobject::MUST_READ,
         true
     );
@@ -115,7 +123,7 @@
     (
         sampledSurfaces::typeName,
         mesh,
- "sampleDict",
+ sampleDict,
         IOobject::MUST_READ,
         true
     );
diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C
--- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C
+++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C
@@ -157,12 +157,21 @@
         timeDir/formatter.getFileName(masterSampleSet, valueSetNames)
     );
 
+ OFstream oFile(fName);
+ if(!oFile.opened())
+ {
+ WarningIn("Foam::sampledSets::writeSampleFile")
+ << " File " << oFile.name() << " was not opened. "
+ << " This means that propably no data will be written"
+ << endl;
+ }
+
     formatter.write
     (
         masterSampleSet,
         valueSetNames,
         valueSets,
- OFstream(fName)()
+ oFile
     );
 }

user2

2010-08-27 10:10

  ~0000007

Updates pushed under 1.7.x commit reference ccc32ab38001

Issue History

Date Modified Username Field Change
2010-08-27 09:02 bgschaid New Issue
2010-08-27 09:04 bgschaid Note Added: 0000005
2010-08-27 09:14 bgschaid Tag Attached: Input/output
2010-08-27 09:26 user2 Assigned To => user2
2010-08-27 09:26 user2 Status new => assigned
2010-08-27 10:10 user2 Note Added: 0000007
2010-08-27 10:10 user2 Status assigned => resolved
2010-08-27 10:10 user2 Fixed in Version => 1.7.x
2010-08-27 10:10 user2 Resolution open => fixed
2010-08-31 10:30 user2 Tag Attached: Post-processing
2010-08-31 10:30 user2 Tag Attached: Utility