Skip to content

Commit

Permalink
Everything is in and it works at solving diffusion problems refs idah…
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Aug 19, 2016
1 parent 89d8334 commit ef7cf20
Show file tree
Hide file tree
Showing 30 changed files with 674 additions and 130 deletions.
34 changes: 34 additions & 0 deletions framework/include/actions/AddArrayBCAction.h
@@ -0,0 +1,34 @@
/****************************************************************/
/* 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 */
/****************************************************************/

#ifndef ADDARRAYBCACTION_H
#define ADDARRAYBCACTION_H

#include "MooseObjectAction.h"

class AddArrayBCAction;

template<>
InputParameters validParams<AddArrayBCAction>();


class AddArrayBCAction : public MooseObjectAction
{
public:
AddArrayBCAction(InputParameters params);

virtual void act() override;
};

#endif // ADDARRAYBCACTION_H
10 changes: 5 additions & 5 deletions framework/include/base/ArrayMooseVariable.h
Expand Up @@ -62,7 +62,7 @@ class SystemBase;
class ArrayMooseVariable : public MooseVariableBase
{
public:
ArrayMooseVariable(unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind, unsigned int count);
ArrayMooseVariable(const std::string & name, unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind, unsigned int count);
virtual ~ArrayMooseVariable();

/**
Expand Down Expand Up @@ -205,10 +205,10 @@ class ArrayMooseVariable : public MooseVariableBase
// * Compute values at quadrature points for the neighbor
// */
// void computeNeighborValues();
// /**
// * Compute nodal values of this variable
// */
// void computeNodalValues();
/**
* Compute nodal values of this variable
*/
void computeNodalValues();
// /**
// * Compute nodal values of this variable in the neighbor
// */
Expand Down
1 change: 1 addition & 0 deletions framework/include/base/Factory.h
Expand Up @@ -38,6 +38,7 @@
#define registerKernel(name) registerObject(name)
#define registerNodalKernel(name) registerObject(name)
#define registerBoundaryCondition(name) registerObject(name)
#define registerArrayBoundaryCondition(name) registerObject(name)
#define registerAux(name) registerObject(name)
#define registerAuxKernel(name) registerObject(name)
#define registerMaterial(name) registerObject(name)
Expand Down
2 changes: 1 addition & 1 deletion framework/include/base/MooseVariable.h
Expand Up @@ -41,7 +41,7 @@ template <typename T> class DenseVector;
class MooseVariable : public MooseVariableBase
{
public:
MooseVariable(unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind);
MooseVariable(const std::string & name, unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind);
virtual ~MooseVariable();

/**
Expand Down
14 changes: 11 additions & 3 deletions framework/include/base/MooseVariableBase.h
Expand Up @@ -50,7 +50,7 @@ class SystemBase;
class MooseVariableBase
{
public:
MooseVariableBase(unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind, unsigned int count = 1);
MooseVariableBase(const std::string & name, unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind, unsigned int count = 1);
virtual ~MooseVariableBase();

/**
Expand All @@ -70,10 +70,16 @@ class MooseVariableBase
SystemBase & sys() { return _sys; }

/**
* Get the variable number
* Get the variable name
*/
const std::string & name() const;

/**
* Get the names of all of the variables represented by this MoosevariableBase
* Note: this is usually built on the fly, so try not to call it too much!
*/
const std::vector<std::string> names() const;

/**
* Kind of the variable (Nonlinear, Auxiliary, ...)
*/
Expand Down Expand Up @@ -134,9 +140,11 @@ class MooseVariableBase
/**
* The number of variables represented by this ArrayMooseVariable.
*/
unsigned int count() { return _count; }
unsigned int count() const { return _count; }

protected:
/// The name of the variable
std::string _name;
/// variable number (from libMesh)
unsigned int _var_num;
/// The FEType associated with this variable
Expand Down
2 changes: 1 addition & 1 deletion framework/include/base/MooseVariableScalar.h
Expand Up @@ -30,7 +30,7 @@ template <typename T> class NumericVector;
class MooseVariableScalar : public MooseVariableBase
{
public:
MooseVariableScalar(unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind);
MooseVariableScalar(const std::string & name, unsigned int var_num, const FEType & fe_type, SystemBase & sys, Assembly & assembly, Moose::VarKindType var_kind);
virtual ~MooseVariableScalar();

void reinit();
Expand Down
4 changes: 2 additions & 2 deletions framework/include/base/NonlinearSystem.h
Expand Up @@ -33,7 +33,7 @@ class Predictor;
class ElementDamper;
class GeneralDamper;
class IntegratedBC;
class NodalBC;
class NodalBCBase;
class PresetNodalBC;
class DGKernel;
class InterfaceKernel;
Expand Down Expand Up @@ -529,7 +529,7 @@ class NonlinearSystem : public SystemTempl<TransientNonlinearImplicitSystem>,
///@{
/// BoundaryCondition Warhouses
MooseObjectWarehouse<IntegratedBC> _integrated_bcs;
MooseObjectWarehouse<NodalBC> _nodal_bcs;
MooseObjectWarehouse<NodalBCBase> _nodal_bcs;
MooseObjectWarehouse<PresetNodalBC> _preset_nodal_bcs;
///@}

Expand Down
14 changes: 5 additions & 9 deletions framework/include/base/SystemBase.h
Expand Up @@ -495,7 +495,7 @@ class SystemTempl : public SystemBase
for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
{
//FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in MooseVariableBase.
MooseVariable * var = new MooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind);
MooseVariable * var = new MooseVariable(var_name, var_num, type, *this, _subproblem.assembly(tid), _var_kind);
var->scalingFactor(scale_factor);
_vars[tid].add(var_name, var);
}
Expand All @@ -513,8 +513,6 @@ class SystemTempl : public SystemBase
*/
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)
{
std::cout<<"addArrayVariable : "<<var_name<<std::endl;

// Turn off automatic variable group identification so that we can be sure that this variable
// group will be ordered exactly like it should be
_sys.identify_variable_groups(false);
Expand All @@ -524,10 +522,8 @@ class SystemTempl : public SystemBase
for (unsigned int i = 0; i < count; i++)
var_names.push_back(var_name + "_" + std::to_string(i));

unsigned int var_num = _sys.add_variables(var_names, type, active_subdomains);

// FIXME: need to get this properly!
var_num = 0;
// The number returned by libMesh is the _last_ variable number... we want to hold onto the _first_
unsigned int var_num = _sys.add_variables(var_names, type, active_subdomains) - (count - 1);

if (active_subdomains == NULL)
{
Expand All @@ -542,7 +538,7 @@ class SystemTempl : public SystemBase
for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
{
//FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in MooseVariableBase.
ArrayMooseVariable * var = new ArrayMooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, count);
ArrayMooseVariable * var = new ArrayMooseVariable(var_name, var_num, type, *this, _subproblem.assembly(tid), _var_kind, count);
var->scalingFactor(scale_factor);
_vars[tid].add(var_name, var);
}
Expand All @@ -561,7 +557,7 @@ class SystemTempl : public SystemBase
for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
{
//FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in MooseVariableBase.
MooseVariableScalar * var = new MooseVariableScalar(var_num, type, *this, _subproblem.assembly(tid), _var_kind);
MooseVariableScalar * var = new MooseVariableScalar(var_name, var_num, type, *this, _subproblem.assembly(tid), _var_kind);
var->scalingFactor(scale_factor);
_vars[tid].add(var_name, var);
}
Expand Down
42 changes: 42 additions & 0 deletions framework/include/bcs/ArrayDirichletBC.h
@@ -0,0 +1,42 @@
/****************************************************************/
/* 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 */
/****************************************************************/

#ifndef ARRAYDIRICHLETBC_H
#define ARRAYDIRICHLETBC_H

#include "ArrayNodalBC.h"

class ArrayDirichletBC;

template<>
InputParameters validParams<ArrayDirichletBC>();

/**
* Boundary condition of a Dirichlet type
*
* Sets the value in the node
*/
class ArrayDirichletBC : public ArrayNodalBC
{
public:
ArrayDirichletBC(const InputParameters & parameters);

protected:
virtual void computeQpResidual() override;

/// The value for this BC
Eigen::VectorXd _value;
};

#endif /* ARRAYDIRICHLETBC_H */
76 changes: 76 additions & 0 deletions framework/include/bcs/ArrayNodalBC.h
@@ -0,0 +1,76 @@
/****************************************************************/
/* 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 */
/****************************************************************/

#ifndef ARRAYNODALBC_H
#define ARRAYNODALBC_H

#include "NodalBCBase.h"

// Forward declarations
class ArrayNodalBC;

// libMesh forward declarations
namespace libMesh
{
template <typename T> class NumericVector;
}

template<>
InputParameters validParams<ArrayNodalBC>();

/**
* Base class for deriving any boundary condition that works at nodes
*/
class ArrayNodalBC : public NodalBCBase
{
public:
ArrayNodalBC(const InputParameters & parameters);

virtual void computeResidual(NumericVector<Number> & residual);
virtual void computeJacobian();
virtual void computeOffDiagJacobian(unsigned int jvar);

protected:
/// The MooseVariable this BC is acting on
ArrayMooseVariable & _array_var;

/// current node being processed
const Node * & _current_node;

/// The residual values to be set in computeQpResidual()
Eigen::Map<Eigen::VectorXd> _residual;

/// Quadrature point index
unsigned int _qp;

/// Value of the unknown variable this BC is acting on
const ArrayVariableValue & _u;

virtual void computeQpResidual() = 0;

/**
* The user can override this function to compute the "on-diagonal"
* Jacobian contribution for this ArrayNodalBC. If not overriden,
* returns 1.
*/
virtual Real computeQpJacobian();

/**
* This is the virtual that derived classes should override for
* computing an off-diagonal jacobian component.
*/
virtual Real computeQpOffDiagJacobian(unsigned int jvar);
};

#endif /* ARRAYNODALBC_H */
9 changes: 2 additions & 7 deletions framework/include/bcs/NodalBC.h
Expand Up @@ -15,9 +15,7 @@
#ifndef NODALBC_H
#define NODALBC_H

#include "BoundaryCondition.h"
#include "RandomInterface.h"
#include "CoupleableMooseVariableDependencyIntermediateInterface.h"
#include "NodalBCBase.h"

// Forward declarations
class NodalBC;
Expand All @@ -34,10 +32,7 @@ InputParameters validParams<NodalBC>();
/**
* Base class for deriving any boundary condition that works at nodes
*/
class NodalBC :
public BoundaryCondition,
public RandomInterface,
public CoupleableMooseVariableDependencyIntermediateInterface
class NodalBC : public NodalBCBase
{
public:
NodalBC(const InputParameters & parameters);
Expand Down
50 changes: 50 additions & 0 deletions framework/include/bcs/NodalBCBase.h
@@ -0,0 +1,50 @@
/****************************************************************/
/* 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 */
/****************************************************************/

#ifndef NODALBCBASE_H
#define NODALBCBASE_H

#include "BoundaryCondition.h"
#include "RandomInterface.h"
#include "CoupleableMooseVariableDependencyIntermediateInterface.h"

// Forward declarations
class NodalBCBase;

// libMesh forward declarations
namespace libMesh
{
template <typename T> class NumericVector;
}

template<>
InputParameters validParams<NodalBCBase>();

/**
* Base class for deriving any boundary condition that works at nodes
*/
class NodalBCBase :
public BoundaryCondition,
public RandomInterface,
public CoupleableMooseVariableDependencyIntermediateInterface
{
public:
NodalBCBase(const InputParameters & parameters);

virtual void computeResidual(NumericVector<Number> & residual) = 0;
virtual void computeJacobian() = 0;
virtual void computeOffDiagJacobian(unsigned int jvar) = 0;
};

#endif /* NODALBCBASE_H */

0 comments on commit ef7cf20

Please sign in to comment.