diff --git a/dart/src/wAssign.cpp b/dart/src/wAssign.cpp index 382827ff84e928506dfd5866037a426abb6ac71d..07c130c35db05d0a26dabd3f0e94891fa04c9c55 100644 --- a/dart/src/wAssign.cpp +++ b/dart/src/wAssign.cpp @@ -77,9 +77,16 @@ void Initial::write(std::ostream &out) const Dirichlet::Dirichlet(std::shared_ptr<tbox::MshData> _msh, int no, int dim, double alpha, double beta, bool pin) : Assign(_msh, no) { f = new F0PsPhiInf(dim, alpha, beta); - // Only retain the first node, so that the DOF associated to this node will be pinned + // Only retain one node, so that the DOF associated to this node will be pinned if (pin) - this->nodes.resize(1); + { + // Pin node with min x min y min z + auto it = std::min_element(nodes.begin(), nodes.end(), [](Node *n1, Node *n2) { + return n1->pos[0] < n2->pos[0] || (n1->pos[0] == n2->pos[0] && n1->pos[1] < n2->pos[1]) || (n1->pos[0] == n2->pos[0] && n1->pos[1] == n2->pos[1] && n1->pos[2] < n2->pos[2]); + }); + nodes.resize(1); + nodes[0] = *it; + } } Dirichlet::Dirichlet(std::shared_ptr<tbox::MshData> _msh, std::string const &name, int dim, double alpha, double beta) : Assign(_msh, name) {