Skip to content

Commit

Permalink
Merge pull request #12880 from lindsayad/allow-1d-lagrange-vec
Browse files Browse the repository at this point in the history
Allow LAGRANGE_VEC simulations to be performed in 1D
  • Loading branch information
permcody committed Feb 8, 2019
2 parents b387463 + 537dabd commit 7540d36
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 66 deletions.
6 changes: 0 additions & 6 deletions framework/include/bcs/VectorIntegratedBC.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,22 +61,16 @@ class VectorIntegratedBC : public IntegratedBCBase, public MooseVariableInterfac


/// shape function values (in QPs) /// shape function values (in QPs)
const VectorVariablePhiValue & _phi; const VectorVariablePhiValue & _phi;
/// curls of shape functions (in QPs)
const VectorVariablePhiCurl & _curl_phi;


// test functions // test functions


/// test function values (in QPs) /// test function values (in QPs)
const VectorVariableTestValue & _test; const VectorVariableTestValue & _test;
/// curls of test functions (in QPs)
const VectorVariableTestCurl & _curl_test;


// solution variable // solution variable


/// the values of the unknown variable this BC is acting on /// the values of the unknown variable this BC is acting on
const VectorVariableValue & _u; const VectorVariableValue & _u;
/// the curl of the unknown variable this BC is acting on
const VectorVariableCurl & _curl_u;
}; };


#endif /* VECTORINTEGRATEDBC_H */ #endif /* VECTORINTEGRATEDBC_H */
1 change: 1 addition & 0 deletions framework/include/kernels/ADKernel.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
using ADKernelTempl<type, compute_stage>::_assembly; \ using ADKernelTempl<type, compute_stage>::_assembly; \
using ADKernelTempl<type, compute_stage>::_current_elem; \ using ADKernelTempl<type, compute_stage>::_current_elem; \
using ADKernelTempl<type, compute_stage>::_t; \ using ADKernelTempl<type, compute_stage>::_t; \
using ADKernelTempl<type, compute_stage>::_dt; \
using ADKernelTempl<type, compute_stage>::getBlockCoordSystem; \ using ADKernelTempl<type, compute_stage>::getBlockCoordSystem; \
using ADKernelTempl<type, compute_stage>::precalculateResidual; \ using ADKernelTempl<type, compute_stage>::precalculateResidual; \
using ADKernelTempl<type, compute_stage>::prepareVectorTag; \ using ADKernelTempl<type, compute_stage>::prepareVectorTag; \
Expand Down
30 changes: 8 additions & 22 deletions framework/include/kernels/VectorKernel.h
Original file line number Original file line Diff line number Diff line change
@@ -1,16 +1,11 @@
/****************************************************************/ //* This file is part of the MOOSE framework
/* DO NOT MODIFY THIS HEADER */ //* https://www.mooseframework.org
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ //*
/* */ //* All rights reserved, see COPYRIGHT for full restrictions
/* (c) 2010 Battelle Energy Alliance, LLC */ //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
/* ALL RIGHTS RESERVED */ //*
/* */ //* Licensed under LGPL 2.1, please see LICENSE for details
/* Prepared by Battelle Energy Alliance, LLC */ //* https://www.gnu.org/licenses/lgpl-2.1.html
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/


#ifndef VECTORKERNEL_H #ifndef VECTORKERNEL_H
#define VECTORKERNEL_H #define VECTORKERNEL_H
Expand Down Expand Up @@ -60,26 +55,17 @@ class VectorKernel : public KernelBase, public MooseVariableInterface<RealVector
/// gradient of the test function /// gradient of the test function
const VectorVariableTestGradient & _grad_test; const VectorVariableTestGradient & _grad_test;


/// curl of the test function
const VectorVariableTestCurl & _curl_test;

/// the current shape functions /// the current shape functions
const VectorVariablePhiValue & _phi; const VectorVariablePhiValue & _phi;


/// gradient of the shape function /// gradient of the shape function
const VectorVariablePhiGradient & _grad_phi; const VectorVariablePhiGradient & _grad_phi;


/// curl of the shape function
const VectorVariablePhiCurl & _curl_phi;

/// Holds the solution at current quadrature points /// Holds the solution at current quadrature points
const VectorVariableValue & _u; const VectorVariableValue & _u;


/// Holds the solution gradient at current quadrature points /// Holds the solution gradient at current quadrature points
const VectorVariableGradient & _grad_u; const VectorVariableGradient & _grad_u;

/// Holds the solution curl at the current quadrature points
const VectorVariableCurl & _curl_u;
}; };


#endif /* VECTORKERNEL_H */ #endif /* VECTORKERNEL_H */
12 changes: 8 additions & 4 deletions framework/src/base/Assembly.C
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ Assembly::buildVectorFE(FEType type)


