本文整理汇总了C++中MooseVariable::activeOnSubdomain方法的典型用法代码示例。如果您正苦于以下问题:C++ MooseVariable::activeOnSubdomain方法的具体用法?C++ MooseVariable::activeOnSubdomain怎么用?C++ MooseVariable::activeOnSubdomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MooseVariable
的用法示例。
在下文中一共展示了MooseVariable::activeOnSubdomain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
ComputeDiracThread::onElement(const Elem * elem)
{
bool has_dirac_kernels_on_elem = _fe_problem.reinitDirac(elem, _tid);
std::set<MooseVariable *> needed_moose_vars;
if (has_dirac_kernels_on_elem)
{
// Only call reinitMaterials() if one or more DiracKernels has
// actually called getMaterialProperty(). Loop over all the
// DiracKernels and check whether this is the case.
bool need_reinit_materials = false;
{
std::vector<DiracKernel *>::const_iterator
dirac_kernel_it = _sys.getDiracKernelWarehouse(_tid).all().begin(),
dirac_kernel_end = _sys.getDiracKernelWarehouse(_tid).all().end();
for (; dirac_kernel_it != dirac_kernel_end; ++dirac_kernel_it)
{
// If any of the DiracKernels have had getMaterialProperty()
// called, we need to reinit Materials.
if ((*dirac_kernel_it)->getMaterialPropertyCalled())
{
need_reinit_materials = true;
break;
}
}
}
if (need_reinit_materials)
_fe_problem.reinitMaterials(_subdomain, _tid, /*swap_stateful=*/false);
std::vector<DiracKernel *>::const_iterator
dirac_kernel_it = _sys.getDiracKernelWarehouse(_tid).all().begin(),
dirac_kernel_end = _sys.getDiracKernelWarehouse(_tid).all().end();
for (; dirac_kernel_it != dirac_kernel_end; ++dirac_kernel_it)
{
DiracKernel * dirac_kernel = *dirac_kernel_it;
if (dirac_kernel->hasPointsOnElem(elem))
{
if (_jacobian == NULL)
dirac_kernel->computeResidual();
else
{
// Get a list of coupled variables from the FEProblem
std::vector<std::pair<MooseVariable *, MooseVariable *> > & coupling_entries = _fe_problem.couplingEntries(_tid);
// Loop over the list of coupled variable pairs
{
std::vector<std::pair<MooseVariable *, MooseVariable *> >::iterator
var_pair_iter = coupling_entries.begin(),
var_pair_end = coupling_entries.end();
for (; var_pair_iter != var_pair_end; ++var_pair_iter)
{
MooseVariable * ivariable = var_pair_iter->first;
MooseVariable * jvariable = var_pair_iter->second;
// The same check that is in ComputeFullJacobianThread::computeJacobian().
// We only want to call computeOffDiagJacobian() if both
// variables are active on this subdomain...
if (ivariable->activeOnSubdomain(_subdomain) && jvariable->activeOnSubdomain(_subdomain))
{
// FIXME: do we need to prepareShapes for ivariable->number?
dirac_kernel->subProblem().prepareShapes(jvariable->number(), _tid);
dirac_kernel->computeOffDiagJacobian(jvariable->number());
}
}
}
}
}
}
// Note that we do not call swapBackMaterials() here as they were
// never swapped in the first place. This avoids messing up
// stored values of stateful material properties.
}
}
示例2:
void
ComputeDiracThread::onElement(const Elem * elem)
{
bool has_dirac_kernels_on_elem = _fe_problem.reinitDirac(elem, _tid);
std::set<MooseVariable *> needed_moose_vars;
const std::vector<MooseSharedPointer<DiracKernel> > & dkernels = _dirac_kernels.getActiveObjects(_tid);
if (has_dirac_kernels_on_elem)
{
// Only call reinitMaterials() if one or more DiracKernels has
// actually called getMaterialProperty(). Loop over all the
// DiracKernels and check whether this is the case.
bool need_reinit_materials = false;
{
for (std::vector<MooseSharedPointer<DiracKernel> >::const_iterator it = dkernels.begin(); it != dkernels.end(); ++it)
{
// If any of the DiracKernels have had getMaterialProperty()
// called, we need to reinit Materials.
if ((*it)->getMaterialPropertyCalled())
{
need_reinit_materials = true;
break;
}
}
}
if (need_reinit_materials)
_fe_problem.reinitMaterials(_subdomain, _tid, /*swap_stateful=*/false);
for (std::vector<MooseSharedPointer<DiracKernel> >::const_iterator it = dkernels.begin(); it != dkernels.end(); ++it)
{
MooseSharedPointer<DiracKernel> dirac_kernel = *it;
if (dirac_kernel->hasPointsOnElem(elem))
{
if (_jacobian == NULL)
dirac_kernel->computeResidual();
else
{
// Get a list of coupled variables from the SubProblem
std::vector<std::pair<MooseVariable *, MooseVariable *> > & coupling_entries =
dirac_kernel->subProblem().assembly(_tid).couplingEntries();
// Loop over the list of coupled variable pairs
{
std::vector<std::pair<MooseVariable *, MooseVariable *> >::iterator
var_pair_iter = coupling_entries.begin(),
var_pair_end = coupling_entries.end();
for (; var_pair_iter != var_pair_end; ++var_pair_iter)
{
MooseVariable * ivariable = var_pair_iter->first;
MooseVariable * jvariable = var_pair_iter->second;
// A variant of the check that is in
// ComputeFullJacobianThread::computeJacobian(). We
// only want to call computeOffDiagJacobian() if both
// variables are active on this subdomain, and the
// off-diagonal variable actually has dofs.
if (dirac_kernel->variable().number() == ivariable->number()
&& ivariable->activeOnSubdomain(_subdomain)
&& jvariable->activeOnSubdomain(_subdomain)
&& (jvariable->numberOfDofs() > 0))
{
dirac_kernel->subProblem().prepareShapes(jvariable->number(), _tid);
dirac_kernel->computeOffDiagJacobian(jvariable->number());
}
}
}
}
}
}
// Note that we do not call swapBackMaterials() here as they were
// never swapped in the first place. This avoids messing up
// stored values of stateful material properties.
}
}