diff --git a/etc/writeArea.py b/etc/writeArea.py new file mode 100644 index 0000000000000000000000000000000000000000..b94085ca56626336777916e612f0f2154b89bf4f --- /dev/null +++ b/etc/writeArea.py @@ -0,0 +1,70 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'input') + writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + coprocessor.RegisterWriter(writer1, filename='insitu/area_%t.vtm', freq=2) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'input': [10]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(True) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + 'Callback to populate the request for current timestep' + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + 'Callback to do co-processing for current timestep' + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, 'localhost', 22222) diff --git a/etc/writeCloud.py b/etc/writeCloud.py new file mode 100644 index 0000000000000000000000000000000000000000..73512ec053dbcd72980165d7ee0221c05dcc10d7 --- /dev/null +++ b/etc/writeCloud.py @@ -0,0 +1,72 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'cloud') + writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + # register writer with coprocessor, with filename + output freq + coprocessor.RegisterWriter(writer1, filename='insitu/cloud_%t.vtm', freq=10) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'cloud': [10]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(True) + + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + 'Callback to populate the request for current timestep' + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + 'Callback to do co-processing for current timestep' + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, 'localhost', 22222) diff --git a/etc/writePatches.py b/etc/writePatches.py new file mode 100644 index 0000000000000000000000000000000000000000..92b8c9f374e46b2ebcda93d2f7e27cd15fa1fb13 --- /dev/null +++ b/etc/writePatches.py @@ -0,0 +1,70 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'patches') + writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + coprocessor.RegisterWriter(writer1, filename='insitu/patches_%t.vtm', freq=2) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'patches': [10]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(True) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + 'Callback to populate the request for current timestep' + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + 'Callback to do co-processing for current timestep' + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, 'localhost', 22222) diff --git a/src/catalyst/Allwclean b/src/catalyst/Allwclean index c65d7b4b27182fe9d2fdd0ae0bdf14590e026932..e19c76477fb468eb8f4832d8f15e0064b1da14af 100755 --- a/src/catalyst/Allwclean +++ b/src/catalyst/Allwclean @@ -3,6 +3,8 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # The wmake functions rm -f $FOAM_LIBBIN/libcatalystFoam* 2>/dev/null # Cleanup library +rm -f $FOAM_SITE_LIBBIN/libcatalystFoam* 2>/dev/null # ... extra safety +rm -f $FOAM_USER_LIBBIN/libcatalystFoam* 2>/dev/null # ... extra safety # Cleanup generated files - remove entire top-level removeObjectDir $PWD diff --git a/src/catalyst/areaMesh/catalystFaMesh.C b/src/catalyst/areaMesh/catalystFaMesh.C index 2db6b2c4f4ee1eb0a09d6d8158464c4ec52d9c47..9988e8f032482d82f962d80b89036ae23e940d6b 100644 --- a/src/catalyst/areaMesh/catalystFaMesh.C +++ b/src/catalyst/areaMesh/catalystFaMesh.C @@ -48,6 +48,29 @@ namespace functionObjects // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +bool Foam::functionObjects::catalystFaMesh::readBasics(const dictionary& dict) +{ + int debugLevel = 0; + if (dict.readIfPresent("debug", debugLevel)) + { + catalystCoprocess::debug = debugLevel; + } + + fileName outputDir; + if (dict.readIfPresent("mkdir", outputDir)) + { + outputDir.expand(); + outputDir.clean(); + Foam::mkDir(outputDir); + } + + dict.lookup("scripts") >> scripts_; // Python scripts + catalystCoprocess::expand(scripts_, dict); // Expand and check availability + + return true; +} + + void Foam::functionObjects::catalystFaMesh::updateState ( polyMesh::readUpdateState state @@ -106,11 +129,7 @@ bool Foam::functionObjects::catalystFaMesh::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - int debugLevel = 0; - if (dict.readIfPresent("debug", debugLevel)) - { - catalystCoprocess::debug = debugLevel; - } + readBasics(dict); // All possible meshes meshes_ = mesh_.lookupClass<faMesh>(); @@ -143,9 +162,7 @@ bool Foam::functionObjects::catalystFaMesh::read(const dictionary& dict) meshes_.filterKeys(wordRes(selectAreas_)); dict.lookup("fields") >> selectFields_; - dict.lookup("scripts") >> scripts_; // Python scripts - catalystCoprocess::expand(scripts_, dict); // Expand and check availability Info<< type() << " " << name() << ":" << nl <<" areas " << flatOutput(selectAreas_) << nl @@ -153,9 +170,9 @@ bool Foam::functionObjects::catalystFaMesh::read(const dictionary& dict) <<" fields " << flatOutput(selectFields_) << nl <<" scripts " << scripts_ << nl; - // Run-time modification of pipeline if (adaptor_.valid()) { + // Run-time modification of pipeline adaptor_().reset(scripts_); } diff --git a/src/catalyst/areaMesh/catalystFaMesh.H b/src/catalyst/areaMesh/catalystFaMesh.H index 6786184e0e17c50e21b7e5abf5b56e05c44e3b00..07b5b72e995685c77d4b3c4bcb11dc635c556e43 100644 --- a/src/catalyst/areaMesh/catalystFaMesh.H +++ b/src/catalyst/areaMesh/catalystFaMesh.H @@ -51,6 +51,7 @@ Usage Property | Description | Required | Default type | catalyst::area | yes | log | report extra information | no | false + mkdir | initial directory to create | no | region | | no | region0 regions | wordRe list of regions | no | fields | wordRe list of fields | yes | @@ -127,8 +128,13 @@ protected: // Protected Member Functions + //- Common boilerplate settings + bool readBasics(const dictionary& dict); + + //- On movement void updateState(polyMesh::readUpdateState state); + //- No copy construct catalystFaMesh(const catalystFaMesh&) = delete; diff --git a/src/catalyst/catalystCoprocess.C b/src/catalyst/catalystCoprocess.C index 5f137ace830ff60d23572e253fb7060f4c46bca0..120859fe88b49908fba2a68ee83972032ba354ba 100644 --- a/src/catalyst/catalystCoprocess.C +++ b/src/catalyst/catalystCoprocess.C @@ -99,6 +99,7 @@ Foam::label Foam::catalystCoprocess::expand string& s = scripts[scripti]; stringOps::inplaceExpand(s, dict, true, true); + fileName::clean(s); // Remove trailing, repeated slashes etc. if (isFile(s)) { diff --git a/src/catalyst/cloud/catalystCloud.C b/src/catalyst/cloud/catalystCloud.C index 2bbcaed50bcde3d9199c34efce8b7a5d508ed8d3..5ac05a649b6fcce066116f8b9339a714fd311269 100644 --- a/src/catalyst/cloud/catalystCloud.C +++ b/src/catalyst/cloud/catalystCloud.C @@ -46,6 +46,31 @@ namespace functionObjects } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool Foam::functionObjects::catalystCloud::readBasics(const dictionary& dict) +{ + int debugLevel = 0; + if (dict.readIfPresent("debug", debugLevel)) + { + catalystCoprocess::debug = debugLevel; + } + + fileName outputDir; + if (dict.readIfPresent("mkdir", outputDir)) + { + outputDir.expand(); + outputDir.clean(); + Foam::mkDir(outputDir); + } + + dict.lookup("scripts") >> scripts_; // Python scripts + catalystCoprocess::expand(scripts_, dict); // Expand and check availability + + return true; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::catalystCloud::catalystCloud @@ -76,11 +101,7 @@ bool Foam::functionObjects::catalystCloud::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - int debugLevel = 0; - if (dict.readIfPresent("debug", debugLevel)) - { - catalystCoprocess::debug = debugLevel; - } + readBasics(dict); selectClouds_.clear(); dict.readIfPresent("clouds", selectClouds_); @@ -95,18 +116,15 @@ bool Foam::functionObjects::catalystCloud::read(const dictionary& dict) selectFields_.clear(); dict.readIfPresent("fields", selectFields_); - dict.lookup("scripts") >> scripts_; // Python scripts - - catalystCoprocess::expand(scripts_, dict); // Expand and check availability Info<< type() << " " << name() << ":" << nl <<" clouds " << flatOutput(selectClouds_) << nl <<" fields " << flatOutput(selectFields_) << nl <<" scripts " << scripts_ << nl; - // Run-time modification of pipeline if (adaptor_.valid()) { + // Run-time modification of pipeline adaptor_().reset(scripts_); } diff --git a/src/catalyst/cloud/catalystCloud.H b/src/catalyst/cloud/catalystCloud.H index 27f46227b675d41de4df11ad92fc0310b8f6c381..fb31f281ca610b8d5baddc88af77402007fb2f2d 100644 --- a/src/catalyst/cloud/catalystCloud.H +++ b/src/catalyst/cloud/catalystCloud.H @@ -52,6 +52,7 @@ Usage Property | Description | Required | Default value type | catalyst::cloud | yes | log | report extra information | no | false + mkdir | initial directory to create | no | cloud | | no | defaultCloud clouds | wordRe list of clouds | no | region | | no | region0 @@ -120,7 +121,11 @@ protected: autoPtr<catalystCoprocess> adaptor_; - // Private Member Functions + // Protected Member Functions + + //- Common boilerplate settings + bool readBasics(const dictionary& dict); + //- No copy construct catalystCloud(const catalystCloud&) = delete; diff --git a/src/catalyst/volMesh/catalystFvMesh.C b/src/catalyst/volMesh/catalystFvMesh.C index e1344a20d60a941fe30ad01abc42d74b2148215b..fa33f54c55d388a1b0064e96434b69eb116a6887 100644 --- a/src/catalyst/volMesh/catalystFvMesh.C +++ b/src/catalyst/volMesh/catalystFvMesh.C @@ -46,6 +46,29 @@ namespace functionObjects // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +bool Foam::functionObjects::catalystFvMesh::readBasics(const dictionary& dict) +{ + int debugLevel = 0; + if (dict.readIfPresent("debug", debugLevel)) + { + catalystCoprocess::debug = debugLevel; + } + + fileName outputDir; + if (dict.readIfPresent("mkdir", outputDir)) + { + outputDir.expand(); + outputDir.clean(); + Foam::mkDir(outputDir); + } + + dict.lookup("scripts") >> scripts_; // Python scripts + catalystCoprocess::expand(scripts_, dict); // Expand and check availability + + return true; +} + + void Foam::functionObjects::catalystFvMesh::updateState ( polyMesh::readUpdateState state @@ -105,12 +128,25 @@ bool Foam::functionObjects::catalystFvMesh::read(const dictionary& dict) { functionObject::read(dict); + // Common settings int debugLevel = 0; if (dict.readIfPresent("debug", debugLevel)) { catalystCoprocess::debug = debugLevel; } + fileName outputDir; + if (dict.readIfPresent("mkdir", outputDir)) + { + outputDir.expand(); + outputDir.clean(); + Foam::mkDir(outputDir); + } + + dict.lookup("scripts") >> scripts_; // Python scripts + catalystCoprocess::expand(scripts_, dict); // Expand and check availability + + // All possible meshes meshes_ = time_.lookupClass<fvMesh>(); @@ -128,9 +164,7 @@ bool Foam::functionObjects::catalystFvMesh::read(const dictionary& dict) meshes_.filterKeys(wordRes(selectRegions_)); dict.lookup("fields") >> selectFields_; - dict.lookup("scripts") >> scripts_; // Python scripts - catalystCoprocess::expand(scripts_, dict); // Expand and check availability Info<< type() << " " << name() << ":" << nl <<" regions " << flatOutput(selectRegions_) << nl @@ -138,9 +172,9 @@ bool Foam::functionObjects::catalystFvMesh::read(const dictionary& dict) <<" fields " << flatOutput(selectFields_) << nl <<" scripts " << scripts_ << nl; - // Run-time modification of pipeline if (adaptor_.valid()) { + // Run-time modification of pipeline adaptor_().reset(scripts_); } diff --git a/src/catalyst/volMesh/catalystFvMesh.H b/src/catalyst/volMesh/catalystFvMesh.H index 0606cb4d71b29ca811af44285ffc5f7835438f7f..a5a264bcf1569ecbe8728f4824c43d46922c7f6a 100644 --- a/src/catalyst/volMesh/catalystFvMesh.H +++ b/src/catalyst/volMesh/catalystFvMesh.H @@ -52,6 +52,7 @@ Usage Property | Description | Required | Default type | catalyst | yes | log | report extra information | no | false + mkdir | initial directory to create | no | region | | no | region0 regions | wordRe list of regions | no | fields | wordRe list of fields | yes | @@ -131,8 +132,13 @@ protected: // Protected Member Functions + //- Common boilerplate settings + bool readBasics(const dictionary& dict); + + //- On movement void updateState(polyMesh::readUpdateState state); + //- No copy construct catalystFvMesh(const catalystFvMesh&) = delete; diff --git a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/Allclean b/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/Allclean index 49abfb94cedd632d823fb83f0e5642b853c93c33..ecc502aaf50977bc14c772dd5d372b20b92ce444 100755 --- a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/Allclean +++ b/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/Allclean @@ -7,7 +7,6 @@ cleanTimeDirectories cleanFaMesh rm -rf processor* - rm -rf insitu #------------------------------------------------------------------------------ diff --git a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/area.cfg b/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/area.cfg deleted file mode 100644 index 2f6850f99531553441118e215c8bd3eca5c86142..0000000000000000000000000000000000000000 --- a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/area.cfg +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -// Insitu processing of finiteArea fields with ParaView Catalyst - -type catalyst::area; -libs ("libcatalystFoam.so"); - -executeControl timeStep; -writeControl none; - -// ************************************************************************* // diff --git a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/catalystArea b/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/catalystArea index 1572d9256d37ccc2aa2eb3a41ecdf5cdd886d1f7..ead19c9e96294f926ed352fcc5f5fd8389faf535 100644 --- a/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/catalystArea +++ b/tutorials/finiteArea/sphereSurfactantFoam/sphereTransport/system/catalystArea @@ -4,15 +4,17 @@ functions { catalystArea { - #include "area.cfg"; - // FUTURE: #includeEtc "caseDicts/postProcessing/catalyst/area.cfg" + #includeEtc "caseDicts/postProcessing/catalyst/area.cfg" // Selected fields (words or regex) fields ( ".*" ); + // Output directory + //mkdir "<case>/images"; + scripts ( - "$FOAM_CASE/system/scripts/writeArea.py" + "<system>/scripts/writeArea.py" ); } } diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean index 8643b2fccc847897489b473df8a012593bb5612f..2830e42a2d0e70e5ea9caf318f271155c6aab44a 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/Allclean @@ -3,14 +3,6 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions cleanCase0 -rm -rf VTK -rm -rf constant/cellToRegion rm -rf constant/*/polyMesh -# Remove ParaView Catalyst output -rm -rf insitu - -# Remove ADIOS output -rm -rf adiosData - # ----------------------------------------------------------------------------- diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst index 4f9bc0480feeef417998b06f6ef9a67ce82e92e0..ab49f45b0937627a60c4826359389a55eb4eb364 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst @@ -4,8 +4,7 @@ functions { catalyst { - #include "catalyst.cfg"; - // FUTURE: #includeEtc "caseDicts/postProcessing/catalyst/default.cfg" + #includeEtc "caseDicts/postProcessing/catalyst/default.cfg" // All regions regions (".*"); @@ -15,8 +14,8 @@ functions scripts ( - "$FOAM_CASE/system/scripts/slice1.py" - "$FOAM_CASE/system/scripts/writePatches.py" + "<system>/scripts/slice1.py" + "<system>/scripts/writePatches.py" ); } } diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst.cfg b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst.cfg deleted file mode 100644 index e9ace6b706c1c55b456b01faf4a564c82d13bce9..0000000000000000000000000000000000000000 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/catalyst.cfg +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -// Insitu processing of finiteVolume fields with ParaView Catalyst - -type catalyst; -libs ("libcatalystFoam.so"); - -executeControl timeStep; -writeControl none; - -// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writeMesh.py b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writeMesh.py new file mode 100644 index 0000000000000000000000000000000000000000..43533a935f14b459731a657bc8f9401ef7b3eabc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writeMesh.py @@ -0,0 +1,70 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'mesh') + writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + coprocessor.RegisterWriter(writer1, filename='insitu/mesh_%t.vtm', freq=2) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'mesh': [10]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(True) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + 'Callback to populate the request for current timestep' + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + 'Callback to do co-processing for current timestep' + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, 'localhost', 22222) diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writePatches.py b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writePatches.py new file mode 100644 index 0000000000000000000000000000000000000000..92b8c9f374e46b2ebcda93d2f7e27cd15fa1fb13 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/scripts/writePatches.py @@ -0,0 +1,70 @@ +from paraview.simple import * +from paraview import coprocessing + +# ----------------------- CoProcessor definition ----------------------- + +def CreateCoProcessor(): + def _CreatePipeline(coprocessor, datadescription): + class Pipeline: + input1 = coprocessor.CreateProducer(datadescription, 'patches') + writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) + + coprocessor.RegisterWriter(writer1, filename='insitu/patches_%t.vtm', freq=2) + + return Pipeline() + + class CoProcessor(coprocessing.CoProcessor): + def CreatePipeline(self, datadescription): + self.Pipeline = _CreatePipeline(self, datadescription) + + coprocessor = CoProcessor() + freqs = {'patches': [10]} + coprocessor.SetUpdateFrequencies(freqs) + return coprocessor + +#-------------------------------------------------------------- +# Global variables that will hold the pipeline for each timestep +# Creating the CoProcessor object, doesn't actually create the ParaView pipeline. +# It will be automatically setup when coprocessor.UpdateProducers() is called the +# first time. +coprocessor = CreateCoProcessor() + +#-------------------------------------------------------------- +# Enable Live-Visualizaton with ParaView +coprocessor.EnableLiveVisualization(True) + +# ---------------------- Data Selection method ---------------------- + +def RequestDataDescription(datadescription): + 'Callback to populate the request for current timestep' + global coprocessor + if datadescription.GetForceOutput() == True: + # We are just going to request all fields and meshes from the simulation + # code/adaptor. + for i in range(datadescription.GetNumberOfInputDescriptions()): + datadescription.GetInputDescription(i).AllFieldsOn() + datadescription.GetInputDescription(i).GenerateMeshOn() + return + + # setup requests for all inputs based on the requirements of the + # pipeline. + coprocessor.LoadRequestedData(datadescription) + +# ------------------------ Processing method ------------------------ + +def DoCoProcessing(datadescription): + 'Callback to do co-processing for current timestep' + global coprocessor + + # Update the coprocessor by providing it the newly generated simulation data. + # If the pipeline hasn't been setup yet, this will setup the pipeline. + coprocessor.UpdateProducers(datadescription) + + # Write output data, if appropriate. + coprocessor.WriteData(datadescription); + + # Write image capture (Last arg: rescale lookup table), if appropriate. + coprocessor.WriteImages(datadescription, rescale_lookuptable=False) + + # Live Visualization, if enabled. + coprocessor.DoLiveVisualization(datadescription, 'localhost', 22222) diff --git a/tutorials/incompressible/icoFoam/cavity/Allclean b/tutorials/incompressible/icoFoam/cavity/Allclean index 5a23af939bb5d58d77cabaf21365ffd83d2d1f17..be7ddb068847225ad69704840909a7b0d05a5466 100755 --- a/tutorials/incompressible/icoFoam/cavity/Allclean +++ b/tutorials/incompressible/icoFoam/cavity/Allclean @@ -4,6 +4,4 @@ cd ${0%/*} || exit 1 # Run from this directory cleanCase -rm -rf insitu - #------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/icoFoam/cavity/system/catalyst b/tutorials/incompressible/icoFoam/cavity/system/catalyst index dc137eabb72b262eab74649a48b8e3873df4370e..4d40d140e5d9a17c467391027f57aa8cfb2f5075 100644 --- a/tutorials/incompressible/icoFoam/cavity/system/catalyst +++ b/tutorials/incompressible/icoFoam/cavity/system/catalyst @@ -4,8 +4,7 @@ functions { catalyst { - #include "catalyst.cfg"; - // FUTURE: #includeEtc "caseDicts/postProcessing/catalyst/default.cfg" + #includeEtc "caseDicts/postProcessing/catalyst/default.cfg" // Regions // regions ( ); @@ -15,8 +14,8 @@ functions scripts ( - "$FOAM_CASE/system/scripts/slice1.py" - "$FOAM_CASE/system/scripts/writeVtm.py" + "<system>/scripts/slice1.py" + "<system>/scripts/writeMesh.py" ); // Calculate a few iterations before starting processing diff --git a/tutorials/incompressible/icoFoam/cavity/system/catalyst.cfg b/tutorials/incompressible/icoFoam/cavity/system/catalyst.cfg deleted file mode 100644 index e9ace6b706c1c55b456b01faf4a564c82d13bce9..0000000000000000000000000000000000000000 --- a/tutorials/incompressible/icoFoam/cavity/system/catalyst.cfg +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -// Insitu processing of finiteVolume fields with ParaView Catalyst - -type catalyst; -libs ("libcatalystFoam.so"); - -executeControl timeStep; -writeControl none; - -// ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavity/system/decomposeParDict b/tutorials/incompressible/icoFoam/cavity/system/decomposeParDict index 4162d1982bfec8621c38d2327738f61c521b3903..e1431eb21eed5d0d2a51bf7d07752e3b992cadeb 100644 --- a/tutorials/incompressible/icoFoam/cavity/system/decomposeParDict +++ b/tutorials/incompressible/icoFoam/cavity/system/decomposeParDict @@ -15,31 +15,13 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 2; +numberOfSubdomains 3; method simple; -simpleCoeffs +coeffs { - n (2 1 1); - delta 0.001; + n (3 1 1); } -hierarchicalCoeffs -{ - n (1 1 1); - delta 0.001; - order xyz; -} - -manualCoeffs -{ - dataFile ""; -} - -distributed no; - -roots ( ); - - // ************************************************************************* // diff --git a/tutorials/incompressible/icoFoam/cavity/system/scripts/writeVtm.py b/tutorials/incompressible/icoFoam/cavity/system/scripts/writeMesh.py similarity index 90% rename from tutorials/incompressible/icoFoam/cavity/system/scripts/writeVtm.py rename to tutorials/incompressible/icoFoam/cavity/system/scripts/writeMesh.py index eb112de4e56a578ce41482627430cdf371a62ee6..a9c04d2c17778824764e2bf429535df0c9f6e5a7 100644 --- a/tutorials/incompressible/icoFoam/cavity/system/scripts/writeVtm.py +++ b/tutorials/incompressible/icoFoam/cavity/system/scripts/writeMesh.py @@ -7,13 +7,14 @@ def CreateCoProcessor(): def _CreatePipeline(coprocessor, datadescription): class Pipeline: input1 = coprocessor.CreateProducer(datadescription, "mesh") - ## input2 = coprocessor.CreateProducer(datadescription, "patches") - writer1 = servermanager.writers.XMLMultiBlockDataWriter(Input=input1) - - # register writer with coprocessor, with filename to use, output frequency + # Register with filename to use, output frequency coprocessor.RegisterWriter(writer1, filename='insitu/mesh_%t.vtm', freq=2) + # input2 = coprocessor.CreateProducer(datadescription, "patches") + # writer2 = servermanager.writers.XMLMultiBlockDataWriter(Input=input2) + # coprocessor.RegisterWriter(writer2, filename='insitu/patches_%t.vtm', freq=2) + return Pipeline() class CoProcessor(coprocessing.CoProcessor): diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allclean b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..0151d5e53a085c9cffe8f8c5cd12587e99d72d64 --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions + +cleanCase +rm -rf constant/*/polyMesh + +# ----------------------------------------------------------------------------- diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..61c2efb007f6b15459808b5982a1ebbb929122fe --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun @@ -0,0 +1,12 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication blockMesh + +# Create ignition cells cellSet +runApplication topoSet + +runApplication $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun-parallel b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun-parallel new file mode 100755 index 0000000000000000000000000000000000000000..da47afd7a0439662946a33ec033a7585502c4cc7 --- /dev/null +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun-parallel @@ -0,0 +1,14 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions + +runApplication blockMesh + +# Create ignition cells cellSet +runApplication topoSet + +runApplication decomposePar + +runParallel $(getApplication) + +#------------------------------------------------------------------------------ diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/thermophysicalProperties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/thermophysicalProperties index 22fca744320f65acea12c377e68d75d9623e5075..603743f9214229b08ff02d4006e3c2ee64c1f25f 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/thermophysicalProperties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/thermophysicalProperties @@ -28,9 +28,9 @@ thermoType chemistryReader foamChemistryReader; -foamChemistryThermoFile "$FOAM_CASE/constant/foam.dat"; +foamChemistryFile "<constant>/foam.inp"; -foamChemistryFile "$FOAM_CASE/constant/foam.inp"; +foamChemistryThermoFile "<constant>/foam.dat"; inertSpecie N2; diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/catalystCloud b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/catalystCloud index 20db93f0c705090075462bb5f42494e7010a09f8..e9b7336918330cdbbe428c582b9809e27b8e1404 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/catalystCloud +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/catalystCloud @@ -4,8 +4,7 @@ functions { catalystCloud1 { - #includeEtc "cloud.cfg"; - // FUTURE: #includeEtc "caseDicts/postProcessing/catalyst/cloud.cfg" + #includeEtc "caseDicts/postProcessing/catalyst/cloud.cfg" // Selected clouds (words or regex) clouds ( coalCloud1 limestoneCloud1 ); @@ -15,7 +14,7 @@ functions scripts ( - "$FOAM_CASE/system/scripts/writeCloud.py" + "<system>/scripts/writeCloud.py" ); } } diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cloud.cfg b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cloud.cfg deleted file mode 100644 index d860e901a9003aa5716b796653b2c0e9ae1e19f1..0000000000000000000000000000000000000000 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/cloud.cfg +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -// Insitu processing of lagrangian clouds with ParaView Catalyst - -type catalyst::cloud; -libs ("libcatalystFoam.so"); - -executeControl timeStep; -writeControl none; - -// ************************************************************************* //