NumericalMethod *FreeWarping :: giveNumericalMethod(MetaStep *mStep) { if ( isParallel() ) { if ( ( solverType == ST_Petsc ) || ( solverType == ST_Feti ) ) { nMethod.reset( classFactory.createSparseLinSolver(solverType, this->giveDomain(1), this) ); } } else { nMethod.reset( classFactory.createSparseLinSolver(solverType, this->giveDomain(1), this) ); } if ( !nMethod ) { OOFEM_ERROR("linear solver creation failed for lstype %d", solverType); } return nMethod.get(); }
int main(int argc, char *argv[]) { int n, i, j, k = 0, res = 0; scanf("%i", &n); for (i = 0; i < n; ++i) scanf("%i %i", &x[i], &y[i]); for (i = 0; i < n; ++i) for (j = i + 1; j < n; ++j) { a[k] = x[i] - x[j]; b[k++] = y[j] - y[j]; } printf("k = %i\n", k); for (i = 0; i < k; ++i) for (j = i + 1; j < k; ++j) if (!isParallel(i, j)) ++res; else printf("%i %i %i %i\n", a[i], b[i], a[j], b[j]); printf("%i\n", (k * k + k) / 2 - res); return 0; }
Node<std::string> InterpreterDraft6::findLCPA(const Arabica::XPath::NodeSet<std::string>& states) { Arabica::XPath::NodeSet<std::string> ancestors = getProperAncestors(states[0], Node<std::string>()); Node<std::string> ancestor; for (int i = 0; i < ancestors.size(); i++) { if (!isParallel(ancestors[i])) continue; for (int j = 0; j < states.size(); j++) { if (!isDescendant(states[j], ancestors[i]) && (states[j] != ancestors[i])) goto NEXT_ANCESTOR; } ancestor = ancestors[i]; break; NEXT_ANCESTOR: ; } return ancestor; }
IRResultType StaticStructural :: initializeFrom(InputRecord *ir) { IRResultType result; // Required by IR_GIVE_FIELD macro result = StructuralEngngModel :: initializeFrom(ir); if ( result != IRRT_OK ) { return result; } int val = SMT_Skyline; IR_GIVE_OPTIONAL_FIELD(ir, val, _IFT_EngngModel_smtype); sparseMtrxType = ( SparseMtrxType ) val; this->deltaT = 1.0; IR_GIVE_OPTIONAL_FIELD(ir, deltaT, _IFT_StaticStructural_deltat); this->solverType = 0; // Default NR IR_GIVE_OPTIONAL_FIELD(ir, solverType, _IFT_StaticStructural_solvertype); int _val = IG_Tangent; IR_GIVE_OPTIONAL_FIELD(ir, _val, _IFT_EngngModel_initialGuess); this->initialGuessType = ( InitialGuess ) _val; mRecomputeStepAfterPropagation = ir->hasField(_IFT_StaticStructural_recomputeaftercrackpropagation); #ifdef __PARALLEL_MODE ///@todo Where is the best place to create these? if ( isParallel() ) { delete communicator; delete commBuff; commBuff = new CommunicatorBuff( this->giveNumberOfProcesses() ); communicator = new NodeCommunicator(this, commBuff, this->giveRank(), this->giveNumberOfProcesses()); } #endif this->field.reset( new DofDistributedPrimaryField(this, 1, FT_Displacements, 0) ); return IRRT_OK; }
NumericalMethod *FreeWarping :: giveNumericalMethod(MetaStep *mStep) { if ( nMethod ) { return nMethod; } if ( isParallel() ) { if ( ( solverType == ST_Petsc ) || ( solverType == ST_Feti ) ) { nMethod = classFactory.createSparseLinSolver(solverType, this->giveDomain(1), this); } } else { nMethod = classFactory.createSparseLinSolver(solverType, this->giveDomain(1), this); } if ( nMethod == NULL ) { OOFEM_ERROR("linear solver creation failed"); } return nMethod; }
void findConLine(TSafeVector *all, int li, TPoint *p1, int *resl, int cnt, TSafeVector *res,int n, int cur_i, int maxl) { if(n<maxl+1){ for(int i=cur_i; i<(all->length()); i++) { if((i!=li) && ( (*(((TLine*)(all->get(i)))->getp1()) == *p1 ) || (*(((TLine*)(all->get(i)))->getp2()) == *p1))) { resl[cnt] = i; if(*(((TLine*)(all->get(i)))->getp1())==*p1) findConLine(all, i, ((TLine*)(all->get(i)))->getp2(), resl, cnt+1, res, n+1,cur_i,maxl); else findConLine(all, i, ((TLine*)(all->get(i)))->getp1(), resl, cnt+1, res, n+1,cur_i,maxl); } } } else{ if((li==resl[0]) && (*(((TLine*)(all->get(resl[0])))->getp2())==*p1)) { if(maxl==4) { if( !( isCrossed(*(TLine*)(all->get(resl[0])), *(TLine*)(all->get(resl[2]))) || isCrossed(*(TLine*)(all->get(resl[1])), *(TLine*)(all->get(resl[3])))) && !( isParallel(*(TLine*)(all->get(resl[0])), *(TLine*)(all->get(resl[1]))) || isParallel(*(TLine*)(all->get(resl[1])), *(TLine*)(all->get(resl[2]))) || isParallel(*(TLine*)(all->get(resl[2])), *(TLine*)(all->get(resl[3]))) || isParallel(*(TLine*)(all->get(resl[3])), *(TLine*)(all->get(resl[0]))) )) { // найден четырехугольник res->setat(new TRectangle(*(TLine*)(all->get(resl[0])),*(TLine*)(all->get(resl[1])),*(TLine*)(all->get(resl[2])),*(TLine*)(all->get(resl[3]))),res->length()); } } else { if( !(isParallel(*(TLine*)(all->get(resl[0])), *(TLine*)(all->get(resl[1]))) || isParallel(*(TLine*)(all->get(resl[1])), *(TLine*)(all->get(resl[2]))) || isParallel(*(TLine*)(all->get(resl[2])), *(TLine*)(all->get(resl[0]))) )) { // найден трехугольник res->setat(new Triangle(*(TLine*)(all->get(resl[0])),*(TLine*)(all->get(resl[1])),*(TLine*)(all->get(resl[2]))),res->length()); } } } } }
bool line::isInLine(const vector3& p)const { auto dir = p - start_; return isParallel(line(start_, dir)); }
void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>& enabledTransitions) { NodeSet<std::string> statesToEnter; NodeSet<std::string> statesForDefaultEntry; monIter_t monIter; #if VERBOSE std::cout << _name << ": Enabled enter transitions: " << std::endl; for (int i = 0; i < enabledTransitions.size(); i++) { std::cout << "\t" << enabledTransitions[i] << std::endl; } std::cout << std::endl; #endif for (int i = 0; i < enabledTransitions.size(); i++) { Element<std::string> transition = ((Element<std::string>)enabledTransitions[i]); if (!isTargetless(transition)) { std::string transitionType = (iequals(transition.getAttribute("type"), "internal") ? "internal" : "external"); NodeSet<std::string> tStates = getTargetStates(transition); #if VERBOSE std::cout << _name << ": Target States: "; for (int i = 0; i < tStates.size(); i++) { std::cout << ATTR(tStates[i], "id") << ", "; } std::cout << std::endl; #endif Node<std::string> ancestor; Node<std::string> source = getSourceState(transition); #if VERBOSE std::cout << _name << ": Source States: " << ATTR(source, "id") << std::endl; #endif assert(source); bool allDescendants = true; for (int j = 0; j < tStates.size(); j++) { if (!isDescendant(tStates[j], source)) { allDescendants = false; break; } } if (iequals(transitionType, "internal") && isCompound(source) && allDescendants) { ancestor = source; } else { NodeSet<std::string> tmpStates; tmpStates.push_back(source); tmpStates.insert(tmpStates.end(), tStates.begin(), tStates.end()); ancestor = findLCCA(tmpStates); } #if VERBOSE std::cout << _name << ": Ancestor: " << ATTR(ancestor, "id") << std::endl; #endif for (int j = 0; j < tStates.size(); j++) { addStatesToEnter(tStates[j], statesToEnter, statesForDefaultEntry); } #if VERBOSE std::cout << _name << ": States to enter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << LOCALNAME(statesToEnter[i]) << ":" << ATTR(statesToEnter[i], "id") << ", "; } std::cout << std::endl; #endif for (int j = 0; j < tStates.size(); j++) { NodeSet<std::string> ancestors = getProperAncestors(tStates[j], ancestor); #if VERBOSE std::cout << _name << ": Proper Ancestors of " << ATTR(tStates[j], "id") << " and " << ATTR(ancestor, "id") << ": "; for (int i = 0; i < ancestors.size(); i++) { std::cout << ATTR(ancestors[i], "id") << ", "; } std::cout << std::endl; #endif for (int k = 0; k < ancestors.size(); k++) { statesToEnter.push_back(ancestors[k]); if(isParallel(ancestors[k])) { NodeSet<std::string> childs = getChildStates(ancestors[k]); for (int l = 0; l < childs.size(); l++) { bool someIsDescendant = false; for (int m = 0; m < statesToEnter.size(); m++) { if (isDescendant(statesToEnter[m], childs[l])) { someIsDescendant = true; break; } } if (!someIsDescendant) { addStatesToEnter(childs[l], statesToEnter, statesForDefaultEntry); } } } } } } } statesToEnter.to_document_order(); #if VERBOSE std::cout << _name << ": States to enter: "; for (int i = 0; i < statesToEnter.size(); i++) { std::cout << ATTR(statesToEnter[i], "id") << ", "; } std::cout << std::endl; #endif for (int i = 0; i < statesToEnter.size(); i++) { Element<std::string> stateElem = (Element<std::string>)statesToEnter[i]; // extension for flattened interpreters for (unsigned int k = 0; k < statesToEnter.size(); k++) { NodeSet<std::string> invokes = filterChildElements(_nsInfo.xmlNSPrefix + "invoke", statesToEnter[k]); for (unsigned int j = 0; j < invokes.size(); j++) { if (HAS_ATTR(invokes[j], "persist") && DOMUtils::attributeIsTrue(ATTR(invokes[j], "persist"))) { invoke(invokes[j]); } } } // --- MONITOR: beforeEnteringState ------------------------------ for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) { try { (*monIter)->beforeEnteringState(shared_from_this(), stateElem, (i + 1 < statesToEnter.size())); } USCXML_MONITOR_CATCH_BLOCK(beforeEnteringState) } // extension for flattened SCXML documents, we will need an explicit uninvoke element NodeSet<std::string> uninvokes = filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", statesToEnter[i]); for (int j = 0; j < uninvokes.size(); j++) { Element<std::string> uninvokeElem = (Element<std::string>)uninvokes[j]; cancelInvoke(uninvokeElem); } _configuration.push_back(stateElem); _statesToInvoke.push_back(stateElem); // if (_binding == LATE && stateElem.getAttribute("isFirstEntry").size() > 0) { if (_binding == LATE && !isMember(stateElem, _alreadyEntered)) { NodeSet<std::string> dataModelElems = filterChildElements(_nsInfo.xmlNSPrefix + "datamodel", stateElem); if(dataModelElems.size() > 0 && _dataModel) { Arabica::XPath::NodeSet<std::string> dataElems = filterChildElements(_nsInfo.xmlNSPrefix + "data", dataModelElems[0]); for (int j = 0; j < dataElems.size(); j++) { if (dataElems[j].getNodeType() == Node_base::ELEMENT_NODE) initializeData(Element<std::string>(dataElems[j])); } } _alreadyEntered.push_back(stateElem); // stateElem.setAttribute("isFirstEntry", ""); } // execute onentry executable content NodeSet<std::string> onEntryElems = filterChildElements(_nsInfo.xmlNSPrefix + "onEntry", stateElem); executeContent(onEntryElems, false); // --- MONITOR: afterEnteringState ------------------------------ for(monIter_t monIter = _monitors.begin(); monIter != _monitors.end(); monIter++) { try { (*monIter)->afterEnteringState(shared_from_this(), stateElem, (i + 1 < statesToEnter.size())); } USCXML_MONITOR_CATCH_BLOCK(afterEnteringState) } if (isMember(stateElem, statesForDefaultEntry)) { // execute initial transition content for compound states Arabica::XPath::NodeSet<std::string> transitions = _xpath.evaluate("" + _nsInfo.xpathPrefix + "initial/" + _nsInfo.xpathPrefix + "transition", stateElem).asNodeSet(); for (int j = 0; j < transitions.size(); j++) { executeContent(transitions[j]); } } if (isFinal(stateElem)) { internalDoneSend(stateElem); Element<std::string> parent = (Element<std::string>)stateElem.getParentNode(); if (isParallel(parent.getParentNode())) { Element<std::string> grandParent = (Element<std::string>)parent.getParentNode(); Arabica::XPath::NodeSet<std::string> childs = getChildStates(grandParent); bool inFinalState = true; for (int j = 0; j < childs.size(); j++) { if (!isInFinalState(childs[j])) { inFinalState = false; break; } } if (inFinalState) { internalDoneSend(parent); } } } } for (int i = 0; i < _configuration.size(); i++) { Element<std::string> stateElem = (Element<std::string>)_configuration[i]; if (isFinal(stateElem) && parentIsScxmlState(stateElem)) { _running = false; _done = true; } } }
void InterpreterDraft6::addStatesToEnter(const Node<std::string>& state, Arabica::XPath::NodeSet<std::string>& statesToEnter, Arabica::XPath::NodeSet<std::string>& statesForDefaultEntry) { std::string stateId = ((Element<std::string>)state).getAttribute("id"); #if VERBOSE std::cout << "Adding state to enter: " << stateId << std::endl; #endif if (isHistory(state)) { if (_historyValue.find(stateId) != _historyValue.end()) { Arabica::XPath::NodeSet<std::string> historyValue = _historyValue[stateId]; #if VERBOSE std::cout << "History State " << ATTR(state, "id") << ": "; for (int i = 0; i < historyValue.size(); i++) { std::cout << ATTR(historyValue[i], "id") << ", "; } std::cout << std::endl; #endif for (int i = 0; i < historyValue.size(); i++) { addStatesToEnter(historyValue[i], statesToEnter, statesForDefaultEntry); NodeSet<std::string> ancestors = getProperAncestors(historyValue[i], state); #if VERBOSE std::cout << "Proper Ancestors: "; for (int i = 0; i < ancestors.size(); i++) { std::cout << ATTR(ancestors[i], "id") << ", "; } std::cout << std::endl; #endif for (int j = 0; j < ancestors.size(); j++) { statesToEnter.push_back(ancestors[j]); } } } else { NodeSet<std::string> transitions = filterChildElements(_nsInfo.xmlNSPrefix + "transition", state); for (int i = 0; i < transitions.size(); i++) { NodeSet<std::string> targets = getTargetStates(transitions[i]); for (int j = 0; j < targets.size(); j++) { addStatesToEnter(targets[j], statesToEnter, statesForDefaultEntry); // Modifications from chris nuernberger NodeSet<std::string> ancestors = getProperAncestors(targets[j], state); for (int k = 0; k < ancestors.size(); k++) { statesToEnter.push_back(ancestors[k]); } } } } } else { statesToEnter.push_back(state); if (isCompound(state)) { statesForDefaultEntry.push_back(state); NodeSet<std::string> tStates = getInitialStates(state); for (int i = 0; i < tStates.size(); i++) { addStatesToEnter(tStates[i], statesToEnter, statesForDefaultEntry); } // addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry); // NodeSet<std::string> tStates = getTargetStates(getInitialState(state)); } else if(isParallel(state)) { NodeSet<std::string> childStates = getChildStates(state); for (int i = 0; i < childStates.size(); i++) { addStatesToEnter(childStates[i], statesToEnter, statesForDefaultEntry); } } } }
//! Go into VisIt processing loop. Will return when receives a 'STEP' or 'RUN' command from VisIt void DDTSim::visitloop() { // Clear the break_to_ddt flag ddtsim_interface.break_to_ddt = false; // If we've just taken one step, OR if we're automatically updating after every step, // tell VisIt to update our data. if (visitSim.stepping() || visitSim.autoupdate()) { // If we have just taken a step, change us to the stopped mode - otherwise we'll keep stepping // Do this before updating timestep/plots, otherwise VisIt will think the simulation is // still in 'running' mode rather than the correct 'stopped' mode. if (visitSim.stepping()) { visitSim.setRunmode(VISIT_SIMMODE_STOPPED); visitSim.setStepping(false); } libsim.TimeStepChanged(); // Update meshes libsim.UpdatePlots(); // Update data } visitSim.incCycleAndTime(); // Do the VisIt control loop. int blocking, err = 0; int visitstate = -6; do { blocking = (visitSim.runmode() == VISIT_SIMMODE_RUNNING) ? 0 : 1; /* Get input from VisIt or timeout so the simulation can run. */ if (!isParallel() || visitSim.rank() == 0) visitstate = libsim.DetectInput(blocking, -1); if (isParallel()) ddtMpiCompat_Bcast(&visitstate, 1, DDTSIM_MPI_INT, 0, DDTSIM_MPI_COMM_WORLD); /* Do different things depending on the output from VisItDetectInput */ if (visitstate >= -6 && visitstate <= -1) { DDTSim::error("(ddtsim) Rank %i can't recover from VisIt/libsim error (code=%i)!\n",visitSim.rank(),visitstate); err = 1; } else if (visitstate == 0) { /* There was no input from VisIt, return control to sim. */ return; } else if (visitstate == 1) { /* VisIt is trying to connect to sim */ int connected = libsim.AttemptToCompleteConnection(); const char* error = libsim.GetLastError(); if (isParallel()) ddtMpiCompat_Bcast(&connected, 1, DDTSIM_MPI_INT, 0, DDTSIM_MPI_COMM_WORLD); if (connected) { visitSim.setAutoupdate(true); libsim.SetSlaveProcessCallback(SlaveProcessCallback); /* Register command callback */ libsim.SetCommandCallback(ControlCommandCallback,(void*)&pointers); /* Register data access callbacks */ libsim.SetGetDomainList(ddtSimGetDomainList, (void*)&pointers); libsim.SetGetMetaData(ddtSimGetMetaData, (void*)&pointers); libsim.SetGetMesh(ddtSimGetMesh, (void*)&pointers); libsim.SetGetVariable(ddtSimGetVariable, (void*)&pointers); } else DDTSim::error("(ddtsim) Rank %i: VisIt did not connect: %s\n",visitSim.rank(), error); } else if (visitstate == 2) { /* VisIt wants to tell the us something */ visitSim.setRunmode(VISIT_SIMMODE_STOPPED); if (!processVisItCommand()) { /* Disconnect on error or closed connection */ libsim.Disconnect(); /* Stop running if VisIt closes */ visitSim.setRunmode(VISIT_SIMMODE_STOPPED); ddtsim_interface.break_to_ddt = true; break; // Break out of while loop } } } while (!err); }
void EventDispatcherBase<TDerived>::markDescendantsForEntry() { for (auto state = derived().begin(); state != derived().end(); ++state) { if (!(state->m_flags & state_type::InEnterSet)) { state.skipChildren(); continue; } if (state->isCompound()) { // Exactly one state of a compound state has to be marked for entry. bool childMarked = false; for (auto child = state.child_begin(); child != state.child_end(); ++child) { if (child->m_flags & state_type::InEnterSet) { childMarked = true; break; } } if (!childMarked) { if (state->m_flags & (state_type::ShallowHistory | state_type::DeepHistory)) { using history_state_type = ShallowHistoryState<TDerived>; history_state_type* historyState = static_cast<history_state_type*>(&*state); if (historyState->m_latestActiveChild) { historyState->m_latestActiveChild->m_flags |= state_type::InEnterSet; continue; } } if (state_type* initialState = state->initialState()) { do { initialState->m_flags |= state_type::InEnterSet; initialState = initialState->parent(); } while (initialState != &*state); } else { state->m_children->m_flags |= state_type::InEnterSet; } } } else if (state->isParallel()) { // All child states of a parallel state have to be marked for entry. for (auto child = state.child_begin(); child != state.child_end(); ++child) { child->m_flags |= state_type::InEnterSet; } } } }
void StructuralEngngModel :: giveInternalForces(FloatArray &answer, bool normFlag, int di, TimeStep *stepN) { // Simply assembles contributions from each element in domain Element *element; IntArray loc; FloatArray charVec; FloatMatrix R; int nelems; EModelDefaultEquationNumbering dn; answer.resize( this->giveNumberOfEquations( EID_MomentumBalance ) ); answer.zero(); if ( normFlag ) internalForcesEBENorm = 0.0; // Update solution state counter stepN->incrementStateCounter(); #ifdef __PARALLEL_MODE if ( isParallel() ) { exchangeRemoteElementData( RemoteElementExchangeTag ); } #endif nelems = this->giveDomain(di)->giveNumberOfElements(); this->timer.resumeTimer(EngngModelTimer :: EMTT_NetComputationalStepTimer); for ( int i = 1; i <= nelems; i++ ) { element = this->giveDomain(di)->giveElement(i); #ifdef __PARALLEL_MODE // Skip remote elements (these are used as mirrors of remote elements on other domains // when nonlocal constitutive models are used. Their introduction is necessary to // allow local averaging on domains without fine grain communication between domains). if ( element->giveParallelMode() == Element_remote ) continue; #endif element->giveLocationArray( loc, EID_MomentumBalance, dn ); element->giveCharacteristicVector( charVec, InternalForcesVector, VM_Total, stepN ); if ( element->giveRotationMatrix(R, EID_MomentumBalance) ) { charVec.rotatedWith(R, 't'); } answer.assemble(charVec, loc); // Compute element norm contribution. if ( normFlag ) internalForcesEBENorm += charVec.computeSquaredNorm(); } this->timer.pauseTimer( EngngModelTimer :: EMTT_NetComputationalStepTimer ); #ifdef __PARALLEL_MODE this->updateSharedDofManagers(answer, InternalForcesExchangeTag); if ( normFlag ) { // Exchange norm contributions. double localEBENorm = internalForcesEBENorm; internalForcesEBENorm = 0.0; MPI_Allreduce(& localEBENorm, & internalForcesEBENorm, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); } #endif // Remember last internal vars update time stamp. internalVarUpdateStamp = stepN->giveSolutionStateCounter(); }
float Plane::intersects(const Plane& plane) const { // Check if the planes intersect. if ((_normal.x == plane._normal.x && _normal.y == plane._normal.y && _normal.z == plane._normal.z) || !isParallel(plane)) { return Plane::INTERSECTS_INTERSECTING; } // Calculate the point where the given plane's normal vector intersects the given plane. kmVec3 point = { plane._normal.x * -plane._distance, plane._normal.y * -plane._distance, plane._normal.z * -plane._distance }; // Calculate whether the given plane is in the positive or negative half-space of this plane // (corresponds directly to the sign of the distance from the point calculated above to this plane). if (distance(point) > 0.0f) { return Plane::INTERSECTS_FRONT; } else { return Plane::INTERSECTS_BACK; } }
int AdaptiveNonLinearStatic :: adaptiveRemap(Domain *dNew) { int ielem, nelem, result = 1; this->initStepIncrements(); this->ndomains = 2; this->domainNeqs.resize(2); this->domainPrescribedNeqs.resize(2); this->domainNeqs.at(2) = 0; this->domainPrescribedNeqs.at(2) = 0; this->domainList->put(2, dNew); #ifdef __PARALLEL_MODE ParallelContext *pcNew = new ParallelContext(this); this->parallelContextList->put(2, pcNew); #endif // init equation numbering //this->forceEquationNumbering(2); this->forceEquationNumbering(); // measure time consumed by mapping Timer timer; double mc1, mc2, mc3; timer.startTimer(); // map primary unknowns EIPrimaryUnknownMapper mapper; d2_totalDisplacement.resize( this->giveNumberOfDomainEquations( 2, EModelDefaultEquationNumbering() ) ); d2_incrementOfDisplacement.resize( this->giveNumberOfDomainEquations( 2, EModelDefaultEquationNumbering() ) ); d2_totalDisplacement.zero(); d2_incrementOfDisplacement.zero(); result &= mapper.mapAndUpdate( d2_totalDisplacement, VM_Total, this->giveDomain(1), this->giveDomain(2), this->giveCurrentStep() ); result &= mapper.mapAndUpdate( d2_incrementOfDisplacement, VM_Incremental, this->giveDomain(1), this->giveDomain(2), this->giveCurrentStep() ); timer.stopTimer(); mc1 = timer.getUtime(); timer.startTimer(); // map internal ip state nelem = this->giveDomain(2)->giveNumberOfElements(); for ( ielem = 1; ielem <= nelem; ielem++ ) { /* HUHU CHEATING */ #ifdef __PARALLEL_MODE if ( this->giveDomain(2)->giveElement(ielem)->giveParallelMode() == Element_remote ) { continue; } #endif result &= this->giveDomain(2)->giveElement(ielem)->adaptiveMap( this->giveDomain(1), this->giveCurrentStep() ); } /* replace domains */ OOFEM_LOG_DEBUG("deleting old domain\n"); //delete domainList->at(1); //domainList->put(1, dNew); //dNew->setNumber(1); //domainList->put(2, NULL); domainList->put( 1, domainList->unlink(2) ); domainList->at(1)->setNumber(1); #ifdef __PARALLEL_MODE parallelContextList->put( 1, parallelContextList->unlink(2) ); parallelContextList->growTo(1); #endif // keep equation numbering of new domain this->numberOfEquations = this->domainNeqs.at(1) = this->domainNeqs.at(2); this->numberOfPrescribedEquations = this->domainPrescribedNeqs.at(1) = this->domainPrescribedNeqs.at(2); this->equationNumberingCompleted = 1; // update solution totalDisplacement = d2_totalDisplacement; incrementOfDisplacement = d2_incrementOfDisplacement; this->ndomains = 1; // init equation numbering // this->forceEquationNumbering(); this->updateDomainLinks(); #ifdef __PARALLEL_MODE if ( isParallel() ) { // set up communication patterns this->initializeCommMaps(true); this->exchangeRemoteElementData(RemoteElementExchangeTag); } #endif timer.stopTimer(); mc2 = timer.getUtime(); timer.startTimer(); // computes the stresses and calls updateYourself to mapped state for ( ielem = 1; ielem <= nelem; ielem++ ) { /* HUHU CHEATING */ #ifdef __PARALLEL_MODE if ( this->giveDomain(1)->giveElement(ielem)->giveParallelMode() == Element_remote ) { continue; } #endif result &= this->giveDomain(1)->giveElement(ielem)->adaptiveUpdate( this->giveCurrentStep() ); } // finish mapping process for ( ielem = 1; ielem <= nelem; ielem++ ) { /* HUHU CHEATING */ #ifdef __PARALLEL_MODE if ( this->giveDomain(1)->giveElement(ielem)->giveParallelMode() == Element_remote ) { continue; } #endif result &= this->giveDomain(1)->giveElement(ielem)->adaptiveFinish( this->giveCurrentStep() ); } nMethod->reinitialize(); // increment time step if mapped state will be considered as new solution stepL // this->giveNextStep(); if ( equilibrateMappedConfigurationFlag ) { // we need to assemble the load vector in same time as the restarted step, // so new time step is generated with same intrincic time as has the // previous step if equilibrateMappedConfigurationFlag is set. // this allows to equlibrate the previously reached state TimeStep *cts = this->giveCurrentStep(); // increment version of solution step cts->incrementVersion(); //cts->setTime(cts->giveTime()-cts->giveTimeIncrement()); //cts = this->givePreviousStep(); //cts->setTime(cts->giveTime()-cts->giveTimeIncrement()); } if ( this->giveCurrentStep()->giveNumber() == this->giveCurrentMetaStep()->giveFirstStepNumber() ) { this->updateAttributes( this->giveCurrentMetaStep() ); } // increment solution state counter - not needed, IPs are updated by adaptiveUpdate previously called // and there is no change in primary vars. // this->giveCurrentStep()->incrementStateCounter(); // assemble new initial load for new discretization this->assembleInitialLoadVector( initialLoadVector, initialLoadVectorOfPrescribed, this, 1, this->giveCurrentStep() ); this->assembleIncrementalReferenceLoadVectors( incrementalLoadVector, incrementalLoadVectorOfPrescribed, refLoadInputMode, this->giveDomain(1), EID_MomentumBalance, this->giveCurrentStep() ); // assemble new total load for new discretization // this->assembleCurrentTotalLoadVector (totalLoadVector, totalLoadVectorOfPrescribed, this->giveCurrentStep()); // set bcloadVector to zero (no increment within same step) timer.stopTimer(); mc3 = timer.getUtime(); // compute processor time used by the program OOFEM_LOG_INFO("user time consumed by primary mapping: %.2fs\n", mc1); OOFEM_LOG_INFO("user time consumed by ip mapping: %.2fs\n", mc2); OOFEM_LOG_INFO("user time consumed by ip update: %.2fs\n", mc3); OOFEM_LOG_INFO("user time consumed by mapping: %.2fs\n", mc1 + mc2 + mc3); // /******** * #if 0 * { * * // evaluate the force error of mapped configuration * this->updateComponent (this->giveCurrentStep(), InternalRhs); * FloatArray rhs; * * loadVector.resize (this->numberOfEquations); * loadVector.zero(); * this->assemble (loadVector, this->giveCurrentStep(), ExternalForcesVector_Total, this->giveDomain(1)) ; * this->assemble (loadVector, this->giveCurrentStep(), ExternalForcesVector_Total, this->giveDomain(1)); * * rhs = loadVector; * rhs.times(loadLevel); * if (initialLoadVector.isNotEmpty()) rhs.add(initialLoadVector); * rhs.subtract(internalForces); * * // * // compute forceError * // * // err is relative error of unbalanced forces * double RR, RR0, forceErr = dotProduct (rhs.givePointer(),rhs.givePointer(),rhs.giveSize()); * if (initialLoadVector.isNotEmpty()) * RR0 = dotProduct (initialLoadVector.givePointer(), initialLoadVector.givePointer(), initialLoadVector.giveSize()); * else * RR0 = 0.0; * RR = dotProduct(loadVector.givePointer(),loadVector.givePointer(),loadVector.giveSize()); * // we compute a relative error norm * if ((RR0 + RR * loadLevel * loadLevel) < calm_SMALL_NUM) forceErr = 0.; * else forceErr = sqrt (forceErr / (RR0+RR * loadLevel * loadLevel)); * * printf ("Relative Force Error of Mapped Configuration is %-15e\n", forceErr); * * } **#endif *************/ #ifdef __OOFEG ESIEventLoop( YES, const_cast< char * >("AdaptiveRemap: Press Ctrl-p to continue") ); #endif // // bring mapped configuration into equilibrium // if ( equilibrateMappedConfigurationFlag ) { // use secant stiffness to resrore equilibrium NonLinearStatic_stiffnessMode oldStiffMode = this->stiffMode; stiffMode = nls_secantStiffness; if ( initFlag ) { if ( !stiffnessMatrix ) { stiffnessMatrix = classFactory.createSparseMtrx(sparseMtrxType); if ( stiffnessMatrix == NULL ) { OOFEM_ERROR("sparse matrix creation failed"); } } if ( nonlocalStiffnessFlag ) { if ( !stiffnessMatrix->isAsymmetric() ) { OOFEM_ERROR("stiffnessMatrix does not support asymmetric storage"); } } stiffnessMatrix->buildInternalStructure( this, 1, EID_MomentumBalance, EModelDefaultEquationNumbering() ); stiffnessMatrix->zero(); // zero stiffness matrix this->assemble( stiffnessMatrix, this->giveCurrentStep(), EID_MomentumBalance, SecantStiffnessMatrix, EModelDefaultEquationNumbering(), this->giveDomain(1) ); initFlag = 0; } // updateYourself() not necessary - the adaptiveUpdate previously called does the job //this->updateYourself(this->giveCurrentStep()); #ifdef VERBOSE OOFEM_LOG_INFO( "Equilibrating mapped configuration [step number %5d.%d]\n", this->giveCurrentStep()->giveNumber(), this->giveCurrentStep()->giveVersion() ); #endif //double deltaL = nMethod->giveUnknownComponent (StepLength, 0); double deltaL = nMethod->giveCurrentStepLength(); // // call numerical model to solve arised problem // #ifdef VERBOSE OOFEM_LOG_RELEVANT( "Solving [step number %5d.%d]\n", this->giveCurrentStep()->giveNumber(), this->giveCurrentStep()->giveVersion() ); #endif //nMethod -> solveYourselfAt(this->giveCurrentStep()) ; nMethod->setStepLength(deltaL / 5.0); if ( initialLoadVector.isNotEmpty() ) { numMetStatus = nMethod->solve( stiffnessMatrix, & incrementalLoadVector, & initialLoadVector, & totalDisplacement, & incrementOfDisplacement, & internalForces, internalForcesEBENorm, loadLevel, refLoadInputMode, currentIterations, this->giveCurrentStep() ); } else { numMetStatus = nMethod->solve( stiffnessMatrix, & incrementalLoadVector, NULL, & totalDisplacement, & incrementOfDisplacement, & internalForces, internalForcesEBENorm, loadLevel, refLoadInputMode, currentIterations, this->giveCurrentStep() ); } loadVector.zero(); this->updateYourself( this->giveCurrentStep() ); this->terminate( this->giveCurrentStep() ); // this->updateLoadVectors (this->giveCurrentStep()); // already in terminate // restore old step length nMethod->setStepLength(deltaL); stiffMode = oldStiffMode; } else { // comment this, if output for mapped configuration (not equilibrated) not wanted this->printOutputAt( this->giveOutputStream(), this->giveCurrentStep() ); } return result; }