Skip to content

Commit

Permalink
Merge pull request #80 from LLNL/feature/zagaris2/mint-su2-utils
Browse files Browse the repository at this point in the history
SU2 I/O support in Mint
  • Loading branch information
gzagaris committed Aug 29, 2019
2 parents d3d0a83 + 7f42c8d commit 1effebf
Show file tree
Hide file tree
Showing 8 changed files with 818 additions and 5 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
## [Unreleased] - Release date yyyy-mm-dd

### Added
- Added support in Mint for reading and writing an unstructured mesh in the [SU2 Mesh file format].
This includes support for both single and mixed cell type topology unstructured mesh types.

### Removed

Expand Down Expand Up @@ -248,3 +250,5 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
[Version 0.2.9]: https://github.com/LLNL/axom/compare/v0.2.8...v0.2.9

[Scalable Checkpoint Restart (SCR)]: https://computation.llnl.gov/projects/scalable-checkpoint-restart-for-mpi
[SU2 Mesh file format]: https://su2code.github.io/docs/Mesh-File/

2 changes: 2 additions & 0 deletions src/axom/mint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set( mint_headers

## utils
utils/vtk_utils.hpp
utils/su2_utils.hpp
)

set( mint_sources
Expand All @@ -102,6 +103,7 @@ set( mint_sources

## utils
utils/vtk_utils.cpp
utils/su2_utils.cpp
)

################################
Expand Down
18 changes: 13 additions & 5 deletions src/axom/mint/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ set( mint_examples
mint_nbody_solver.cpp
mint_particle_mesh.cpp
mint_rectilinear_mesh.cpp
mint_su2_mesh.cpp
mint_unstructured_mixed_topology_mesh.cpp
mint_unstructured_single_topology_mesh.cpp

user_guide/mint_tutorial.cpp
user_guide/mint_getting_started.cpp
)
Expand All @@ -22,10 +23,17 @@ set( mint_example_dependencies
slic
)

blt_list_append( TO mint_example_dependencies ELEMENTS sidre conduit IF AXOM_MINT_USE_SIDRE )
blt_list_append( TO mint_example_dependencies ELEMENTS raja IF RAJA_FOUND )
blt_list_append( TO mint_example_dependencies ELEMENTS openmp IF ENABLE_OPENMP )
blt_list_append( TO mint_example_dependencies ELEMENTS cuda IF ENABLE_CUDA )
blt_list_append( TO mint_example_dependencies ELEMENTS sidre conduit
IF ${AXOM_MINT_USE_SIDRE} )

blt_list_append( TO mint_example_dependencies ELEMENTS raja
IF ${RAJA_FOUND} )

blt_list_append( TO mint_example_dependencies ELEMENTS openmp
IF ${ENABLE_OPENMP} )

blt_list_append( TO mint_example_dependencies ELEMENTS cuda
IF ${ENABLE_CUDA} )

foreach( example ${mint_examples} )

Expand Down
116 changes: 116 additions & 0 deletions src/axom/mint/examples/mint_su2_mesh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
// other Axom Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)

// Mint includes
#include "axom/mint/mesh/Mesh.hpp" /* for mesh base class */
#include "axom/mint/utils/su2_utils.hpp" /* for su2 i/o routines */
#include "axom/mint/utils/vtk_utils.hpp" /* for vtk i/o routines */

// Slic includes
#include "axom/slic/interface/slic.hpp" /* for slic macros */
#include "axom/slic/streams/GenericOutputStream.hpp" /* logging to terminal */

// C/C++ includes
#include <string> /* for C++ string */
#include <cstring> /* for strcmp() */

/*!
* \file
*
* \brief A simple example that illustrates how to read in an su2 mesh.
*/

//------------------------------------------------------------------------------
// GLOBALS
//------------------------------------------------------------------------------
static struct
{
bool dumpVtk;
std::string file;
} Parameters;

namespace slic = axom::slic;
namespace mint = axom::mint;

//------------------------------------------------------------------------------
// FUNCTION PROTOTYPES
//------------------------------------------------------------------------------
void parse_args( int argc, char** argv );

int main ( int argc, char** argv )
{
// STEP 0: initialize the slic logging environment
slic::initialize();
slic::setLoggingMsgLevel( slic::message::Debug );
slic::addStreamToAllMsgLevels(
new slic::GenericOutputStream( &std::cout, "[<LEVEL>]: <MESSAGE>\n" ) );

// STEP 1: parse command line arguemnts
parse_args( argc, argv );

// STEP 2: read SU2 mesh
SLIC_INFO( "reading file [" << Parameters.file << "]\n" );

mint::Mesh* mesh = nullptr;
int rc = mint::read_su2( Parameters.file, mesh );
SLIC_ERROR_IF( (rc != 0), "Failed to read SU2 file!" );
SLIC_ASSERT( mesh != nullptr );

// STEP 3: print some mesh information
SLIC_INFO( "MESH DIMENSION: " << mesh->getDimension() );
SLIC_INFO( "NUMBER OF NODES: " << mesh->getNumberOfNodes() );
SLIC_INFO( "NUMBER OF CELLS: " << mesh->getNumberOfCells() );
if ( mesh->hasMixedCellTypes() )
{
SLIC_INFO( "MIXED_CELL_TOPOLOGY" );
}
else
{
SLIC_INFO( "SINGLE_CELL_TOPOLOGY" );
}

// STEP 4: dump a corresponding VTK file
if ( Parameters.dumpVtk )
{
std::string vtkFile = Parameters.file + ".vtk";
SLIC_INFO( "generating vtk file [" << vtkFile << "]" );

mint::write_vtk( mesh, vtkFile );
}

// STEP 4: finalize
delete mesh;
slic::flushStreams();
slic::finalize();
return 0;
}

//------------------------------------------------------------------------------
// FUNCTION PROTOTYPE IMPLEMENTATION
//------------------------------------------------------------------------------
void parse_args( int argc, char** argv )
{
Parameters.file = "";
Parameters.dumpVtk = false;

for ( int i=1; i < argc; ++i )
{
if ( strcmp( argv[i], "--file" )==0 )
{
Parameters.file = std::string( argv[ ++i ] );
}
else if ( strcmp(argv[i], "--vtk" )==0 )
{
Parameters.dumpVtk = true;
}

}

SLIC_ERROR_IF( Parameters.file.length() == 0,
"must specify a valid SU2 file." );

}


1 change: 1 addition & 0 deletions src/axom/mint/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set( mint_tests
mint_fem_single_fe.cpp

## util tests
mint_su2_io.cpp
mint_util_write_vtk.cpp
)

Expand Down

0 comments on commit 1effebf

Please sign in to comment.