_vector_fe[dim][type]->get_phi(); _vector_fe[dim][type]->get_phi();
_vector_fe[dim][type]->get_dphi(); _vector_fe[dim][type]->get_dphi();
_vector_fe[dim][type]->get_curl_phi(); if (type.family == NEDELEC_ONE)
_vector_fe[dim][type]->get_curl_phi();
// Pre-request xyz. We have always computed xyz, but due to // Pre-request xyz. We have always computed xyz, but due to
// recent optimizations in libmesh, we now need to explicity // recent optimizations in libmesh, we now need to explicity
// request it, since apps (Yak) may rely on it being computed. // request it, since apps (Yak) may rely on it being computed.
Expand Down Expand Up @@ -344,7 +345,8 @@ Assembly::buildVectorFaceFE(FEType type)


_vector_fe_face[dim][type]->get_phi(); _vector_fe_face[dim][type]->get_phi();
_vector_fe_face[dim][type]->get_dphi(); _vector_fe_face[dim][type]->get_dphi();
_vector_fe_face[dim][type]->get_curl_phi(); if (type.family == NEDELEC_ONE)
_vector_fe_face[dim][type]->get_curl_phi();
} }
} }


Expand All @@ -371,7 +373,8 @@ Assembly::buildVectorNeighborFE(FEType type)


_vector_fe_neighbor[dim][type]->get_phi(); _vector_fe_neighbor[dim][type]->get_phi();
_vector_fe_neighbor[dim][type]->get_dphi(); _vector_fe_neighbor[dim][type]->get_dphi();
_vector_fe_neighbor[dim][type]->get_curl_phi(); if (type.family == NEDELEC_ONE)
_vector_fe_neighbor[dim][type]->get_curl_phi();
} }
} }


Expand Down Expand Up @@ -399,7 +402,8 @@ Assembly::buildVectorFaceNeighborFE(FEType type)


_vector_fe_face_neighbor[dim][type]->get_phi(); _vector_fe_face_neighbor[dim][type]->get_phi();
_vector_fe_face_neighbor[dim][type]->get_dphi(); _vector_fe_face_neighbor[dim][type]->get_dphi();
_vector_fe_face_neighbor[dim][type]->get_curl_phi(); if (type.family == NEDELEC_ONE)
_vector_fe_face_neighbor[dim][type]->get_curl_phi();
} }
} }


Expand Down
5 changes: 1 addition & 4 deletions framework/src/bcs/VectorIntegratedBC.C
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ VectorIntegratedBC::VectorIntegratedBC(const InputParameters & parameters)
_var(*mooseVariable()), _var(*mooseVariable()),
_normals(_var.normals()), _normals(_var.normals()),
_phi(_assembly.phiFace(_var)), _phi(_assembly.phiFace(_var)),
_curl_phi(_assembly.curlPhiFace(_var)),
_test(_var.phiFace()), _test(_var.phiFace()),
_curl_test(_var.curlPhiFace()), _u(_is_implicit ? _var.sln() : _var.slnOld())
_u(_is_implicit ? _var.sln() : _var.slnOld()),
_curl_u(_is_implicit ? _var.curlSln() : _var.curlSlnOld())
{ {
addMooseVariableDependency(mooseVariable()); addMooseVariableDependency(mooseVariable());
} }
Expand Down
26 changes: 9 additions & 17 deletions framework/src/kernels/VectorKernel.C
Original file line number Original file line Diff line number Diff line change
@@ -1,16 +1,11 @@
/****************************************************************/ //* This file is part of the MOOSE framework
/* DO NOT MODIFY THIS HEADER */ //* https://www.mooseframework.org
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ //*
/* */ //* All rights reserved, see COPYRIGHT for full restrictions
/* (c) 2010 Battelle Energy Alliance, LLC */ //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
/* ALL RIGHTS RESERVED */ //*
/* */ //* Licensed under LGPL 2.1, please see LICENSE for details
/* Prepared by Battelle Energy Alliance, LLC */ //* https://www.gnu.org/licenses/lgpl-2.1.html
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/


#include "VectorKernel.h" #include "VectorKernel.h"
#include "Assembly.h" #include "Assembly.h"
Expand Down Expand Up @@ -41,13 +36,10 @@ VectorKernel::VectorKernel(const InputParameters & parameters)
_var(*mooseVariable()), _var(*mooseVariable()),
_test(_var.phi()), _test(_var.phi()),
_grad_test(_var.gradPhi()), _grad_test(_var.gradPhi()),
_curl_test(_var.curlPhi()),
_phi(_assembly.phi(_var)), _phi(_assembly.phi(_var)),
_grad_phi(_assembly.gradPhi(_var)), _grad_phi(_assembly.gradPhi(_var)),
_curl_phi(_assembly.curlPhi(_var)),
_u(_is_implicit ? _var.sln() : _var.slnOld()), _u(_is_implicit ? _var.sln() : _var.slnOld()),
_grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld()), _grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld())
_curl_u(_is_implicit ? _var.curlSln() : _var.curlSlnOld())
{ {
addMooseVariableDependency(mooseVariable()); addMooseVariableDependency(mooseVariable());
} }
Expand Down
9 changes: 9 additions & 0 deletions test/include/kernels/VectorFEWave.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class VectorFEWave : public VectorKernel
virtual Real computeQpResidual() override; virtual Real computeQpResidual() override;
virtual Real computeQpJacobian() override; virtual Real computeQpJacobian() override;


