Skip to content

Commit c485e08

Browse files
authored
Merge pull request #3542 from lindsayad/add_cope_constraint_rows
Add and use copy_constraint_rows
2 parents 0fc5f5a + 224aef1 commit c485e08

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

include/mesh/mesh_base.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,8 +1863,14 @@ class MeshBase : public ParallelObject
18631863
const std::map<subdomain_id_type, std::string> & get_subdomain_name_map () const
18641864
{ return _block_id_to_name; }
18651865

1866-
typedef std::map<const Node *, std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real>>>
1867-
constraint_rows_type;
1866+
typedef std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real>> constraint_rows_mapped_type;
1867+
typedef std::map<const Node *, constraint_rows_mapped_type> constraint_rows_type;
1868+
1869+
1870+
/**
1871+
* Copy the constraints from the other mesh to this mesh
1872+
*/
1873+
void copy_constraint_rows(const MeshBase & other_mesh);
18681874

18691875
constraint_rows_type & get_constraint_rows()
18701876
{ return _constraint_rows; }
@@ -2162,7 +2168,7 @@ class MeshBase : public ParallelObject
21622168
// constrained in terms of values on spline control nodes.
21632169
//
21642170
// _constraint_rows[constrained_node_id][i].first.first is an
2165-
// element id,
2171+
// element,
21662172
// _constraint_rows[constrained_node_id][i].first.second is the
21672173
// local node id of that element which is a constraining node,
21682174
// _constraint_rows[constrained_node_id][i].second is that node's

src/mesh/distributed_mesh.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ DistributedMesh::DistributedMesh (const DistributedMesh & other_mesh) :
152152
_next_free_unpartitioned_elem_id(this->n_processors())
153153
{
154154
this->copy_nodes_and_elements(other_mesh, true);
155+
this->copy_constraint_rows(other_mesh);
155156
_n_nodes = other_mesh.n_nodes();
156157
_n_elem = other_mesh.n_elem();
157158
_max_node_id = other_mesh.max_node_id();
@@ -195,6 +196,7 @@ DistributedMesh::DistributedMesh (const UnstructuredMesh & other_mesh) :
195196
_next_free_unpartitioned_elem_id(this->n_processors())
196197
{
197198
this->copy_nodes_and_elements(other_mesh, true);
199+
this->copy_constraint_rows(other_mesh);
198200

199201
auto & this_boundary_info = this->get_boundary_info();
200202
const auto & other_boundary_info = other_mesh.get_boundary_info();

src/mesh/mesh_base.C

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,5 +1925,22 @@ bool MeshBase::nodes_and_elements_equal(const MeshBase & other_mesh) const
19251925
return true;
19261926
}
19271927

1928+
void
1929+
MeshBase::copy_constraint_rows(const MeshBase & other_mesh)
1930+
{
1931+
const auto & other_constraint_rows = other_mesh.get_constraint_rows();
1932+
for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
1933+
{
1934+
const Node * const our_node = this->node_ptr(other_node->id());
1935+
constraint_rows_mapped_type our_node_constraints;
1936+
for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
1937+
{
1938+
const auto & [other_elem, local_node_id] = other_inner_key_pair;
1939+
const Elem * const our_elem = this->elem_ptr(other_elem->id());
1940+
our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
1941+
}
1942+
_constraint_rows[our_node] = std::move(our_node_constraints);
1943+
}
1944+
}
19281945

19291946
} // namespace libMesh

src/mesh/replicated_mesh.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ReplicatedMesh::ReplicatedMesh (const ReplicatedMesh & other_mesh) :
9191
_n_nodes(0), _n_elem(0) // copy_* will increment this
9292
{
9393
this->copy_nodes_and_elements(other_mesh, true);
94+
this->copy_constraint_rows(other_mesh);
9495

9596
auto & this_boundary_info = this->get_boundary_info();
9697
const auto & other_boundary_info = other_mesh.get_boundary_info();
@@ -110,6 +111,7 @@ ReplicatedMesh::ReplicatedMesh (const UnstructuredMesh & other_mesh) :
110111
_n_nodes(0), _n_elem(0) // copy_* will increment this
111112
{
112113
this->copy_nodes_and_elements(other_mesh, true);
114+
this->copy_constraint_rows(other_mesh);
113115

114116
auto & this_boundary_info = this->get_boundary_info();
115117
const auto & other_boundary_info = other_mesh.get_boundary_info();

0 commit comments

Comments
 (0)