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

FILTERS: Adding MeshIO reader and writers. #1009

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,57 @@ PYBIND11_MODULE(simplnx, mod)
dataType.value("float64", DataType::float64);
dataType.value("boolean", DataType::boolean);

mod.def(
"convert_np_dtype_to_datatype",
[](const py::dtype& dtype) {
if(dtype.is(py::dtype::of<int8>()))
{
return DataType::int8;
}
if(dtype.is(py::dtype::of<uint8>()))
{
return DataType::uint8;
}
if(dtype.is(py::dtype::of<int16>()))
{
return DataType::int16;
}
if(dtype.is(py::dtype::of<uint16>()))
{
return DataType::uint16;
}
if(dtype.is(py::dtype::of<int32>()))
{
return DataType::int32;
}
if(dtype.is(py::dtype::of<uint32>()))
{
return DataType::uint32;
}
if(dtype.is(py::dtype::of<int64>()))
{
return DataType::int64;
}
if(dtype.is(py::dtype::of<uint64>()))
{
return DataType::uint64;
}
if(dtype.is(py::dtype::of<float32>()))
{
return DataType::float32;
}
if(dtype.is(py::dtype::of<float64>()))
{
return DataType::float64;
}
if(dtype.is(py::dtype::of<bool>()))
{
return DataType::boolean;
}
throw std::invalid_argument("Unable to convert dtype to DataType: Unsupported dtype.");
},
"Convert numpy dtype to simplnx DataType", "dtype"_a);

py::enum_<ArrayHandlingType> arrayHandlingType(mod, "ArrayHandlingType");
arrayHandlingType.value("Copy", ArrayHandlingType::Copy);
arrayHandlingType.value("Move", ArrayHandlingType::Move);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# MeshIO: Read Mesh File

## Group (Subgroup)
Core (IO/Read)

## Description
The `ReadMeshFile` filter uses the Python MeshIO library to read a mesh file into a simplnx geometry.

The following mesh formats are supported by this filter:
+ Abaqus (.inp)
+ Ansys (.msh)
+ Gmsh (.msh)
+ Med (.med)
+ TetGen (.node/.ele)
+ VTK (.vtu)

*NOTE*: This filter makes the assumption (for cell and point data stored inside the mesh file) that the first element in the numpy shape list is the only tuple dimension, and every other shape list element is part of the component dimensions!

## Parameters

### Input Parameters
- **`Input File`** (str): The path to the input mesh file.

### Created Parameters
- **`Created Geometry`** (nx.DataPath): The path to the geometry that will be created.
- **`Vertex Attribute Matrix Name`** (str): The name of the vertex attribute matrix that will be created inside the geometry.
- **`Cell Attribute Matrix Name`** (str): The name of the cell attribute matrix that will be created inside the geometry.
- **`Vertex Array Name`** (str): The name of the vertex array that will be created inside the geometry.
- **`Cell Array Name`** (str): The name of the cell array that will be created inside the geometry.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MeshIO: Write Abaqus File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteAbaqusFile` filter uses the Python MeshIO library to write a simplnx geometry to an Abaqus .inp file.

*Note*: This filter does not support writing cell data or point data to the mesh file.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.

### Output Parameters
- **`Output File`** (str): The path to the output .inp file.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MeshIO: Write Ansys File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteAnsysFile` filter uses the Python MeshIO library to write a simplnx geometry to an Ansys .msh file.

*Note*: This filter does not support writing cell data or point data to the mesh file.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.

### Output Parameters
- **`Output File`** (str): The path to the output .msh file.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MeshIO: Write Gmsh File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteGmshFile` filter uses the Python MeshIO library to write a simplnx geometry to a Gmsh .msh file.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.
- **`Cell Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the cell data arrays to include in the output mesh file.
- **`Point Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the point data arrays to include in the output mesh file.

### Output Parameters
- **`Output File`** (str): The path to the output .msh file.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# MeshIO: Write Med File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteMedFile` filter uses the Python MeshIO library to write a simplnx geometry to a Med .med file.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.
- **`Cell Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the cell data arrays to include in the output mesh file.
- **`Point Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the point data arrays to include in the output mesh file.

### Output Parameters
- **`Output File`** (str): The path to the output .med file.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MeshIO: Write TetGen File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteTetGenFile` filter uses the Python MeshIO library to write a simplnx tetrahedral geometry to TetGen .node and .ele files.

*Note*: Either .node or .ele can be chosen as the output file; the one that is not chosen will also be automatically created.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.
- **`Cell Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the cell data arrays to include in the output mesh file.
- **`Point Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the point data arrays to include in the output mesh file.

### Output Parameters
- **`Output File`** (str): The path to the output .node/.ele file. Regardless of which extension is chosen as the output file, both .node and .ele files will be written to the chosen location with the chosen file name.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MeshIO: Write Vtu File

## Group (Subgroup)
Core (IO/Read)

## Description
The `WriteVtuFile` filter uses the Python MeshIO library to write a simplnx geometry to a VTK .vtu file.

The output file can also be compressed if the user chooses LZMA or ZLIB as the Output Compression Type.

## Parameters

### Input Parameters
- **`Input Geometry`** (nx.DataPath): Specifies the complete path to the input geometry.
- **`Cell Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the cell data arrays to include in the output mesh file.
- **`Point Data Arrays To Write`** (List[nx.DataPath]): List of DataPaths to the point data arrays to include in the output mesh file.

### Output Parameters
- **`Output File`** (str): The path to the output .vtu file.
- **`Output Compression Type`** (int): The compression type to use when writing the output file. The choices are Uncompressed, LZMA, and ZLIB.

## Example Pipelines

## License & Copyright

Please see the description file distributed with this **Plugin**

## DREAM3D-NX Help

If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues) GItHub site where the community of DREAM3D-NX users can help answer your questions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,62 @@
pass
# FILTER_END: ReadPeregrineHDF5File

# FILTER_START: WriteAbaqusFile
try:
from DataAnalysisToolkit.WriteAbaqusFile import WriteAbaqusFile
_filters.append(WriteAbaqusFile)
except ImportError:
pass
# FILTER_END: WriteAbaqusFile

# FILTER_START: WriteAnsysFile
try:
from DataAnalysisToolkit.WriteAnsysFile import WriteAnsysFile
_filters.append(WriteAnsysFile)
except ImportError:
pass
# FILTER_END: WriteAnsysFile

# FILTER_START: WriteMedFile
try:
from DataAnalysisToolkit.WriteMedFile import WriteMedFile
_filters.append(WriteMedFile)
except ImportError:
pass
# FILTER_END: WriteMedFile

# FILTER_START: WriteGmshFile
try:
from DataAnalysisToolkit.WriteGmshFile import WriteGmshFile
_filters.append(WriteGmshFile)
except ImportError:
pass
# FILTER_END: WriteGmshFile

# FILTER_START: WriteTetGenFile
try:
from DataAnalysisToolkit.WriteTetGenFile import WriteTetGenFile
_filters.append(WriteTetGenFile)
except ImportError:
pass
# FILTER_END: WriteTetGenFile

# FILTER_START: WriteVtuFile
try:
from DataAnalysisToolkit.WriteVtuFile import WriteVtuFile
_filters.append(WriteVtuFile)
except ImportError:
pass
# FILTER_END: WriteVtuFile

# FILTER_START: ReadMeshFile
try:
from DataAnalysisToolkit.ReadMeshFile import ReadMeshFile
_filters.append(ReadMeshFile)
except ImportError:
pass
# FILTER_END: ReadMeshFile

import simplnx as nx

class NXDataAnalysisToolkit:
Expand Down
Loading
Loading