Skip to content

Commit 8e7d6c0

Browse files
authored
Merge pull request ITHACA-FV#646 from vressegu/mergeForkRedlum
Merge fork from redlum developpers
2 parents 8052486 + 0b0841d commit 8e7d6c0

81 files changed

Lines changed: 56405 additions & 661 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
115 KB
Loading

src/ITHACA_CORE/EigenFunctions/EigenFunctions.C

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,49 @@ vectorTensorProduct(
121121
const Eigen::Matrix<float, Eigen::Dynamic, 1>& g,
122122
const Eigen::Tensor<float, 3 >& c,
123123
const Eigen::Matrix<float, Eigen::Dynamic, 1>& a);
124+
125+
Eigen::VectorXd repeatElements(Eigen::VectorXd input, int n)
126+
{
127+
if (!(n > 0))
128+
{
129+
Info << "The integer for the EigenFunctions::repeat method must be positive. Aborting" << endl;
130+
abort();
131+
}
132+
else
133+
{
134+
Eigen::VectorXd output(input.size() * n);
135+
for (int i = 0; i < input.size(); i++)
136+
{
137+
for (int r = 0; r < n; r++)
138+
{
139+
output(i * n + r) = input(i);
140+
}
141+
}
142+
return output;
143+
}
144+
}
145+
146+
Eigen::VectorXd reorderVectorFromDim(Eigen::VectorXd input, int dim)
147+
{
148+
if ((input.size() % dim) != 0)
149+
{
150+
Info << "EigenFunctions::reorderVectorFromDim has incompatible vector size " <<
151+
"and reordering dimension. Aborting" << endl;
152+
abort();
153+
}
154+
else
155+
{
156+
Eigen::VectorXd output(input.size());
157+
int n = int(input.size() / dim);
158+
for (int i = 0; i < n; i++)
159+
{
160+
for (int d = 0; d < dim; d++)
161+
{
162+
output(i * dim + d) = input(i + d * dim);
163+
}
164+
}
165+
return output;
166+
}
167+
}
168+
124169
}

src/ITHACA_CORE/EigenFunctions/EigenFunctions.H

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,29 @@ Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> vectorTensorProduct(
249249
const Eigen::Tensor<T, 3 >& c,
250250
const Eigen::Matrix<T, Eigen::Dynamic, 1>& a);
251251

252+
253+
//------------------------------------------------------------------------------
254+
/// @brief Repeat each element n times after themselves
255+
///
256+
/// @details Example: input = (a, b); n = 3
257+
/// output = (a, a, a, b, b, b)
258+
///
259+
/// @param input Eigen::VectorXd
260+
/// @param n int
261+
Eigen::VectorXd repeatElements(Eigen::VectorXd input, int n);
262+
263+
//------------------------------------------------------------------------------
264+
/// @brief Changes the order of the vector's elements given a dimension
265+
///
266+
/// @details Example: input = (a_1, b_1, a_2, b_2, a_3, b_3); dim = 3
267+
/// output = (a_1, a_2, a_3, b_1, b_2, b_3)
268+
/// Typically switch from a component then coordinate order to the opposite
269+
/// as did the change in the Foam2Eigen mapping
270+
///
271+
/// @param input Eigen::VectorXd
272+
/// @param dim int
273+
Eigen::VectorXd reorderVectorFromDim(Eigen::VectorXd input, int dim);
274+
252275
};
253276

254277
template <typename T>

0 commit comments

Comments
 (0)