From b49d0d0ea927875827d5410fe4808efb2a7908ed Mon Sep 17 00:00:00 2001
From: absingh <absingh@mpi-cbg.de>
Date: Fri, 17 Apr 2020 14:50:18 +0200
Subject: [PATCH] EqnsStruct.cpp

---
 src/CMakeLists.txt               |   2 +-
 src/DCPSE_op/DCPSE_op_test.cpp   | 102 +----------------
 src/DCPSE_op/DCPSE_op_test2.cpp  |  50 +--------
 src/DCPSE_op/DCPSE_op_test3d.cpp |  52 +--------
 src/DCPSE_op/EqnsStruct.hpp      | 185 +++++++++++++++++++++++++++++++
 5 files changed, 194 insertions(+), 197 deletions(-)
 create mode 100644 src/DCPSE_op/EqnsStruct.hpp

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d88a00fb..124f6db8 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 ea07731b..9906fdfa 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 244136ba..8c3426c4 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 a90cb53b..467ee70d 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 00000000..1e578f17
--- /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
-- 
GitLab