Skip to content

Commit

Permalink
add damper system
Browse files Browse the repository at this point in the history
r2291
  • Loading branch information
friedmud authored and permcody committed Feb 14, 2014
1 parent b761494 commit a36e89d
Show file tree
Hide file tree
Showing 26 changed files with 908 additions and 74 deletions.
4 changes: 4 additions & 0 deletions framework/include/base/ComputeDamping.h
@@ -0,0 +1,4 @@
#ifndef COMPUTEPOSTPROCESSORS_H
#define COMPUTEPOSTPROCESSORS_H

#endif //COMPUTEPOSTPROCESSORS_H
15 changes: 15 additions & 0 deletions framework/include/base/MooseSystem.h
Expand Up @@ -21,6 +21,8 @@
#include "PostprocessorData.h"
#include "PostprocessorWarehouse.h"
#include "FunctionWarehouse.h"
#include "DamperData.h"
#include "DamperWarehouse.h"

//libmesh includes
#include "transient_system.h"
Expand Down Expand Up @@ -224,6 +226,10 @@ class MooseSystem
std::string name,
InputParameters parameters);

void addDamper(std::string damper_name,
std::string name,
InputParameters parameters);

/**
* Computes a block diagonal jacobian for the full system.
*/
Expand All @@ -247,6 +253,8 @@ class MooseSystem

void reinitKernels(THREAD_ID tid, const NumericVector<Number>& soln, const Elem * elem, DenseVector<Number> * Re, DenseMatrix<Number> * Ke = NULL);

void reinitDampers(THREAD_ID tid, const NumericVector<Number>& increment);

void reinitDGKernels(THREAD_ID tid, const NumericVector<Number>& soln, const Elem * elem, const unsigned int side, const Elem * neighbor, DenseVector<Number> * Re, bool reinitKe = false);

void reinitBCs(THREAD_ID tid, const NumericVector<Number>& soln, const Elem * elem, const unsigned int side, const unsigned int boundary_id);
Expand All @@ -257,6 +265,8 @@ class MooseSystem

void compute_postprocessors (const NumericVector<Number>& soln);

Real compute_damping(const NumericVector<Number>& soln, const NumericVector<Number>& update);

void subdomainSetup(THREAD_ID tid, unsigned int block_id);

/**
Expand Down Expand Up @@ -384,6 +394,7 @@ class MooseSystem
std::vector<AuxData *> _aux_data;
std::vector<MaterialData> _material_data;
std::vector<PostprocessorData> _postprocessor_data;
std::vector<DamperData *> _damper_data;

DofMap * _dof_map;

Expand Down Expand Up @@ -427,6 +438,7 @@ class MooseSystem
std::vector<InitialConditionWarehouse> _ics;
std::vector<PostprocessorWarehouse> _pps;
std::vector<FunctionWarehouse> _functions;
std::vector<DamperWarehouse> _dampers;

std::vector<bool> _first;

Expand Down Expand Up @@ -579,6 +591,7 @@ class MooseSystem
friend class ComputeInternalResiduals;
friend class ComputeInternalPostprocessors;
friend class GenericExecutionerBlock;
friend class ComputeInternalDamping;

friend class PDEBase;
friend class InitialCondition;
Expand All @@ -592,11 +605,13 @@ class MooseSystem
friend class Steady;
friend class Postprocessor;
friend class FunctionNeumannBC;
friend class Damper;

friend class QuadraturePointData;
friend class ElementData;
friend class FaceData;
friend class AuxData;
friend class DamperData;
};

/**
Expand Down
1 change: 0 additions & 1 deletion framework/include/bcs/BoundaryCondition.h
Expand Up @@ -143,7 +143,6 @@ class BoundaryCondition :
*/
NumericVector<Number> * & _current_residual;


/**
* Holds the current solution at the current quadrature point on the face.
*/
Expand Down
32 changes: 32 additions & 0 deletions framework/include/dampers/ConstantDamper.h
@@ -0,0 +1,32 @@
#ifndef CONSTANTDAMPER_H
#define CONSTANTDAMPER_H

// Moose Includes
#include "Damper.h"

//Forward Declarations
class ConstantDamper;

template<>
InputParameters validParams<ConstantDamper>();

class ConstantDamper : public Damper
{
public:
ConstantDamper(std::string name, MooseSystem & moose_system, InputParameters parameters);

protected:
/**
* This MUST be overriden by a child ConstantDamper.
*
* This is where they actually compute a number between 0 and 1.
*/
virtual Real computeQpDamping();

/**
* The constant amount of the newton update to take.
*/
Real _damping;
};

#endif //CONSTANTDAMPER_H
84 changes: 84 additions & 0 deletions framework/include/dampers/Damper.h
@@ -0,0 +1,84 @@
#ifndef DAMPER_H
#define DAMPER_H

// Moose Includes
#include "DamperData.h"
#include "PDEBase.h"
#include "MaterialPropertyInterface.h"

//Forward Declarations
class Damper;

template<>
InputParameters validParams<Damper>();

