OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
nlineardynamic.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include <iostream>
36 using namespace std;
37 
38 #include "../sm/EngineeringModels/nlineardynamic.h"
39 #include "../sm/Elements/nlstructuralelement.h"
40 #include "../sm/Elements/structuralelementevaluator.h"
41 #include "nummet.h"
42 #include "timestep.h"
43 #include "metastep.h"
44 #include "element.h"
45 #include "dof.h"
46 #include "error.h"
47 #include "verbose.h"
48 #include "sparsenonlinsystemnm.h"
49 #include "nrsolver.h"
50 #include "outputmanager.h"
51 #include "datastream.h"
52 #include "classfactory.h"
53 #include "timer.h"
54 #include "contextioerr.h"
55 #include "sparsemtrx.h"
56 #include "errorestimator.h"
57 #include "unknownnumberingscheme.h"
58 #include "assemblercallback.h"
59 
60 #ifdef __PARALLEL_MODE
61  #include "loadbalancer.h"
62  #include "problemcomm.h"
63  #include "processcomm.h"
64 #endif
65 
66 namespace oofem {
67 REGISTER_EngngModel(NonLinearDynamic);
68 
69 NonLinearDynamic :: NonLinearDynamic(int i, EngngModel *_master) : StructuralEngngModel(i, _master),
70  totalDisplacement(), incrementOfDisplacement(), internalForces(), forcesVector()
71 {
73 
74  ndomains = 1;
76  initFlag = commInitFlag = 1;
77 }
78 
79 
81 {
82 }
83 
84 
86 {
87  if ( mStep == NULL ) {
88  OOFEM_ERROR("undefined meta step");
89  }
90 
91  if ( this->nMethod ) {
92  this->nMethod->reinitialize();
93  } else {
94  this->nMethod.reset( new NRSolver(this->giveDomain(1), this) );
95  }
96 
97  return this->nMethod.get();
98 }
99 
100 
101 void
103 {
104  IRResultType result; // Required by IR_GIVE_FIELD macro
105 
106  InputRecord *ir = mStep->giveAttributesRecord();
107 
109 
110  deltaT = 1.0;
112  if ( deltaT < 0. ) {
113  OOFEM_ERROR("deltaT < 0");
114  }
115 
116  eta = 0;
118 
119  delta = 0;
121 }
122 
123 
126 {
127  IRResultType result; // Required by IR_GIVE_FIELD macro
128 
130  if ( result != IRRT_OK ) {
131  return result;
132  }
133 
134  int val = 0;
136  solverType = ( LinSystSolverType ) val;
137 
138  val = 0;
140  sparseMtrxType = ( SparseMtrxType ) val;
141 
144 
145  deltaT = 1.0;
147  if ( deltaT < 0. ) {
148  OOFEM_ERROR("deltaT < 0");
149  }
150 
151  val = 0;
154 
155  gamma = 0.5;
156  beta = 0.25; // Default Newmark parameters.
158  OOFEM_LOG_INFO("Selecting Newmark-beta metod\n");
162  OOFEM_LOG_INFO("Selecting Two-point Backward Euler method\n");
164  OOFEM_LOG_INFO("Selecting Three-point Backward Euler metod\n");
165  } else {
166  OOFEM_WARNING("Time-stepping scheme not found!");
167  return IRRT_BAD_FORMAT;
168  }
169 
170  MANRMSteps = 0;
172 
173 #ifdef __PARALLEL_MODE
174  if ( isParallel() ) {
176  communicator = new NodeCommunicator(this, commBuff, this->giveRank(),
177  this->giveNumberOfProcesses());
178 
180  nonlocalExt = 1;
182  this->giveNumberOfProcesses());
183  }
184  }
185 #endif
186 
187  return IRRT_OK;
188 }
189 
190 
192 {
193  int eq = dof->__giveEquationNumber();
194 #ifdef DEBUG
195  if ( eq == 0 ) {
196  OOFEM_ERROR("invalid equation number");
197  }
198 #endif
199 
200  if ( tStep != this->giveCurrentStep() ) {
201  OOFEM_ERROR("unknown time step encountered");
202  return 0.;
203  }
204 
205  switch ( mode ) {
206  case VM_Incremental:
207  return incrementOfDisplacement.at(eq);
208 
209  case VM_Total:
210  return totalDisplacement.at(eq);
211 
212  case VM_Velocity:
213  return velocityVector.at(eq);
214 
215  case VM_Acceleration:
216  return accelerationVector.at(eq);
217 
218  default:
219  OOFEM_ERROR("Unknown is of undefined ValueModeType for this problem");
220  }
221 
222  return 0.0;
223 }
224 
225 
227 {
228  int istep = giveNumberOfFirstStep();
229  int mStepNum = 1;
230  StateCounterType counter = 1;
231  double deltaTtmp = deltaT;
232  double totalTime = deltaT;
234 
235  //Do not increase deltaT on microproblem
236  if ( pScale == microScale ) {
237  deltaTtmp = 0.;
238  }
239 
240  if ( currentStep ) {
241  totalTime = currentStep->giveTargetTime() + deltaTtmp;
242  istep = currentStep->giveNumber() + 1;
243  counter = currentStep->giveSolutionStateCounter() + 1;
244  mStepNum = currentStep->giveMetaStepNumber();
245  td = currentStep->giveTimeDiscretization();
246 
247  if ( !this->giveMetaStep(mStepNum)->isStepValid(istep) ) {
248  mStepNum++;
249  if ( mStepNum > nMetaSteps ) {
250  OOFEM_ERROR("no next step available, mStepNum=%d > nMetaSteps=%d", mStepNum, nMetaSteps);
251  }
252  }
253  }
254 
255  previousStep = std :: move(currentStep);
256  currentStep.reset( new TimeStep(istep, this, mStepNum, totalTime, deltaTtmp, counter, td) );
257 
258  return currentStep.get();
259 }
260 
261 
263 {
264  if ( commInitFlag ) {
265  #ifdef __VERBOSE_PARALLEL
266  // Force equation numbering before setting up comm maps.
268  OOFEM_LOG_INFO("[process rank %d] neq is %d\n", this->giveRank(), neq);
269  #endif
270  if ( isParallel() ) {
271  // Set up communication patterns.
272  this->initializeCommMaps();
273  }
274  commInitFlag = 0;
275  }
276 
278 }
279 
280 
281 void
283 {
284  if ( commInitFlag ) {
285  #ifdef __VERBOSE_PARALLEL
286  // Force equation numbering before setting up comm maps.
288  OOFEM_LOG_INFO("[process rank %d] neq is %d\n", this->giveRank(), neq);
289  #endif
290  if ( isParallel() ) {
291  // Set up communication patterns.
292  this->initializeCommMaps();
293  }
294  commInitFlag = 0;
295  }
296 
297 #ifdef VERBOSE
298  OOFEM_LOG_RELEVANT( "\n\nSolving [Step number %8d, Time %15e]\n\n", tStep->giveNumber(), tStep->giveTargetTime() );
299 #endif
300 
301  proceedStep(1, tStep);
302 }
303 
304 void
306 {
307  Domain *domain = this->giveDomain(1);
309 
310  if ( tStep->isTheFirstStep() && initFlag ) {
311  // Initialization
316  velocityVector.resize(neq);
320  internalForces.resize(neq);
332 
334  -deltaT, deltaT, 0);
335 
336  // Considering initial conditions.
337  for ( auto &node : domain->giveDofManagers() ) {
338  for ( Dof *dof: *node ) {
339  // Ask for initial values obtained from
340  // bc (boundary conditions) and ic (initial conditions).
341  if ( !dof->isPrimaryDof() ) {
342  continue;
343  }
344 
345  int jj = dof->__giveEquationNumber();
346  if ( jj ) {
347  totalDisplacement.at(jj) = dof->giveUnknown(VM_Total, stepWhenIcApply);
348  velocityVector.at(jj) = dof->giveUnknown(VM_Velocity, stepWhenIcApply);
349  accelerationVector.at(jj) = dof->giveUnknown(VM_Acceleration, stepWhenIcApply);
350  }
351  }
352  }
353  this->giveInternalForces(internalForces, true, 1, tStep);
354  }
355 }
356 
357 void
359 {
360  // creates system of governing eq's and solves them at given time step
361  // first assemble problem at current time step
362 
364 
365  // Time-stepping constants
366  this->determineConstants(tStep);
367 
368 
369 
370  if ( initFlag ) {
371  // First assemble problem at current time step.
372  // Option to take into account initial conditions.
373  if ( !effectiveStiffnessMatrix ) {
375  // create mass matrix as compcol storage, need only mass multiplication by vector, not linear system solution.
377  }
378 
380  OOFEM_ERROR("sparse matrix creation failed");
381  }
382 
383  if ( nonlocalStiffnessFlag ) {
384  if ( !effectiveStiffnessMatrix->isAsymmetric() ) {
385  OOFEM_ERROR("effectiveStiffnessMatrix does not support asymmetric storage");
386  }
387  }
388 
389  effectiveStiffnessMatrix->buildInternalStructure( this, di, EModelDefaultEquationNumbering() );
390  massMatrix->buildInternalStructure( this, di, EModelDefaultEquationNumbering() );
391 
392  // Assemble mass matrix
393  this->assemble( *massMatrix, tStep, MassMatrixAssembler(),
395 
396  // Initialize vectors
397  help.resize(neq);
398  help.zero();
399  rhs.resize(neq);
400  rhs.zero();
401  rhs2.resize(neq);
402  rhs2.zero();
403 
409 
410  forcesVector.resize(neq);
411  forcesVector.zero();
412 
413  totIterations = 0;
414  initFlag = 0;
415  }
416 
417 #ifdef VERBOSE
418  OOFEM_LOG_DEBUG("Assembling load\n");
419 #endif
420 
421  // Assemble the external forces
422  FloatArray loadVector;
424  loadVector.zero();
425  this->assembleVector( loadVector, tStep, ExternalForceAssembler(),
426  VM_Total, EModelDefaultEquationNumbering(), this->giveDomain(di) );
428 
429  // Assembling the effective load vector
430  for ( int i = 1; i <= neq; i++ ) {
431  //help.beScaled(a2, previousVelocityVector);
432  //help.add(a3, previousAccelerationVector);
433  //help.add(a4 * eta, previousVelocityVector);
434  //help.add(a5 * eta, previousAccelerationVector);
435  //help.add(a6 * eta, previousIncrementOfDisplacement);
437  + eta * ( a4 * previousVelocityVector.at(i)
440  }
441 
442  massMatrix->times(help, rhs);
443 
444  if ( delta != 0 ) {
445  //help.beScaled(a4 * delta, previousVelocityVector);
446  //help.add(a5 * delta, previousAccelerationVector);
447  //help.add(a6 * delta, previousIncrementOfDisplacement);
448  for ( int i = 1; i <= neq; i++ ) {
449  help.at(i) = delta * ( a4 * previousVelocityVector.at(i)
452  }
453  this->timesMtrx(help, rhs2, TangentStiffnessMatrix, this->giveDomain(di), tStep);
454 
455  help.zero();
456  rhs.add(rhs2);
457 
458  //this->assembleVector(rhs, tStep, MatrixProductAssembler(TangentAssembler(), help), VM_Total,
459  // EModelDefaultEquationNumbering(), this->giveDomain(1));
460  }
461 
462  rhs.add(loadVector);
464 
465  //
466  // Set-up numerical model.
467  //
468  this->giveNumericalMethod( this->giveCurrentMetaStep() );
469 
470  //
471  // Call numerical model to solve problem.
472  //
473  double loadLevel = 1.0;
474 
475  if ( totIterations == 0 ) {
477  }
478 
479  NM_Status numMetStatus = nMethod->solve(*effectiveStiffnessMatrix, rhs, NULL,
482  if ( !( numMetStatus & NM_Success ) ) {
483  OOFEM_ERROR("NRSolver failed to solve problem");
484  }
485 
488  for ( int i = 1; i <= neq; i++ ) {
490  velocityVector.at(i) = a1 * incrementOfDisplacement.at(i) - a4 *rhs.at(i) - a5 *rhs2.at(i)
492  }
494 }
495 
496 
497 void
499 {
500  TimeDiscretizationType timeDiscretization = tStep->giveTimeDiscretization();
501 
502  if ( timeDiscretization == TD_Newmark ) {
503  OOFEM_LOG_DEBUG("Solving using Newmark-beta method\n");
504  } else if ( timeDiscretization == TD_TwoPointBackward ) {
505  OOFEM_LOG_DEBUG("Solving using Backward Euler method\n");
506  } else if ( timeDiscretization == TD_ThreePointBackward ) {
507  OOFEM_LOG_DEBUG("Solving using Three-point Backward Euler method\n");
508  if ( tStep->isTheFirstStep() ) {
509  timeDiscretization = TD_TwoPointBackward;
510  }
511  } else {
512  OOFEM_ERROR("Time-stepping scheme not found!\n")
513  }
514 
515  deltaT = tStep->giveTimeIncrement();
516 
517  double dt2 = deltaT * deltaT;
518 
519  if ( timeDiscretization == TD_Newmark ) {
520  a0 = 1. / ( beta * dt2 );
521  a1 = gamma / ( beta * deltaT );
522  a2 = 1. / ( beta * deltaT );
523  a3 = 1. / ( 2. * beta ) - 1.;
524  a4 = ( gamma / beta ) - 1.;
525  a5 = deltaT / 2. * ( gamma / beta - 2. );
526  a6 = 0.;
527  } else if ( timeDiscretization == TD_TwoPointBackward ) {
528  a0 = 1. / dt2;
529  a1 = 1. / deltaT;
530  a2 = 1. / deltaT;
531  a3 = 0.;
532  a4 = 0.;
533  a5 = 0.;
534  a6 = 0.;
535  } else if ( timeDiscretization == TD_ThreePointBackward ) {
536  a0 = 2. / dt2;
537  a1 = 3. / ( 2. * deltaT );
538  a2 = 2. / deltaT;
539  a3 = 0.;
540  a4 = 0.;
541  a5 = 0.;
542  a6 = 1. / ( 2. * deltaT );
543  }
544 }
545 
546 
548 {
549  totIterations = 0;
550 
556 
558 }
559 
561 //
562 // Updates some component, which is used by numerical method
563 // to newly reached state. used mainly by numerical method
564 // when new tanget stiffness is needed during finding
565 // of new equlibrium stage.
566 //
567 {
568 #ifdef TIME_REPORT
569  Timer timer;
570 #endif
571 
572  switch ( cmpn ) {
573  case NonLinearLhs:
574  // Prevent assembly if already assembled ( totIterations > 0 )
575  // Allow if MANRMSteps != 0
576  if ( ( totIterations == 0 ) || MANRMSteps ) {
577 #ifdef VERBOSE
578  OOFEM_LOG_DEBUG("Updating effective stiffness matrix\n");
579 #endif
580 #ifdef TIME_REPORT
581  timer.startTimer();
582 #endif
583 #if 1
584  effectiveStiffnessMatrix->zero();
585  this->assemble(*effectiveStiffnessMatrix, tStep, EffectiveTangentAssembler(TangentStiffness, false, 1 + this->delta * a1, this->a0 + this->eta * this->a1),
587 #else
588  this->assemble(effectiveStiffnessMatrix, tStep, TangentStiffnessMatrix,
590  effectiveStiffnessMatrix->times(1. + this->delta * a1);
591  effectiveStiffnessMatrix->add(this->a0 + this->eta * this->a1, this->massMatrix);
592 #endif
593 #ifdef TIME_REPORT
594  timer.stopTimer();
595  OOFEM_LOG_DEBUG( "User time consumed by updating nonlinear LHS: %.2fs\n", timer.getUtime() );
596 #endif
597  }
598  break;
599  case InternalRhs:
600 #ifdef VERBOSE
601  OOFEM_LOG_DEBUG("Updating internal RHS\n");
602 #endif
603  {
604 #ifdef TIME_REPORT
605  timer.startTimer();
606 #endif
607  if ( ( currentIterations != 0 ) || ( totIterations == 0 ) ) {
608  this->giveInternalForces(internalForces, true, d->giveNumber(), tStep);
609 
610  // Updating the residual vector @ NR-solver
612 
613  massMatrix->times(help, rhs2);
614 
618 
619  if ( delta != 0 ) {
621  this->timesMtrx(help, rhs2, TangentStiffnessMatrix, this->giveDomain(1), tStep);
622  //this->assembleVector(rhs2, tStep, MatrixProductAssembler(TangentAssembler(), help), VM_Total,
623  // EModelDefaultEquationNumbering(), this->giveDomain(1));
624 
626  }
627  }
628 #ifdef TIME_REPORT
629  timer.stopTimer();
630  OOFEM_LOG_DEBUG( "User time consumed by updating internal RHS: %.2fs\n", timer.getUtime() );
631 #endif
632  }
633  break;
634  default:
635  OOFEM_ERROR("Unknown Type of component.");
636  }
637 }
638 
639 void
641 {
642  if ( !this->giveDomain(1)->giveOutputManager()->testTimeStepOutput(tStep) ) {
643  return; // Do not print even Solution step header
644  }
645 
646  fprintf(file, "\n\nOutput for time %.3e, solution step number %d\n", tStep->giveTargetTime(), tStep->giveNumber() );
647  fprintf(file, "Equilibrium reached in %d iterations\n\n", currentIterations);
648 
649  nMethod->printState(file);
650 
651  this->giveDomain(1)->giveOutputManager()->doDofManOutput(file, tStep);
652  this->giveDomain(1)->giveOutputManager()->doElementOutput(file, tStep);
653  this->printReactionForces(tStep, 1, file);
654 }
655 
656 void
658 {
659  static char dofchar[] = "dva";
660  static ValueModeType dofmodes[] = {
661  VM_Total, VM_Velocity, VM_Acceleration
662  };
663 
664  iDof->printMultipleOutputAt(stream, tStep, dofchar, dofmodes, 3);
665 }
666 
668 {
669  contextIOResultType iores;
670 
671  if ( ( iores = EngngModel :: saveContext(stream, mode) ) != CIO_OK ) {
672  THROW_CIOERR(iores);
673  }
674 
675  if ( ( iores = incrementOfDisplacement.storeYourself(stream) ) != CIO_OK ) {
676  THROW_CIOERR(iores);
677  }
678 
679  if ( ( iores = totalDisplacement.storeYourself(stream) ) != CIO_OK ) {
680  THROW_CIOERR(iores);
681  }
682 
683  if ( ( iores = velocityVector.storeYourself(stream) ) != CIO_OK ) {
684  THROW_CIOERR(iores);
685  }
686 
687  if ( ( iores = accelerationVector.storeYourself(stream) ) != CIO_OK ) {
688  THROW_CIOERR(iores);
689  }
690 
691  return CIO_OK;
692 }
693 
694 
696 {
697  contextIOResultType iores;
698 
699  if ( ( iores = EngngModel :: restoreContext(stream, mode) ) != CIO_OK ) {
700  THROW_CIOERR(iores);
701  }
702 
703  if ( ( iores = incrementOfDisplacement.restoreYourself(stream) ) != CIO_OK ) {
704  THROW_CIOERR(iores);
705  }
706 
707  if ( ( iores = totalDisplacement.restoreYourself(stream) ) != CIO_OK ) {
708  THROW_CIOERR(iores);
709  }
710 
711  if ( ( iores = velocityVector.restoreYourself(stream) ) != CIO_OK ) {
712  THROW_CIOERR(iores);
713  }
714 
715  if ( ( iores = accelerationVector.restoreYourself(stream) ) != CIO_OK ) {
716  THROW_CIOERR(iores);
717  }
718 
719  return CIO_OK;
720 }
721 
722 
723 void
725 {
727 
728  this->giveNumericalMethod( this->giveCurrentMetaStep() )->setDomain( this->giveDomain(1) );
729 #ifdef __PARALLEL_MODE
730  if ( this->giveLoadBalancer() ) {
731  this->giveLoadBalancer()->setDomain( this->giveDomain(1) );
732  }
733 
734 #endif
735 }
736 
737 
738 void
740  const UnknownNumberingScheme &s, Domain *domain)
741 {
742 #ifdef TIME_REPORT
743  Timer timer;
744  timer.startTimer();
745 #endif
746 
747  EngngModel :: assemble(answer, tStep, ma, s, domain);
748 
749  if ( ( nonlocalStiffnessFlag ) && dynamic_cast< const TangentAssembler* >(&ma) ) {
750  // Add nonlocal contribution.
751  for ( auto &elem : domain->giveElements() ) {
752  static_cast< NLStructuralElement * >( elem.get() )->addNonlocalStiffnessContributions(answer, s, tStep);
753  }
754 
755  // Print storage statistics.
756  answer.printStatistics();
757  }
758 
759 #ifdef TIME_REPORT
760  timer.stopTimer();
761  OOFEM_LOG_DEBUG( "NonLinearDynamic info: user time consumed by assembly: %.2fs\n", timer.getUtime() );
762 #endif
763 }
764 
765 #ifdef __OOFEG
766 void
768 {
769  Domain *domain = this->giveDomain(1);
770  CharType ctype;
771 
772  if ( type != 1 ) {
773  return;
774  }
775 
776  ctype = TangentStiffnessMatrix;
777 
778  for ( auto &elem : domain->giveElements() ) {
779  elem->showSparseMtrxStructure(ctype, gc, tStep);
780  }
781 
782  for ( auto &elem : domain->giveElements() ) {
783  elem->showExtendedSparseMtrxStructure(ctype, gc, tStep);
784  }
785 }
786 #endif
787 
788 
789 void
791 {
792  int nelem = domain->giveNumberOfElements();
793  //int neq = this->giveNumberOfDomainEquations(1, EModelDefaultEquationNumbering());
794  int jj, kk, n;
795  FloatMatrix charMtrx;
796  IntArray loc;
798 
799  answer.resize( this->giveNumberOfDomainEquations(domain->giveNumber(), en) );
800  answer.zero();
801  for ( int i = 1; i <= nelem; i++ ) {
802  Element *element = domain->giveElement(i);
803  // Skip remote elements (these are used as mirrors of remote elements on other domains
804  // when nonlocal constitutive models are used. They introduction is necessary to
805  // allow local averaging on domains without fine grain communication between domains).
806  if ( element->giveParallelMode() == Element_remote ) {
807  continue;
808  }
809 
810  element->giveLocationArray(loc, en);
811  element->giveCharacteristicMatrix(charMtrx, type, tStep);
812 
813  //
814  // assemble it manually
815  //
816 #ifdef DEBUG
817  if ( loc.giveSize() != charMtrx.giveNumberOfRows() ) {
818  OOFEM_ERROR("dimension mismatch");
819  }
820 
821 #endif
822 
823  n = loc.giveSize();
824 
825  for ( int j = 1; j <= n; j++ ) {
826  jj = loc.at(j);
827  if ( jj ) {
828  for ( int k = 1; k <= n; k++ ) {
829  kk = loc.at(k);
830  if ( kk ) {
831  answer.at(jj) += charMtrx.at(j, k) * vec.at(kk);
832  }
833  }
834  }
835  }
836  }
837 
839 }
840 
841 
842 int
843 NonLinearDynamic :: estimateMaxPackSize(IntArray &commMap, DataStream &buff, int packUnpackType)
844 {
845  int count = 0, pcount = 0;
846  Domain *domain = this->giveDomain(1);
847 
848  if ( packUnpackType == 0 ) {
849  for ( int map: commMap ) {
850  DofManager *dman = domain->giveDofManager( map );
851  for ( Dof *dof: *dman ) {
852  if ( dof->isPrimaryDof() && ( dof->__giveEquationNumber() ) ) {
853  count++;
854  } else {
855  pcount++;
856  }
857  }
858  }
859 
860  return ( buff.givePackSizeOfDouble(1) * max(count, pcount) );
861  } else if ( packUnpackType == 1 ) {
862  for ( int map: commMap ) {
863  count += domain->giveElement( map )->estimatePackSize(buff);
864  }
865 
866  return count;
867  }
868 
869  return 0;
870 }
871 
872 
873 #ifdef __PARALLEL_MODE
874 LoadBalancer *
876 {
877  if ( lb ) {
878  return lb;
879  }
880 
881  if ( loadBalancingFlag ) {
882  lb = classFactory.createLoadBalancer( "parmetis", this->giveDomain(1) );
883  return lb;
884  } else {
885  return NULL;
886  }
887 }
888 
889 
892 {
893  if ( lbm ) {
894  return lbm;
895  }
896 
897  if ( loadBalancingFlag ) {
898  lbm = classFactory.createLoadBalancerMonitor( "wallclock", this);
899  return lbm;
900  } else {
901  return NULL;
902  }
903 }
904 #endif
905 
906 void
908 {
909  Domain *domain = this->giveDomain(1);
910  int ndofman = domain->giveNumberOfDofManagers(), _eq;
911 
912  for ( int idofman = 1; idofman <= ndofman; idofman++ ) {
913  DofManager *_dm = domain->giveDofManager(idofman);
914  for ( Dof *_dof: *_dm ) {
915  if ( _dof->isPrimaryDof() ) {
916  if ( ( _eq = _dof->__giveEquationNumber() ) ) {
917  // pack values in solution vectors
918  _dof->updateUnknownsDictionary( tStep, VM_Total, totalDisplacement.at(_eq) );
919  }
920  }
921  }
922  }
923 }
924 
925 void
927 {
928  Domain *domain = this->giveDomain(1);
929  int ndofman = domain->giveNumberOfDofManagers(), _eq;
930  //int myrank = this->giveRank();
931 
932  // resize target arrays
936 
937  for ( int idofman = 1; idofman <= ndofman; idofman++ ) {
938  DofManager *_dm = domain->giveDofManager(idofman);
939  for ( Dof *_dof: *_dm ) {
940  if ( _dof->isPrimaryDof() ) {
941  if ( ( _eq = _dof->__giveEquationNumber() ) ) {
942  // pack values in solution vectors
943  totalDisplacement.at(_eq) = _dof->giveUnknownsDictionaryValue( tStep, VM_Total );
944  #if 0
945  // debug print
946  if ( _dm->giveParallelMode() == DofManager_shared ) {
947  fprintf(stderr, "[%d] Shared: %d(%d) -> %d\n", myrank, idofman, idof, _eq);
948  } else {
949  fprintf(stderr, "[%d] Local : %d(%d) -> %d\n", myrank, idofman, idof, _eq);
950  }
951 
952  #endif
953  }
954  }
955  }
956  }
957 
958  this->initializeCommMaps(true);
959  nMethod->reinitialize();
960  // reinitialize error estimator (if any)
961  if ( this->giveDomainErrorEstimator(1) ) {
963  }
964 
965  initFlag = true;
966 }
967 
968 } // end namespace oofem
EngngModelTimer timer
E-model timer.
Definition: engngm.h:267
virtual void initializeYourself(TimeStep *tStep)
Provides the opportunity to initialize state variables stored in element integration points according...
virtual void updateAttributes(MetaStep *mStep)
Update receiver attributes according to step metaStep attributes.
Definition: engngm.C:589
LinSystSolverType
The values of this type should be related not to specific solvers, but more to specific packages that...
The representation of EngngModel default unknown numbering.
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Definition: floatarray.C:258
#define NM_Success
Numerical method exited with success.
Definition: nmstatus.h:47
LoadBalancer * createLoadBalancer(const char *name, Domain *d)
Definition: classfactory.C:457
std::unique_ptr< TimeStep > currentStep
Current time step.
Definition: engngm.h:231
InputRecord * giveAttributesRecord()
Returns e-model attributes.
Definition: metastep.h:95
Class and object Domain.
Definition: domain.h:115
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Definition: engngm.C:391
LoadBalancerMonitor * lbm
Definition: engngm.h:293
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
Definition: engngm.C:262
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition: domain.h:432
Base class for all matrices stored in sparse format.
Definition: sparsemtrx.h:60
#define _IFT_NRSolver_manrmsteps
Definition: nrsolver.h:57
Class representing meta step.
Definition: metastep.h:62
#define _IFT_NonLinearDynamic_ddtScheme
This class implements Newton-Raphson Method, derived from abstract NumericalMethod class for solving ...
Definition: nrsolver.h:95
SparseMtrx * createSparseMtrx(SparseMtrxType type)
Creates new instance of sparse matrix corresponding to given keyword.
Definition: classfactory.C:105
Abstract base class for "structural" finite elements with geometrical nonlinearities.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
contextIOResultType storeYourself(DataStream &stream) const
Definition: floatarray.C:872
std::unique_ptr< TimeStep > previousStep
Previous time step.
Definition: engngm.h:233
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
int max(int i, int j)
Returns bigger value form two given decimals.
Definition: mathfem.h:71
MetaStep * giveMetaStep(int i)
Returns the i-th meta step.
Definition: engngm.C:1765
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
int nonlocalExt
Flag indicating if nonlocal extension active, which will cause data to be sent between shared element...
Definition: engngm.h:280
long StateCounterType
StateCounterType type used to indicate solution state.
This base class is an abstraction for numerical algorithm.
Definition: nummet.h:80
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
std::unique_ptr< TimeStep > stepWhenIcApply
Solution step when IC (initial conditions) apply.
Definition: engngm.h:229
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
SparseMtrxType sparseMtrxType
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
FloatArray previousAccelerationVector
Abstract base class for all finite elements.
Definition: element.h:145
FloatArray previousIncrementOfDisplacement
Base class for dof managers.
Definition: dofmanager.h:113
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
Definition: engngm.h:1060
std::vector< std::unique_ptr< DofManager > > & giveDofManagers()
Definition: domain.h:400
virtual void solveYourself()
Starts solution process.
Definition: engngm.C:501
Implementation for assembling the consistent mass matrix.
StateCounterType internalVarUpdateStamp
Contains last time stamp of internal variable update.
Compressed column.
int giveNumber()
Returns domain number.
Definition: domain.h:266
virtual int __giveEquationNumber() const =0
Returns equation number of receiver, usually assigned by emodel.
int giveNumberOfElements() const
Returns number of elements in domain.
Definition: domain.h:434
virtual void giveCharacteristicMatrix(FloatMatrix &answer, CharType type, TimeStep *tStep)
Computes characteristic matrix of receiver of requested type in given time step.
Definition: element.C:569
virtual void printMultipleOutputAt(FILE *File, TimeStep *tStep, char *ch, ValueModeType *mode, int nite)
Prints Dof output (it prints value of unknown related to dof at given timeStep).
Definition: dof.C:92
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
Definition: nmstatus.h:44
#define OOFEM_LOG_DEBUG(...)
Definition: logger.h:128
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual void giveInternalForces(FloatArray &answer, bool normFlag, int di, TimeStep *tStep)
Evaluates the nodal representation of internal forces by assembling contributions from individual ele...
std::unique_ptr< SparseMtrx > massMatrix
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
void printReactionForces(TimeStep *tStep, int id, FILE *out)
Computes and prints reaction forces, computed from nodal internal forces.
#define OOFEM_LOG_RELEVANT(...)
Definition: logger.h:126
virtual void printStatistics() const
Prints the receiver statistics (one-line) to stdout.
Definition: sparsemtrx.h:275
virtual void updateComponent(TimeStep *tStep, NumericalCmpn, Domain *d)
Updates components mapped to numerical method if necessary during solution process.
virtual int estimateMaxPackSize(IntArray &commMap, DataStream &buff, int packUnpackType)
Determines the space necessary for send/receive buffer.
double giveTimeIncrement()
Returns solution step associated time increment.
Definition: timestep.h:150
bool isTheFirstStep()
Check if receiver is first step.
Definition: timestep.C:134
virtual void updateAttributes(MetaStep *mStep)
Update receiver attributes according to step metaStep attributes.
virtual void assemble(SparseMtrx &answer, TimeStep *tStep, const MatrixAssembler &ma, const UnknownNumberingScheme &s, Domain *domain)
Assembles characteristic matrix of required type into given sparse matrix.
Definition: engngm.C:803
void beScaled(double s, const FloatArray &b)
Sets receiver to be .
Definition: floatarray.C:146
bool loadBalancingFlag
If set to true, load balancing is active.
Definition: engngm.h:295
MetaStep * giveCurrentMetaStep()
Returns current meta step.
Definition: engngm.C:1684
std::unique_ptr< SparseMtrx > effectiveStiffnessMatrix
ProblemCommunicator * nonlocCommunicator
NonLocal Communicator. Necessary when nonlocal constitutive models are used.
Definition: engngm.h:306
TimeDiscretizationType
Time discretization used by transient solvers.
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
#define OOFEM_LOG_INFO(...)
Definition: logger.h:127
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
#define _IFT_NonLinearDynamic_eta
NumericalCmpn
Type representing numerical component.
Definition: numericalcmpn.h:46
#define _IFT_EngngModel_smtype
Definition: engngm.h:82
void doElementOutput(FILE *, TimeStep *)
Does the element output.
#define OOFEM_ERROR(...)
Definition: error.h:61
Callback class for assembling specific types of matrices.
#define _IFT_NonLinearDynamic_delta
int ndomains
Number of receiver domains.
Definition: engngm.h:205
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Exchanges necessary remote DofManagers data.
Definition: engngm.C:1957
SparseMtrxType
Enumerative type used to identify the sparse matrix type.
The reference incremental load vector is defined as totalLoadVector assembled at given time...
Implementation for assembling external forces vectors in standard monolithic FE-problems.
Newmark-beta method.
void giveLocationArray(IntArray &locationArray, const UnknownNumberingScheme &s, IntArray *dofIds=NULL) const
Returns the location array (array of code numbers) of receiver for given numbering scheme...
Definition: element.C:390
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
virtual TimeStep * giveNextStep()
Returns next time step (next to current step) of receiver.
contextIOResultType restoreYourself(DataStream &stream)
Definition: floatarray.C:895
ProblemCommunicator * communicator
Communicator.
Definition: engngm.h:303
LinSystSolverType solverType
CommunicatorBuff * commBuff
Common Communicator buffer.
Definition: engngm.h:301
int nMetaSteps
Number of meta steps.
Definition: engngm.h:225
virtual int giveNumberOfFirstStep(bool force=false)
Returns number of first time step used by receiver.
Definition: engngm.h:730
#define _IFT_NonLinearDynamic_gamma
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
FloatArray incrementOfDisplacement
void timesMtrx(FloatArray &answer, FloatArray &vec, CharType type, Domain *domain, TimeStep *tStep)
Abstract base class representing general load balancer.
Definition: loadbalancer.h:108
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
virtual LoadBalancer * giveLoadBalancer()
Returns reference to receiver&#39;s load balancer.
#define _IFT_NonLinearDynamic_nonlocstiff
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
Definition: engngm.C:1527
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to output domain stream, for given time step.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
virtual void packMigratingData(TimeStep *tStep)
Packs receiver data when rebalancing load.
TimeDiscretizationType giveTimeDiscretization()
Returns time discretization.
Definition: timestep.h:196
Class representing vector of real numbers.
Definition: floatarray.h:82
int estimatePackSize(DataStream &buff)
Estimates the necessary pack size to hold all packed data of receiver.
Definition: element.C:1575
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
Definition: element.h:1069
TimeDiscretizationType initialTimeDiscretization
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
std::unique_ptr< SparseNonLinearSystemNM > nMethod
Numerical method used to solve the problem.
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
virtual void reinitialize()
#define _IFT_EngngModel_lstype
Definition: engngm.h:81
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual void unpackMigratingData(TimeStep *tStep)
Unpacks receiver data when rebalancing load.
virtual int givePackSizeOfDouble(int count)=0
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
virtual void showSparseMtrxStructure(int type, oofegGraphicContext &gc, TimeStep *tStep)
Shows the sparse structure of required matrix, type == 1 stiffness.
int giveNumberOfTimeStepWhenIcApply()
Returns the time step number, when initial conditions should apply.
Definition: engngm.h:754
CharType
Definition: chartype.h:87
virtual NumericalMethod * giveNumericalMethod(MetaStep *mStep)
Returns reference to receiver&#39;s numerical method.
Class representing the general Input Record.
Definition: inputrecord.h:101
FloatArray previousVelocityVector
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class implementing single timer, providing wall clock and user time capabilities. ...
Definition: timer.h:46
void assemble(SparseMtrx &answer, TimeStep *tStep, const MatrixAssembler &ma, const UnknownNumberingScheme &, Domain *domain)
Assembles characteristic matrix of required type into given sparse matrix.
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Definition: engngm.h:1058
void initializeCommMaps(bool forceInit=false)
Definition: engngm.C:1942
ClassFactory & classFactory
Definition: classfactory.C:59
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
LoadBalancerMonitor * createLoadBalancerMonitor(const char *name, EngngModel *e)
Definition: classfactory.C:447
void proceedStep(int di, TimeStep *tStep)
FloatArray previousTotalDisplacement
LoadBalancer * lb
Load Balancer.
Definition: engngm.h:292
Element in active domain is only mirror of some remote element.
Definition: element.h:102
#define _IFT_NonLinearDynamic_nonlocalext
virtual ErrorEstimator * giveDomainErrorEstimator(int n)
Service for accessing ErrorEstimator corresponding to particular domain.
Definition: engngm.h:349
OutputManager * giveOutputManager()
Returns domain output manager.
Definition: domain.C:1436
This class implements extension of EngngModel for structural models.
FloatArray internalForcesEBENorm
Norm of nodal internal forces evaluated on element by element basis (squared)
The Communicator and corresponding buffers (represented by this class) are separated in order to allo...
Definition: communicator.h:60
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
Two-point Backward Euler method.
virtual void setDomain(Domain *d)
sets associated Domain
Definition: loadbalancer.h:162
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
virtual void setDomain(Domain *d)
Definition: nummet.h:114
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
FloatArray previousInternalForces
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
void determineConstants(TimeStep *tStep)
virtual TimeStep * giveCurrentStep(bool force=false)
Returns current time step.
Definition: engngm.h:683
virtual void solveYourselfAt(TimeStep *tStep)
Solves problem for given time step.
int giveSize() const
Definition: intarray.h:203
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
Definition: engngm.C:1521
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
Definition: engngm.C:1592
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define _IFT_NonLinearDynamic_deltat
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
problemScale pScale
Multiscale mode.
Definition: engngm.h:257
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
double deltaT
Intrinsic time increment.
void doDofManOutput(FILE *, TimeStep *)
Does the dofmanager output.
Definition: outputmanager.C:78
virtual double giveUnknownComponent(ValueModeType type, TimeStep *tStep, Domain *d, Dof *dof)
Returns requested unknown.
#define _IFT_NonLinearDynamic_beta
Three-point Backward Euler method.
Callback class for assembling effective tangents composed of stiffness and mass matrix.
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: floatmatrix.h:156
void startTimer()
Definition: timer.C:69
double getUtime()
Returns total user time elapsed in seconds.
Definition: timer.C:105
#define OOFEM_WARNING(...)
Definition: error.h:62
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from dofManagers, element, and active boundary condi...
Definition: engngm.C:986
Class representing solution step.
Definition: timestep.h:80
DofManager is shared by neighboring partitions, it is necessary to sum contributions from all contrib...
Definition: dofmanager.h:82
void stopTimer()
Definition: timer.C:77
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual LoadBalancerMonitor * giveLoadBalancerMonitor()
Returns reference to receiver&#39;s load balancer monitor.
Abstract base class representing general load balancer monitor.
Definition: loadbalancer.h:68
virtual void printDofOutputAt(FILE *stream, Dof *iDof, TimeStep *tStep)
DOF printing routine.
virtual void solveYourself()
Starts solution process.
#define REGISTER_EngngModel(class)
Definition: classfactory.h:160
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011