void SimpleCrossSection :: giveTemperatureVector(FloatArray &answer, GaussPoint *gp, TimeStep *tStep) { Element *elem = gp->giveElement(); answer.clear(); //sum up all prescribed temperatures over an element StructuralElement *selem = dynamic_cast< StructuralElement * >(elem); selem->computeResultingIPTemperatureAt(answer, tStep, gp, VM_Total); /* add external source, if provided */ FieldManager *fm = this->domain->giveEngngModel()->giveContext()->giveFieldManager(); FM_FieldPtr tf; if ( ( tf = fm->giveField(FT_Temperature) ) ) { // temperature field registered FloatArray gcoords, et2; int err; elem->computeGlobalCoordinates( gcoords, gp->giveNaturalCoordinates() ); if ( ( err = tf->evaluateAt(et2, gcoords, VM_Total, tStep) ) ) { OOFEM_ERROR("tf->evaluateAt failed, element %d, error code %d", elem->giveNumber(), err); } if ( et2.isNotEmpty() ) { if ( answer.isEmpty() ) { answer = et2; } else { answer.at(1) += et2.at(1); } } } }
double B3SolidMaterial :: giveHumidityIncrement(GaussPoint *gp, TimeStep *tStep) //computes humidity increment at given TimeStep { double humIncrement = 0.; int err, wflag = 0; /* ask for humidity from external sources, if provided */ FieldManager *fm = domain->giveEngngModel()->giveContext()->giveFieldManager(); FM_FieldPtr tf; FloatArray gcoords, et2, ei2; if ( ( tf = fm->giveField(FT_HumidityConcentration) ) ) { // humidity field registered gp->giveElement()->computeGlobalCoordinates( gcoords, gp->giveNaturalCoordinates() ); if ( ( err = tf->evaluateAt(et2, gcoords, VM_Total, tStep) ) ) { OOFEM_ERROR("tf->evaluateAt failed, error value %d", err); } if ( ( err = tf->evaluateAt(ei2, gcoords, VM_Incremental, tStep) ) ) { OOFEM_ERROR("tf->evaluateAt failed, error value %d", err); } // convert water mass to relative humidity humIncrement = this->inverse_sorption_isotherm( et2.at(1) ) - this->inverse_sorption_isotherm( et2.at(1) - ei2.at(1) ); wflag = 1; } if ( wflag == 0 ) { OOFEM_ERROR("external fields not found"); } return humIncrement; }
void LEPlic :: doLagrangianPhase(TimeStep *tStep) { //Maps element nodes along trajectories using basic Runge-Kutta method (midpoint rule) int i, ci, ndofman = domain->giveNumberOfDofManagers(); int nsd = 2; double dt = tStep->giveTimeIncrement(); DofManager *dman; Node *inode; IntArray velocityMask; FloatArray x, x2(nsd), v_t, v_tn1; FloatMatrix t; #if 1 EngngModel *emodel = domain->giveEngngModel(); int err; #endif velocityMask = {V_u, V_v}; updated_XCoords.resize(ndofman); updated_YCoords.resize(ndofman); for ( i = 1; i <= ndofman; i++ ) { dman = domain->giveDofManager(i); inode = dynamic_cast< Node * >(dman); // skip dofmanagers with no position information if ( !inode ) { continue; } // get node coordinates x = * ( inode->giveCoordinates() ); // get velocity field v(tn, x(tn)) for dof manager #if 1 /* Original version */ dman->giveUnknownVector( v_t, velocityMask, VM_Total, tStep->givePreviousStep() ); /* Modified version */ //dman->giveUnknownVector(v_t, velocityMask, VM_Total, tStep); // Original version // compute updated position x(tn)+0.5*dt*v(tn,x(tn)) for ( ci = 1; ci <= nsd; ci++ ) { x2.at(ci) = x.at(ci) + 0.5 *dt *v_t.at(ci); } // compute interpolated velocity field at x2 [ v(tn+1, x(tn)+0.5*dt*v(tn,x(tn))) = v(tn+1, x2) ] FM_FieldPtr vfield; vfield = emodel->giveContext()->giveFieldManager()->giveField(FT_Velocity); if ( vfield == NULL ) { OOFEM_ERROR("Velocity field not available"); } err = vfield->evaluateAt(v_tn1, x2, VM_Total, tStep); if ( err == 1 ) { // point outside domain -> be explicit v_tn1 = v_t; } else if ( err != 0 ) { OOFEM_ERROR("vfield->evaluateAt failed, error code %d", err); } // compute final updated position for ( ci = 1; ci <= nsd; ci++ ) { x2.at(ci) = x.at(ci) + dt *v_tn1.at(ci); } #else // pure explicit version dman->giveUnknownVector(v_t, velocityMask, VM_Total, tStep); for ( ci = 1; ci <= nsd; ci++ ) { x2.at(ci) = x.at(ci) + dt *v_t.at(ci); } #endif // store updated node position updated_XCoords.at(i) = x2.at(1); updated_YCoords.at(i) = x2.at(2); } }