Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO: filter mesh levels for VTK #2723

Merged
merged 19 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@

<VTK
name="vtkOutput"
plotLevel="3"/>
levelNames="{ FE1 }"
plotLevel="3"/>

<!-- output the displacement values to a file named displacement_history.hdf5 -->
<TimeHistory
Expand Down
1 change: 1 addition & 0 deletions inputFiles/wavePropagation/elas3D_DAS_smoke.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<Outputs>
<VTK
name="vtkOutput"
levelNames="{ FE1 }"
plotLevel="3"/>
<Restart
name="restartOutput"/>
Expand Down
1 change: 1 addition & 0 deletions inputFiles/wavePropagation/elas3D_small_base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<!-- output all the mesh values registered with a plot level LEVEL_0, LEVEL_1, LEVEL_2, LEVEL_3 -->
<VTK
name="vtkOutput"
levelNames="{ FE1 }"
plotLevel="3"/>

<!-- output the pressure values to a file named pressure_history.hdf5 -->
Expand Down
2 changes: 1 addition & 1 deletion integratedTests
Submodule integratedTests updated 990 files
6 changes: 6 additions & 0 deletions src/coreComponents/fileIO/Outputs/VTKOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ VTKOutput::VTKOutput( string const & name,
m_plotLevel(),
m_onlyPlotSpecifiedFieldNames(),
m_fieldNames(),
m_levelNames(),
m_writer( getOutputDirectory() + '/' + m_plotFileRoot )
{
enableLogLevelInput();
Expand Down Expand Up @@ -70,6 +71,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 ).
Expand All @@ -88,6 +93,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;
Expand Down
4 changes: 4 additions & 0 deletions src/coreComponents/fileIO/Outputs/VTKOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 (an empty array means all levels are saved)
array1d< string > m_levelNames;

/// VTK output mode
vtk::VTKOutputMode m_writeBinaryData = vtk::VTKOutputMode::BINARY;

Expand Down
28 changes: 22 additions & 6 deletions src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,14 +1156,24 @@ 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;
}
tbeltzun marked this conversation as resolved.
Show resolved Hide resolved

string const & meshBodyName = meshBody.getName();

ElementRegionManager const & elemManager = meshLevel.getElemManager();

ParticleManager const & particleManager = meshLevel.getParticleManager();

string const meshPath = joinPath( getCycleSubFolder( cycle ), meshBody.getName(), meshLevel.getName() );
string const meshPath = joinPath( getCycleSubFolder( cycle ), meshBodyName, meshLevelName );

int const mpiSize = MpiWrapper::commSize();

auto addElementRegion = [&]( ElementRegionBase const & region )
Expand All @@ -1180,8 +1190,9 @@ void VTKPolyDataWriterInterface::writeVtmFile( integer const cycle,

auto addParticleRegion = [&]( ParticleRegionBase 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 );
Expand Down Expand Up @@ -1290,15 +1301,20 @@ 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;
}
tbeltzun marked this conversation as resolved.
Show resolved Hide resolved

ElementRegionManager const & elemManager = meshLevel.getElemManager();
ParticleManager const & particleManager = meshLevel.getParticleManager();
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() )
Expand Down
11 changes: 11 additions & 0 deletions src/coreComponents/fileIO/vtk/VTKPolyDataWriterInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,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 (an empty array means all levels are saved)
*/
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.
Expand Down Expand Up @@ -318,6 +326,9 @@ class VTKPolyDataWriterInterface
/// Names of the fields to output
std::set< string > m_fieldNames;

/// Names of the mesh levels to output (an empty array means all levels are saved)
std::set< string > m_levelNames;

/// The previousCycle
integer m_previousCycle;

Expand Down
1 change: 1 addition & 0 deletions src/coreComponents/schema/docs/VTK.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Name Type Default Description
childDirectory string Child directory path
fieldNames groupNameRef_array {} Names of the fields to output. If this attribute is specified, GEOSX outputs all the fields specified by the user, regardless of their `plotLevel`
format geos_vtk_VTKOutputMode binary Output data format. Valid options: ``binary``, ``ascii``
levelNames string_array {} Names of mesh levels to output.
logLevel integer 0 Log level
name groupName required A name is required for any non-unique nodes
onlyPlotSpecifiedFieldNames integer 0 If this flag is equal to 1, then we only plot the fields listed in `fieldNames`. Otherwise, we plot all the fields with the required `plotLevel`, plus the fields listed in `fieldNames`
Expand Down
2 changes: 2 additions & 0 deletions src/coreComponents/schema/schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,8 @@ the relative residual norm satisfies:
<xsd:attribute name="fieldNames" type="groupNameRef_array" default="{}" />
<!--format => Output data format. Valid options: ``binary``, ``ascii``-->
<xsd:attribute name="format" type="geos_vtk_VTKOutputMode" default="binary" />
<!--levelNames => Names of mesh levels to output.-->
<xsd:attribute name="levelNames" type="string_array" default="{}" />
<!--logLevel => Log level-->
<xsd:attribute name="logLevel" type="integer" default="0" />
<!--onlyPlotSpecifiedFieldNames => If this flag is equal to 1, then we only plot the fields listed in `fieldNames`. Otherwise, we plot all the fields with the required `plotLevel`, plus the fields listed in `fieldNames`-->
Expand Down