2013-08-08 05:34:54 +08:00
|
|
|
#ifndef PHYSICS_MODEL_H
|
|
|
|
#define PHYSICS_MODEL_H
|
|
|
|
|
|
|
|
#include <map>
|
2013-08-22 07:06:07 +08:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2013-08-08 05:34:54 +08:00
|
|
|
#include "Array2D.h"
|
|
|
|
#include "MatrixLibrary.h"
|
|
|
|
#include "ATC_Error.h"
|
|
|
|
#include "Material.h"
|
|
|
|
#include "WeakEquation.h"
|
|
|
|
#include "NonLinearSolver.h"
|
|
|
|
#include "ATC_TypeDefs.h"
|
|
|
|
#include "Utility.h"
|
|
|
|
|
|
|
|
namespace ATC
|
|
|
|
{
|
|
|
|
class ATC_Coupling;
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModel
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief An adaptor for the FE_Engine of the specific weak form of
|
|
|
|
* the continuum PDE for the FE_Engine.
|
|
|
|
* It is assumed that the PDE fits this template:
|
|
|
|
* DENSITY(FIELDS) FIELD_RATE
|
|
|
|
* = DIV FLUX(FIELDS, GRAD_FIELDS) + SOURCE(FIELDS,GRAD_FIELDS)
|
|
|
|
* + PRESCRIBED_SOURCE(X,t) + EXTRINSIC_SOURCE(FIELDS,GRAD_FIELDS)
|
|
|
|
* Also it is important to understand that the physics model only handles
|
|
|
|
* extrinsic fields or surrogates of intrinsic fields
|
|
|
|
*/
|
|
|
|
class PhysicsModel
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// constructor
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModel(std::string fileName);
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
// destructor
|
|
|
|
virtual ~PhysicsModel();
|
|
|
|
|
|
|
|
/** parse material file */
|
2013-08-22 07:06:07 +08:00
|
|
|
void parse_material_file(std::string fileName);
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
/** initialize */
|
|
|
|
void initialize(void);
|
|
|
|
|
|
|
|
// set timescale parameters based on a given lengthscale
|
|
|
|
virtual void set_timescales(const double lengthscale) {};
|
|
|
|
|
|
|
|
/** access number of materials */
|
|
|
|
int nMaterials(void) const { return materials_.size(); }
|
|
|
|
|
|
|
|
/** access material index from name */
|
2013-08-22 07:06:07 +08:00
|
|
|
int material_index(const std::string & name) const;
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
/** access material from index */
|
|
|
|
const Material * material(const int index) const {return materials_[index];}
|
|
|
|
|
|
|
|
/** access to parameter values */
|
2013-08-22 07:06:07 +08:00
|
|
|
bool parameter_value(const std::string& name, double& value,
|
2013-08-08 05:34:54 +08:00
|
|
|
const int imat = 0) const ;
|
|
|
|
|
|
|
|
/** return fields ids and length */
|
2013-08-22 07:06:07 +08:00
|
|
|
void num_fields(std::map<FieldName,int> & fieldSizes,
|
2013-08-08 05:34:54 +08:00
|
|
|
Array2D<bool> & rhsMask) const;
|
|
|
|
|
|
|
|
/** is the material model linear */
|
|
|
|
bool is_linear(FieldName name) const {
|
2013-08-22 07:06:07 +08:00
|
|
|
std::vector< Material* >::const_iterator iter;
|
2013-08-08 05:34:54 +08:00
|
|
|
for (iter = materials_.begin(); iter != materials_.end(); iter++) {
|
|
|
|
Material * mat = *iter;
|
|
|
|
bool linear = mat->linear_flux(name)
|
|
|
|
&& mat->linear_source(name)
|
|
|
|
&& mat->constant_density(name);
|
|
|
|
if (! linear) return linear;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** is rhs linear */
|
|
|
|
bool has_linear_rhs(FieldName name) const {
|
2013-08-22 07:06:07 +08:00
|
|
|
std::vector< Material* >::const_iterator iter;
|
2013-08-08 05:34:54 +08:00
|
|
|
for (iter = materials_.begin(); iter != materials_.end(); iter++) {
|
|
|
|
Material * mat = *iter;
|
|
|
|
bool constant = mat->linear_flux(name) && mat->linear_source(name);
|
|
|
|
if (! constant) return constant;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** is mass matrix constant */
|
|
|
|
bool has_constant_mass(FieldName name) const {
|
2013-08-22 07:06:07 +08:00
|
|
|
std::vector< Material* >::const_iterator iter;
|
2013-08-08 05:34:54 +08:00
|
|
|
for (iter = materials_.begin(); iter != materials_.end(); iter++) {
|
|
|
|
Material * mat = *iter;
|
|
|
|
bool constant = mat->constant_density(name);
|
|
|
|
if (! constant) return constant;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** access to weak equations */
|
|
|
|
const WeakEquation * weak_equation(FieldName field) const
|
|
|
|
{
|
2013-08-22 07:06:07 +08:00
|
|
|
std::map<FieldName,WeakEquation *>::const_iterator itr = weakEqns_.find(field);
|
2013-08-08 05:34:54 +08:00
|
|
|
if (itr == weakEqns_.end()) return NULL;
|
|
|
|
return (weakEqns_.find(field))->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** requires ics */
|
|
|
|
bool is_dynamic(FieldName field) const
|
|
|
|
{
|
|
|
|
return (weak_equation(field)->type() == WeakEquation::DYNAMIC_PDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** query null weak equations per material */
|
|
|
|
bool null(FieldName field, int matID) const
|
|
|
|
{
|
|
|
|
return null_(field,matID);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/** parameter values */
|
2013-08-22 07:06:07 +08:00
|
|
|
std::map<std::string, double> parameterValues_;
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
/** material models */
|
2013-08-22 07:06:07 +08:00
|
|
|
std::vector<Material *> materials_;
|
|
|
|
std::map<std::string,int> materialNameToIndexMap_;// maps tag to index
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
/** weak equations */
|
2013-08-22 07:06:07 +08:00
|
|
|
std::map<FieldName,WeakEquation *> weakEqns_;
|
2013-08-08 05:34:54 +08:00
|
|
|
|
|
|
|
/** null weak equations per material */
|
|
|
|
Array2D<int> null_;
|
|
|
|
|
|
|
|
/** type tag */
|
2013-08-22 07:06:07 +08:00
|
|
|
std::string type_;
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// note that these classes do not use inheritance other than from the
|
|
|
|
// generic base class above. Inheritance is meant to come from the
|
|
|
|
// weak equations that they contain
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelThermal
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelThermal : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelThermal(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelElastic
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelElastic : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelElastic(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelThemoMechanical
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelThermoElastic : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelThermoElastic(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelShear
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelShear : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelShear(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelThemoShear
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelThermoShear : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelThermoShear(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelSpecies
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelSpecies : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelSpecies(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelTwoTemperature
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelTwoTemperature : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelTwoTemperature(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusion
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusion : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusion(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionEquilibrium
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionEquilibrium : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionEquilibrium(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionSchrodinger
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionSchrodinger : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionSchrodinger(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionConvection
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionConvection : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionConvection(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionEquilibrium
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionConvectionEquilibrium : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionConvectionEquilibrium(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionSchrodinger
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionConvectionSchrodinger : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionConvectionSchrodinger(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelDriftDiffusionSchrodingerSlice
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelDriftDiffusionSchrodingerSlice : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelDriftDiffusionSchrodingerSlice(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelElectrostatic
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelElectrostatic : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelElectrostatic(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelElectrostaticEquilibrium
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelElectrostaticEquilibrium : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelElectrostaticEquilibrium(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelElectrostatic
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelSpeciesElectrostatic : public PhysicsModel
|
|
|
|
{
|
|
|
|
public:
|
2013-08-22 07:06:07 +08:00
|
|
|
PhysicsModelSpeciesElectrostatic(std::string filename);
|
2013-08-08 05:34:54 +08:00
|
|
|
};
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// @class PhysicsModelTangentOperator
|
|
|
|
// @brief adaptor to NonLinearSolver to solve rhs(x,y) = 0 for x
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
class PhysicsModelTangentOperator : public TangentOperator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PhysicsModelTangentOperator(ATC_Coupling * atc,
|
|
|
|
const PhysicsModel * physicsModel,
|
|
|
|
Array2D<bool> & rhsMask,
|
|
|
|
IntegrationDomainType integrationType,
|
|
|
|
FIELDS & rhs,
|
|
|
|
FIELDS & fields,
|
|
|
|
FieldName fieldName,
|
|
|
|
const int dof=0);
|
|
|
|
PhysicsModelTangentOperator(ATC_Coupling * atc,
|
|
|
|
const PhysicsModel * physicsModel,
|
|
|
|
Array2D<bool> & rhsMask,
|
|
|
|
IntegrationDomainType integrationType,
|
|
|
|
FieldName fieldName,
|
|
|
|
const int dof=0);
|
|
|
|
~PhysicsModelTangentOperator(){};
|
|
|
|
void function(const VECTOR & x, DENS_VEC & r);
|
|
|
|
void tangent(const VECTOR & x, DENS_VEC & r, MATRIX & K);
|
|
|
|
private:
|
|
|
|
ATC_Coupling * atc_;
|
|
|
|
const PhysicsModel * physicsModel_;
|
|
|
|
Array2D<bool> rhsMask_;
|
|
|
|
IntegrationDomainType integrationType_;
|
|
|
|
FIELDS & rhs_;
|
|
|
|
FIELDS & fields_;
|
|
|
|
FieldName fieldName_;
|
|
|
|
int dof_;
|
|
|
|
SPAR_MAT stiffness_;
|
|
|
|
};
|
|
|
|
|
2015-08-19 22:56:21 +08:00
|
|
|
}
|
2013-08-08 05:34:54 +08:00
|
|
|
#endif
|