coupled vector neighbor variable #29568
-
Check these boxes if you have followed the posting rules.
QuestionHello, I want to couple a vector variable in an FVKernels. I found a similar discussion at #22473. So, I use the function #pragma once
#include "DGKernel.h"
class DGPoreAdvection : public DGKernel
{
public:
static InputParameters validParams();
DGPoreAdvection(const InputParameters & parameters);
protected:
virtual Real computeQpResidual(Moose::DGResidualType type);
virtual Real computeQpJacobian(Moose::DGJacobianType type);
const VectorVariableValue & _velocity;
const ADVectorVariableValue & _velocity_neighbor;
}; Source #include "DGPoreAdvection.h"
registerMooseObject("MiracleApp", DGPoreAdvection);
InputParameters
DGPoreAdvection::validParams()
{
InputParameters params = DGKernel::validParams();
params.addRequiredCoupledVar("velocity", "the velocity of pore");
return params;
}
DGPoreAdvection::DGPoreAdvection(const InputParameters & parameters)
: DGKernel(parameters),
_velocity(coupledVectorValue("velocity")),
_velocity_neighbor(adCoupledVectorNeighborValue("velocity"))
{
}
Real
DGPoreAdvection::computeQpResidual(Moose::DGResidualType type)
{
Real r = 0.0;
auto average = [](const auto & elem_value, const auto & neighbor_value)
{ return (elem_value + neighbor_value) / 2; };
const auto vdotn =
average(_velocity[_qp], MetaPhysicL::raw_value(_velocity_neighbor[_qp])) * _normals[_qp];
const auto face_u = [&]()
{
if (vdotn >= 0)
return _u[_qp];
else
return _u_neighbor[_qp];
}();
switch (type)
{
case Moose::Element:
r += vdotn * face_u * _test[_i][_qp];
break;
case Moose::Neighbor:
r -= vdotn * face_u * _test_neighbor[_i][_qp];
break;
}
return r;
}
Real
DGPoreAdvection::computeQpJacobian(Moose::DGJacobianType type)
{
Real r = 0.0;
auto average = [](const auto & elem_value, const auto & neighbor_value)
{ return (elem_value + neighbor_value) / 2; };
const auto vdotn =
average(_velocity[_qp], MetaPhysicL::raw_value(_velocity_neighbor[_qp])) * _normals[_qp];
const auto face_u = [&]()
{
if (vdotn >= 0)
return _phi[_j][_qp];
else
return _phi_neighbor[_j][_qp];
}();
switch (type)
{
case Moose::ElementElement:
case Moose::ElementNeighbor:
r += vdotn * face_u * _test[_i][_qp];
break;
case Moose::NeighborElement:
case Moose::NeighborNeighbor:
r -= vdotn * face_u * _test_neighbor[_i][_qp];
break;
}
return r;
} gdb backtrace Thread 1 "miracle-dbg" received signal SIGSEGV, Segmentation fault.
0x00007ffff49c4487 in NeighborCoupleable::coupledNeighborValue (this=0x555556242788, var_name=..., comp=0)
at /home/wang/projects/moose/framework/src/interfaces/NeighborCoupleable.C:33
33 return (_c_is_implicit) ? var->slnNeighbor() : var->slnOldNeighbor();
(gdb) bt
#0 0x00007ffff49c4487 in NeighborCoupleable::coupledNeighborValue (this=0x555556242788, var_name=..., comp=0)
at /home/wang/projects/moose/framework/src/interfaces/NeighborCoupleable.C:33
#1 0x00007ffff338dac3 in DGPoreDiffusion::DGPoreDiffusion (this=0x555556241f40, parameters=...)
at /home/wang/projects/miracle/src/dgkernels/DGPoreDiffusion.C:20
#2 0x00007ffff33927de in std::make_unique<DGPoreDiffusion, InputParameters const&> ()
at /home/wang/miniforge/envs/moose/x86_64-conda-linux-gnu/include/c++/12.3.0/bits/unique_ptr.h:1065
#3 0x00007ffff33925a8 in RegistryEntry<DGPoreDiffusion>::build (this=0x55555564bb20, parameters=...)
at /home/wang/projects/moose/framework/build/header_symlinks/Registry.h:275
#4 0x00007ffff4afd52b in Factory::createUnique (this=0x55555582e530, obj_name=..., name=..., parameters=...,
tid=0, print_deprecated=false) at /home/wang/projects/moose/framework/src/base/Factory.C:101
#5 0x00007ffff5341a96 in Factory::createUnique<DGKernelBase> (this=0x55555582e530, obj_name=..., name=...,
parameters=..., tid=0) at /home/wang/projects/moose/framework/build/header_symlinks/Factory.h:254
#6 0x00007ffff5307247 in Factory::create<DGKernelBase> (this=0x55555582e530, obj_name=..., name=...,
parameters=..., tid=0) at /home/wang/projects/moose/framework/build/header_symlinks/Factory.h:270
#7 0x00007ffff52c322d in NonlinearSystemBase::addDGKernel (this=0x555555cc9540, dg_kernel_name=..., name=...,
parameters=...) at /home/wang/projects/moose/framework/src/systems/NonlinearSystemBase.C:643
#8 0x00007ffff67f557d in FEProblemBase::addDGKernel (this=0x555555ca6580, dg_kernel_name=..., name=...,
parameters=...) at /home/wang/projects/moose/framework/src/problems/FEProblemBase.C:3275
#9 0x00007ffff481eeef in AddDGKernelAction::act (this=0x555555ae38f0)
at /home/wang/projects/moose/framework/src/actions/AddDGKernelAction.C:30
#10 0x00007ffff4813b39 in Action::timedAct (this=0x555555ae38f0)
at /home/wang/projects/moose/framework/src/actions/Action.C:84
#11 0x00007ffff4818af0 in ActionWarehouse::executeActionsWithAction (this=0x55555582dc58, task=...)
at /home/wang/projects/moose/framework/src/actions/ActionWarehouse.C:388
#12 0x00007ffff481859d in ActionWarehouse::executeAllActions (this=0x55555582dc58)
at /home/wang/projects/moose/framework/src/actions/ActionWarehouse.C:346
#13 0x00007ffff4b32eb6 in MooseApp::runInputFile (this=0x55555582d540)
at /home/wang/projects/moose/framework/src/base/MooseApp.C:1123
#14 0x00007ffff4b3ad65 in MooseApp::run (this=0x55555582d540)
at /home/wang/projects/moose/framework/src/base/MooseApp.C:1552
#15 0x0000555555557e94 in Moose::main<MiracleTestApp> (argc=3, argv=0x7fffffffb5f8)
at /home/wang/projects/moose/framework/build/header_symlinks/MooseMain.h:47
#16 0x00005555555576fd in main (argc=3, argv=0x7fffffffb5f8) at /home/wang/projects/miracle/src/main.C:17 I checked many times. The error seems to come from |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello You have to use the functor APIs (see MooseFunctor.h) to couple finite element variables into finite volume. We do not have the right level of support in the coupleable API at the moment Guillaume |
Beta Was this translation helpful? Give feedback.
I have solved it. Thanks.
Maybe I make a stupid error.
The
diffusivity
is a variable value. I write in the input by following