Skip to content

Commit

Permalink
Add FV support for indicators
Browse files Browse the repository at this point in the history
Enable ElementalIndicators to work with FV variables.

Refs idaholab#16069
  • Loading branch information
cpgr committed Nov 18, 2020
1 parent 4553e21 commit 7a7d105
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 16 deletions.
2 changes: 1 addition & 1 deletion framework/include/indicators/ElementIndicator.h
Expand Up @@ -52,7 +52,7 @@ class ElementIndicator : public Indicator,
const MooseArray<Real> & _JxW;
const MooseArray<Real> & _coord;

MooseVariable & _var;
// MooseVariable & _var;

/// Holds the solution at current quadrature points
const VariableValue & _u;
Expand Down
12 changes: 5 additions & 7 deletions framework/src/indicators/ElementIndicator.C
Expand Up @@ -10,7 +10,7 @@
#include "ElementIndicator.h"

#include "Assembly.h"
#include "MooseVariableFE.h"
#include "MooseVariableField.h"
#include "SystemBase.h"

#include "libmesh/threads.h"
Expand Down Expand Up @@ -51,14 +51,12 @@ ElementIndicator::ElementIndicator(const InputParameters & parameters)
_JxW(_assembly.JxW()),
_coord(_assembly.coordTransformation()),

_var(_subproblem.getStandardVariable(_tid, parameters.get<VariableName>("variable"))),

_u(_var.sln()),
_grad_u(_var.gradSln())
_u(mooseVariableField().sln()),
_grad_u(mooseVariableField().gradSln())
{
const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
const std::vector<MooseVariableFieldBase *> & coupled_vars = getCoupledMooseVars();
for (const auto & var : coupled_vars)
addMooseVariableDependency(var);

addMooseVariableDependency(mooseVariable());
addMooseVariableDependency(&mooseVariableField());
}
@@ -0,0 +1,80 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 20
ny = 1
[]

[Variables]
[u]
order = CONSTANT
family = MONOMIAL
fv = true
[]
[]

[Problem]
kernel_coverage_check = false
[]

[Functions]
[solution]
type = ParsedFunction
value = (exp(x)-1)/(exp(1)-1)
[]
[]

[FVKernels]
[diff]
type = FVDiffusion
variable = u
coeff = coeff
[]
[conv]
type = FVAdvection
variable = u
velocity = '1 0 0'
[]
[]

[FVBCs]
[left]
type = FVDirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = FVDirichletBC
variable = u
boundary = right
value = 1
[]
[]

[Materials]
[diff]
type = ADGenericConstantMaterial
prop_names = 'coeff'
prop_values = '1'
[]
[]

[Executioner]
type = Steady
solve_type = NEWTON
[]

[Adaptivity]
[Indicators]
[error]
type = AnalyticalIndicator
variable = u
function = solution
[]
[]
[]

[Outputs]
exodus = true
[]
Binary file not shown.
12 changes: 9 additions & 3 deletions test/tests/indicators/analytical_indicator/tests
@@ -1,13 +1,19 @@
[Tests]
issues = '#1275'
issues = '#1275 #16069'
design = 'AnalyticalIndicator.md'

[./test]
[analytical]
type = 'Exodiff'
input = 'analytical_indicator_test.i'
exodiff = 'analytical_indicator_test_out.e'
scale_refine = 2

requirement = "The system shall include the ability to compute the square of the difference between a solution variable and an analytical function for the purpose of performing automatic mesh adaptivity."
[../]
[]
[analytical_fv]
type = 'Exodiff'
input = 'analytical_indicator_fv.i'
exodiff = 'analytical_indicator_fv_out.e'
requirement = "The system shall include the ability to compute the square of the difference between a FV solution variable and an analytical function for the purpose of performing automatic mesh adaptivity."
[]
[]
@@ -0,0 +1,92 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[u]
order = CONSTANT
family = MONOMIAL
fv = true
[]
[]

[Problem]
kernel_coverage_check = false
[]

[Functions]
[solution]
type = ParsedFunction
value = (exp(x)-1)/(exp(1)-1)
[]
[]

[FVKernels]
[diff]
type = FVDiffusion
variable = u
coeff = coeff
[]
[conv]
type = FVAdvection
variable = u
velocity = '1 0 0'
[]
[]

[FVBCs]
[left]
type = FVDirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = FVDirichletBC
variable = u
boundary = right
value = 1
[]
[]

[Materials]
[diff]
type = ADGenericConstantMaterial
prop_names = 'coeff'
prop_values = '1'
[]
[]

[Executioner]
type = Transient
num_steps = 2
dt = 1
solve_type = NEWTON
[]

[Adaptivity]
marker = marker
max_h_level = 1
[Indicators]
[error]
type = AnalyticalIndicator
variable = u
function = solution
[]
[]
[Markers]
[marker]
type = ErrorFractionMarker
coarsen = 0.1
indicator = error
refine = 0.3
[]
[]
[]

[Outputs]
exodus = true
[]
Binary file not shown.
16 changes: 11 additions & 5 deletions test/tests/markers/error_fraction_marker/tests
Expand Up @@ -2,23 +2,29 @@
design = 'ErrorFractionMarker.md'
issues = '#1301'

[./test]
[test]
type = 'Exodiff'
input = 'error_fraction_marker_test.i'
exodiff = 'error_fraction_marker_test_out.e'
scale_refine = 2

requirement = "The system shall include a means for setting mesh refinement flags based on percent of error for a sorted vector of error values computed for each finite element."
[../]
[]


[./no_clear]
[no_clear]
type = 'Exodiff'
input = 'error_fraction_marker_no_clear_test.i'
exodiff = 'error_fraction_marker_no_clear_test_out.e-s003'
scale_refine = 0

issues = '#9914'
requirement = "The system shall include the ability to use the same error extremes during all calculations of error fraction values during mesh adaptivity."
[../]
[]
[fv]
type = 'Exodiff'
input = 'error_fraction_marker_fv.i'
exodiff = 'error_fraction_marker_fv_out.e-s002'
issues = '#16069'
requirement = "The system shall include a means for setting mesh refinement flags based on percent of error for a sorted vector of error values computed for each finite element using FV variables"
[]
[]

0 comments on commit 7a7d105

Please sign in to comment.