Skip to content

Commit

Permalink
Add exception checking
Browse files Browse the repository at this point in the history
Add test for converting vector functors
refs idaholab#19420
  • Loading branch information
GiudGiud committed May 26, 2023
1 parent 787dbda commit db3b479
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
84 changes: 84 additions & 0 deletions test/tests/materials/functor_conversion/conversion_vec.i
@@ -0,0 +1,84 @@
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 1
nx = 10
xmax = 2
[]
[subdomain1]
input = gen
type = SubdomainBoundingBoxGenerator
bottom_left = '1.0 0 0'
block_id = 1
top_right = '2.0 1.0 0'
[]
[interface]
input = subdomain1
type = SideSetsBetweenSubdomainsGenerator
primary_block = '0'
paired_block = '1'
new_boundary = 'primary0_interface'
[]
[]

[Variables]
[u]
order = FIRST
family = LAGRANGE_VEC
initial_condition = 2
[]
[]

[AuxVariables]
[v]
order = FIRST
family = MONOMIAL_VEC
initial_condition = 3
[]
[]

[FunctorMaterials]
[block0]
type = GenericVectorFunctorMaterial
block = '0'
prop_names = 'D'
prop_values = '4 3 2'
[]
[block1]
type = GenericVectorFunctorMaterial
block = '1'
prop_names = 'D'
prop_values = '2 1 0'
[]
[]

[Materials]
[convert_to_reg]
type = VectorMaterialFunctorConverter
functors_in = 'D u v'
reg_props_out = 'm1 m3 m4'
outputs = 'exo'
[]
[convert_to_ad]
type = VectorMaterialFunctorConverter
functors_in = 'D u v'
ad_props_out = 'm1a m3a m4a'
outputs = 'exo'
[]
[]

[Executioner]
type = Steady
solve_type = NEWTON
[]

[Problem]
solve = false
[]

[Outputs]
[exo]
type = Exodus
hide = 'u v'
[]
[]
Binary file not shown.
33 changes: 31 additions & 2 deletions test/tests/materials/functor_conversion/tests
@@ -1,11 +1,40 @@
[Tests]
design = 'Materials/MaterialFunctorConverter.md'
design = 'MaterialFunctorConverter.md'
[scalar]
type = 'Exodiff'
input = 'conversion.i'
exodiff = 'conversion_out.e'
exodiff = 'conversion_exo.e'
requirement = "The system shall be able to convert functors to regular (using automatic "
"differentiation or not) material properties."
issues = "#19420"
[]
# Note: Functions are declared as real functors, even functions that return a vector.
# They are excluded from the conversions for now until we find a solution #24502
[vector]
type = 'Exodiff'
input = 'conversion_vec.i'
exodiff = 'conversion_vec_exo.e'
requirement = "The system shall be able to convert vector functors to regular vector material "
"properties."
issues = "#19420"
[]

[exception_checks]
requirement = 'The system shall error'
issues = '#19420'
[ad_and_regular]
type = RunException
input = conversion.i
cli_args = "Materials/convert_to_reg/ad_props_out='m1 m2 m3 m4'"
expect_err = 'We dont support converting functors to both AD and regular material properties'
detail = 'if the user requests conversions to both AD and regular material properties, as this is not supported,'
[]
[wrong_size]
type = RunException
input = conversion.i
cli_args = "Materials/convert_to_reg/reg_props_out='m1 m2 m3'"
expect_err = 'The number of output properties must match the number of input functors'
detail = 'if the user inputs a different number of functors and material properties, as the conversion match one to one, and'
[]
[]
[]

0 comments on commit db3b479

Please sign in to comment.