Commit 0c7d2b57 authored by incardon's avatar incardon

VTK adding folder for vtk test and documentation

parent 8038508e
SUBDIRS = src
SUBDIRS = src vtk
bin_PROGRAMS =
\ No newline at end of file
bin_PROGRAMS =
......@@ -91,6 +91,79 @@ IMMDX_LIB_METIS([],[echo "Cannot detect metis, use the --with-metis option if it
INCLUDES_PATH+="-I. -Isrc/config/ -I../openfpm_io/src -I../openfpm_data/src -I../openfpm_devices/src -I../openfpm_vcluster/src/"
###### Check for se-class1
AC_MSG_CHECKING(whether to build with security enhancement class1)
se_class1=no
AC_ARG_ENABLE(se-class1,
AC_HELP_STRING(
[--enable-se-class1],
[enable security enhancement class1]
),
se_class1="$enableval"
)
AC_MSG_RESULT($se_class1)
if test x"$se_class1" = x"yes"; then
AC_DEFINE([SE_CLASS1],[],[Security enhancement class 1])
fi
###### Check for se-class 2
AC_MSG_CHECKING(whether to build with security enhancement class 2)
se_class2=no
AC_ARG_ENABLE(se-class2,
AC_HELP_STRING(
[--enable-se-class2],
[enable security enhancement class 2]
),
se_class2="$enableval"
)
AC_MSG_RESULT($se_class2)
if test x"$se_class2" = x"yes"; then
AC_DEFINE([SE_CLASS2],[],[Security enhancement class 2])
fi
###### Check for se-class 3
AC_MSG_CHECKING(whether to build with security enhancement class 3)
se_class3=no
AC_ARG_ENABLE(se-class3,
AC_HELP_STRING(
[--enable-se-class3],
[enable security enhancement class 3]
),
se_class3="$enableval"
)
AC_MSG_RESULT($se_class3)
if test x"$se_class3" = x"yes"; then
AC_DEFINE([SE_CLASS3],[],[Security enhancement class 3])
fi
###### Check for action on error
action_on_e=continue
AC_ARG_WITH([action-on-error],
AS_HELP_STRING([--with-action-on-error=stop,throw,continue],
[specify the action to do in case of error]),
[action_on_e="$withval"],
[action_on_e=continue])
if test x"$action_on_e" = x"stop"; then
AC_DEFINE([STOP_ON_ERROR],[],[If an error occur stop the program])
fi
if test x"$action_on_e" = x"throw"; then
AC_DEFINE([THROW_ON_ERROR],[],[when an error accur continue but avoid unsafe operation])
fi
##### CHECK FOR BOOST ##############
AX_BOOST([1.52],[],[echo "boost not found"
......@@ -124,6 +197,10 @@ else
gpu_support=no
fi
if test x$gpu_support = x"no"; then
CUDA_LIBS=""
CUDA_CFLAGS=""
fi
# Set this conditional if cuda is wanted
......@@ -142,7 +219,7 @@ AC_SUBST(INCLUDES_PATH)
# Checks for library functions.
AC_CONFIG_FILES([Makefile src/Makefile])
AC_CONFIG_FILES([Makefile src/Makefile vtk/Makefile ])
AC_OUTPUT
echo ""
echo "***********************************"
......@@ -162,6 +239,21 @@ if [ test x"$debuger" = x"yes" ]; then
else
echo "* debug: no *"
fi
if [ test x"$se_class1" = x"yes" ]; then
echo "* se-class1: yes *"
else
echo "* se-class1: no *"
fi
if [ test x"$se_class2" = x"yes" ]; then
echo "* se-class2: yes *"
else
echo "* se-class2: no *"
fi
if [ test x"$se_class3" = x"yes" ]; then
echo "* se-class3: yes *"
else
echo "* se-class3: no *"
fi
if [ test x"$gpu_support" = x"no" ]; then
echo "* gpu: no *"
else
......
openfpm_data @ c145364a
Subproject commit 20abc8eed3bca0ffc5055c7c8fad6c95a484ffc1
Subproject commit c145364a145d40bd39819f3e8d44054d16e59352
openfpm_io @ a94658c3
Subproject commit d3a6ccf23ab183d35d77317aba70193ac0ca0bc7
Subproject commit a94658c3e4fc0f68fd261e7df39cd2a353bd4682
......@@ -9,6 +9,8 @@
#define CARTDECOMPOSITION_HPP
#include "config.h"
#include "VCluster.hpp"
#include "Graph/CartesianGraphFactory.hpp"
#include "Decomposition.hpp"
#include "Vector/map_vector.hpp"
#include <vector>
......@@ -28,6 +30,17 @@
#include "ie_ghost.hpp"
#include "nn_processor.hpp"
#define CARTDEC_ERROR 2000lu
// Macro that decide what to do in case of error
#ifdef STOP_ON_ERROR
#define ACTION_ON_ERROR() exit(1);
#elif defined(THROW_ON_ERROR)
#define ACTION_ON_ERROR() throw CARTDEC_ERROR;
#else
#define ACTION_ON_ERROR()
#endif
/**
* \brief This class decompose a space into subspaces
*
......@@ -116,14 +129,20 @@ private:
//! Cell-list that store the geometrical information of the local internal ghost boxes
CellList<dim,T,FAST> lgeo_cell;
/*! \brief Constructor, it decompose and distribute the sub-domains across the processors
*
* \param v_cl Virtual cluster, used internally for communications
*
*
*/
void CreateDecomposition(Vcluster & v_cl)
{
#ifdef SE_CLASS1
if (&v_cl == NULL)
{
std::cerr << __FILE__ << ":" << __LINE__ << " error VCluster instance is null, check that you ever initialized it \n";
ACTION_ON_ERROR()
}
#endif
// Calculate the total number of box and and the spacing
// on each direction
// Get the box containing the domain
......@@ -678,6 +697,7 @@ p1[0]<-----+ +----> p2[0]
return bbox;
}
////////////// Functions to get decomposition information ///////////////
/*! \brief Write the decomposition as VTK file
......
LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS)
bin_PROGRAMS = pdata
pdata_SOURCES = main.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp
pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS)
pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -Wno-unused-function
pdata_CFLAGS = $(CUDA_CFLAGS)
pdata_LDADD = $(LINKLIBS) -lmetis
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* CartDecomposition_gen_vtk.hpp
*
* Created on: Aug 28, 2015
* Author: i-bird
*/
#include "Decomposition/CartDecomposition.hpp"
int main(int argc, char ** argv)
{
// Initialize the global VCluster
init_global_v_cluster(&argc,&argv);
// Vcluster
Vcluster & vcl = *global_v_cluster;
//! [Create CartDecomposition vtk gen]
CartDecomposition<2,float> dec(vcl);
// Physical domain
Box<2,float> box({0.0,0.0},{1.0,1.0});
// division on each direction
size_t div[2] = {20,20};
// Define ghost
Ghost<2,float> g(0.01);
// Decompose and write the decomposed graph
dec.setParameters(div,box,g);
// create a ghost border
dec.calculateGhostBoxes();
// Write the decomposition
dec.write("CartDecomposition/out_");
//! [Create CartDecomposition]
delete &vcl;
}
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'Legacy VTK Reader'
dom_boxvtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/CartDecomposition/dom_box.vtk'])
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
renderView1.CameraPosition = [0.5, 0.5, 2.7320508075688776]
renderView1.CameraFocalPoint = [0.5, 0.5, 0.0]
renderView1.CameraParallelScale = 0.5843857695756589
# show data in view
dom_boxvtkDisplay = Show(dom_boxvtk, renderView1)
WriteImage("domain.png")
# change representation type
dom_boxvtkDisplay.SetRepresentationType('Surface With Edges')
WriteImage("domain_decomposed.png")
# create a new 'Legacy VTK Reader'
vtk_partitionvtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/Metis/vtk_partition.vtk'])
idLUT = GetColorTransferFunction('id')
idLUT.RGBPoints = [0.0, 0.231373, 0.298039, 0.752941, 1.5, 0.865003, 0.865003, 0.865003, 3.0, 0.705882, 0.0156863, 0.14902]
idLUT.ScalarRangeInitialized = 1.0
# show data in view
vtk_partitionvtkDisplay = Show(vtk_partitionvtk, renderView1)
# trace defaults for the display properties.
vtk_partitionvtkDisplay.ColorArrayName = ['POINTS', 'id']
vtk_partitionvtkDisplay.LookupTable = idLUT
#changing interaction mode based on data extents
renderView1.CameraPosition = [0.5, 0.5, 2.7320508075688776]
renderView1.CameraFocalPoint = [0.5, 0.5, 0.0]
renderView1.CameraParallelScale = 0.5843857695756589
# show color bar/color legend
vtk_partitionvtkDisplay.SetScalarBarVisibility(renderView1, False)
# create a new 'Transform'
transform1 = Transform(Input=vtk_partitionvtk)
transform1.Transform = 'Transform'
# Properties modified on transform1.Transform
transform1.Transform.Translate = [0.025, 0.025, 0.0]
transform1.Transform.Scale = [1.0, 1.0, 0.0]
# show data in view
transform1Display = Show(transform1, renderView1)
# hide data in view
Hide(vtk_partitionvtk, renderView1)
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'computation'))
# change representation type
transform1Display.SetRepresentationType('Points')
# Properties modified on transform1Display
transform1Display.PointSize = 5.0
# set active source
SetActiveSource(vtk_partitionvtk)
# write decomposed
WriteImage("domain_graph.png")
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'id'))
# change representation type
dom_boxvtkDisplay.SetRepresentationType('Surface')
# write decomposed
WriteImage("domain_graph_decomposed.png")
# create a new 'Legacy VTK Reader'
out_subdomains_0vtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/CartDecomposition/out_subdomains_0.vtk'])
# create a new 'Legacy VTK Reader'
out_subdomains_1vtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/CartDecomposition/out_subdomains_1.vtk'])
# create a new 'Legacy VTK Reader'
out_subdomains_2vtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/CartDecomposition/out_subdomains_2.vtk'])
# create a new 'Legacy VTK Reader'
out_subdomains_3vtk = LegacyVTKReader(FileNames=['/home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/vtk/CartDecomposition/out_subdomains_3.vtk'])
# set active source
#SetActiveSource(out_subdomains_0vtk)
# get color transfer function/color map for 'data'
#dataLUT = GetColorTransferFunction('data')
#dataLUT.RGBPoints = [285.3226244096321, 0.231373, 0.298039, 0.752941, 312.3676762575527, 0.865003, 0.865003, 0.865003, 339.4127281054734, 0.705882, 0.0156863, 0.14902]
#dataLUT.ScalarRangeInitialized = 1.0
# show data in view
out_subdomains_3vtkDisplay = Show(out_subdomains_3vtk, renderView1)
# trace defaults for the display properties.
#out_subdomains_3vtkDisplay.ColorArrayName = ['CELLS', 'data']
#out_subdomains_3vtkDisplay.LookupTable = dataLUT
#out_subdomains_3vtkDisplay.ScalarOpacityUnitDistance = 0.5153778246772277
# show color bar/color legend
#out_subdomains_3vtkDisplay.SetScalarBarVisibility(renderView1, True)
# show data in view
out_subdomains_1vtkDisplay = Show(out_subdomains_1vtk, renderView1)
# trace defaults for the display properties.
#out_subdomains_1vtkDisplay.ColorArrayName = ['CELLS', 'data']
#out_subdomains_1vtkDisplay.LookupTable = dataLUT
#out_subdomains_1vtkDisplay.ScalarOpacityUnitDistance = 0.5153778246772277
# show color bar/color legend
#out_subdomains_1vtkDisplay.SetScalarBarVisibility(renderView1, True)
# show data in view
out_subdomains_2vtkDisplay = Show(out_subdomains_2vtk, renderView1)
# trace defaults for the display properties.
#out_subdomains_2vtkDisplay.ColorArrayName = ['CELLS', 'data']
#out_subdomains_2vtkDisplay.LookupTable = dataLUT
#out_subdomains_2vtkDisplay.ScalarOpacityUnitDistance = 0.5153778246772277
# show color bar/color legend
#out_subdomains_2vtkDisplay.SetScalarBarVisibility(renderView1, True)
# show data in view
out_subdomains_0vtkDisplay = Show(out_subdomains_0vtk, renderView1)
# trace defaults for the display properties.
#out_subdomains_0vtkDisplay.ColorArrayName = ['CELLS', 'data']
#out_subdomains_0vtkDisplay.LookupTable = dataLUT
#out_subdomains_0vtkDisplay.ScalarOpacityUnitDistance = 0.5153778246772277
# show color bar/color legend
#out_subdomains_0vtkDisplay.SetScalarBarVisibility(renderView1, True)
# get opacity transfer function/opacity map for 'data'
#dataPWF = GetOpacityTransferFunction('data')
#dataPWF.Points = [285.3226244096321, 0.0, 0.5, 0.0, 339.4127281054734, 1.0, 0.5, 0.0]
#dataPWF.ScalarRangeInitialized = 1
# turn off scalar coloring
ColorBy(out_subdomains_0vtkDisplay, None)
# set active source
#SetActiveSource(out_subdomains_1vtk)
# turn off scalar coloring
ColorBy(out_subdomains_1vtkDisplay, None)
# turn off scalar coloring
ColorBy(out_subdomains_2vtkDisplay, None)
# set active source
#SetActiveSource(out_subdomains_3vtk)
# turn off scalar coloring
ColorBy(out_subdomains_3vtkDisplay, None)
# change representation type
out_subdomains_3vtkDisplay.SetRepresentationType('Surface With Edges')
# change representation type
out_subdomains_2vtkDisplay.SetRepresentationType('Surface With Edges')
# change representation type
out_subdomains_1vtkDisplay.SetRepresentationType('Surface With Edges')
# change representation type
out_subdomains_0vtkDisplay.SetRepresentationType('Surface With Edges')
# change solid color
out_subdomains_0vtkDisplay.DiffuseColor = [1.0, 0.3333333333333333, 0.0]
# change solid color
out_subdomains_1vtkDisplay.DiffuseColor = [0.6666666666666666, 1.0, 0.0]
# change solid color
out_subdomains_2vtkDisplay.DiffuseColor = [0.0, 0.3333333333333333, 1.0]
# change solid color
out_subdomains_3vtkDisplay.DiffuseColor = [1.0, 1.0, 0.0]
# Properties modified on out_subdomains_0vtkDisplay
out_subdomains_0vtkDisplay.LineWidth = 4.0
# change representation type
out_subdomains_0vtkDisplay.SetRepresentationType('Surface With Edges')
# Properties modified on out_subdomains_1vtkDisplay
out_subdomains_1vtkDisplay.LineWidth = 4.0
# change representation type
out_subdomains_1vtkDisplay.SetRepresentationType('Surface With Edges')
# Properties modified on out_subdomains_2vtkDisplay
out_subdomains_2vtkDisplay.LineWidth = 4.0
# change representation type
out_subdomains_2vtkDisplay.SetRepresentationType('Surface With Edges')
# Properties modified on out_subdomains_3vtkDisplay
out_subdomains_3vtkDisplay.LineWidth = 4.0
# change representation type
out_subdomains_3vtkDisplay.SetRepresentationType('Surface With Edges')
# hide data in view
Hide(dom_boxvtk, renderView1)
WriteImage("domain_subdomain_decomposed.png")
# hide data in view
Hide(transform1, renderView1)
WriteImage("domain_subdomain_decomposed_wg.png")
#Destroy everything
Delete(transform1)
del transform1
Delete(out_subdomains_3vtk)
del out_subdomains_3vtk
Delete(out_subdomains_2vtk)
del out_subdomains_2vtk
Delete(out_subdomains_1vtk)
del out_subdomains_1vtk
Delete(out_subdomains_0vtk)
del out_subdomains_0vtk
Delete(dom_boxvtk)
del dom_boxvtk
Delete(vtk_partitionvtk)
del vtk_partitionvtk
\ No newline at end of file
This diff is collapsed.
LINKLIBS = $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS)
bin_PROGRAMS = cart_dec metis_dec dom_box
cart_dec_SOURCES = CartDecomposition_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp
cart_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
cart_dec_CFLAGS = $(CUDA_CFLAGS)
cart_dec_LDADD = $(LINKLIBS) -lmetis
metis_dec_SOURCES = Metis_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp
metis_dec_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
metis_dec_CFLAGS = $(CUDA_CFLAGS)
metis_dec_LDADD = $(LINKLIBS) -lmetis
dom_box_SOURCES = domain_gen_vtk.cpp ../openfpm_devices/src/memory/HeapMemory.cpp ../openfpm_devices/src/memory/PtrMemory.cpp ../openfpm_vcluster/src/VCluster.cpp ../openfpm_data/src/Memleak_check.cpp
dom_box_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLAGS) -I../src -Wno-unused-function
dom_box_CFLAGS = $(CUDA_CFLAGS)
dom_box_LDADD = $(LINKLIBS)
.cu.o :
$(NVCC) $(NVCCFLAGS) -o $@ -c $<
This diff is collapsed.
/*
* Metis_gen_vtk.hpp
*
* Created on: Aug 29, 2015
* Author: i-bird
*/
#ifndef VTK_METIS_GEN_VTK_CPP_
#define VTK_METIS_GEN_VTK_CPP_
#include "Graph/CartesianGraphFactory.hpp"
#include "Graph/map_graph.hpp"
#include "metis_util.hpp"
#include "SubdomainGraphNodes.hpp"
int main(int argc, char ** argv)
{
CartesianGraphFactory<2,Graph_CSR<nm_v,nm_e>> g_factory;
// Cartesian grid
size_t sz[2] = {20,20};
// Box
Box<2,float> box({0.0,0.0},{1.0,1.0});
// Graph to decompose
Graph_CSR<nm_v,nm_e> g = g_factory.construct<nm_e::communication,float,1,0,1>(sz,box);
// Convert the graph to metis
Metis<Graph_CSR<nm_v,nm_e>> met(g,4);
// decompose
met.decompose<nm_v::id>();
// Write the decomposition
VTKWriter<Graph_CSR<nm_v,nm_e>,GRAPH> vtk(g);
vtk.write("Metis/vtk_partition.vtk");
}
#endif /* VTK_METIS_GEN_VTK_CPP_ */
/*
* domain_vtk_gen.cpp
*
* Created on: Aug 30, 2015
* Author: Pietro Incardona
*/
#include "Space/Shape/Box.hpp"
#include "Vector/map_vector.hpp"
#include "VTKWriter.hpp"
int main(int argc, char ** argv)
{
//! [Output a vector of boxes]
// Physical domain
Box<2,float> box({0.0,0.0},{1.0,1.0});
// Cell
Box<2,float> cell = box;
// division on each direction
size_t div[2] = {20,20};
Point<2,float> p_div({20.0,20.0});
cell /= p_div;
// create 20 cell on each direction
openfpm::vector<Box<2,float>> v_box;
for (size_t i = 0; i <= div[0] ; i++)
{
for (size_t j = 0 ; j <= div[1] ; j++)
{
Point<2,float> p({(float)i,(float)j});
Box<2,float> box = cell * p;
v_box.add(box);
}
}
// write the vector of boxes
VTKWriter<openfpm::vector<Box<2,float>>,VECTOR_BOX> vtk_box1;
vtk_box1.add(v_box);
vtk_box1.write("CartDecomposition/dom_box.vtk");
//! [Output a vector of boxes]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment