Skip to content

Commit

Permalink
Split MooseVariableInterface into a templated base class to help with…
Browse files Browse the repository at this point in the history
… ArrayKernel refs idaholab#6881
  • Loading branch information
friedmud committed Aug 7, 2016
1 parent 87b4b7d commit bf3a7d4
Show file tree
Hide file tree
Showing 14 changed files with 465 additions and 517 deletions.
16 changes: 13 additions & 3 deletions framework/include/base/ArrayMooseVariable.h
Expand Up @@ -20,6 +20,8 @@

#include "libmesh/dense_matrix.h"

#include "Eigen/Core"

// Forward declarations
class Assembly;
class SubProblem;
Expand All @@ -35,9 +37,9 @@ template <typename T> class NumericVector;
template <typename T> class DenseVector;
}

typedef MooseArray<DenseVector<Real> > ArrayVariableValue;
typedef MooseArray<DenseMatrix<Real> > ArrayVariableGradient;
// typedef MooseArray<RealTensor> VariableSecond;
typedef MooseArray<Eigen::VectorXd> ArrayVariableValue;
typedef MooseArray<Eigen::Matrix<Real, Eigen::Dynamic, LIBMESH_DIM> > ArrayVariableGradient;
typedef MooseArray<RealTensor> ArrayVariableSecond;

// typedef MooseArray<std::vector<Real> > VariableTestValue;
// typedef MooseArray<std::vector<RealGradient> > VariableTestGradient;
Expand Down Expand Up @@ -328,6 +330,14 @@ class ArrayMooseVariable : public MooseVariableBase
/// DOF indices (neighbor)
std::vector<dof_id_type> _dof_indices_neighbor;

/// Cache of local dof indices for the first variable in the variable group
std::vector<dof_id_type> _local_dof_indices;

/// Interface to raw PetscVector data
Eigen::Map<Eigen::VectorXd> _mapped_values;

// Interface to the current gradient
Eigen::Map<Eigen::Vector3d> _mapped_grad_phi;

bool _need_u_old;
bool _need_u_older;
Expand Down
1 change: 1 addition & 0 deletions framework/include/base/DisplacedProblem.h
Expand Up @@ -112,6 +112,7 @@ class DisplacedProblem : public SubProblem
virtual bool hasScalarVariable(const std::string & var_name) override;
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string & var_name) override;
virtual void addVariable(const std::string & var_name, const FEType & type, Real scale_factor, const std::set< SubdomainID > * const active_subdomains = NULL);
virtual void addArrayVariable(const std::string & var_name, const FEType & type, Real scale_factor, unsigned int count, const std::set< SubdomainID > * const active_subdomains = NULL);
virtual void addAuxVariable(const std::string & var_name, const FEType & type, const std::set< SubdomainID > * const active_subdomains = NULL);
virtual void addScalarVariable(const std::string & var_name, Order order, Real scale_factor = 1., const std::set< SubdomainID > * const active_subdomains = NULL);
virtual void addAuxScalarVariable(const std::string & var_name, Order order, Real scale_factor = 1., const std::set< SubdomainID > * const active_subdomains = NULL);
Expand Down
1 change: 1 addition & 0 deletions framework/include/base/FEProblem.h
Expand Up @@ -435,6 +435,7 @@ class FEProblem :
// NL /////
NonlinearSystem & getNonlinearSystem() { return _nl; }
void addVariable(const std::string & var_name, const FEType & type, Real scale_factor, const std::set< SubdomainID > * const active_subdomains = NULL);
void addArrayVariable(const std::string & var_name, const FEType & type, Real scale_factor, unsigned int count, const std::set< SubdomainID > * const active_subdomains = NULL);
void addScalarVariable(const std::string & var_name, Order order, Real scale_factor = 1., const std::set< SubdomainID > * const active_subdomains = NULL);
void addKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
void addNodalKernel(const std::string & kernel_name, const std::string & name, InputParameters parameters);
Expand Down
142 changes: 6 additions & 136 deletions framework/include/base/MooseVariableInterface.h
Expand Up @@ -17,11 +17,12 @@

#include "MooseVariable.h"
#include "InputParameters.h"
#include "MooseVariableInterfaceBase.h"

/**
* Interface for objects that need to get values of MooseVariables
*/
class MooseVariableInterface
class MooseVariableInterface : public MooseVariableInterfaceBase<MooseVariable, VariableValue, VariableGradient, VariableSecond>
{
public:
/**
Expand All @@ -30,141 +31,10 @@ class MooseVariableInterface
* @param nodal true if the variable is nodal
* @param var_param_name the parameter name where we will find the coupled variable name
*/
MooseVariableInterface(const MooseObject * moose_object, bool nodal, std::string var_param_name = "variable");

/**
* Get the variable that this object is using.
* @return The variable this object is using.
*/
MooseVariable * mooseVariable();

virtual ~MooseVariableInterface();

protected:
/**
* The value of the variable this object is operating on.
*
* This is computed by default and should already be available as _u
*
* @return The reference to be stored off and used later.
*/
virtual const VariableValue & value();

/**
* The old value of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableValue & valueOld();

/**
* The older value of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableValue & valueOlder();

/**
* The time derivative of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableValue & dot();

/**
* The derivative of the time derivative of the variable this object is operating on
* with respect to this variable's coefficients.
*
* This is useful for creating Jacobian entries for residual statements that use _u_dot
*
* @return The reference to be stored off and used later.
*/
virtual const VariableValue & dotDu();

/**
* The gradient of the variable this object is operating on.
*
* This is computed by default and should already be available as _grad_u
*
* @return The reference to be stored off and used later.
*/
virtual const VariableGradient & gradient();

/**
* The old gradient of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableGradient & gradientOld();

/**
* The older gradient of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableGradient & gradientOlder();

/**
* The second derivative of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableSecond & second();

/**
* The old second derivative of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableSecond & secondOld();

/**
* The older second derivative of the variable this object is operating on.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableSecond & secondOlder();

/**
* The second derivative of the test function.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableTestSecond & secondTest();

/**
* The second derivative of the test function on the current face.
* This should be called in e.g. IntegratedBC when you need second
* derivatives of the test function function on the boundary.
*
* @return The reference to be stored off and used later.
*/
virtual const VariableTestSecond & secondTestFace();

/**
* The second derivative of the trial function.
*
* @return The reference to be stored off and used later.
*/
virtual const VariablePhiSecond & secondPhi();

/**
* The second derivative of the trial function on the current face.
* This should be called in e.g. IntegratedBC when you need second
* derivatives of the trial function function on the boundary.
*
* @return The reference to be stored off and used later.
*/
virtual const VariablePhiSecond & secondPhiFace();

/// Whether or not this object is acting only at nodes
bool _nodal;

/// The variable this object is acting on
MooseVariable * _variable;

protected:
Assembly * _mvi_assembly;
MooseVariableInterface(const MooseObject * moose_object, bool nodal, std::string var_param_name = "variable") :
MooseVariableInterfaceBase(moose_object, nodal, var_param_name)
{
}
};


Expand Down

0 comments on commit bf3a7d4

Please sign in to comment.