Skip to content

Commit 481e525

Browse files
committed
Add constructor for default of enforcement type
Return a pair for the topological neighbor
1 parent e8c737a commit 481e525

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

include/geom/elem.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ class Elem : public ReferenceCountedObject<Elem>,
342342
* boundary, it will return a corresponding element on the opposite
343343
* side, along with the side neigh_side.
344344
*/
345-
const Elem * topological_neighbor_side(const unsigned int i,
346-
const MeshBase & mesh,
347-
const PointLocatorBase & point_locator,
348-
const PeriodicBoundaries * pb,
349-
unsigned int * neigh_side) const;
345+
const std::pair<const Elem *, unsigned int>
346+
topological_neighbor_side(const unsigned int i,
347+
const MeshBase & mesh,
348+
const PointLocatorBase & point_locator,
349+
const PeriodicBoundaries * pb) const;
350350

351351
/**
352352
* \returns \p true if the element \p elem in question is a neighbor or

src/base/periodic_boundary_base.C

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace libMesh
3333

3434
PeriodicBoundaryBase::PeriodicBoundaryBase() :
3535
myboundary(BoundaryInfo::invalid_id),
36-
pairedboundary(BoundaryInfo::invalid_id)
36+
pairedboundary(BoundaryInfo::invalid_id),
37+
_enforcement_type(EnforcementType::STRONG_ENFORCEMENT)
3738
{
3839
}
3940

@@ -42,7 +43,8 @@ PeriodicBoundaryBase::PeriodicBoundaryBase() :
4243
PeriodicBoundaryBase::PeriodicBoundaryBase(const PeriodicBoundaryBase & o) :
4344
myboundary(o.myboundary),
4445
pairedboundary(o.pairedboundary),
45-
variables(o.variables)
46+
variables(o.variables),
47+
_enforcement_type(EnforcementType::STRONG_ENFORCEMENT)
4648
{
4749
// Make a deep copy of _transformation_matrix, if it's not null
4850
if(o._transformation_matrix)

src/geom/elem.C

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,18 +1153,21 @@ const Elem * Elem::topological_neighbor (const unsigned int i,
11531153
}
11541154

11551155

1156-
const Elem *
1156+
const std::pair<const Elem *, unsigned int>
11571157
Elem::topological_neighbor_side(const unsigned int i,
11581158
const MeshBase & mesh,
11591159
const PointLocatorBase & point_locator,
1160-
const PeriodicBoundaries * pb,
1161-
unsigned int * neigh_side) const
1160+
const PeriodicBoundaries * pb) const
11621161
{
11631162
libmesh_assert_less (i, this->n_neighbors());
11641163

11651164
const Elem * neighbor_i = this->neighbor_ptr(i);
11661165
if (neighbor_i != nullptr)
1167-
return neighbor_i;
1166+
{
1167+
unsigned int neighbor_side = neighbor_i->which_neighbor_am_i(this);
1168+
const std::pair<const Elem *, unsigned int> neighbor_and_side (neighbor_i, neighbor_side);
1169+
return neighbor_and_side;
1170+
}
11681171

11691172
if (pb)
11701173
{
@@ -1176,6 +1179,8 @@ Elem::topological_neighbor_side(const unsigned int i,
11761179
for (const auto & id : bc_ids)
11771180
if (pb->boundary(id))
11781181
{
1182+
unsigned int neighbor_side = 0;
1183+
unsigned int * neigh_side = &neighbor_side;
11791184
neighbor_i = pb->neighbor(id, point_locator, this, i, neigh_side);
11801185

11811186
// Since coarse elements do not have more refined
@@ -1184,11 +1189,12 @@ Elem::topological_neighbor_side(const unsigned int i,
11841189
if (neighbor_i)
11851190
while (level() < neighbor_i->level())
11861191
neighbor_i = neighbor_i->parent();
1187-
return neighbor_i;
1192+
const std::pair<const Elem *, unsigned int> neighbor_and_side (neighbor_i, neighbor_side);
1193+
return neighbor_and_side;
11881194
}
11891195
}
1190-
1191-
return nullptr;
1196+
const std::pair<const Elem *, unsigned int> neighbor_and_side (nullptr, 0);
1197+
return neighbor_and_side;
11921198
}
11931199

11941200

0 commit comments

Comments
 (0)