Voxelyze
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
CVX_Material Class Reference

Defines the properties a raw material. More...

#include <VX_Material.h>

Inheritance diagram for CVX_Material:
CVX_MaterialVoxel CVX_MaterialLink

List of all members.

Public Member Functions

 CVX_Material (float youngsModulus=1e6f, float density=1e3f)
 Default Constructor.
 CVX_Material (rapidjson::Value &mat)
 Constructs this CVX_Material object from a rapidjson parser node that contains valid "materials" sub-nodes.
 CVX_Material (const CVX_Material &vIn)
 Destructor. Specified as virtual so we can just keep track of generic material pointers for voxel and link materials.
virtual CVX_Materialoperator= (const CVX_Material &vIn)
 Equals operator.
void clear ()
 Resets all material information to default.
const char * lastError () const
 Returns the last error encountered for this object.
void setName (const char *name)
 Adds an optional name to the material.
const char * name () const
 Returns the optional material name if one was specifed. Otherwise returns an empty string.
float stress (float strain, float transverseStrainSum=0.0f, bool forceLinear=false)
 returns the stress of the material model accounting for volumetric strain effects.
float modulus (float strain)
 returns the modulus (slope of the stress/strain curve) of the material model at the specified strain.
bool isYielded (float strain)
 Returns true if the specified strain is past the yield point (if one is specified).
bool isFailed (float strain)
 Returns true if the specified strain is past the failure point (if one is specified).
void setColor (int red, int green, int blue, int alpha=255)
 Sets the material color. Values from [0,255].
void setRed (int red)
 Sets the red channel of the material color.
void setGreen (int green)
 Sets the green channel of the material color.
void setBlue (int blue)
 Sets the blue channel of the material color.
void setAlpha (int alpha)
 Sets the alpha channel of the material color.
int red () const
 Returns the red channel of the material color [0,255] or -1 if unspecified.
int green () const
 Returns the green channel of the material color [0,255] or -1 if unspecified.
int blue () const
 Returns the blue channel of the material color [0,255] or -1 if unspecified.
int alpha () const
 Returns the alpha channel of the material color [0,255] or -1 if unspecified.
bool setModel (int dataPointCount, float *pStrainValues, float *pStressValues)
 Defines the physical material behavior with a series of true stress/strain data points.
bool setModelLinear (float youngsModulus, float failureStress=-1)
 Convenience function to quickly define a linear material.
bool setModelBilinear (float youngsModulus, float plasticModulus, float yieldStress, float failureStress=-1)
 Convenience function to quickly define a bilinear material.
bool isModelLinear () const
 Returns true if the material model is a simple linear behavior.
float youngsModulus () const
 Returns Youngs modulus in Pa.
float yieldStress () const
 Returns the yield stress in Pa or -1 if unspecified.
float failureStress () const
 Returns the failure stress in Pa or -1 if unspecified.
int modelDataPoints () const
 Returns the number of data points in the current material model data arrays.
const float * modelDataStrain () const
 Returns a pointer to the first strain value data point in a continuous array. The number of values can be determined from modelDataPoints(). The assumed first value of 0 is included.
const float * modelDataStress () const
 Returns a pointer to the first stress value data point in a continuous array. The number of values can be determined from modelDataPoints(). The assumed first value of 0 is included.
void setPoissonsRatio (float poissonsRatio)
 Defines Poisson's ratio for the material.
float poissonsRatio () const
 Returns the current Poissons ratio.
float bulkModulus () const
 Calculates the bulk modulus from Young's modulus and Poisson's ratio.
float lamesFirstParameter () const
 Calculates Lame's first parameter from Young's modulus and Poisson's ratio.
float shearModulus () const
 Calculates the shear modulus from Young's modulus and Poisson's ratio.
bool isXyzIndependent () const
 Returns true if poisson's ratio is zero - i.e. deformations in each dimension are independent of those in other dimensions.
void setDensity (float density)
 Defines the density for the material in Kg/m^3.
float density () const
 Returns the current density.
void setStaticFriction (float staticFrictionCoefficient)
 Defines the coefficient of static friction.
