-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Solver] Semi-implicit Navier-Stokes solver #681
Changes from all commits
1c8caac
32aa0f4
0705b03
96349e4
d76a013
2615f21
6975f03
1618d47
c43daff
63b2483
47eec5a
55b887b
161d8f4
56ac0c2
14b7eea
e0ddac0
cf21e40
a99ad6a
953c9da
8ec176c
8552f8b
fe75ce9
3bb5e2e
1d490eb
4f412ed
f875118
1d52272
1378824
c69acfa
290d53a
5eabcdc
94a6fba
82d4a9f
2280ff7
356ceab
a5ac395
71c60b3
c4ca0ae
fc03f99
5a54f43
e156c26
211bb84
d5f101d
b2955e6
d1b8d91
0c880f3
a9889eb
473fa0c
32eec61
d4e6744
ac9dbd2
1b877d1
921e00c
d59d84a
89e1fbb
7fff2ae
23323d9
998629b
132d1e6
b087eca
337504e
992e983
78a77d8
2696abe
5eeecaa
bba0ec9
266e16c
a24fb37
458891f
0a656dc
9277579
c210996
ad1f83e
f3ebc7e
6cf5e7d
424bd60
bf7d687
17d8332
60b501c
35ef202
c0b3250
d444b84
4c8813f
b8d693b
7e07053
3f06493
81c5426
13692de
acc7d54
f8fa3e9
766991a
965b3fd
d73a5f0
48b56c6
b38c3c2
76a7e0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,7 +412,7 @@ inline Eigen::Matrix<double, 2, 1> mpm::Cell<2>::local_coordinates_point( | |
if (indices.size() == 3) { | ||
// 2 0 | ||
// |\ | ||
// | \ | ||
// | \ | ||
// c | \ b | ||
// | \ | ||
// | \ | ||
|
@@ -844,3 +844,107 @@ template <unsigned Tdim> | |
inline unsigned mpm::Cell<Tdim>::previous_mpirank() const { | ||
return this->previous_mpirank_; | ||
} | ||
|
||
//! Map cell volume to nodes | ||
template <unsigned Tdim> | ||
bool mpm::Cell<Tdim>::map_cell_volume_to_nodes(unsigned phase) { | ||
bool status = true; | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to use exception handling here, instead, use assert. A failure here will give incorrect results, so this should fail. |
||
// Check if cell volume is set | ||
if (volume_ == std::numeric_limits<double>::lowest()) | ||
this->compute_volume(); | ||
|
||
for (unsigned i = 0; i < nodes_.size(); ++i) { | ||
nodes_[i]->update_volume(true, phase, volume_ / nnodes_); | ||
} | ||
|
||
} catch (std::exception& exception) { | ||
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what()); | ||
status = false; | ||
} | ||
return status; | ||
} | ||
|
||
//! Return local node indices | ||
template <unsigned Tdim> | ||
Eigen::VectorXi mpm::Cell<Tdim>::local_node_indices() { | ||
Eigen::VectorXi indices; | ||
try { | ||
indices.resize(nodes_.size()); | ||
indices.setZero(); | ||
unsigned node_idx = 0; | ||
for (auto node_itr = nodes_.cbegin(); node_itr != nodes_.cend(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this be the same for both standard linear and GIMP elements? |
||
++node_itr) { | ||
indices(node_idx) = (*node_itr)->active_id(); | ||
node_idx++; | ||
} | ||
} catch (std::exception& exception) { | ||
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what()); | ||
} | ||
return indices; | ||
} | ||
|
||
//! Initialise element matrix | ||
template <unsigned Tdim> | ||
bool mpm::Cell<Tdim>::initialise_element_matrix() { | ||
bool status = true; | ||
if (this->status()) { | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need an exception block |
||
// Initialse Laplacian matrix (NxN) | ||
laplacian_matrix_.resize(nnodes_, nnodes_); | ||
laplacian_matrix_.setZero(); | ||
|
||
// Initialse poisson RHS matrix (Nx(N*Tdim)) | ||
poisson_right_matrix_.resize(nnodes_, nnodes_ * Tdim); | ||
poisson_right_matrix_.setZero(); | ||
|
||
// Initialse correction RHS matrix (NxTdim) | ||
correction_matrix_.resize(nnodes_, nnodes_ * Tdim); | ||
correction_matrix_.setZero(); | ||
|
||
} catch (std::exception& exception) { | ||
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what()); | ||
status = false; | ||
} | ||
} | ||
return status; | ||
} | ||
|
||
//! Compute local matrix of laplacian | ||
template <unsigned Tdim> | ||
void mpm::Cell<Tdim>::compute_local_laplacian( | ||
const Eigen::MatrixXd& grad_shapefn, double pvolume, | ||
double multiplier) noexcept { | ||
|
||
std::lock_guard<std::mutex> guard(cell_mutex_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use mutex lock and unlock |
||
laplacian_matrix_ += | ||
grad_shapefn * grad_shapefn.transpose() * multiplier * pvolume; | ||
} | ||
|
||
//! Compute local poisson RHS matrix | ||
//! Used in poisson equation RHS for Navier Stokes solver | ||
template <unsigned Tdim> | ||
void mpm::Cell<Tdim>::compute_local_poisson_right( | ||
const Eigen::VectorXd& shapefn, const Eigen::MatrixXd& grad_shapefn, | ||
double pvolume, double multiplier) noexcept { | ||
|
||
std::lock_guard<std::mutex> guard(cell_mutex_); | ||
for (unsigned i = 0; i < Tdim; i++) { | ||
poisson_right_matrix_.block(0, i * nnodes_, nnodes_, nnodes_) += | ||
shapefn * grad_shapefn.col(i).transpose() * multiplier * pvolume; | ||
} | ||
} | ||
|
||
//! Compute local correction matrix | ||
//! Used to compute corrector of nodal velocity for Navier Stokes solver | ||
template <unsigned Tdim> | ||
void mpm::Cell<Tdim>::compute_local_correction_matrix( | ||
const Eigen::VectorXd& shapefn, const Eigen::MatrixXd& grad_shapefn, | ||
double pvolume) noexcept { | ||
|
||
std::lock_guard<std::mutex> guard(cell_mutex_); | ||
for (unsigned i = 0; i < Tdim; i++) { | ||
correction_matrix_.block(0, i * nnodes_, nnodes_, nnodes_) += | ||
shapefn * grad_shapefn.col(i).transpose() * pvolume; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make all unaltered functions as const and add inline when appropriate?