diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d88a00fb095a9ae8aa0c2ccc4e486edfef0aed0b..124f6db8f793a05b3bae41bc4462d33f4e297d32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) ########################### Executables -add_executable(numerics DCPSE_op/DCPSE_op_test3d.cpp DCPSE_op/DCPSE_op_test2.cpp DCPSE_op/DCPSE_op_test.cpp main.cpp Matrix/SparseMatrix_unit_tests.cpp interpolation/interpolation_unit_tests.cpp Vector/Vector_unit_tests.cpp Solvers/petsc_solver_unit_tests.cpp FiniteDifference/FDScheme_unit_tests.cpp FiniteDifference/eq_unit_test_3d.cpp FiniteDifference/eq_unit_test.cpp Operators/Vector/vector_dist_operators_unit_tests.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/CudaMemory.cu ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp DCPSE_op/DCPSE_Solver.hpp MatrixAssembler/MatrixAssembler.hpp) +add_executable(numerics DCPSE_op/DCPSE_op_test3d.cpp DCPSE_op/DCPSE_op_test2.cpp DCPSE_op/DCPSE_op_test.cpp main.cpp Matrix/SparseMatrix_unit_tests.cpp interpolation/interpolation_unit_tests.cpp Vector/Vector_unit_tests.cpp Solvers/petsc_solver_unit_tests.cpp FiniteDifference/FDScheme_unit_tests.cpp FiniteDifference/eq_unit_test_3d.cpp FiniteDifference/eq_unit_test.cpp Operators/Vector/vector_dist_operators_unit_tests.cpp ../../openfpm_vcluster/src/VCluster/VCluster.cpp ../../openfpm_devices/src/memory/CudaMemory.cu ../../openfpm_devices/src/memory/HeapMemory.cpp ../../openfpm_devices/src/memory/PtrMemory.cpp ../../openfpm_devices/src/Memleak_check.cpp DCPSE_op/DCPSE_Solver.hpp MatrixAssembler/MatrixAssembler.hpp DCPSE_op/EqnsStruct.hpp) ########################### diff --git a/src/DCPSE_op/DCPSE_op_test.cpp b/src/DCPSE_op/DCPSE_op_test.cpp index ea07731b133d219e86c02bf49de278609b08eab3..9906fdfaecd92e8943f1203d832c4274b50d1fee 100644 --- a/src/DCPSE_op/DCPSE_op_test.cpp +++ b/src/DCPSE_op/DCPSE_op_test.cpp @@ -17,110 +17,18 @@ #include "DCPSE_Solver.hpp" #include "Operators/Vector/vector_dist_operators.hpp" #include "Vector/vector_dist_subset.hpp" - - -//! Specify the general characteristic of system to solve -struct equations { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 1; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -struct equations2d1 { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 2; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -struct equationsp { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 1; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -struct equations2dp { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 2; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - - -//Change accordingly as per test -const bool equations2d1::boundary[] = {NON_PERIODIC, NON_PERIODIC}; -const bool equations::boundary[] = {NON_PERIODIC, NON_PERIODIC}; -const bool equations2dp::boundary[] = {PERIODIC, NON_PERIODIC}; -const bool equationsp::boundary[] = {PERIODIC, NON_PERIODIC}; +#include "EqnsStruct.hpp" //template<typename T> //struct Debug; + + BOOST_AUTO_TEST_SUITE(dcpse_op_suite_tests) BOOST_AUTO_TEST_CASE(dcpse_Active2D) { + equations equation2dp = {}; + equations equationp = {}; const size_t sz[2] = {31, 31}; Box<2, double> box({0, 0}, {10,10}); double Lx=box.getHigh(0); diff --git a/src/DCPSE_op/DCPSE_op_test2.cpp b/src/DCPSE_op/DCPSE_op_test2.cpp index 244136baa334e7d3396808415ddf3b91ec0133d5..8c3426c451b3f47a1ed4448339a3695e2394858a 100644 --- a/src/DCPSE_op/DCPSE_op_test2.cpp +++ b/src/DCPSE_op/DCPSE_op_test2.cpp @@ -17,58 +17,12 @@ #include "DCPSE_Solver.hpp" #include "Operators/Vector/vector_dist_operators.hpp" #include "Vector/vector_dist_subset.hpp" +#include "EqnsStruct.hpp" + //int vector_dist_expression_op<void,void,VECT_COPY_N_TO_N>::i = 0; //int vector_dist_expression_op<void,void,VECT_COPY_1_TO_N>::i = 0; -//! Specify the general characteristic of system to solve -struct equations2 { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 2; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -struct equations1d { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 2; - //! number of fields in the system - static const unsigned int nvar = 1; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -const bool equations2::boundary[] = {NON_PERIODIC, NON_PERIODIC}; -const bool equations1d::boundary[] = {NON_PERIODIC, NON_PERIODIC}; - //template<typename T> //struct Debug; diff --git a/src/DCPSE_op/DCPSE_op_test3d.cpp b/src/DCPSE_op/DCPSE_op_test3d.cpp index a90cb53bfbafbe416a3d201a550fab25df802d0f..467ee70d9c159dcc747e7df8c2f8639c93a35b56 100644 --- a/src/DCPSE_op/DCPSE_op_test3d.cpp +++ b/src/DCPSE_op/DCPSE_op_test3d.cpp @@ -17,57 +17,7 @@ #include "DCPSE_Solver.hpp" #include "Operators/Vector/vector_dist_operators.hpp" #include "Vector/vector_dist_subset.hpp" - -//int vector_dist_expression_op<void,void,VECT_COPY_N_TO_N>::i = 0; -//int vector_dist_expression_op<void,void,VECT_COPY_1_TO_N>::i = 0; - -//! Specify the general characteristic of system to solve -struct equations3d3 { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 3; - //! number of fields in the system - static const unsigned int nvar = 3; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, .. - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -struct equations3d { - //! dimensionaly of the equation ( 3D problem ...) - static const unsigned int dims = 3; - //! number of fields in the system - static const unsigned int nvar = 1; - - //! boundary at X and Y - static const bool boundary[]; - - //! type of space float, double, ... - typedef double stype; - - //! type of base particles - typedef vector_dist<dims, double, aggregate<double>> b_part; - - //! type of SparseMatrix for the linear solver - typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; - - //! type of Vector for the linear solver - typedef Vector<double> Vector_type; -}; - -const bool equations3d::boundary[] = {NON_PERIODIC, NON_PERIODIC}; -const bool equations3d3::boundary[] = {NON_PERIODIC, NON_PERIODIC}; +#include "EqnsStruct.hpp" //template<typename T> diff --git a/src/DCPSE_op/EqnsStruct.hpp b/src/DCPSE_op/EqnsStruct.hpp new file mode 100644 index 0000000000000000000000000000000000000000..1e578f17dc710226e9fc3654a26322bc37f2a016 --- /dev/null +++ b/src/DCPSE_op/EqnsStruct.hpp @@ -0,0 +1,185 @@ +// +// Created by Abhinav Singh on 17.04.20. +// + +#ifndef OPENFPM_PDATA_EQNSSTRUCT_HPP +#define OPENFPM_PDATA_EQNSSTRUCT_HPP + +//! Specify the general characteristic of system to solve +struct equations { + + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims; + //! number of fields in the system + static const unsigned int nvar; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, ... + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + +struct equations* create_equations( int dims, int nvar, bool boundary[]) +{ + struct equations* newEquations = (struct equations*)malloc( sizeof( struct equations ) ); + if( newEquations ) + { + newEquations->dims = a; + newEquations->nvar = b; + newEquations->boundary[] = boundary[]; + } + return newEquations; +} + +void destroy_equations( struct equations* obj ) +{ + if( obj ) + free( obj ); +} + +void print_equations( struct equations* obj ) +{ + if( obj ) + { + std::cout<<("Equation dimension->dims = %d\n"<<obj->dims)<<std::endl; + printf("Equation variables->vars = %d\n"<<obj->vars)<<std::endl; + printf("Equation boundary conditions->vars = %d\n"<<obj->boundary[])<<std::endl; + } +} + + +/* +struct equations2d2 { + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims = 2; + //! number of fields in the system + static const unsigned int nvar = 2; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, ... + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + + +struct equations2d1p { + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims = 2; + //! number of fields in the system + static const unsigned int nvar = 1; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, ... + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + +struct equations2d2p { + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims = 2; + //! number of fields in the system + static const unsigned int nvar = 2; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, ... + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + +const bool equations2d1p::boundary[] = {NON_PERIODIC, NON_PERIODIC}; +const bool equations2d::boundary[] = {NON_PERIODIC, NON_PERIODIC}; +const bool equations2d1p::boundary[] = {PERIODIC, NON_PERIODIC}; +const bool equations2d2p::boundary[] = {PERIODIC, NON_PERIODIC}; + + +struct equations3d3 { + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims = 3; + //! number of fields in the system + static const unsigned int nvar = 3; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, .. + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + +struct equations3d1 { + //! dimensionaly of the equation ( 3D problem ...) + static const unsigned int dims = 3; + //! number of fields in the system + static const unsigned int nvar = 1; + + //! boundary at X and Y + static const bool boundary[]; + + //! type of space float, double, ... + typedef double stype; + + //! type of base particles + typedef vector_dist<dims, double, aggregate<double>> b_part; + + //! type of SparseMatrix for the linear solver + typedef SparseMatrix<double, int, EIGEN_BASE> SparseMatrix_type; + + //! type of Vector for the linear solver + typedef Vector<double> Vector_type; +}; + +const bool equations3d1::boundary[] = {NON_PERIODIC, NON_PERIODIC}; +const bool equations3d3::boundary[] = {NON_PERIODIC, NON_PERIODIC}; +*/ + + + +#endif //OPENFPM_PDATA_EQNSSTRUCT_HPP