OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
eq.hpp
1/*
2 * eq.hpp
3 *
4 * Created on: Oct 5, 2015
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_EQ_HPP_
9#define OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_EQ_HPP_
10
11#define EQS_FIELD 0
12#define EQS_POS 1
13
14//#define PERIODIC true
15//#define NON_PERIODIC false
16
17#include "util/util_num.hpp"
18#include "Matrix/SparseMatrix.hpp"
19
28template<typename expr1,typename expr2,typename Sys_eqs>
29class Eq
30{
36 template<unsigned int ord=EQS_FIELD> static void value(const grid_key_dx<Sys_eqs::dims> & pos)
37 {
38 if (EQS_FIELD)
39 value_f(pos);
40 else
41 value_s(pos);
42 }
43
49 {
50 return expr1::value_s(it) - expr2::value_s(it);
51 }
52
58 {
59 return expr1::value_s(it) - expr2::value_s(it);
60 }
61};
62
63
64// spatial position + value
65
66template<unsigned int dim,typename T>
67struct pos_val
68{
73 {
74 value = 0.0;
75 }
76
78 T value;
79};
80
81template<unsigned int f, typename Sys_eqs>
82class Field
83{
85
86public:
87
92 static void value(const map_grid & g_map, grid_dist_key_dx<Sys_eqs::dims> & kmap, const grid_sm<Sys_eqs::dims,void> & gs, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
93 {
94 cols[g_map.template get<0>(kmap)*Sys_eqs::nvar + f] += coeff;
95 }
96
101 static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs, const comb<Sys_eqs::dims> (& s_pos)[Sys_eqs::nvar])
102 {
103 return grid_key_dx<Sys_eqs::dims>(s_pos[f]);
104 }
105};
106
108{
109
110};
111
112inline size_t mat_factor(size_t nvar, size_t sz, const size_t ord)
113{
114 return nvar;
115}
116
117#include "mul.hpp"
118#include "Average.hpp"
119#include "Derivative.hpp"
120#include "sum.hpp"
121#include "Laplacian.hpp"
122
123#endif /* OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_EQ_HPP_ */
Equation.
Definition eq.hpp:30
static void value(const grid_key_dx< Sys_eqs::dims > &pos)
Create the row of the Matrix.
Definition eq.hpp:36
static openfpm::vector< cval< typename Sys_eqs::stype > > value_s(grid_key_dx< Sys_eqs::dims > &it)
fill the row
Definition eq.hpp:48
static void value_f(grid_key_dx< Sys_eqs::dims > &it)
fill the row
Definition eq.hpp:57
Definition eq.hpp:83
static void value(const map_grid &g_map, grid_dist_key_dx< Sys_eqs::dims > &kmap, const grid_sm< Sys_eqs::dims, void > &gs, typename Sys_eqs::stype(&spacing)[Sys_eqs::dims], std::unordered_map< long int, typename Sys_eqs::stype > &cols, typename Sys_eqs::stype coeff)
fill the row
Definition eq.hpp:92
Grid key for a distributed grid.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
Declaration grid_sm.
Definition grid_sm.hpp:167
Implementation of 1-D std::vector like structure.
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
Definition eq.hpp:68
pos_val()
Initialize to zero the value.
Definition eq.hpp:72