/// curl of the test function
const VectorVariableTestCurl & _curl_test;

/// curl of the shape function
const VectorVariablePhiCurl & _curl_phi;

/// Holds the solution curl at the current quadrature points
const VectorVariableCurl & _curl_u;

Function & _x_ffn; Function & _x_ffn;
Function & _y_ffn; Function & _y_ffn;
Function & _z_ffn; Function & _z_ffn;
Expand Down
26 changes: 13 additions & 13 deletions test/src/kernels/VectorFEWave.C
Original file line number Original file line Diff line number Diff line change
@@ -1,18 +1,15 @@
/****************************************************************/ //* This file is part of the MOOSE framework
/* DO NOT MODIFY THIS HEADER */ //* https://www.mooseframework.org
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ //*
/* */ //* All rights reserved, see COPYRIGHT for full restrictions
/* (c) 2010 Battelle Energy Alliance, LLC */ //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
/* ALL RIGHTS RESERVED */ //*
/* */ //* Licensed under LGPL 2.1, please see LICENSE for details
/* Prepared by Battelle Energy Alliance, LLC */ //* https://www.gnu.org/licenses/lgpl-2.1.html
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#include "VectorFEWave.h" #include "VectorFEWave.h"
#include "Function.h" #include "Function.h"
#include "Assembly.h"


registerMooseObject("MooseTestApp", VectorFEWave); registerMooseObject("MooseTestApp", VectorFEWave);


Expand All @@ -29,6 +26,9 @@ validParams<VectorFEWave>()


VectorFEWave::VectorFEWave(const InputParameters & parameters) VectorFEWave::VectorFEWave(const InputParameters & parameters)
: VectorKernel(parameters), : VectorKernel(parameters),
_curl_test(_var.curlPhi()),
_curl_phi(_assembly.curlPhi(_var)),
_curl_u(_is_implicit ? _var.curlSln() : _var.curlSlnOld()),
_x_ffn(getFunction("x_forcing_func")), _x_ffn(getFunction("x_forcing_func")),
_y_ffn(getFunction("y_forcing_func")), _y_ffn(getFunction("y_forcing_func")),
_z_ffn(getFunction("z_forcing_func")) _z_ffn(getFunction("z_forcing_func"))
Expand Down
Binary file not shown.
63 changes: 63 additions & 0 deletions test/tests/kernels/vector_fe/lagrange_vec_1d.i
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,63 @@
# This example reproduces the libmesh vector_fe example 1 results

[Mesh]
type = GeneratedMesh
dim = 1
nx = 15
xmin = -1
elem_type = EDGE3
[]

[Variables]
[./u]
family = LAGRANGE_VEC
order = SECOND
[../]
[]

[Kernels]
[./diff]
type = VectorDiffusion
variable = u
[../]
[./body_force]
type = VectorBodyForce
variable = u
function_x = 'ffx'
[../]
[]

[BCs]
[./bnd]
type = LagrangeVecFunctionDirichletBC
variable = u
x_exact_soln = 'x_exact_sln'
boundary = 'left right'
[../]
[]

[Functions]
[./x_exact_sln]
type = ParsedFunction
value = 'cos(.5*pi*x)'
[../]
[./ffx]
type = ParsedFunction
value = '.25*pi*pi*cos(.5*pi*x)'
[../]
[]

[Preconditioning]
[./pre]
type = SMP
[../]
[]

[Executioner]
type = Steady
solve_type = NEWTON
[]

[Outputs]
exodus = true
[]
19 changes: 19 additions & 0 deletions test/tests/kernels/vector_fe/tests
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@
issues = "#10049" issues = "#10049"
requirement = "MOOSE shall be able to solve multi-dimensional problems with LAGRANGE_VEC variables" requirement = "MOOSE shall be able to solve multi-dimensional problems with LAGRANGE_VEC variables"
[../] [../]
[./lagrange_vec_1d]
type = Exodiff
input = 'lagrange_vec_1d.i'
exodiff = 'lagrange_vec_1d_out.e'
abs_zero = 1e-8
design = "moose_variables.md"
issues = "#10049"
requirement = "MOOSE shall be able to solve one-dimensional problems with LAGRANGE_VEC variables"
[../]
[./lagrange_vec_1d_jac]
type = PetscJacobianTester
input = 'lagrange_vec_1d.i'
ratio_tol = 1e-7
difference_tol = 1e-6
design = "moose_variables.md"
issues = "#10049"
cli_args = 'Outputs/exodus=false Mesh/nx=3'
requirement = "MOOSE shall be able to solve one-dimensional problems with LAGRANGE_VEC variables and produce the correct Jacobian"
[../]
[./ad_lagrange_vec] [./ad_lagrange_vec]
type = Exodiff type = Exodiff
input = 'ad_lagrange_vec.i' input = 'ad_lagrange_vec.i'
Expand Down

0 comments on commit 7540d36

Please sign in to comment.