Skip to content

Commit

Permalink
WIP sideset updater
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Dec 20, 2024
1 parent 5b7a658 commit 6879736
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 3 deletions.
35 changes: 35 additions & 0 deletions framework/include/interfacekernels/InterfaceDiffusionTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//* 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

#include "InterfaceKernel.h"

/**
* DG kernel for interfacing diffusion between two variables on adjacent blocks
*/
class InterfaceDiffusionTest : public InterfaceKernel
{
public:
static InputParameters validParams();

InterfaceDiffusionTest(const InputParameters & parameters);

protected:
virtual Real computeQpResidual(Moose::DGResidualType type) override;
virtual Real computeQpJacobian(Moose::DGJacobianType type) override;

const MaterialProperty<Real> & _D;
const MaterialProperty<Real> & _D_neighbor;

// dislocation velocities
// slip direction and normal element
const MaterialProperty<std::vector<RealVectorValue>> & _slip_direction_edge;
const MaterialProperty<std::vector<RealVectorValue>> & _slip_plane_normalboth;
};
76 changes: 76 additions & 0 deletions framework/src/interfacekernels/InterfaceDiffusionTest.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//* 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

#include "InterfaceDiffusionTest.h"

registerMooseObject("MooseApp", InterfaceDiffusionTest);

InputParameters
InterfaceDiffusionTest::validParams()
{
InputParameters params = InterfaceKernel::validParams();
params.addParam<MaterialPropertyName>("D", "D", "The diffusion coefficient.");
params.addParam<MaterialPropertyName>(
"D_neighbor", "D_neighbor", "The neighboring diffusion coefficient.");
params.addClassDescription(
"The kernel is utilized to establish flux equivalence on an interface for variables.");
return params;
}

InterfaceDiffusionTest::InterfaceDiffusionTest(const InputParameters & parameters)
: InterfaceKernel(parameters),
_D(getMaterialProperty<Real>("D")),
_D_neighbor(getNeighborMaterialProperty<Real>("D_neighbor")),
_slip_direction_edge(getMaterialProperty<std::vector<RealVectorValue>>("slip_direction_edge")),
_slip_plane_normalboth(
getMaterialProperty<std::vector<RealVectorValue>>("slip_plane_normalboth"))
{
}

Real
InterfaceDiffusionTest::computeQpResidual(Moose::DGResidualType type)
{
Real r = 0;

switch (type)
{
case Moose::Element:
r = _test[_i][_qp] * -_D_neighbor[_qp] * _grad_neighbor_value[_qp] * _normals[_qp];
break;

case Moose::Neighbor:
r = _test_neighbor[_i][_qp] * _D[_qp] * _grad_u[_qp] * _normals[_qp];
break;
}

return r;
}

Real
InterfaceDiffusionTest::computeQpJacobian(Moose::DGJacobianType type)
{
Real jac = 0;

switch (type)
{
case Moose::ElementElement:
case Moose::NeighborNeighbor:
break;

case Moose::NeighborElement:
jac = _test_neighbor[_i][_qp] * _D[_qp] * _grad_phi[_j][_qp] * _normals[_qp];
break;

case Moose::ElementNeighbor:
jac = _test[_i][_qp] * -_D_neighbor[_qp] * _grad_phi_neighbor[_j][_qp] * _normals[_qp];
break;
}

return jac;
}
12 changes: 9 additions & 3 deletions framework/src/meshmodifiers/SidesetAroundSubdomainUpdater.C
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,16 @@ SidesetAroundSubdomainUpdater::finalize()
{
for (const auto & [elem_id, side] : sent_data)
{
_boundary_info.remove_side(mesh.elem_ptr(elem_id), side, _boundary_id);
// delete boundaries using parents
auto elem_ptr = mesh.elem_ptr(elem_id)->level() > 0 ? mesh.elem_ptr(elem_id)->parent()
: mesh.elem_ptr(elem_id);
_boundary_info.remove_side(elem_ptr, side, _boundary_id);
if (_displaced_boundary_info)
_displaced_boundary_info->remove_side(
displaced_mesh->elem_ptr(elem_id), side, _boundary_id);
_displaced_boundary_info->remove_side((displaced_mesh->elem_ptr(elem_id)->level() > 0)
? displaced_mesh->elem_ptr(elem_id)->parent()
: displaced_mesh->elem_ptr(elem_id),
side,
_boundary_id);
}
};

Expand Down

0 comments on commit 6879736

Please sign in to comment.