diff --git a/utilities/pFlowToVTK/pFlowToVTK.C b/utilities/pFlowToVTK/pFlowToVTK.C index 7087589a..8064c7cd 100755 --- a/utilities/pFlowToVTK/pFlowToVTK.C +++ b/utilities/pFlowToVTK/pFlowToVTK.C @@ -67,10 +67,17 @@ int main(int argc, char** argv ) "path to output folder of VTK", "path"); + wordVector fields; + bool allFields = true; + cmds.addOption("-f,--fields", + fields.vectorField(), + "a space-separated list of fields names to be converted to VTK", + "word"); + cmds.addOption( "-t,--time", times.vectorField(), - "a space separated lits of time folders, or a strided range begin:stride:end, or an interval begin:end", + "a space separated lists of time folders, or a strided range begin:stride:end, or an interval begin:end", " "); if(!cmds.parse(argc, argv)) return 0; @@ -85,6 +92,12 @@ int main(int argc, char** argv ) fileSystem destFolderField = fileSystem(outFolder); wordList geomfiles{"triSurface"}; + + if(cmds.count("--fields")) + { + allFields = false; + } + realCombinedRange validRange; if( cmds.count("--time") ) { @@ -116,14 +129,31 @@ int main(int argc, char** argv ) if(!noParticle) { - if( !pFlow::PFtoVTK::convertTimeFolderPointFields( - folders.folder(), - folders.time(), - destFolderField, - "sphereFields" ) - ) + + if(allFields) { - fatalExit; + if( !pFlow::PFtoVTK::convertTimeFolderPointFields( + folders.folder(), + folders.time(), + destFolderField, + "sphereFields" ) + ) + { + fatalExit; + } + }else + { + if(!pFlow::PFtoVTK::convertTimeFolderPointFieldsSelected( + folders.folder(), + folders.time(), + destFolderField, + "sphereFields", + fields, + !pFlow::equal(folders.time(),static_cast(0.0)) ) + ) + { + fatalExit; + } } } diff --git a/utilities/pFlowToVTK/pointFieldToVTK.H b/utilities/pFlowToVTK/pointFieldToVTK.H index 59e82e6d..2f04d03e 100755 --- a/utilities/pFlowToVTK/pointFieldToVTK.H +++ b/utilities/pFlowToVTK/pointFieldToVTK.H @@ -354,6 +354,93 @@ bool convertTimeFolderPointFields( return true; } + + + +bool convertTimeFolderPointFieldsSelected( + fileSystem timeFolder, + real time, + fileSystem destPath, + word bName, + wordVector fieldsName, + bool mustExist) +{ + + // check if pointStructure exist in this folder + IOfileHeader pStructHeader( + objectFile( + pointStructureFile__, + timeFolder, + objectFile::READ_ALWAYS, + objectFile::WRITE_ALWAYS) + ); + + if( !pStructHeader.headerOk(true) ) + { + output<(pStructHeader); + auto& pStruct = pStructObjPtr().getObject(); + + // get a list of files in this timeFolder; + + auto posVec = std::as_const(pStruct).pointPosition().hostVectorAll(); + auto* pos = posVec.data(); + + Report(1)<<"Writing pointStructure to vtk file with "<< yellowText(pStruct.numActive()) + <<" active particles"<