class Damper : protected PDEBase, protected MaterialPropertyInterface
{
public:
Damper(std::string name, MooseSystem & moose_system, InputParameters parameters);

/**
* Computes this Damper's damping for one element.
*/
Real computeDamping();

protected:
/**
* This MUST be overriden by a child damper.
*
* This is where they actually compute a number between 0 and 1.
*/
virtual Real computeQpDamping() = 0;

/**
* Data associated just with dampers (ie the newton update).
*/
DamperData & _damper_data;

/**
* Convenience reference to the ElementData object inside of MooseSystem
*/
ElementData & _element_data;

/**
* The current newton increment.
*/
MooseArray<Real> & _u_increment;

/**
* Holds the current solution at the current quadrature point.
*/
MooseArray<Real> & _u;

/**
* Holds the current solution gradient at the current quadrature point.
*/
MooseArray<RealGradient> & _grad_u;

/**
* Holds the current solution second derivative at the current quadrature point.
*/
MooseArray<RealTensor> & _second_u;

/**
* Holds the previous solution at the current quadrature point.
*/
MooseArray<Real> & _u_old;

/**
* Holds the t-2 solution at the current quadrature point.
*/
MooseArray<Real> & _u_older;

/**
* Holds the previous solution gradient at the current quadrature point.
*/
MooseArray<RealGradient> & _grad_u_old;

/**
* Holds the t-2 solution gradient at the current quadrature point.
*/
MooseArray<RealGradient> & _grad_u_older;
};

#endif
89 changes: 89 additions & 0 deletions framework/include/dampers/DamperData.h
@@ -0,0 +1,89 @@
#ifndef DAMPERDATA_H
#define DAMPERDATA_H

//MOOSE includes
#include "Moose.h"
#include "MooseArray.h"
#include "ElementData.h"

//Forward Declarations
class MooseSystem;

namespace libMesh
{
class QGauss;
class DofMap;
class FEBase;
template<class T> class NumericVector;
template<class T> class DenseVector;
template<class T> class DenseSubVector;
template<class T> class DenseMatrix;
}

/**
* One stop shop for all the data a Kernel class needs.
*
* _One_ of these will get built for each MooseSystem.
*/
class DamperData
{
public:
DamperData(MooseSystem & moose_system, ElementData & element_data);

~DamperData();

void init();

/**
* Computes the value of the increment for each variable at the quadrature points.
*/
void reinit(const NumericVector<Number>& increment_vec);

/**
* The MooseSystem
*/
MooseSystem & _moose_system;

MooseArray<MooseArray<Real> > _var_increments;

/**
* A reference to the element data class... so we can reuse that data.
*
* This also means that the element data needs to get reinit BEFORE damper data!
*/
ElementData & _element_data;

/**
* Dof Maps for all the variables.
*/
std::vector<std::vector<unsigned int> > & _var_dof_indices;

/**
* quadrature rule.
*/
QGauss * & _qrule;

/**
* number of quadrature points for current element
*/
unsigned int & _n_qpoints;

/**
* Map to vector of variable numbers that need to be evaluated
* at the quadrature points
*
* NOTE: This variable is used differently in ElementData and FaceData
* In ElementData, the mapping uses only index zero (0), since all variables lives
* inside the whole domain.
* In FaceData, the mapping goes from boundary id to list of variables active
* on this boundary (not all variables are needed on all boundaries)
*/
std::map<unsigned int, std::set<unsigned int> > & _var_nums;

/**
* Shape function.
*/
std::map<FEType, const std::vector<std::vector<Real> > *> & _phi;
};

#endif //DAMPERDATA_H
83 changes: 83 additions & 0 deletions framework/include/dampers/DamperFactory.h
@@ -0,0 +1,83 @@
#ifndef DAMPERFACTORY_H
#define DAMPERFACTORY_H

#include "Damper.h"

// System includes
#include <map>
#include <string>
#include <vector>
#include <typeinfo>

// LibMesh includes
#include <parameters.h>

// forward declarations
class MooseSystem;

/**
* Typedef to make things easier.
*/
typedef Damper * (*damperBuildPtr)(std::string name, MooseSystem & moose_system, InputParameters parameters);

/**
* Typedef to hide implementation details
*/
typedef std::vector<std::string>::iterator DamperNamesIterator;

/**
* Typedef to make things easier.
*/
typedef InputParameters (*damperParamsPtr)();

/**
* Templated build function used for generating function pointers to build classes on demand.
*/
template<typename DamperType>
Damper * buildDamper(std::string name, MooseSystem & moose_system, InputParameters parameters)
{
return new DamperType(name, moose_system, parameters);
}

/**
* Responsible for building Dampers on demand and storing them for retrieval
*/
class DamperFactory
{
public:
static DamperFactory * instance();

template<typename DamperType>
void registerDamper(std::string name)
{
if (_name_to_build_pointer.find(name) == _name_to_build_pointer.end())
{
_name_to_build_pointer[name] = &buildDamper<DamperType>;
_name_to_params_pointer[name] = &validParams<DamperType>;
}
else
mooseError("Damper '" + name + "' already registered.");
}

Damper *create(std::string damper_name, std::string name, MooseSystem & moose_system, InputParameters parameters)
{
return (*_name_to_build_pointer[damper_name])(name, moose_system, parameters);
}

DamperNamesIterator registeredDampersBegin();
DamperNamesIterator registeredDampersEnd();

InputParameters getValidParams(std::string name);

private:
DamperFactory();

virtual ~DamperFactory();

std::map<std::string, damperBuildPtr> _name_to_build_pointer;
std::map<std::string, damperParamsPtr> _name_to_params_pointer;

std::vector<std::string> _registered_damper_names;
};

#endif //DAMPERFACTORY_H

0 comments on commit a36e89d

Please sign in to comment.