void UserDefinedTemperatureField :: computeValueAt(FloatArray &answer, TimeStep *stepN, FloatArray &coords, ValueModeType mode) // Returns the value of the receiver at time and given position respecting the mode. { int err; double result; if ( ( mode != VM_Incremental ) && ( mode != VM_Total ) ) { _error2( "computeComponentArrayAt: unknown mode (%s)", __ValueModeTypeToString(mode) ); } answer.resize(this->size); std::ostringstream buff; for ( int i = 1; i <= size; i++ ) { buff << "x=" << coords.at(1) << ";y=" << coords.at(2) << ";z=" << coords.at(3) << ";t=" << stepN->giveTargetTime() << ";" <<ftExpression[i-1]; result = myParser.eval(buff.str().c_str(), err); if ( err ) { _error("computeValueAt: parser syntax error"); } answer.at(i) = result; if ( ( mode == VM_Incremental ) && ( !stepN->isTheFirstStep() ) ) { buff << "x=" << coords.at(1) << ";y=" << coords.at(2) << ";z=" << coords.at(3) << ";t=" << (stepN->giveTargetTime() - stepN->giveTimeIncrement()) << ";" << ftExpression[i-1]; result = myParser.eval(buff.str().c_str(), err); if ( err ) { _error("computeValueAt: parser syntax error"); } answer.at(i) -= result; } } }
void PrimaryField :: update(ValueModeType mode, TimeStep *tStep, FloatArray &vectorToStore) { if ( mode == VM_Total ) { * this->giveSolutionVector(tStep) = vectorToStore; } else { OOFEM_ERROR("unsupported mode %s", __ValueModeTypeToString(mode)); } }
// returns hydration power [W/m3 of concrete] void HydratingConcreteMat :: computeInternalSourceVector(FloatArray &val, GaussPoint *gp, TimeStep *atTime, ValueModeType mode) { HydratingConcreteMatStatus *ms = ( HydratingConcreteMatStatus * ) this->giveStatus(gp); val.resize(1); if ( mode == VM_Total ) { val.at(1) = ms->GivePower(atTime); } else { OOFEM_ERROR2( "Undefined mode %s\n", __ValueModeTypeToString(mode) ); } }
int NonStationaryTransportProblem :: giveUnknownDictHashIndx(EquationID type, ValueModeType mode, TimeStep *stepN) { if ( mode == VM_Total ) { //Nodal temperature return 0; } else if ( mode == VM_RhsTotal ) { //Nodal Rhs return 1; } else { _error2( "ValueModeType %s undefined", __ValueModeTypeToString(mode) ); } return 0; }
int NonStationaryTransportProblem :: giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep) { if ( mode == VM_Total ) { //Nodal temperature return 0; } else if ( mode == VM_RhsTotal ) { //Nodal Rhs return 1; } else { OOFEM_ERROR("ValueModeType %s undefined", __ValueModeTypeToString(mode)); } return 0; }
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)); } }
double NLTransientTransportProblem :: giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) // returns unknown quantity like displacement, velocity of equation // This function translates this request to numerical method language { if ( this->requiresUnknownsDictionaryUpdate() ) { if ( mode == VM_Incremental ) { //get difference between current and previous time variable return dof->giveUnknowns()->at(0) - dof->giveUnknowns()->at(1); } int hash = this->giveUnknownDictHashIndx(mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR("Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode) ); } } double t = tStep->giveTargetTime(); TimeStep *previousStep = this->givePreviousStep(), *currentStep = this->giveCurrentStep(); if ( dof->__giveEquationNumber() == 0 ) { OOFEM_ERROR("invalid equation number on DoF %d", dof->giveDofID() ); } if ( ( t >= previousStep->giveTargetTime() ) && ( t <= currentStep->giveTargetTime() ) ) { ///@todo Shouldn't it be enough to just run this? //UnknownsField->giveUnknownValue(dof, mode, currentStep); double rtdt = UnknownsField->giveUnknownValue(dof, VM_Total, currentStep); double rt = UnknownsField->giveUnknownValue(dof, VM_Total, previousStep); double psi = ( t - previousStep->giveTargetTime() ) / currentStep->giveTimeIncrement(); if ( mode == VM_Velocity ) { return ( rtdt - rt ) / currentStep->giveTimeIncrement(); } else if ( mode == VM_Total ) { return psi * rtdt + ( 1. - psi ) * rt; } else if ( mode == VM_Incremental ) { if ( previousStep->isIcApply() ) { return 0; } else { return ( rtdt - rt ); } } else { OOFEM_ERROR("Unknown mode %s is undefined for this problem", __ValueModeTypeToString(mode) ); } } else { OOFEM_ERROR("time value %f not within bounds %f and %f", t, previousStep->giveTargetTime(), currentStep->giveTargetTime() ); } return 0.; // to make compiler happy; }
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) ); } }
int NLTransientTransportProblem :: giveUnknownDictHashIndx(ValueModeType mode, TimeStep *tStep) { if ( mode == VM_Total ) { //Nodal temperature if ( tStep->giveNumber() == this->giveCurrentStep()->giveNumber() ) { //current time return 0; } else if ( tStep->giveNumber() == this->giveCurrentStep()->giveNumber() - 1 ) { //previous time return 1; } else { OOFEM_ERROR("No history available at TimeStep %d = %f, called from TimeStep %d = %f", tStep->giveNumber(), tStep->giveTargetTime(), this->giveCurrentStep()->giveNumber(), this->giveCurrentStep()->giveTargetTime() ); } } else { OOFEM_ERROR("ValueModeType %s undefined", __ValueModeTypeToString(mode)); } return 0; }
double NonStationaryTransportProblem :: giveUnknownComponent(EquationID type, ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) // returns unknown quantity like displacement, velocity of equation eq // This function translates this request to numerical method language { if ( type != EID_ConservationEquation ) { // heat and mass concetration vector OOFEM_ERROR2( "giveUnknownComponent: EquationID %s is undefined for this problem", __EquationIDToString(type) ); return 0.; } if ( this->requiresUnknownsDictionaryUpdate() ) { int hash = this->giveUnknownDictHashIndx(type, mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR2( "giveUnknown: Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode) ); } } if ( dof->__giveEquationNumber() == 0 ) { OOFEM_ERROR2( "giveUnknownComponent: invalid equation number on DoF %d", dof->giveNumber() ); } return UnknownsField->giveUnknownValue(dof, mode, tStep); }
double SUPG :: giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) // returns unknown quantity like displaacement, velocity of equation eq // This function translates this request to numerical method language { if ( this->requiresUnknownsDictionaryUpdate() ) { int hash = this->giveUnknownDictHashIndx(mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR("Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode)); } } else { int eq = dof->__giveEquationNumber(); if ( eq == 0 ) { OOFEM_ERROR("invalid equation number"); } if ( mode == VM_Acceleration ) { return accelerationVector.at(eq); /* * if (tStep->isTheCurrentTimeStep()) { * return accelerationVector.at(eq); * } else if (tStep == givePreviousStep()) { * return previousAccelerationVector.at(eq); * } else OOFEM_ERROR("VM_Acceleration history past previous step not supported"); */ } else if ( mode == VM_Velocity ) { return VelocityPressureField->giveUnknownValue(dof, VM_Total, tStep); } else { return VelocityPressureField->giveUnknownValue(dof, mode, tStep); } } return 0; }
double IncrementalLinearStatic :: giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) { if ( this->requiresUnknownsDictionaryUpdate() ) { int hash = this->giveUnknownDictHashIndx(mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR("Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode) ); } } else { OOFEM_ERROR("Only the mode requiresUnknownsDictionaryUpdate() is supported"); } return 0.; }
double NonStationaryTransportProblem :: giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) // returns unknown quantity like displacement, velocity of equation eq // This function translates this request to numerical method language { if ( this->requiresUnknownsDictionaryUpdate() ) { int hash = this->giveUnknownDictHashIndx(mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR("Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode)); } } if ( dof->__giveEquationNumber() == 0 ) { OOFEM_ERROR("invalid equation number on DoF %d", dof->giveDofID()); } return UnknownsField->giveUnknownValue(dof, mode, tStep); }
double NonStationaryTransportProblem :: giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) // returns unknown quantity like displacement, velocity of equation eq // This function translates this request to numerical method language { if ( this->requiresUnknownsDictionaryUpdate() ) { if (mode == VM_TotalIntrinsic) mode = VM_Total; int hash = this->giveUnknownDictHashIndx(mode, tStep); if ( dof->giveUnknowns()->includes(hash) ) { return dof->giveUnknowns()->at(hash); } else { OOFEM_ERROR("Dof unknowns dictionary does not contain unknown of value mode (%s)", __ValueModeTypeToString(mode)); } } if ( dof->__giveEquationNumber() == 0 ) { OOFEM_ERROR("invalid equation number on DoF %d", dof->giveDofID()); } if (mode == VM_TotalIntrinsic) { /* if (tStep == this->giveCurrentStep()) { double rt = UnknownsField->giveUnknownValue(dof, VM_Total, tStep); double rtm1 = UnknownsField->giveUnknownValue(dof, VM_Total, tStep); return (1.-alpha)*rtm1+alpha*rt; } else { OOFEM_ERROR ("mode only supported for current step"); } */ mode = VM_Total; } return UnknownsField->giveUnknownValue(dof, mode, tStep); }