float staticFriction () const
 Returns the current coefficient of static friction.
void setKineticFriction (float kineticFrictionCoefficient)
 Defines the coefficient of kinetic friction.
float kineticFriction () const
 Returns the current coefficient of kinetic friction.
void setInternalDamping (float zeta)
 Defines the internal material damping ratio. The effect is to damp out vibrations within a structure. zeta = mu/2 (mu = loss factor) = 1/(2Q) (Q = amplification factor). High values of zeta may lead to simulation instability. Recommended value: 1.0.
float internalDamping () const
 Returns the internal material damping ratio.
void setGlobalDamping (float zeta)
 Defines the viscous damping of any voxels using this material relative to ground (no motion). Translation C (damping coefficient) is calculated according to zeta*2*sqrt(m*k) where k=E*nomSize. Rotational damping coefficient is similarly calculated High values relative to 1.0 may cause simulation instability.
float globalDamping () const
 Returns the global material damping ratio.
void setCollisionDamping (float zeta)
 Defines the material damping ratio for when this material collides with something. This gives some control over the elasticity of a collision. A value of zero results in a completely elastic collision.
float collisionDamping () const
 Returns the collision material damping ratio.
void setExternalScaleFactor (Vec3D< double > factor)
 Scales all voxels of this material by a specified factor in each dimension (1.0 is no scaling). This allows enables volumetric displacement-based actuation within a structure. As such, mass is unchanged when the external scale factor changes. Actual size is obtained by multiplying nominal size by the provided factor.
void setExternalScaleFactor (double factor)
 Convenience function to specify isotropic external scaling factor. See setExternalScaleFactor(Vec3D<> factor).
Vec3D< double > externalScaleFactor ()
 Returns the current external scaling factor (unitless). See description of setExternalScaleFactor().
void setCte (float cte)
 Defines the coefficient of thermal expansion.
float cte () const
 Returns the current coefficient of thermal expansion per degree C.

Protected Member Functions

virtual bool updateAll ()
 Updates and recalculates eveything possible (used by inherited classed when material properties have changed)
virtual bool updateDerived ()
 Updates all the derived quantities cached as member variables for this and derived classes. (Especially if density, size or elastic modulus changes.)
void writeJSON (rapidjson::PrettyWriter< rapidjson::StringBuffer > &w)
 Writes this material's data to the rapidjson writing object.
bool readJSON (rapidjson::Value &mat)
 reads this material data from the rapidjson Value.

Protected Attributes

std::string error
 The last error encountered.
std::string myName
 The name of this material. Default is "".
int r
 Red color value of this material from 0-255. Default is -1 (invalid/not set).
int g
 Green color value of this material from 0-255. Default is -1 (invalid/not set).
int b
 Blue color value of this material from 0-255. Default is -1 (invalid/not set).
int a
 Alpha value of this material from 0-255. Default is -1 (invalid/not set).
bool linear
 Set to true if this material is specified as linear.
float E
 Young's modulus (stiffness) in Pa.
float sigmaYield
 Yield stress in Pa.
float sigmaFail
 Failure stress in Pa.
std::vector< float > strainData
 strain data points
std::vector< float > stressData
 stress data points
float nu
 Poissonss Ratio.
float rho
 Density in Kg/m^3.
float alphaCTE
 Coefficient of thermal expansion (CTE)
float muStatic
 Static coefficient of friction.
float muKinetic
 Kinetic coefficient of friction.
float zetaInternal
 Internal damping ratio.
float zetaGlobal
 Global damping ratio.
float zetaCollision
 Collision damping ratio.
Vec3D< double > extScale
 A prescribed scaling factor. default of (1,1,1) is no scaling.
float _eHat
 Cached effective elastic modulus for materials with non-zero Poisson's ratio.
std::vector< CVX_Material * > dependentMaterials
 Any materials in this list will have updateDerived() called whenever it's called for this material. For example, in Voxelyze this is used for updatng link materials when one or both voxel materials change.

Friends

class CVoxelyze
class CVX_Voxel
class CVX_Link

Detailed Description

Defines the properties a raw material.

Contains all information relevant to a physical material to be simulated. All units are SI standard.

A physical material model may be specified as a series of true stress/strain data points, or by simple linear or bilinear parameters.

If a function returns unsuccessfully, check lastError() for the cause.


Constructor & Destructor Documentation

CVX_Material::CVX_Material ( float  youngsModulus = 1e6f,
float  density = 1e3f 
)

Default Constructor.

Parameters:
[in]youngsModulusThe Young's Modulus (stiffness) of this material in Pascals.
[in]densityThe density of this material in Kg/m^3
CVX_Material::CVX_Material ( rapidjson::Value &  mat) [inline]

Constructs this CVX_Material object from a rapidjson parser node that contains valid "materials" sub-nodes.

Parameters:
[in]matpointer to a rapidjson Value that contains material information. See rapidjson documentation and the *.vxl.json format info in the voxelyze user guide.
CVX_Material::CVX_Material ( const CVX_Material vIn) [inline]

Destructor. Specified as virtual so we can just keep track of generic material pointers for voxel and link materials.

Copy constructor


Member Function Documentation

bool CVX_Material::isFailed ( float  strain) [inline]

Returns true if the specified strain is past the failure point (if one is specified).

Parameters:
[in]strainThe strain to query.
bool CVX_Material::isYielded ( float  strain) [inline]

Returns true if the specified strain is past the yield point (if one is specified).

Parameters:
[in]strainThe strain to query.
float CVX_Material::modulus ( float  strain)

returns the modulus (slope of the stress/strain curve) of the material model at the specified strain.

Parameters:
[in]strainThe strain to query.
void CVX_Material::setAlpha ( int  alpha)

Sets the alpha channel of the material color.

Parameters:
[in]alphaAlpha channel [0,255]
void CVX_Material::setBlue ( int  blue)

Sets the blue channel of the material color.

Parameters:
[in]blueBlue channel [0,255]
void CVX_Material::setCollisionDamping ( float  zeta)

Defines the material damping ratio for when this material collides with something. This gives some control over the elasticity of a collision. A value of zero results in a completely elastic collision.

Parameters:
[in]zetadamping ratio [0, INF). (unitless)
void CVX_Material::setColor ( int  red,
int  green,
int  blue,
int  alpha = 255 
)

Sets the material color. Values from [0,255].

Parameters:
[in]redRed channel
[in]greenGreen channel
[in]blueBlue channel
[in]alphaAlpha channel
void CVX_Material::setCte ( float  cte) [inline]

Defines the coefficient of thermal expansion.

Parameters:
[in]cteDesired coefficient of thermal expansion per degree C (-INF, INF)
void CVX_Material::setDensity ( float  density)

Defines the density for the material in Kg/m^3.

Parameters:
[in]densityDesired density (0, INF)
void CVX_Material::setExternalScaleFactor ( Vec3D< double >  factor)

Scales all voxels of this material by a specified factor in each dimension (1.0 is no scaling). This allows enables volumetric displacement-based actuation within a structure. As such, mass is unchanged when the external scale factor changes. Actual size is obtained by multiplying nominal size by the provided factor.

Parameters:
[in]factorMultiplication factor (0, INF) for the size of all voxels of this material in its local x, y, and z axes. (unitless)
void CVX_Material::setExternalScaleFactor ( double  factor) [inline]

Convenience function to specify isotropic external scaling factor. See setExternalScaleFactor(Vec3D<> factor).

Parameters:
[in]factorexternal scaling factor (0, INF).
void CVX_Material::setGlobalDamping ( float  zeta)

Defines the viscous damping of any voxels using this material relative to ground (no motion). Translation C (damping coefficient) is calculated according to zeta*2*sqrt(m*k) where k=E*nomSize. Rotational damping coefficient is similarly calculated High values relative to 1.0 may cause simulation instability.

Parameters:
[in]zetadamping ratio [0, INF). (unitless)
void CVX_Material::setGreen ( int  green)

Sets the green channel of the material color.

Parameters:
[in]greenGreen channel [0,255]
void CVX_Material::setInternalDamping ( float  zeta)

Defines the internal material damping ratio. The effect is to damp out vibrations within a structure. zeta = mu/2 (mu = loss factor) = 1/(2Q) (Q = amplification factor). High values of zeta may lead to simulation instability. Recommended value: 1.0.

Parameters:
[in]zetadamping ratio [0, INF). (unitless)
void CVX_Material::setKineticFriction ( float  kineticFrictionCoefficient)

Defines the coefficient of kinetic friction.

Parameters:
[in]kineticFrictionCoefficientCoefficient of kinetc friction [0, INF).
bool CVX_Material::setModel ( int  dataPointCount,
float *  pStrainValues,
float *  pStressValues 
)

Defines the physical material behavior with a series of true stress/strain data points.

Parameters:
[in]dataPointCountThe expected number of data points.
[in]pStrainValuespointer to the first strain value data point in a contiguous array (Units: Pa).
[in]pStressValuespointer to the first stress value data point in a contiguous array (Units: Pa).

The arrays are assumed to be of equal length. The first data point is assumed to be [0,0] and need not be provided. At least 1 non-zero data point must be provided. The inital segment from [0,0] to the first strain and stress value is interpreted as young's modulus. The slope of the stress/strain curve should never exceed this value in subsequent segments. The last data point is assumed to represent failure of the material. The 0.2% offset method is used to calculate the yield point.

Restrictions on pStrainValues:

  • The values must be positive and increasing in order.
  • Strains are defined in absolute numbers according to delta l / L.

Restrictions on pStressValues:

  • The values must be positive and increasing in order.

Special cases:

  • 1 data point (linear): Yield and failure are assumed to occur simultaneously at the single data point.
  • 2 data points (bilinear): Yield is taken as the first data point, failure at the second.
bool CVX_Material::setModelBilinear ( float  youngsModulus,
float  plasticModulus,
float  yieldStress,
float  failureStress = -1 
)

Convenience function to quickly define a bilinear material.

Parameters:
[in]youngsModulusYoung's modulus (Units: Pa).
[in]plasticModulusPlastic modulus (Units: Pa).
[in]yieldStressYield stress.
[in]failureStressOptional failure stress (Units: Pa). -1 indicates failure is not an option.

Specified Young's modulus, plastic modulus, yield stress, and failure stress must all be positive. Plastic modulus must be less than Young's modulus and failure stress must be greater than the yield stress.

bool CVX_Material::setModelLinear ( float  youngsModulus,
float  failureStress = -1 
)

Convenience function to quickly define a linear material.

Parameters:
[in]youngsModulusYoung's modulus (Units: Pa).
[in]failureStressOptional failure stress (Units: Pa). -1 indicates failure is not an option.

Specified Young's modulus and failure stress must both be positive. Yield stress is interpreted as identical to failure stress. If failure stress is not specified an arbitrary data point consistent with the specified Young's modulus is added to the model.

void CVX_Material::setName ( const char *  name) [inline]

Adds an optional name to the material.

Parameters:
[in]nameDesired name.
void CVX_Material::setPoissonsRatio ( float  poissonsRatio)

Defines Poisson's ratio for the material.

Parameters:
[in]poissonsRatioDesired Poisson's ratio [0, 0.5).
void CVX_Material::setRed ( int  red)

Sets the red channel of the material color.

Parameters:
[in]redRed channel [0,255]
void CVX_Material::setStaticFriction ( float  staticFrictionCoefficient)

Defines the coefficient of static friction.

Parameters:
[in]staticFrictionCoefficientCoefficient of static friction [0, INF).
float CVX_Material::stress ( float  strain,
float  transverseStrainSum = 0.0f,
bool  forceLinear = false 
)

returns the stress of the material model accounting for volumetric strain effects.

Parameters:
[in]strainThe strain to query. The resulting stress in this direction will be returned.
[in]transverseStrainSumThe sum of the two principle normal strains in the plane perpendicular to strain.
[in]forceLinearIf true, the result will be calculated according to the elastic modulus of the material regardless of non-linearities in the model.

The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator Friends