Permalink
Browse files

Merge pull request #12880 from lindsayad/allow-1d-lagrange-vec

Allow LAGRANGE_VEC simulations to be performed in 1D
  • Loading branch information...
permcody committed Feb 8, 2019
2 parents b387463 + 537dabd commit 7540d36ddd208a0ffc87f9d1be343e5a61541370
@@ -61,22 +61,16 @@ class VectorIntegratedBC : public IntegratedBCBase, public MooseVariableInterfac

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

// test functions

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

// solution variable

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

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

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

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

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

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

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

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

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

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

#endif /* VECTORKERNEL_H */
@@ -313,7 +313,8 @@ Assembly::buildVectorFE(FEType type)

_vector_fe[dim][type]->get_phi();
_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
// recent optimizations in libmesh, we now need to explicity
// request it, since apps (Yak) may rely on it being computed.
@@ -344,7 +345,8 @@ Assembly::buildVectorFaceFE(FEType type)

_vector_fe_face[dim][type]->get_phi();
_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();
}
}

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

_vector_fe_neighbor[dim][type]->get_phi();
_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();
}
}

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

_vector_fe_face_neighbor[dim][type]->get_phi();
_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();
}
}

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

#include "VectorKernel.h"
#include "Assembly.h"
@@ -41,13 +36,10 @@ VectorKernel::VectorKernel(const InputParameters & parameters)
_var(*mooseVariable()),
_test(_var.phi()),
_grad_test(_var.gradPhi()),
_curl_test(_var.curlPhi()),
_phi(_assembly.phi(_var)),
_grad_phi(_assembly.gradPhi(_var)),
_curl_phi(_assembly.curlPhi(_var)),
_u(_is_implicit ? _var.sln() : _var.slnOld()),
_grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld()),
_curl_u(_is_implicit ? _var.curlSln() : _var.curlSlnOld())
_grad_u(_is_implicit ? _var.gradSln() : _var.gradSlnOld())
{
addMooseVariableDependency(mooseVariable());
}
@@ -28,6 +28,15 @@ class VectorFEWave : public VectorKernel
virtual Real computeQpResidual() 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 & _y_ffn;
Function & _z_ffn;
@@ -1,18 +1,15 @@
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "VectorFEWave.h"
#include "Function.h"
#include "Assembly.h"

registerMooseObject("MooseTestApp", VectorFEWave);

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

VectorFEWave::VectorFEWave(const InputParameters & 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")),
_y_ffn(getFunction("y_forcing_func")),
_z_ffn(getFunction("z_forcing_func"))
Binary file not shown.
@@ -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
[]
@@ -27,6 +27,25 @@
issues = "#10049"
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]
type = Exodiff
input = 'ad_lagrange_vec.i'

0 comments on commit 7540d36

Please sign in to comment.