Branch data Line data Source code
1 : : #include <stddef.h>
2 : : #include <sstream>
3 : :
4 : : #include "util.hpp"
5 : : #include "AMR/AMR_types.hpp"
6 : :
7 : : namespace AMR {
8 : : namespace util {
9 : :
10 : : /**
11 : : * @brief Split a string based on a given delimiter
12 : : *
13 : : * @param s The string to split
14 : : * @param delim The delimiter to use
15 : : * @param elems The vector which will be filled
16 : : */
17 : 0 : void split(const std::string &s, char delim,
18 : : std::vector<std::string> &elems)
19 : : {
20 [ - - ]: 0 : std::stringstream ss;
21 [ - - ]: 0 : ss.str(s);
22 : 0 : std::string item;
23 [ - - ][ - - ]: 0 : while (std::getline(ss, item, delim)) {
[ - - ]
24 [ - - ]: 0 : elems.push_back(item);
25 : : }
26 : 0 : }
27 : :
28 : : /**
29 : : * @brief Build a vector of split strings based on a delmiter
30 : : *
31 : : * @param s The string to split
32 : : * @param delim The delimiter to use
33 : : *
34 : : * @return A vector split by delim. Does not handle empty tokens
35 : : */
36 : 0 : std::vector<std::string> split(const std::string &s, char delim) {
37 : 0 : std::vector<std::string> elems;
38 [ - - ]: 0 : split(s, delim, elems);
39 : 0 : return elems;
40 : 0 : }
41 : :
42 : :
43 : : /**
44 : : * @brief function to find the mid point between two points (nodes)
45 : : *
46 : : * @param edge_node_A First node/point
47 : : * @param edge_node_B Second node/point
48 : : *
49 : : * @return The mid point between the two nodes
50 : : */
51 : 0 : coordinate_t find_mid_point(
52 : : coordinate_t edge_node_A,
53 : : coordinate_t edge_node_B
54 : : )
55 : : {
56 : : coordinate_t mid_point;
57 : :
58 [ - - ]: 0 : for(size_t i = 0; i < DIMENSION; i++)
59 : : {
60 : 0 : mid_point[i] = (edge_node_A[i]+edge_node_B[i])/2.0;
61 : : }
62 : :
63 : 0 : return mid_point;
64 : : }
65 : :
66 : : /**
67 : : * @brief Function to find the mid point between two points (nodes)
68 : : *
69 : : * @param x1 x coord of first point
70 : : * @param y1 y coord of first point
71 : : * @param z1 z coord of first point
72 : : * @param x2 x coord of second point
73 : : * @param y2 y coord of second point
74 : : * @param z2 z coord of second point
75 : : *
76 : : * @return The mid point between the two nodes
77 : : */
78 : 0 : coordinate_t find_mid_point(real_t x1, real_t y1,
79 : : real_t z1, real_t x2, real_t y2, real_t z2)
80 : : {
81 : :
82 : : coordinate_t mid_point;
83 : :
84 : 0 : mid_point[0] = (x1+x2)/2.0;
85 : 0 : mid_point[1] = (y1+y2)/2.0;
86 : 0 : mid_point[2] = (z1+z2)/2.0;
87 : :
88 : 0 : return mid_point;
89 : : }
90 : :
91 : : /*
92 : : real_t jacobian(size_t a, size_t b, size_t c, size_t d)
93 : : {
94 : :
95 : : std::cout << "A: x " << m_x[a] << " y " << m_y[a] << " z " << m_z[a] << std::endl;
96 : : std::cout << "b: x " << m_x[b] << " y " << m_y[b] << " z " << m_z[b] << std::endl;
97 : : std::cout << "c: x " << m_x[c] << " y " << m_y[c] << " z " << m_z[c] << std::endl;
98 : : std::cout << "d: x " << m_x[d] << " y " << m_y[d] << " z " << m_z[d] << std::endl;
99 : :
100 : : const std::array< tk::real, 3 > ba = {{ m_x[b]-m_x[a], m_y[b]-m_y[a], m_z[b]-m_z[a] }};
101 : : const std::array< tk::real, 3 > ca = {{ m_x[c]-m_x[a], m_y[c]-m_y[a], m_z[c]-m_z[a] }};
102 : : const std::array< tk::real, 3 > da = {{ m_x[d]-m_x[a], m_y[d]-m_y[a], m_z[d]-m_z[a] }};
103 : :
104 : : const auto J = tk::triple( ba, ca, da );
105 : :
106 : : return J;
107 : :
108 : : }*/
109 : :
110 : : }
111 : : }
112 : :
|