diff --git a/inputFiles/wavePropagation/benchmarks/elas3D_benchmark_base.xml b/inputFiles/wavePropagation/benchmarks/elas3D_benchmark_base.xml index a1759a7b731..36a95b6e247 100644 --- a/inputFiles/wavePropagation/benchmarks/elas3D_benchmark_base.xml +++ b/inputFiles/wavePropagation/benchmarks/elas3D_benchmark_base.xml @@ -220,7 +220,8 @@ + levelNames="{ FE1 }" + plotLevel="3"/> diff --git a/inputFiles/wavePropagation/elas3D_small_base.xml b/inputFiles/wavePropagation/elas3D_small_base.xml index 0ed1a918810..8581b072068 100644 --- a/inputFiles/wavePropagation/elas3D_small_base.xml +++ b/inputFiles/wavePropagation/elas3D_small_base.xml @@ -198,6 +198,7 @@ diff --git a/src/coreComponents/fileIO/Outputs/VTKOutput.cpp b/src/coreComponents/fileIO/Outputs/VTKOutput.cpp index b0b2d9493dd..1e8b4dbbc7c 100644 --- a/src/coreComponents/fileIO/Outputs/VTKOutput.cpp +++ b/src/coreComponents/fileIO/Outputs/VTKOutput.cpp @@ -36,6 +36,7 @@ VTKOutput::VTKOutput( string const & name, m_plotLevel(), m_onlyPlotSpecifiedFieldNames(), m_fieldNames(), + m_levelNames(), m_writer( getOutputDirectory() + '/' + m_plotFileRoot ) { registerWrapper( viewKeysStruct::plotFileRoot, &m_plotFileRoot ). @@ -67,6 +68,10 @@ VTKOutput::VTKOutput( string const & name, setInputFlag( InputFlags::OPTIONAL ). setDescription( "Names of the fields to output. If this attribute is specified, GEOSX outputs all the fields specified by the user, regardless of their `plotLevel`" ); + registerWrapper( viewKeysStruct::levelNames, &m_levelNames ). + setInputFlag( InputFlags::OPTIONAL ). + setDescription( "Names of mesh levels to output." ); + registerWrapper( viewKeysStruct::binaryString, &m_writeBinaryData ). setApplyDefaultValue( m_writeBinaryData ). setInputFlag( InputFlags::OPTIONAL ). @@ -85,6 +90,7 @@ void VTKOutput::postProcessInput() { m_writer.setOutputLocation( getOutputDirectory(), m_plotFileRoot ); m_writer.setFieldNames( m_fieldNames.toViewConst() ); + m_writer.setLevelNames( m_levelNames.toViewConst() ); m_writer.setOnlyPlotSpecifiedFieldNamesFlag( m_onlyPlotSpecifiedFieldNames ); string const fieldNamesString = viewKeysStruct::fieldNames; diff --git a/src/coreComponents/fileIO/Outputs/VTKOutput.hpp b/src/coreComponents/fileIO/Outputs/VTKOutput.hpp index 93abd3e865d..a6f0d613112 100644 --- a/src/coreComponents/fileIO/Outputs/VTKOutput.hpp +++ b/src/coreComponents/fileIO/Outputs/VTKOutput.hpp @@ -94,6 +94,7 @@ class VTKOutput : public OutputBase static constexpr auto outputRegionTypeString = "outputRegionType"; static constexpr auto onlyPlotSpecifiedFieldNames = "onlyPlotSpecifiedFieldNames"; static constexpr auto fieldNames = "fieldNames"; + static constexpr auto levelNames = "levelNames"; } vtkOutputViewKeys; /// @endcond @@ -120,6 +121,9 @@ class VTKOutput : public OutputBase /// array of names of the fields to output array1d< string > m_fieldNames; + /// array of names of the mesh levels to output + array1d< string > m_levelNames; + /// VTK output mode vtk::VTKOutputMode m_writeBinaryData = vtk::VTKOutputMode::BINARY; diff --git a/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.cpp b/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.cpp index b762d23a51f..7d6ab5629d8 100644 --- a/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.cpp +++ b/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.cpp @@ -968,18 +968,27 @@ void VTKPolyDataWriterInterface::writeVtmFile( integer const cycle, { if( meshLevel.isShallowCopy() ) - { return; + + string const & meshLevelName = meshLevel.getName(); + + if( !m_levelNames.empty()) + { + if( m_levelNames.find( meshLevelName ) == m_levelNames.end()) + return; } + string const & meshBodyName = meshBody.getName(); + ElementRegionManager const & elemManager = meshLevel.getElemManager(); - string const meshPath = joinPath( getCycleSubFolder( cycle ), meshBody.getName(), meshLevel.getName() ); + string const meshPath = joinPath( getCycleSubFolder( cycle ), meshBodyName, meshLevelName ); int const mpiSize = MpiWrapper::commSize(); auto addRegion = [&]( ElementRegionBase const & region ) { - std::vector< string > const blockPath{ meshBody.getName(), meshLevel.getName(), region.getCatalogName(), region.getName() }; - string const regionPath = joinPath( meshPath, region.getName() ); + string const & regionName = region.getName(); + std::vector< string > const blockPath{ meshBodyName, meshLevelName, region.getCatalogName(), regionName }; + string const regionPath = joinPath( meshPath, regionName ); for( int i = 0; i < mpiSize; i++ ) { string const dataSetName = getRankFileName( i ); @@ -1085,14 +1094,19 @@ void VTKPolyDataWriterInterface::write( real64 const time, { if( meshLevel.isShallowCopy() ) - { return; + + string const & meshLevelName = meshLevel.getName(); + + if( !m_levelNames.empty()) + { + if( m_levelNames.find( meshLevelName ) == m_levelNames.end()) + return; } ElementRegionManager const & elemManager = meshLevel.getElemManager(); NodeManager const & nodeManager = meshLevel.getNodeManager(); EmbeddedSurfaceNodeManager const & embSurfNodeManager = meshLevel.getEmbSurfNodeManager(); - string const & meshLevelName = meshLevel.getName(); string const & meshBodyName = meshBody.getName(); if( m_requireFieldRegistrationCheck && !m_fieldNames.empty() ) diff --git a/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp b/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp index 6990cfec159..b7ef767a549 100644 --- a/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp +++ b/src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp @@ -144,6 +144,14 @@ class VTKPolyDataWriterInterface m_fieldNames.insert( fieldNames.begin(), fieldNames.end() ); } + /** + * @brief Set the names of the mesh levels to output + * @param[in] levelNames the mesh levels to output + */ + void setLevelNames( arrayView1d< string const > const & levelNames ) + { + m_levelNames.insert( levelNames.begin(), levelNames.end() ); + } /** * @brief Main method of this class. Write all the files for one time step. @@ -307,6 +315,9 @@ class VTKPolyDataWriterInterface /// Names of the fields to output std::set< string > m_fieldNames; + /// Names of the mesh levels to output + std::set< string > m_levelNames; + /// The previousCycle integer m_previousCycle;