Skip to content
Snippets Groups Projects

Feature eigen

Merged Adrien Crovato requested to merge feature_eigen into master
4 files
+ 20
52
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 6
34
@@ -266,20 +266,6 @@ void Newton::buildJac(Eigen::SparseMatrix<double, Eigen::RowMajor> &J)
// Multithread
tbb::spin_mutex mutex;
// List of rows to build Jacobian matrix
std::vector<int> rows(pbl->msh->nodes.size());
for (size_t i = 0; i < rows.size(); ++i)
rows[i] = pbl->msh->nodes[i]->row;
// Kutta condition step 1: equality of normal flux through the wake
// -> add the upper wake node rows to lower wake nodes rows and zero the upper wake node rows
// Nishida Thesis, pp. 29, Eq 2.17
// -> directly assemble upper rows on lower rows
// Galbraith paper
for (auto wake : pbl->wBCs)
tbb::parallel_do(wake->nodMap.begin(), wake->nodMap.end(), [&](std::pair<Node *, Node *> p) {
rows[p.first->row] = p.second->row;
});
// List of triplets to build Jacobian matrix
std::deque<Eigen::Triplet<double>> T;
@@ -470,7 +456,7 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
for (size_t ii = 0; ii < e->nodes.size(); ++ii)
{
Node *nodi = e->nodes[ii];
R(nodi->row) -= beU(ii);
R(rows[nodi->row]) -= beU(ii);
}
}
// Assembly (subsonic)
@@ -478,7 +464,7 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
for (size_t ii = 0; ii < e->nodes.size(); ++ii)
{
Node *nodi = e->nodes[ii];
R(nodi->row) -= be(ii);
R(rows[nodi->row]) -= be(ii);
}
});
// Apply freestream (Neumann) BCs
@@ -493,7 +479,7 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
for (size_t ii = 0; ii < e->nodes.size(); ++ii)
{
Node *nodi = e->nodes[ii];
R(nodi->row) += be(ii);
R(rows[nodi->row]) += be(ii);
}
});
}
@@ -509,25 +495,13 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
for (size_t ii = 0; ii < p.first->nodes.size(); ++ii)
{
Node *nodi = p.first->nodes[ii];
R(nodi->row) += be(ii);
R(rows[nodi->row]) += be(ii);
}
});
}
// Slip BCs are naturally enforced in FEM, hence not applied explicitely
// Kutta condition (3 steps)
// Equality of normal flux through the wake
// -> add the upper wake node rows to lower wake nodes rows and zero the upper wake node rows
// Nishida Thesis, pp. 29, Eq 2.17
// here we do not use Galbraith method (as in J) as it would be slower (rows[] needs to be rebuilt!)
for (auto wake : pbl->wBCs)
{
tbb::parallel_do(wake->nodMap.begin(), wake->nodMap.end(), [&](std::pair<Node *, Node *> p) {
R(p.second->row) += R[p.first->row];
R(p.first->row) = 0.;
});
}
// Equality of velocity norm through the wake
// Kutta condition step 2: equality of velocity norm through the wake
// -> add the Kutta equation on the upper wake node rows
// Nishida Thesis, pp. 29-30, Eq. 2.18
for (auto wake : pbl->wBCs)
@@ -546,7 +520,7 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
}
});
}
// Equality of velocity norm on the Trailing edge (Kutta)
// Kutta condition step 3: equality of velocity norm on the Trailing edge (Kutta)
// -> add the Kutta equation on the upper TE node rows (only works for 2D cases)
// Galbraith paper, pp. 7, Eq. 34
for (auto kutta : pbl->kSCs)
@@ -567,10 +541,8 @@ void Newton::buildRes(Eigen::Map<Eigen::VectorXd> &R)
// Apply Dirichlet BCs
for (auto dBC : pbl->dBCs)
{
for (auto nod : dBC->nodes)
R(nod->row) = 0.;
}
if (verbose > 1)
std::cout << "R (" << R.size() << ")\n";
Loading