Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mosaic/software/parallel-computing/openfpm/openfpm_io
  • argupta/openfpm_io
2 results
Show changes
Commits on Source (26)
......@@ -40,12 +40,15 @@ set(HDF5_PREFER_PARALLEL TRUE)
set (ENV{BOOST_ROOT} ${BOOST_ROOT})
set (Boost_NO_BOOST_CMAKE OFF)
find_package(Boost 1.72.0 REQUIRED COMPONENTS unit_test_framework iostreams program_options OPTIONAL_COMPONENTS fiber context)
find_package(Boost 1.72.0 REQUIRED COMPONENTS unit_test_framework iostreams program_options system filesystem
OPTIONAL_COMPONENTS fiber context)
find_package(MPI REQUIRED)
find_package(HDF5 REQUIRED)
find_package(TinyObjLoader)
find_package(PETSc)
find_package(OpenMP)
if (NOT CUDA_ON_BACKEND STREQUAL "HIP")
find_package(OpenMP)
endif()
if (CUDA_ON_BACKEND STREQUAL "HIP" AND NOT HIP_FOUND)
find_package(HIP)
endif()
......
......@@ -21,17 +21,19 @@ if ( CUDA_ON_BACKEND STREQUAL "HIP" AND HIP_FOUND )
set_source_files_properties(${CUDA_SOURCES} PROPERTIES LANGUAGE CXX)
hip_add_executable(io main.cpp
MetaParser/MetaParser_unit_test.cpp
${CUDA_SOURCES}
ObjReader/ObjReader_unit_test.cpp)
MetaParser/MetaParser_unit_test.cpp
${CUDA_SOURCES}
ObjReader/ObjReader_unit_test.cpp
CSVReader/tests/CSVReader_unit_test.cpp)
else()
add_executable(io main.cpp
MetaParser/MetaParser_unit_test.cpp
add_executable(io main.cpp
MetaParser/MetaParser_unit_test.cpp
${CUDA_SOURCES}
ObjReader/ObjReader_unit_test.cpp)
ObjReader/ObjReader_unit_test.cpp
CSVReader/tests/CSVReader_unit_test.cpp)
set_property(TARGET io PROPERTY CUDA_ARCHITECTURES OFF)
......@@ -107,13 +109,13 @@ endif()
install(FILES RawReader/RawReader.hpp
RawReader/RawReader_unit_tests.hpp
DESTINATION openfpm_io/include/RawReader
DESTINATION openfpm_io/include/RawReader
COMPONENT OpenFPM)
install(FILES CSVWriter/csv_multiarray.hpp
CSVWriter/CSVWriter.hpp
CSVWriter/is_csv_writable.hpp
DESTINATION openfpm_io/include/CSVWriter/
DESTINATION openfpm_io/include/CSVWriter/
COMPONENT OpenFPM)
install(FILES CSVReader/CSVReader.hpp
......@@ -121,11 +123,11 @@ install(FILES CSVReader/CSVReader.hpp
COMPONENT OpenFPM)
install(FILES GraphMLWriter/GraphMLWriter.hpp
DESTINATION openfpm_io/include/GraphMLWriter
DESTINATION openfpm_io/include/GraphMLWriter
COMPONENT OpenFPM)
install(FILES util/util.hpp util/GBoxes.hpp
DESTINATION openfpm_io/include/util
DESTINATION openfpm_io/include/util
COMPONENT OpenFPM)
install(FILES VTKWriter/VTKWriter.hpp
......@@ -138,11 +140,11 @@ install(FILES VTKWriter/VTKWriter.hpp
VTKWriter/VTKWriter_grids_util.hpp
VTKWriter/VTKWriter_vector_box.hpp
VTKWriter/is_vtk_writable.hpp
DESTINATION openfpm_io/include/VTKWriter/
DESTINATION openfpm_io/include/VTKWriter/
COMPONENT OpenFPM)
install(FILES MetaParser/MetaParser.hpp
DESTINATION openfpm_io/include/MetaParser/
DESTINATION openfpm_io/include/MetaParser/
COMPONENT OpenFPM)
install(FILES HDF5_wr/HDF5_wr.hpp
......@@ -164,7 +166,7 @@ install(FILES util/PathsAndFiles.hpp
COMPONENT OpenFPM)
install(FILES Plot/GoogleChart.hpp Plot/util.hpp
DESTINATION openfpm_io/include/Plot
DESTINATION openfpm_io/include/Plot
COMPONENT OpenFPM)
......
......@@ -113,9 +113,6 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
}
}
// initialize complete grid including ghost layer with -1
init_grid_and_ghost<Phi_0>(grid, -1.0);
// assign pixel values to domain. For each pixel get factor_refinement number of grid points with corresponding value
auto dom = grid.getDomainIterator();
std::vector<BYTE> pixel_line; // one x-line of the image stack which will be read
......
......@@ -3,6 +3,7 @@
*
* Created on: Feb 6, 2016
* Author: i-bird
* Modified pvtp writer by: Abhinav
*/
#ifndef OPENFPM_IO_SRC_VTKWRITER_POINT_SET_HPP_
......@@ -15,6 +16,8 @@
#include <string>
#include "byteswap_portable.hpp"
#include "MetaParser/MetaParser.hpp"
#include <util/PathsAndFiles.hpp>
/*! \brief Store a reference to the vector position
*
......@@ -246,7 +249,7 @@ struct prop_out_v_pvtp
void lastProp()
{
v_out += " <PDataArray type=\"Float32\" Name=\"domain\"/>\n </PPointData>\n";
v_out += " <PDataArray type=\"Float32\" Name=\"domain\"/>\n </PPointData>\n";
}
};
......@@ -619,16 +622,21 @@ public:
* \return true if the write complete successfully
*
*/
bool write_pvtp(std::string file,const openfpm::vector<std::string> & prop_names,size_t n,long int timestamp=-1)
bool write_pvtp(std::string file,const openfpm::vector<std::string> & prop_names,size_t n,long int timestamp=-1,double time=-1)
{
//openfpm::vector< ele_vpp<typename pair::second>> vpp;
// Header for the vtk
create_directory_if_not_exist("VTPDATA",1);
std::string vtk_header;
std::string Name_data;
std::string PpointEnd;
std::string Piece;
vtk_header = "<VTKFile type=\"PPolyData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n <PPolyData>\n <PPointData>\n";
if(time==-1){
vtk_header = "<VTKFile type=\"PPolyData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n <PPolyData>\n <PPointData>\n";
}
else{
vtk_header = "<VTKFile type=\"PPolyData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n <PPolyData>\n <FieldData> \n <DataArray type=\"Float64\" Name=\"TimeValue\" NumberOfTuples=\"1\" format=\"ASCII\">\n "+std::to_string(time)+"\n </DataArray>\n </FieldData>\n <PPointData>\n";
}
prop_out_v_pvtp< ele_vpp<typename pair::second>, typename pair::first::value_type::coord_type> pp(Name_data,prop_names);
boost::mpl::for_each< boost::mpl::range_c<int,0, pair::second::value_type::max_prop> >(pp);
pp.lastProp();
......@@ -637,12 +645,12 @@ public:
if (timestamp==-1) {
for (int i = 0; i < n; i++)
{ Piece += " <Piece Source=\"" + file.substr(0, file.size()) + "_" +std::to_string(i) + ".vtp\"/>\n";}
{ Piece += " <Piece Source=\"./VTPDATA/" + file.substr(0, file.size()) + "_" +std::to_string(i) + ".vtp\"/>\n";}
file += ".pvtp";
}
else{
for (int i = 0; i < n; i++)
{ Piece += " <Piece Source=\"" + file.substr(0, file.size()) + "_" +std::to_string(i) + "_" + std::to_string(timestamp) + ".vtp\"/>\n";}
{ Piece += " <Piece Source=\"./VTPDATA/" + file.substr(0, file.size()) + "_" +std::to_string(i) + "_" + std::to_string(timestamp) + ".vtp\"/>\n";}
file += "_" + std::to_string(timestamp) + ".pvtp";
}
std::string closingFile=" </PPolyData>\n</VTKFile>";
......@@ -744,11 +752,12 @@ public:
std::string closingFile=" </PointData>\n </Piece>\n </PolyData>\n</VTKFile>";
// write the file
std::ofstream ofs(file);
create_directory_if_not_exist("VTPDATA",1);
std::ofstream ofs("VTPDATA/"+file);
// Check if the file is open
if (ofs.is_open() == false)
{std::cerr << "Error cannot create the VTK file: " + file + "\n";}
{std::cerr << "Error cannot create the VTK/VTP file. Maybe the \"VTPDATA\" folder cannot be created.: " + file + "\n";}
ofs << vtk_header << point_prop_header << point_list <<
vertex_prop_header << vertex_list << point_data_header << point_data << closingFile;
......
......@@ -1114,10 +1114,10 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
vtk_v.add(v3ps,v3pp,90);
openfpm::vector<std::string> prp_names;
vtk_v.write_pvtp("vtk_points",prp_names,2);
vtk_v.write("vtk_points.vtp",prp_names);
//auto &v_cl=create_vcluster();
//size_t n=v_cl.size();
vtk_v.write_pvtp("vtk_points",prp_names,2);
#ifndef SE_CLASS3
......@@ -1125,7 +1125,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
bool test = true;
// Check that match
test = compare("vtk_points.vtp","test_data/vtk_points_test.vtp");
test = compare("VTPDATA/vtk_points.vtp","test_data/vtk_points_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
//It just checks generation of the format and not actual data (File names)
......@@ -1143,7 +1143,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp.vtp","test_data/vtk_points_pp_test.vtp");
test = compare("VTPDATA/vtk_points_pp.vtp","test_data/vtk_points_pp_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1160,10 +1160,10 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp_header.vtp","test_data/vtk_points_pp_header_test.vtp");
test = compare("VTPDATA/vtk_points_pp_header.vtp","test_data/vtk_points_pp_header_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
test = compare("vtk_points_pp_header_bin.vtp","test_data/vtk_points_pp_header_bin_test.vtp");
test = compare("VTPDATA/vtk_points_pp_header_bin.vtp","test_data/vtk_points_pp_header_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1226,7 +1226,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_properties )
#ifndef SE_CLASS3
// Check that match
bool test = compare("vtk_points_with_prp_names.vtp","test_data/vtk_points_with_prp_names_test.vtp");
bool test = compare("VTPDATA/vtk_points_with_prp_names.vtp","test_data/vtk_points_with_prp_names_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1285,7 +1285,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_check_out_precision )
#ifndef SE_CLASS3
// Check that match
bool test = compare("vtk_points_with_prp_names_prec_check.vtp","test_data/vtk_points_with_prp_names_prec_check_test.vtp");
bool test = compare("VTPDATA/vtk_points_with_prp_names_prec_check.vtp","test_data/vtk_points_with_prp_names_prec_check_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1391,9 +1391,9 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
bool test = true;
// Check that match
test = compare("vtk_points_bin.vtp","test_data/vtk_points_bin_test.vtp");
test = compare("VTPDATA/vtk_points_bin.vtp","test_data/vtk_points_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
test = compare("vtk_points_bin2.vtp","test_data/vtk_points_bin_test.vtp");
test = compare("VTPDATA/vtk_points_bin2.vtp","test_data/vtk_points_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1407,7 +1407,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_pp_bin.vtp","test_data/vtk_points_pp_bin_test.vtp");
test = compare("VTPDATA/vtk_points_pp_bin.vtp","test_data/vtk_points_pp_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1505,7 +1505,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
bool test = true;
// Check that match
test = compare("vtk_points_2d_bin.vtp","test_data/vtk_points_2d_bin_test.vtp");
test = compare("VTPDATA/vtk_points_2d_bin.vtp","test_data/vtk_points_2d_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......@@ -1519,7 +1519,7 @@ BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
#ifndef SE_CLASS3
// Check that match
test = compare("vtk_points_2d_pp_bin.vtp","test_data/vtk_points_2d_pp_bin_test.vtp");
test = compare("VTPDATA/vtk_points_2d_pp_bin.vtp","test_data/vtk_points_2d_pp_bin_test.vtp");
BOOST_REQUIRE_EQUAL(test,true);
#endif
......
......@@ -100,7 +100,7 @@ static bool check_if_directory_exists(std::string path)
*
* @param path Std::string that contains path including name of the folder that should be created.
*/
static void create_directory_if_not_exist(std::string path)
static void create_directory_if_not_exist(std::string path,bool silent=0)
{
auto & v_cl = create_vcluster();
if (v_cl.rank() == 0)
......@@ -110,7 +110,11 @@ static void create_directory_if_not_exist(std::string path)
boost::filesystem::create_directory(path);
// BOOST_LOG_TRIVIAL(info) << "Created directory with name: " << path;
}
else std::cout << "Folder for current settings ( '" << path << "' ) already exists. New files will be saved to this folder." << std::endl;
else {
if(!silent){
std::cout << "Folder for current settings ( '" << path << "' ) already exists. New files will be saved to this folder." << std::endl;
}
}
// BOOST_LOG_TRIVIAL(info) << "Folder for current settings ( '" << path << "' ) already exists. New files will be saved to this folder.";
}
}
......
......@@ -8,7 +8,7 @@
<PPoints>
<PDataArray type="Float64" Name="Points" NumberOfComponents="3"/>
</PPoints>
<Piece Source="vtk_points_0.vtp"/>
<Piece Source="vtk_points_1.vtp"/>
<Piece Source="./VTPDATA/vtk_points_0.vtp"/>
<Piece Source="./VTPDATA/vtk_points_1.vtp"/>
</PPolyData>
</VTKFile>
\ No newline at end of file