-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27810 from oanaoana/ghosting
Ghosting boundaries
- Loading branch information
Showing
8 changed files
with
310 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
modules/heat_transfer/include/relationshipmanagers/GhostBoundary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
// Framework includes | ||
#include "AutomaticMortarGeneration.h" | ||
#include "RelationshipManager.h" | ||
|
||
// libMesh includes | ||
#include "libmesh/mesh_base.h" | ||
|
||
using libMesh::boundary_id_type; | ||
using libMesh::CouplingMatrix; | ||
using libMesh::Elem; | ||
using libMesh::GhostingFunctor; | ||
using libMesh::MeshBase; | ||
using libMesh::processor_id_type; | ||
|
||
/** | ||
* GhostBoundary is used to ghost elements on a boundary. It is | ||
* useful when non-local elements are required for geometric searches or when | ||
* residual objects such as \p GapHeatTransfer require access into nonlocal entries | ||
* in the solution vector corresponding to degrees of freedom from the boundary | ||
* elements | ||
*/ | ||
class GhostBoundary : public RelationshipManager | ||
{ | ||
public: | ||
GhostBoundary(const InputParameters &); | ||
|
||
GhostBoundary(const GhostBoundary & other); | ||
|
||
static InputParameters validParams(); | ||
|
||
virtual void operator()(const MeshBase::const_element_iterator & /*range_begin*/, | ||
const MeshBase::const_element_iterator & /*range_end*/, | ||
processor_id_type p, | ||
map_type & coupled_elements) override; | ||
|
||
virtual std::unique_ptr<GhostingFunctor> clone() const override; | ||
|
||
virtual void redistribute() override { this->mesh_reinit(); } | ||
|
||
std::string getInfo() const override; | ||
|
||
virtual bool operator>=(const RelationshipManager & other) const override; | ||
|
||
protected: | ||
virtual void internalInitWithMesh(const MeshBase &) override; | ||
|
||
/// The boundary for which we will ghost elements | ||
const std::vector<BoundaryName> & _boundary_name; | ||
|
||
/// null matrix for generating full variable coupling | ||
const CouplingMatrix * const _null_mat = nullptr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
modules/heat_transfer/src/relationshipmanagers/GhostBoundary.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
// App includes | ||
#include "GhostBoundary.h" | ||
#include "Executioner.h" | ||
#include "FEProblemBase.h" | ||
#include "MooseApp.h" | ||
|
||
// libMesh includes | ||
#include "libmesh/elem.h" | ||
#include "libmesh/mesh_base.h" | ||
#include "libmesh/boundary_info.h" | ||
|
||
registerMooseObject("HeatTransferApp", GhostBoundary); | ||
|
||
using namespace libMesh; | ||
|
||
InputParameters | ||
GhostBoundary::validParams() | ||
{ | ||
InputParameters params = RelationshipManager::validParams(); | ||
params.addRequiredParam<std::vector<BoundaryName>>("boundary", | ||
"The name of the primary boundary sideset."); | ||
params.addClassDescription("This class constructs a relationship manager system' " | ||
"to communicate ghost elements on a boundary."); | ||
return params; | ||
} | ||
|
||
GhostBoundary::GhostBoundary(const InputParameters & params) | ||
: RelationshipManager(params), _boundary_name(getParam<std::vector<BoundaryName>>("boundary")) | ||
{ | ||
} | ||
|
||
GhostBoundary::GhostBoundary(const GhostBoundary & other) | ||
: RelationshipManager(other), _boundary_name(other._boundary_name) | ||
{ | ||
} | ||
|
||
void | ||
GhostBoundary::internalInitWithMesh(const MeshBase &) | ||
{ | ||
} | ||
|
||
std::string | ||
GhostBoundary::getInfo() const | ||
{ | ||
std::ostringstream oss; | ||
oss << "GhostBoundary"; | ||
return oss.str(); | ||
} | ||
|
||
void | ||
GhostBoundary::operator()(const MeshBase::const_element_iterator & /*range_begin*/, | ||
const MeshBase::const_element_iterator & /*range_end*/, | ||
const processor_id_type p, | ||
map_type & coupled_elements) | ||
{ | ||
// We ask the user to pass boundary names instead of ids to our constraint object. However, We | ||
// are unable to get the boundary ids from boundary names until we've attached the MeshBase object | ||
// to the MooseMesh | ||
const bool generating_mesh = !_moose_mesh->getMeshPtr(); | ||
const auto boundary_ids = generating_mesh ? std::vector<BoundaryID>{Moose::INVALID_BOUNDARY_ID} | ||
: _moose_mesh->getBoundaryIDs(_boundary_name); | ||
|
||
for (const Elem * const elem : _mesh->active_element_ptr_range()) | ||
{ | ||
if (generating_mesh) | ||
{ // We are still generating the mesh, so it's possible we don't even have the right boundary | ||
// ids created yet! So we actually ghost all boundary elements and all lower dimensional | ||
// elements who have parents on a boundary | ||
if (elem->on_boundary()) | ||
coupled_elements.insert(std::make_pair(elem, _null_mat)); | ||
} | ||
else | ||
{ | ||
// We've finished generating our mesh so we can be selective and only ghost elements lying on | ||
// our boundary | ||
const BoundaryInfo & binfo = _mesh->get_boundary_info(); | ||
for (auto side : elem->side_index_range()) | ||
for (auto boundary_id : boundary_ids) | ||
if ((elem->processor_id() != p) && (binfo.has_boundary_id(elem, side, boundary_id))) | ||
{ | ||
coupled_elements.insert(std::make_pair(elem, _null_mat)); | ||
goto countBreak; | ||
} | ||
countBreak:; | ||
} | ||
} | ||
} | ||
|
||
bool | ||
GhostBoundary::operator>=(const RelationshipManager & other) const | ||
{ | ||
if (auto asoi = dynamic_cast<const GhostBoundary *>(&other)) | ||
if (_boundary_name == asoi->_boundary_name && baseGreaterEqual(*asoi)) | ||
return true; | ||
return false; | ||
} | ||
|
||
std::unique_ptr<GhostingFunctor> | ||
GhostBoundary::clone() const | ||
{ | ||
return _app.getFactory().copyConstruct(*this); | ||
} |
64 changes: 64 additions & 0 deletions
64
.../heat_transfer/test/tests/heat_conduction/2d_quadrature_gap_heat_transfer/perfect_split.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[Mesh] | ||
[fmg] | ||
type = FileMeshGenerator | ||
file = 'perfect.cpa.gz' | ||
[] | ||
parallel_type = distributed | ||
[] | ||
|
||
[Variables] | ||
[temp] | ||
[] | ||
[] | ||
|
||
[Kernels] | ||
[hc] | ||
type = HeatConduction | ||
variable = temp | ||
[] | ||
[] | ||
|
||
[BCs] | ||
[left] | ||
type = DirichletBC | ||
variable = temp | ||
boundary = leftleft | ||
value = 300 | ||
[] | ||
[right] | ||
type = DirichletBC | ||
variable = temp | ||
boundary = rightright | ||
value = 400 | ||
[] | ||
[] | ||
|
||
[ThermalContact] | ||
[left_to_right] | ||
secondary = leftright | ||
quadrature = true | ||
primary = rightleft | ||
emissivity_primary = 0 | ||
emissivity_secondary = 0 | ||
variable = temp | ||
type = GapHeatTransfer | ||
[] | ||
[] | ||
|
||
[Materials] | ||
[hcm] | ||
type = HeatConductionMaterial | ||
block = 'left right' | ||
specific_heat = 1 | ||
thermal_conductivity = 1 | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
solve_type = 'PJFNK' | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters