本文整理汇总了C++中FloatArray::subtract方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatArray::subtract方法的具体用法?C++ FloatArray::subtract怎么用?C++ FloatArray::subtract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatArray
的用法示例。
在下文中一共展示了FloatArray::subtract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strain
void FE2FluidMaterial :: giveDeviatoricPressureStiffness(FloatArray &answer, MatResponseMode mode, GaussPoint *gp, TimeStep *tStep)
{
FE2FluidMaterialStatus *ms = static_cast<FE2FluidMaterialStatus*> (this->giveStatus(gp));
ms->computeTangents(tStep);
if ( mode == TangentStiffness ) {
answer = ms->giveDeviatoricPressureTangent();
#ifdef DEBUG_TANGENT
// Numerical ATS for debugging
FloatArray strain(3); strain.zero();
FloatArray sig, sigh;
double epspvol, pressure = 0.0;
double h = 1.00; // Linear problem, size of this doesn't matter.
computeDeviatoricStressVector (sig, epspvol, gp, strain, pressure, tStep);
computeDeviatoricStressVector (sigh, epspvol, gp, strain, pressure+h, tStep);
FloatArray dsigh; dsigh.beDifferenceOf(sigh,sig); dsigh.times(1/h);
printf("Analytical deviatoric pressure tangent = "); answer.printYourself();
printf("Numerical deviatoric pressure tangent = "); dsigh.printYourself();
dsigh.subtract(answer);
double norm = dsigh.computeNorm();
if (norm > answer.computeNorm()*DEBUG_ERR && norm > 0.0) {
OOFEM_ERROR("Error in deviatoric pressure tangent");
}
#endif
} else {
OOFEM_ERROR("Mode not implemented");
}
}
示例2: computeDeformationGradientVector
void
NLStructuralElement :: computeDeformationGradientVector(FloatArray &answer, GaussPoint *gp, TimeStep *tStep)
{
// Computes the deformation gradient in the Voigt format at the Gauss point gp of
// the receiver at time step tStep.
// Order of components: 11, 22, 33, 23, 13, 12, 32, 31, 21 in the 3D.
// Obtain the current displacement vector of the element and subtract initial displacements (if present)
FloatArray u;
this->computeVectorOf({D_u, D_v, D_w}, VM_Total, tStep, u); // solution vector
if ( initialDisplacements ) {
u.subtract(* initialDisplacements);
}
// Displacement gradient H = du/dX
FloatMatrix B;
this->computeBHmatrixAt(gp, B);
answer.beProductOf(B, u);
// Deformation gradient F = H + I
MaterialMode matMode = gp->giveMaterialMode();
if ( matMode == _3dMat || matMode == _PlaneStrain ) {
answer.at(1) += 1.0;
answer.at(2) += 1.0;
answer.at(3) += 1.0;
} else if ( matMode == _PlaneStress ) {
answer.at(1) += 1.0;
answer.at(2) += 1.0;
} else if ( matMode == _1dMat ) {
answer.at(1) += 1.0;
} else {
OOFEM_ERROR("MaterialMode is not supported yet (%s)", __MaterialModeToString(matMode) );
}
}
示例3: giveShrinkageStrainVector
void
B3SolidMaterial :: giveShrinkageStrainVector(FloatArray &answer,
GaussPoint *gp,
TimeStep *tStep,
ValueModeType mode)
{
FloatArray prevAnswer;
if ( this->shMode == B3_NoShrinkage ) {
answer.resize( StructuralMaterial :: giveSizeOfVoigtSymVector( gp->giveMaterialMode() ) );
answer.zero();
return;
}
if ( ( mode != VM_Total ) && ( mode != VM_Incremental ) ) {
OOFEM_ERROR("unsupported mode");
}
if ( this->shMode == B3_AverageShrinkage ) {
this->computeTotalAverageShrinkageStrainVector(answer, gp, tStep);
if ( ( mode == VM_Incremental ) && ( !tStep->isTheFirstStep() ) ) {
this->computeTotalAverageShrinkageStrainVector( prevAnswer, gp, tStep->givePreviousStep() );
answer.subtract(prevAnswer);
}
} else {
this->computePointShrinkageStrainVector(answer, gp, tStep);
}
}
示例4:
double LineSurfaceTension :: SpatialLocalizerI_giveDistanceFromParametricCenter(const FloatArray &coords)
{
FloatArray c;
c = *this->giveNode(1)->giveCoordinates();
c.add(*this->giveNode(2)->giveCoordinates());
c.times(0.5);
c.subtract(coords);
return c.computeNorm();
}
示例5: initialize
void
PrimaryField :: initialize(ValueModeType mode, TimeStep *tStep, FloatArray &answer, const UnknownNumberingScheme &s)
{
if ( mode == VM_Total ) {
answer = * ( this->giveSolutionVector(tStep) );
} else if ( mode == VM_Incremental ) {
int indxm1 = this->resolveIndx(tStep, -1);
answer = * ( this->giveSolutionVector(tStep) );
answer.subtract( * this->giveSolutionVector(indxm1) );
} else {
OOFEM_ERROR("unsupported mode %s", __ValueModeTypeToString(mode));
}
}
示例6: giveEndForcesVector
void
Beam3d :: giveEndForcesVector(FloatArray &answer, TimeStep *tStep)
{
// computes exact global end-forces vector
FloatArray loadEndForces;
this->giveInternalForcesVector(answer, tStep);
// add exact end forces due to nonnodal loading
this->computeForceLoadVector(loadEndForces, tStep, VM_Total);
if ( loadEndForces.giveSize() ) {
answer.subtract(loadEndForces);
}
}
示例7: giveEndForcesVector
void
Beam2d :: giveEndForcesVector(FloatArray &answer, TimeStep *tStep)
{
// stress equivalent vector in nodes (vector of internal forces)
FloatArray load;
this->giveInternalForcesVector(answer, tStep, false);
// subtract exact end forces due to nonnodal loading
this->computeLocalForceLoadVector(load, tStep, VM_Total);
if ( load.isNotEmpty() ) {
answer.subtract(load);
}
}
示例8: initialize
void
PrimaryField :: initialize(ValueModeType mode, TimeStep *atTime, FloatArray &answer)
{
int neq = emodel->giveNumberOfEquations(this->ut);
answer.resize(neq);
answer.zero();
if ( mode == VM_Total ) {
answer = * ( this->giveSolutionVector(atTime) );
} else if ( mode == VM_Incremental ) {
int indxm1 = this->resolveIndx(atTime, -1);
answer = * ( this->giveSolutionVector(atTime) );
answer.subtract( *this->giveSolutionVector(indxm1) );
} else {
_error2( "giveUnknownValue: unsupported mode %s", __ValueModeTypeToString(mode) );
}
}
示例9: pnum
void TransportGradientPeriodic :: computeField(FloatArray &flux, TimeStep *tStep)
{
DofIDEquationNumbering pnum(true, grad_ids);
EngngModel *emodel = this->giveDomain()->giveEngngModel();
FloatArray tmp;
int npeq = grad_ids.giveSize();
// sigma = residual (since we use the slave dofs) = f_ext - f_int
flux.resize(npeq);
flux.zero();
emodel->assembleVector(flux, tStep, InternalForceAssembler(), VM_Total, pnum, this->domain);
tmp.resize(npeq);
tmp.zero();
emodel->assembleVector(tmp, tStep, ExternalForceAssembler(), VM_Total, pnum, this->domain);
flux.subtract(tmp);
// Divide by the RVE-volume
flux.times(1.0 / ( this->domainSize(this->giveDomain(), this->set) + this->domainSize(this->giveDomain(), this->masterSet) ));
}
示例10: computeReaction
void
StructuralEngngModel :: computeReaction(FloatArray &answer, TimeStep *tStep, int di)
{
FloatArray contribution;
answer.resize( this->giveNumberOfDomainEquations( di, EModelDefaultPrescribedEquationNumbering() ) );
answer.zero();
// Add internal forces
this->assembleVector( answer, tStep, LastEquilibratedInternalForcesVector, VM_Total,
EModelDefaultPrescribedEquationNumbering(), this->giveDomain(di) );
// Subtract external loading
///@todo All engineering models should be using this (for consistency)
//this->assembleVector( answer, tStep, ExternalForcesVector, VM_Total,
// EModelDefaultPrescribedEquationNumbering(), this->giveDomain(di) );
///@todo This method is overloaded in some functions, it needs to be generalized.
this->computeExternalLoadReactionContribution(contribution, tStep, di);
answer.subtract(contribution);
this->updateSharedDofManagers(answer, EModelDefaultPrescribedEquationNumbering(), ReactionExchangeTag);
}
示例11: giveLocalCoordinates
void
CCTPlate3d :: giveLocalCoordinates(FloatArray &answer, FloatArray &global)
// Returns global coordinates given in global vector
// transformed into local coordinate system of the
// receiver
{
FloatArray offset;
// test the parametr
if ( global.giveSize() != 3 ) {
_error("giveLocalCoordinate : cannot transform coordinates - size mismatch");
exit(1);
}
// first ensure that receiver's GtoLRotationMatrix[3,3] is defined
if ( GtoLRotationMatrix == NULL ) {
this->computeGtoLRotationMatrix();
}
offset = global;
offset.subtract(*this->giveNode(1)->giveCoordinates());
answer.beProductOf(* GtoLRotationMatrix, offset);
}
示例12: computeReaction
void
StructuralEngngModel :: computeReaction(FloatArray &answer, TimeStep *tStep, int di)
{
int numRestrDofs = 0;
FloatArray contribution;
FloatArray EquivForces;
numRestrDofs = this->giveNumberOfPrescribedDomainEquations(di, EID_MomentumBalance);
answer.resize(numRestrDofs);
answer.zero();
// Internal forces contribution
this->computeInternalForceReactionContribution(contribution, tStep, di);
answer.add(contribution);
// External loading contribution
this->computeExternalLoadReactionContribution(contribution, tStep, di);
answer.subtract(contribution);
#ifdef __PARALLEL_MODE
this->updateSharedPrescribedDofManagers( answer, ReactionExchangeTag );
#endif
}
示例13: computeSpatialJump
void
StructuralInterfaceElement :: computeSpatialJump(FloatArray &answer, IntegrationPoint *ip, TimeStep *tStep)
{
// Computes the spatial jump vector at the Gauss point (ip) of
// the receiver, at time step (tStep). jump = N*u
FloatMatrix N;
FloatArray u;
if ( !this->isActivated(tStep) ) {
answer.resize(3);
answer.zero();
return;
}
this->computeNmatrixAt(ip, N);
this->computeVectorOf(VM_Total, tStep, u);
// subtract initial displacements, if defined
if ( initialDisplacements ) {
u.subtract(* initialDisplacements);
}
answer.beProductOf(N, u);
}
示例14: sigmaCr
//.........这里部分代码省略.........
//
// construct mapping matrix of active cracks
// this mapping will dynamically change as
// some crack can unlo or reload
//
this->updateActiveCrackMap(gp);
status->giveCrackMap(crackMapping);
// start iteration until stress computed from elastic increment
// is equal to stress computed from cracking strain increment
// we do this computation in reduced stress strain space
dSigma.resize(0);
for ( iter = 1; iter <= 20; iter++ ) {
//
// first check if already cracked
//
if ( status->giveNumberOfTempActiveCracks() ) {
// active crack exist
this->giveCrackedStiffnessMatrix(dcr, TangentStiffness, gp, atTime);
fullDecr = de;
fullDecr.add(dcr);
decr.beSubMatrixOf(fullDecr, crackMapping);
if ( dSigma.giveSize() == 0 ) {
fullDSigma.beProductOf(de, strainIncrement);
dSigma.beSubArrayOf(fullDSigma, crackMapping);
}
decr.solveForRhs(dSigma, crackStrainIterativeIncrement);
for ( i = 1; i <= 3; i++ ) {
if ( ( ind = crackMapping.at(i) ) ) {
crackStrainVector.at(i) += crackStrainIterativeIncrement.at(ind);
}
}
// check for crack closing, updates also cracking map
this->checkIfClosedCracks(gp, crackStrainVector, crackMapping);
// elastic strain component
elastStrain.beDifferenceOf(principalStrain, crackStrainVector);
sigmaEl.beProductOf(de, elastStrain);
// Stress in cracks
for ( i = 1; i <= 3; i++ ) {
if ( crackMapping.at(i) ) {
sigmaCr.at(i) = giveNormalCrackingStress(gp, crackStrainVector.at(i), i);
}
}
// update status
status->letCrackStrainVectorBe(crackStrainVector);
} else {
//
// no active crack exist - elastic behaviour
//
elastStrain.beDifferenceOf(principalStrain, crackStrainVector);
sigmaEl.beProductOf(de, elastStrain);
sigmaCr.zero();
}
// check for new cracks
// and update crack map if necessary
// when we update map, we need to add new crack at end
// because sigmaCr is build
this->checkForNewActiveCracks(activatedCracks, gp, crackStrainVector,
sigmaEl, sigmaCr, principalStrain);
if ( activatedCracks.giveSize() ) {
// update crack map also
this->updateActiveCrackMap(gp, & activatedCracks);
status->giveCrackMap(crackMapping); // update crackMap
}
//
// compute unbalanced stress
// dSigma = sigmaEl - sigmaCr for active cracks
fullDSigma = sigmaEl;
fullDSigma.subtract(sigmaCr);
dSigma.beSubArrayOf(fullDSigma, crackMapping);
// find max error in dSigma
// if max err < allovedErr -> stop iteration
// allowed Err is computed relative to Ft;
// check only for active cracks
maxErr = 0.;
for ( i = 1; i <= dSigma.giveSize(); i++ ) {
if ( fabs( dSigma.at(i) ) > maxErr ) {
maxErr = fabs( dSigma.at(i) );
}
}
if ( maxErr < rcm_STRESSRELERROR * this->give(pscm_Ft, gp) ) {
status->letPrincipalStressVectorBe(sigmaEl);
answer = sigmaEl;
return;
}
} // loop
// convergence not reached
_error("GiveRealStressVector3d - convergence not reached");
}
示例15: shearStrain
void
SimpleInterfaceMaterial :: giveRealStressVector(FloatArray &answer, GaussPoint *gp,
//const FloatArray &totalStrain,// @todo temporary -should not be here /JB
const FloatArray &strainVector,
TimeStep *tStep)
//
// returns real stress vector in 3d stress space of receiver according to
// previous level of stress and current
// strain increment, the only way, how to correctly update gp records
//
{
SimpleInterfaceMaterialStatus *status = static_cast< SimpleInterfaceMaterialStatus * >( this->giveStatus(gp) );
//this->initGpForNewStep(gp);
this->initTempStatus(gp);
FloatArray shearStrain(2), shearStress; //, strainVector;
StructuralElement *el = static_cast< StructuralElement * >( gp->giveElement() );
//el->computeStrainVector(strainVector, gp, tStep);
FloatArray tempShearStressShift = status->giveTempShearStressShift();
const double normalStrain = strainVector.at(1);
double normalStress, maxShearStress, dp;
double shift = -this->kn * this->stiffCoeff * normalClearance;
MaterialMode mMode = el->giveMaterialMode();
//answer.resize(giveSizeOfReducedStressStrainVector(mMode));
answer.zero();
if ( normalStrain + normalClearance <= 0. ) {
normalStress = this->kn * ( normalStrain + normalClearance ) + shift; //in compression and after the clearance gap closed
maxShearStress = fabs(normalStress) * this->frictCoeff;
} else {
normalStress = this->kn * this->stiffCoeff * ( normalStrain + normalClearance ) + shift;
maxShearStress = 0.;
}
switch ( mMode ) {
case _1dInterface:
answer.resize(1);
break;
case _2dInterface:
answer.resize(2);
shearStrain.at(1) = strainVector.at(2);
shearStress.beScaled(this->kn, shearStrain);
shearStress.subtract(tempShearStressShift);
dp = shearStress.dotProduct(shearStress, 1);
if ( dp > maxShearStress * maxShearStress ) {
shearStress.times( maxShearStress / sqrt(dp) );
}
tempShearStressShift.beScaled(this->kn, shearStrain);
tempShearStressShift.subtract(shearStress);
answer.at(2) = shearStress.at(1);
break;
case _3dInterface:
case _3dMat: //JB
answer.resize(3);
shearStrain.at(1) = strainVector.at(2);
shearStrain.at(2) = strainVector.at(3);
shearStress.beScaled(this->kn, shearStrain);
shearStress.subtract(tempShearStressShift);
dp = shearStress.dotProduct(shearStress, 2);
if ( dp > maxShearStress * maxShearStress ) {
shearStress.times( maxShearStress / sqrt(dp) );
}
tempShearStressShift.beScaled(this->kn, shearStrain);
tempShearStressShift.subtract(shearStress);
answer.at(2) = shearStress.at(1);
answer.at(3) = shearStress.at(2);
break;
default:
OOFEM_ERROR("Unsupported interface mode");
}
double lim = 1.e+50;
answer.at(1) = min(normalStress, lim); //threshold on maximum
answer.at(1) = max(answer.at(1), -lim); //threshold on minimum
//answer.at(1) = normalStress > lim ? lim : normalStress < -lim ? -lim : normalStress;
// update gp
status->setTempShearStressShift(tempShearStressShift);
status->letTempStrainVectorBe(strainVector);
status->letTempStressVectorBe(answer);
}