OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
engngm.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 // Milan ?????????????????
36 //#include "gpinitmodule.h"
37 // Milan ?????????????????
38 
39 #include "nummet.h"
40 #include "sparsemtrx.h"
41 #include "engngm.h"
42 #include "timestep.h"
43 #include "metastep.h"
44 #include "element.h"
45 #include "set.h"
46 #include "load.h"
47 #include "bodyload.h"
48 #include "boundaryload.h"
49 #include "nodalload.h"
50 #include "oofemcfg.h"
51 #include "timer.h"
52 #include "dofmanager.h"
53 #include "node.h"
54 #include "activebc.h"
55 #include "timestep.h"
56 #include "verbose.h"
57 #include "datastream.h"
58 #include "oofemtxtdatareader.h"
59 #include "sloangraph.h"
60 #include "logger.h"
61 #include "errorestimator.h"
62 #include "contextioerr.h"
63 #include "outputmanager.h"
64 #include "exportmodulemanager.h"
65 #include "initmodulemanager.h"
66 #include "feinterpol3d.h"
67 #include "classfactory.h"
68 #include "xfem/xfemmanager.h"
69 #include "parallelcontext.h"
70 #include "unknownnumberingscheme.h"
71 #include "contact/contactmanager.h"
72 
73 #ifdef __PARALLEL_MODE
74  #include "problemcomm.h"
75  #include "processcomm.h"
76  #include "loadbalancer.h"
77 #endif
78 
79 #include <cstdio>
80 #include <cstdarg>
81 #include <ctime>
82 
83 #ifdef __OOFEG
84  #include "oofeggraphiccontext.h"
85 #endif
86 
87 
88 namespace oofem {
89 EngngModel :: EngngModel(int i, EngngModel *_master) : domainNeqs(), domainPrescribedNeqs()
90 {
91  suppressOutput = false;
92 
93  number = i;
94  defaultErrEstimator = NULL;
95  numberOfSteps = 0;
98  renumberFlag = false;
100  ndomains = 0;
101  nMetaSteps = 0;
102  profileOpt = false;
104 
105  outputStream = NULL;
106 
107  referenceFileName = "";
108 
110  contextOutputStep = 0;
111  pMode = _processor; // for giveContextFile()
112  pScale = macroScale;
113 
116  master = _master; // master mode by default
117  // create context if in master mode; otherwise request context from master
118  if ( master ) {
120  } else {
121  context = new EngngModelContext();
122  }
123 
124  parallelFlag = 0;
125  numProcs = 1;
126  rank = 0;
127  nonlocalExt = 0;
128 #ifdef __PARALLEL_MODE
129  loadBalancingFlag = false;
131  lb = NULL;
132  lbm = NULL;
133  communicator = NULL;
134  nonlocCommunicator = NULL;
135  commBuff = NULL;
136  #ifdef __USE_MPI
137  comm = MPI_COMM_SELF;
138  #endif
139 #endif
140 }
141 
142 
144 {
145  delete exportModuleManager;
146 
147  delete initModuleManager;
148 
149  // master deletes the context
150  if ( master == NULL ) {
151  delete context;
152  }
153 
154  //fclose (inputStream) ;
155  if ( outputStream ) {
156  fclose(outputStream);
157  }
158 
159  delete defaultErrEstimator;
160 
161 #ifdef __PARALLEL_MODE
162  if ( loadBalancingFlag ) {
163  delete lb;
164  delete lbm;
165  }
166 
167  delete communicator;
168  delete nonlocCommunicator;
169  delete commBuff;
170 #endif
171 }
172 
173 
174 void EngngModel :: setParallelMode(bool newParallelFlag)
175 {
176  parallelFlag = newParallelFlag;
177  if ( parallelFlag ) {
178  initParallel();
179  }
180 }
181 
182 
183 void
185 {
186  // create domains
187  domainNeqs.clear();
191  domainList.clear();
192  domainList.reserve(ndomains);
193  for ( int i = 1; i <= ndomains; i++ ) {
194  domainList.emplace_back(new Domain(i, 0, this));
195  }
196 
197  this->initParallelContexts();
198 }
199 
200 
202 {
204 
205  bool inputReaderFinish = true;
206 
207  this->coreOutputFileName = std :: string(dataOutputFileName);
208  this->dataOutputFileName = std :: string(dataOutputFileName);
209 
210  if ( this->giveProblemMode() == _postProcessor ) {
211  // modify output file name to prevent output to be lost
212  this->dataOutputFileName.append(".oofeg");
213  }
214 
215 
216  this->Instanciate_init(); // Must be done after initializeFrom
217 
218 
219  this->startTime = time(NULL);
220 
221 # ifdef VERBOSE
222  OOFEM_LOG_DEBUG( "Reading all data from \"%s\"\n", referenceFileName.c_str() );
223 # endif
224 
225  simulationDescription = std::string(desc);
226 
227  // instanciate receiver
228  this->initializeFrom(ir);
231 
232  if ( this->nMetaSteps == 0 ) {
233  inputReaderFinish = false;
234  this->instanciateDefaultMetaStep(ir);
235  } else {
236  this->instanciateMetaSteps(dr);
237  }
238 
239  // instanciate initialization module manager
241  // instanciate export module manager
243  this->instanciateDomains(dr);
244 
246 
247  // Milan ??????????????????
248  //GPImportModule* gim = new GPImportModule(this);
249  //gim -> getInput();
250  // Milan ??????????????????
251 
252  // check emodel input record if no default metastep, since all has been read
253  if ( inputReaderFinish ) {
254  ir->finish();
255  }
256 
257  return 1;
258 }
259 
260 
263 {
264  IRResultType result; // Required by IR_GIVE_FIELD macro
265 
267  if ( numberOfSteps <= 0 ) {
268  OOFEM_ERROR("nsteps not specified, bad format");
269  }
270 
271  contextOutputStep = 0;
273  if ( contextOutputStep ) {
275  }
276 
277  renumberFlag = false;
279  profileOpt = false;
281  nMetaSteps = 0;
283  int _val = 1;
285  nonLinFormulation = ( fMode ) _val;
286 
287  int eeTypeId = -1;
289  if ( eeTypeId >= 0 ) {
292  }
293 
295  // fprintf (stderr, "Parallel mode is %d\n", parallelFlag);
296 
297 #ifdef __PARALLEL_MODE
298  /* Load balancing support */
299  _val = 0;
301  loadBalancingFlag = _val;
302 
303  _val = 0;
306 
307 #endif
308 
310 
311  if(suppressOutput) {
312 // printf("Suppressing output.\n");
313  }
314  else {
315 
316  if ( ( outputStream = fopen(this->dataOutputFileName.c_str(), "w") ) == NULL ) {
317  OOFEM_ERROR("Can't open output file %s", this->dataOutputFileName.c_str());
318  }
319 
320  fprintf(outputStream, "%s", PRG_HEADER);
321  fprintf(outputStream, "\nStarting analysis on: %s\n", ctime(& this->startTime) );
322  fprintf(outputStream, "%s\n", simulationDescription.c_str());
323 
324 #ifdef __PARALLEL_MODE
325  if ( this->isParallel() ) {
326  fprintf(outputStream, "Problem rank is %d/%d on %s\n\n", this->rank, this->numProcs, this->processor_name);
327  }
328 #endif
329  }
330 
331  return IRRT_OK;
332 }
333 
334 
335 int
337 {
338  int result = 1;
339  // read problem domains
340  for ( auto &domain: domainList ) {
341  result &= domain->instanciateYourself(dr);
342  }
343  this->postInitialize();
344 
345  return result;
346 }
347 
348 
349 int
351 {
352  int result = 1;
353 
354  // create meta steps
355  metaStepList.clear();
356  metaStepList.reserve(nMetaSteps);
357  for ( int i = 1; i <= this->nMetaSteps; i++ ) {
358  //MetaStep *mstep = new MetaStep(i, this);
359  metaStepList.emplace_back(i, this);
360  }
361 
362  // read problem domains
363  for ( int i = 1; i <= this->nMetaSteps; i++ ) {
365  result &= metaStepList[i-1].initializeFrom(ir);
366  }
367 
368  this->numberOfSteps = metaStepList.size();
369  return result;
370 }
371 
372 
373 int
375 {
376  if ( numberOfSteps == 0 ) {
377  OOFEM_ERROR("nsteps cannot be zero");
378  }
379 
380  // create default meta steps
381  this->nMetaSteps = 1;
382  metaStepList.clear();
383  //MetaStep *mstep = new MetaStep(1, this, numberOfSteps, *ir);
384  metaStepList.emplace_back(1, this, numberOfSteps, *ir);
385 
386  return 1;
387 }
388 
389 
390 int
392 {
393  //
394  // returns number of equations of current problem
395  // this method is implemented here, because some method may add some
396  // conditions into the system and this may results into increased number of
397  // equations.
398  //
400  this->forceEquationNumbering();
401  }
402 
403  return num.isDefault() ? domainNeqs.at(id) : domainPrescribedNeqs.at(id);
404 }
405 
406 
407 int
409 {
410  // forces equation renumbering for current time step
411  // intended mainly for problems with changes of static system
412  // during solution
413  // OUTPUT:
414  // sets this->numberOfEquations and this->numberOfPrescribedEquations and returns this value
415 
416  Domain *domain = this->giveDomain(id);
417  TimeStep *currStep = this->giveCurrentStep();
418 
419  this->domainNeqs.at(id) = 0;
420  this->domainPrescribedNeqs.at(id) = 0;
421 
422  if ( !this->profileOpt ) {
423  for ( auto &node : domain->giveDofManagers() ) {
424  node->askNewEquationNumbers(currStep);
425  }
426 
427  for ( auto &elem : domain->giveElements() ) {
428  int nnodes = elem->giveNumberOfInternalDofManagers();
429  for ( int k = 1; k <= nnodes; k++ ) {
430  elem->giveInternalDofManager(k)->askNewEquationNumbers(currStep);
431  }
432  }
433 
434  // For special boundary conditions;
435  for ( auto &bc : domain->giveBcs() ) {
436  int nnodes = bc->giveNumberOfInternalDofManagers();
437  for ( int k = 1; k <= nnodes; k++ ) {
438  bc->giveInternalDofManager(k)->askNewEquationNumbers(currStep);
439  }
440  }
441  } else {
442  // invoke profile reduction
443  int initialProfile, optimalProfile;
444  Timer timer;
445  OOFEM_LOG_INFO("\nRenumbering DOFs with Sloan's algorithm...\n");
446  timer.startTimer();
447 
448  SloanGraph graph(domain);
449  graph.initialize();
450  graph.tryParameters(0, 0);
451  initialProfile = graph.giveOptimalProfileSize();
452  graph.tryParameters(2, 1);
453  graph.tryParameters(1, 0);
454  graph.tryParameters(5, 1);
455  graph.tryParameters(10, 1);
456  optimalProfile = graph.giveOptimalProfileSize();
457 
458  timer.stopTimer();
459 
460  OOFEM_LOG_DEBUG( "Sloan's algorithm done in %.2fs\n", timer.getUtime() );
461  OOFEM_LOG_DEBUG("Nominal profile %d (old) %d (new)\n", initialProfile, optimalProfile);
462 
463  //FILE* renTableFile = fopen ("rentab.dat","w");
464  //graph.writeOptimalRenumberingTable (renTableFile);
465  graph.askNewOptimalNumbering(currStep);
466  }
467 
468  return domainNeqs.at(id);
469 }
470 
471 
472 int
474 {
475  // set numberOfEquations counter to zero
476  this->numberOfEquations = 0;
477  this->numberOfPrescribedEquations = 0;
478 
479  OOFEM_LOG_DEBUG("Renumbering dofs in all domains\n");
480  for ( int i = 1; i <= this->giveNumberOfDomains(); i++ ) {
481  domainNeqs.at(i) = 0;
482  this->numberOfEquations += this->forceEquationNumbering(i);
483  }
484 
486 
487  for ( int i = 1; i <= this->giveNumberOfDomains(); i++ ) {
489  }
490 
491  for ( std :: size_t i = 1; i <= parallelContextList.size(); i++ ) {
492  this->parallelContextList[i-1].init((int)i);
493  }
494 
495 
496  return this->numberOfEquations;
497 }
498 
499 
500 void
502 {
503  int smstep = 1, sjstep = 1;
504 
506 
507  if ( this->currentStep ) {
508  smstep = this->currentStep->giveMetaStepNumber();
509  sjstep = this->giveMetaStep(smstep)->giveStepRelativeNumber( this->currentStep->giveNumber() ) + 1;
510  }
511 
512  for ( int imstep = smstep; imstep <= nMetaSteps; imstep++, sjstep = 1 ) { //loop over meta steps
513  auto activeMStep = this->giveMetaStep(imstep);
514  // update state according to new meta step
515  this->initMetaStepAttributes(activeMStep);
516 
517  int nTimeSteps = activeMStep->giveNumberOfSteps();
518  for ( int jstep = sjstep; jstep <= nTimeSteps; jstep++ ) { //loop over time steps
521 
522  this->preInitializeNextStep();
523  this->giveNextStep();
524 
525  // renumber equations if necessary. Ensure to call forceEquationNumbering() for staggered problems
526  if ( this->requiresEquationRenumbering( this->giveCurrentStep() ) ) {
527  this->forceEquationNumbering();
528  }
529 
530  OOFEM_LOG_DEBUG("Number of equations %d\n", this->giveNumberOfDomainEquations( 1, EModelDefaultEquationNumbering()) );
531 
532  this->initializeYourself( this->giveCurrentStep() );
533  this->solveYourselfAt( this->giveCurrentStep() );
534  this->updateYourself( this->giveCurrentStep() );
535 
537 
538  this->terminate( this->giveCurrentStep() );
539 
540  double _steptime = this->giveSolutionStepTime();
541  OOFEM_LOG_INFO("EngngModel info: user time consumed by solution step %d: %.2fs\n",
542  this->giveCurrentStep()->giveNumber(), _steptime);
543 
544  if ( !suppressOutput ) {
545  fprintf(this->giveOutputStream(), "\nUser time consumed by solution step %d: %.3f [s]\n\n",
546  this->giveCurrentStep()->giveNumber(), _steptime);
547  }
548 
549 #ifdef __PARALLEL_MODE
550  if ( loadBalancingFlag ) {
551  this->balanceLoad( this->giveCurrentStep() );
552  }
553 
554 #endif
555  }
556  }
557 }
558 
560 {
561  int smstep = 1, sjstep = 1;
562  if ( this->currentStep ) {
563  smstep = this->currentStep->giveMetaStepNumber();
564  sjstep = this->giveMetaStep(smstep)->giveStepRelativeNumber( this->currentStep->giveNumber() ) + 1;
565  }
566 
567  // test if sjstep still valid for MetaStep
568  if (sjstep > this->giveMetaStep(smstep)->giveNumberOfSteps())
569  smstep++;
570  if (smstep > nMetaSteps) return NULL; // no more metasteps
571 
572  this->initMetaStepAttributes(this->giveMetaStep(smstep));
573 
574  this->preInitializeNextStep();
575  return this->giveNextStep();
576 }
577 
578 
579 void
581 {
582  // update attributes
583  this->updateAttributes(mStep); // virtual function
584  // finish data acquiring
585  mStep->giveAttributesRecord()->finish();
586 }
587 
588 void
590 {
591  MetaStep *mStep1 = this->giveMetaStep( mStep->giveNumber() ); //this line ensures correct input file in staggered problem
592  InputRecord *ir = mStep1->giveAttributesRecord();
593 
594  if ( this->giveNumericalMethod(mStep1) ) {
595  this->giveNumericalMethod(mStep1)->initializeFrom(ir);
596  }
597 
598 #ifdef __PARALLEL_MODE
599  if ( this->giveLoadBalancer() ) {
600  this->giveLoadBalancer()->initializeFrom(ir);
601  }
602 
603  if ( this->giveLoadBalancerMonitor() ) {
605  }
606 
607 #endif
608 }
609 
610 
611 void
613 {
614  for ( auto &domain: domainList ) {
615 # ifdef VERBOSE
616  VERBOSE_PRINT0( "Updating domain ", domain->giveNumber() )
617 # endif
618 
619  for ( auto &dman : domain->giveDofManagers() ) {
620  dman->updateYourself(tStep);
621  }
622 
623  // Update xfem manager if it is present
624  if ( domain->hasXfemManager() ) {
625  domain->giveXfemManager()->updateYourself(tStep);
626  }
627 
628 # ifdef VERBOSE
629  VERBOSE_PRINT0("Updated nodes ", domain->giveNumberOfDofManagers())
630 # endif
631 
632 
633  for ( auto &elem : domain->giveElements() ) {
634  // skip remote elements (these are used as mirrors of remote elements on other domains
635  // when nonlocal constitutive models are used. They introduction is necessary to
636  // allow local averaging on domains without fine grain communication between domains).
637  if ( elem->giveParallelMode() == Element_remote ) {
638  continue;
639  }
640 
641  elem->updateYourself(tStep);
642  }
643 
644 # ifdef VERBOSE
645  VERBOSE_PRINT0("Updated Elements ", domain->giveNumberOfElements())
646 # endif
647  }
648 
649  // if there is an error estimator, it should be updated so that values can be exported.
650  if ( this->defaultErrEstimator ) {
652  }
653 }
654 
655 void
657 {
658  if ( !suppressOutput ) {
659  this->doStepOutput(tStep);
660  fflush( this->giveOutputStream() );
661  } else {
663  }
664 
665  this->saveStepContext(tStep, CM_State | CM_Definition);
666 }
667 
668 
669 void
671 {
672  if ( !suppressOutput ) {
673  this->printOutputAt(this->giveOutputStream(), tStep);
674  fflush( this->giveOutputStream() );
675  }
676 
677  // export using export manager
679 }
680 
681 void
683 {
684  if ( this->giveContextOutputMode() == COM_Always || this->giveContextOutputMode() == COM_Required ||
685  ( this->giveContextOutputMode() == COM_UserDefined && tStep->giveNumber() % this->giveContextOutputStep() == 0 ) ) {
686 
687  auto fname = this->giveContextFileName(this->giveCurrentStep()->giveNumber(), this->giveCurrentStep()->giveVersion());
688  FileDataStream stream(fname, true);
689  this->saveContext(stream, mode);
690  }
691 }
692 
693 
694 void
696 {
697  int domCount = 0;
698 
699  for ( auto &domain: domainList ) {
700  domCount += domain->giveOutputManager()->testTimeStepOutput(tStep);
701  }
702 
703  if ( domCount == 0 ) {
704  return; // do not print even Solution step header
705  }
706 
707  fprintf(file, "\n==============================================================");
708  fprintf(file, "\nOutput for time %.8e ", tStep->giveTargetTime() * this->giveVariableScale(VST_Time) );
709  fprintf(file, "\n==============================================================\n");
710  for ( auto &domain: domainList ) {
711  fprintf( file, "Output for domain %3d\n", domain->giveNumber() );
712 
713  domain->giveOutputManager()->doDofManOutput(file, tStep);
714  domain->giveOutputManager()->doElementOutput(file, tStep);
715  }
716 }
717 
718 
719 void
720 EngngModel :: printOutputAt(FILE *file, TimeStep *tStep, const IntArray &nodeSets, const IntArray &elementSets)
721 {
722  for ( auto &domain: domainList ) {
723  int dnum = domain->giveNumber();
724  fprintf( file, "Output for domain %3d\n", dnum );
725  int nset = nodeSets.giveSize() < dnum ? 0 : nodeSets.at(dnum);
726  int eset = elementSets.giveSize() < dnum ? 0 : elementSets.at(dnum);
727 
728  this->outputNodes(file, *domain, tStep, nset);
729  this->outputElements(file, *domain, tStep, eset);
731 #if 0
732  this->outputReactionForces(file, *domain, tStep, nset);
733 #endif
734  }
735 }
736 
737 
738 void
739 EngngModel :: outputNodes(FILE *file, Domain &domain, TimeStep *tStep, int setNum)
740 {
741  fprintf(file, "\n\nNode output:\n------------------\n");
742 
743  if ( setNum == 0 ) { // No set specified, export all
744  for ( auto &dman : domain.giveDofManagers() ) {
745  if ( dman->giveParallelMode() == DofManager_null ) {
746  continue;
747  }
748  dman->printOutputAt(file, tStep);
749  }
750  } else {
751  auto &nodes = domain.giveSet(setNum)->giveNodeList();
752 
753  for ( int inode : nodes ) {
754  auto dman = domain.giveDofManager(inode);
755  if ( dman->giveParallelMode() == DofManager_null ) {
756  continue;
757  }
758  dman->printOutputAt(file, tStep);
759  }
760  }
761  fprintf(file, "\n\n");
762 }
763 
764 
765 void
766 EngngModel :: outputElements(FILE *file, Domain &domain, TimeStep *tStep, int setNum)
767 {
768  fprintf(file, "\n\nElement output:\n---------------\n");
769 
770  if ( setNum == 0 ) {
771  for ( auto &elem : domain.giveElements() ) {
772  if ( elem->giveParallelMode() == Element_remote ) {
773  continue;
774  }
775  elem->printOutputAt(file, tStep);
776  }
777  } else {
778  auto &elements = domain.giveSet(setNum)->giveElementList();
779  for ( int ielem : elements ) {
780  auto element = domain.giveElement(ielem);
781  if ( element->giveParallelMode() == Element_remote ) {
782  continue;
783  }
784  element->printOutputAt(file, tStep);
785  }
786  }
787  fprintf(file, "\n\n");
788 }
789 
790 
792 {
793  printf("\nEngineeringModel: instance %s\n", this->giveClassName() );
794  printf("number of steps: %d\n", this->giveNumberOfSteps() );
795  printf("number of eq's : %d\n", numberOfEquations);
796 }
797 
798 void EngngModel :: printDofOutputAt(FILE *stream, Dof *iDof, TimeStep *tStep)
799 {
800  iDof->printSingleOutputAt(stream, tStep, 'd', VM_Total);
801 }
802 
804  const UnknownNumberingScheme &s, Domain *domain)
805 {
806  IntArray loc;
807  FloatMatrix mat, R;
808 
810  int nelem = domain->giveNumberOfElements();
811 #ifdef _OPENMP
812  #pragma omp parallel for shared(answer) private(mat, R, loc)
813 #endif
814  for ( int ielem = 1; ielem <= nelem; ielem++ ) {
815  auto element = domain->giveElement(ielem);
816  // skip remote elements (these are used as mirrors of remote elements on other domains
817  // when nonlocal constitutive models are used. They introduction is necessary to
818  // allow local averaging on domains without fine grain communication between domains).
819  if ( element->giveParallelMode() == Element_remote || !element->isActivated(tStep) || !this->isElementActivated(element) ) {
820  continue;
821  }
822 
823  ma.matrixFromElement(mat, *element, tStep);
824 
825  if ( mat.isNotEmpty() ) {
826  ma.locationFromElement(loc, *element, s);
828  if ( element->giveRotationMatrix(R) ) {
829  mat.rotatedWith(R);
830  }
831 
832 #ifdef _OPENMP
833  #pragma omp critical
834 #endif
835  if ( answer.assemble(loc, mat) == 0 ) {
836  OOFEM_ERROR("sparse matrix assemble error");
837  }
838  }
839  }
840 
841  for ( auto &bc : domain->giveBcs() ) {
842  auto abc = dynamic_cast< ActiveBoundaryCondition * >(bc.get());
843 
844  if ( abc ) {
847  ma.assembleFromActiveBC(answer, *abc, tStep, s, s);
848  } else if ( bc->giveSetNumber() ) {
849  if ( !bc->isImposed(tStep) ) continue;
850  auto load = dynamic_cast< Load * >(bc.get());
851  if ( !load ) continue;
852  // Now we assemble the corresponding load type for the respective components in the set:
853  IntArray loc, bNodes;
854  FloatMatrix mat, R;
855  BodyLoad *bodyLoad;
856  SurfaceLoad* sLoad;
857  EdgeLoad* eLoad;
858  Set *set = domain->giveSet( bc->giveSetNumber() );
859 
860  if ( ( bodyLoad = dynamic_cast< BodyLoad * >(load) ) ) { // Body load:
861  const IntArray &elements = set->giveElementList();
862  for ( auto ielem : elements ) {
863  auto element = domain->giveElement( ielem );
864  mat.clear();
865  ma.matrixFromLoad(mat, *element, bodyLoad, tStep);
866 
867  if ( mat.isNotEmpty() ) {
868  if ( element->giveRotationMatrix(R) ) {
869  mat.rotatedWith(R);
870  }
871 
872  ma.locationFromElement(loc, *element, s);
873  answer.assemble(loc, mat);
874  }
875  }
876  } else if ( ( sLoad = dynamic_cast< SurfaceLoad * >(load) ) ) {
877  const auto &surfaces = set->giveBoundaryList();
878  for ( int ibnd = 1; ibnd <= surfaces.giveSize() / 2; ++ibnd ) {
879  auto element = domain->giveElement( surfaces.at(ibnd * 2 - 1) );
880  int boundary = surfaces.at(ibnd * 2);
881  mat.clear();
882  ma.matrixFromSurfaceLoad(mat, *element, sLoad, boundary, tStep);
883 
884  if ( mat.isNotEmpty() ) {
885  element->giveInterpolation()->boundaryGiveNodes(bNodes, boundary);
886  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
887  mat.rotatedWith(R);
888  }
889 
890  ma.locationFromElementNodes(loc, *element, bNodes, s);
891  answer.assemble(loc, mat);
892  }
893  }
894  } else if ( ( eLoad = dynamic_cast< EdgeLoad * >(load) ) ) {
895  const auto &edges = set->giveEdgeList();
896  for ( int ibnd = 1; ibnd <= edges.giveSize() / 2; ++ibnd ) {
897  auto element = domain->giveElement( edges.at(ibnd * 2 - 1) );
898  int boundary = edges.at(ibnd * 2);
899  mat.clear();
900  ma.matrixFromEdgeLoad(mat, *element, eLoad, boundary, tStep);
901 
902  if ( mat.isNotEmpty() ) {
903  element->giveInterpolation()->boundaryEdgeGiveNodes(bNodes, boundary);
904  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
905  mat.rotatedWith(R);
906  }
907 
908  ma.locationFromElementNodes(loc, *element, bNodes, s);
909  answer.assemble(loc, mat);
910  }
911  }
912  }
913  }
914  }
915 
916  if ( domain->hasContactManager() ) {
917  OOFEM_ERROR("Contact problems temporarily deactivated");
918  //domain->giveContactManager()->assembleTangentFromContacts(answer, tStep, type, s, s);
919  }
920 
922 
923  answer.assembleBegin();
924  answer.assembleEnd();
925 }
926 
927 
929  const UnknownNumberingScheme &rs, const UnknownNumberingScheme &cs,
930  Domain *domain)
931 // Same as assemble, but with different numbering for rows and columns
932 {
933  IntArray r_loc, c_loc, dofids(0);
934  FloatMatrix mat, R;
935 
937  int nelem = domain->giveNumberOfElements();
938 #ifdef _OPENMP
939  #pragma omp parallel for shared(answer) private(mat, R, r_loc, c_loc)
940 #endif
941  for ( int ielem = 1; ielem <= nelem; ielem++ ) {
942  Element *element = domain->giveElement(ielem);
943 
944  if ( element->giveParallelMode() == Element_remote || !element->isActivated(tStep) || !this->isElementActivated(element) ) {
945  continue;
946  }
947 
948  ma.matrixFromElement(mat, *element, tStep);
949  if ( mat.isNotEmpty() ) {
950  ma.locationFromElement(r_loc, *element, rs);
951  ma.locationFromElement(c_loc, *element, cs);
952  // Rotate it
954  if ( element->giveRotationMatrix(R) ) {
955  mat.rotatedWith(R);
956  }
957 
958 #ifdef _OPENMP
959  #pragma omp critical
960 #endif
961  if ( answer.assemble(r_loc, c_loc, mat) == 0 ) {
962  OOFEM_ERROR("sparse matrix assemble error");
963  }
964  }
965  }
966 
967  for ( auto &gbc : domain->giveBcs() ) {
968  ActiveBoundaryCondition *bc = dynamic_cast< ActiveBoundaryCondition * >( gbc.get() );
969  if ( bc != NULL ) {
970  ma.assembleFromActiveBC(answer, *bc, tStep, rs, cs);
971  }
972  }
973 
974  if ( domain->hasContactManager() ) {
975  OOFEM_ERROR("Contant problems temporarily deactivated");
976  //domain->giveContactManager()->assembleTangentFromContacts(answer, tStep, type, rs, cs);
977  }
978 
980 
981  answer.assembleBegin();
982  answer.assembleEnd();
983 }
984 
985 
987  const VectorAssembler &va, ValueModeType mode,
988  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
989 {
990  if ( eNorms ) {
991  int maxdofids = domain->giveMaxDofID();
992 #ifdef __PARALLEL_MODE
993  if ( this->isParallel() ) {
994  int val;
995  MPI_Allreduce(& maxdofids, & val, 1, MPI_INT, MPI_MAX, this->comm);
996  maxdofids = val;
997  }
998 #endif
999  eNorms->resize(maxdofids);
1000  eNorms->zero();
1001  }
1002 
1003  this->assembleVectorFromDofManagers(answer, tStep, va, mode, s, domain, eNorms);
1004  this->assembleVectorFromElements(answer, tStep, va, mode, s, domain, eNorms);
1005  this->assembleVectorFromBC(answer, tStep, va, mode, s, domain, eNorms);
1006 
1007  if ( this->isParallel() ) {
1008  if ( eNorms ) {
1009  FloatArray localENorms = * eNorms;
1010  this->giveParallelContext(domain->giveNumber())->accumulate(localENorms, *eNorms);
1011  }
1012  }
1013 }
1014 
1015 
1017  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
1018 {
1020  IntArray loc, dofids;
1021  FloatArray charVec;
1022  FloatMatrix R;
1023  IntArray dofIDarry;
1024  int nnode = domain->giveNumberOfDofManagers();
1025 
1027  // Note! For normal master dofs, loc is unique to each node, but there can be slave dofs, so we must keep it shared, unfortunately.
1028 #ifdef _OPENMP
1029  #pragma omp parallel for shared(answer, eNorms) private(R, charVec, loc, dofids)
1030 #endif
1031  for ( int i = 1; i <= nnode; i++ ) {
1032  DofManager *node = domain->giveDofManager(i);
1033 
1034  charVec.clear();
1035  for ( int iload : *node->giveLoadArray() ) { // to more than one load
1036  Load *load = domain->giveLoad(iload);
1037  va.vectorFromNodeLoad(charVec, *node, static_cast< NodalLoad* >(load), tStep, mode);
1038 
1039  if ( node->giveParallelMode() == DofManager_shared ) {
1040  charVec.times( 1. / ( node->givePartitionsConnectivitySize() ) );
1041  }
1042 
1043  if ( charVec.isNotEmpty() ) {
1044  if ( node->computeM2LTransformation(R, dofIDarry) ) {
1045  charVec.rotatedWith(R, 't');
1046  }
1047 
1048  if ( load->giveDofIDs().giveSize() ) {
1049  node->giveLocationArray(load->giveDofIDs(), loc, s);
1050  } else {
1051  node->giveCompleteLocationArray(loc, s);
1052  }
1053 #ifdef _OPENMP
1054  #pragma omp critical
1055 #endif
1056  {
1057  answer.assemble(charVec, loc);
1058  if ( eNorms ) {
1059  node->giveCompleteMasterDofIDArray(dofids);
1060  eNorms->assembleSquared(charVec, dofids);
1061  }
1062  }
1063  }
1064  }
1065  }
1066 
1068 }
1069 
1070 
1072  const VectorAssembler &va, ValueModeType mode,
1073  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
1074 {
1075  int nbc = domain->giveNumberOfBoundaryConditions();
1076 
1078  for ( int i = 1; i <= nbc; ++i ) {
1079  GeneralBoundaryCondition *bc = domain->giveBc(i);
1081  Load *load;
1082 
1083  if ( ( abc = dynamic_cast< ActiveBoundaryCondition * >(bc) ) ) {
1084  va.assembleFromActiveBC(answer, *abc, tStep, mode, s, eNorms);
1085  } else if ( bc->giveSetNumber() && ( load = dynamic_cast< Load * >(bc) ) && bc->isImposed(tStep) ) {
1086  // Now we assemble the corresponding load type fo the respective components in the set:
1087  IntArray dofids, loc, bNodes;
1088  FloatArray charVec;
1089  FloatMatrix R;
1090  BodyLoad *bodyLoad;
1091  SurfaceLoad *sLoad;
1092  EdgeLoad *eLoad;
1093  //BoundaryEdgeLoad *eLoad;
1094  NodalLoad *nLoad;
1095  Set *set = domain->giveSet( bc->giveSetNumber() );
1096 
1097  if ( ( bodyLoad = dynamic_cast< BodyLoad * >(load) ) ) { // Body load:
1098  const IntArray &elements = set->giveElementList();
1099  for ( int ielem = 1; ielem <= elements.giveSize(); ++ielem ) {
1100  Element *element = domain->giveElement( elements.at(ielem) );
1101  if ( element->isActivated(tStep) && this->isElementActivated(element) ) {
1102  charVec.clear();
1103  va.vectorFromLoad(charVec, *element, bodyLoad, tStep, mode);
1104 
1105  if ( charVec.isNotEmpty() ) {
1106  if ( element->giveRotationMatrix(R) ) {
1107  charVec.rotatedWith(R, 't');
1108  }
1109 
1110  va.locationFromElement(loc, *element, s, & dofids);
1111  answer.assemble(charVec, loc);
1112 
1113  if ( eNorms ) {
1114  eNorms->assembleSquared(charVec, dofids);
1115  }
1116  }
1117  }
1118  }
1119  } else if ( ( sLoad = dynamic_cast< SurfaceLoad * >(load) ) ) { // Surface load:
1120  const IntArray &boundaries = set->giveBoundaryList();
1121  for ( int ibnd = 1; ibnd <= boundaries.giveSize() / 2; ++ibnd ) {
1122  Element *element = domain->giveElement( boundaries.at(ibnd * 2 - 1) );
1123  if ( element->isActivated(tStep) && this->isElementActivated(element) ) {
1124 
1125  int boundary = boundaries.at(ibnd * 2);
1126  charVec.clear();
1127  va.vectorFromSurfaceLoad(charVec, *element, sLoad, boundary, tStep, mode);
1128 
1129  if ( charVec.isNotEmpty() ) {
1130  //element->giveInterpolation()->boundaryGiveNodes(bNodes, boundary);
1131  element->giveBoundarySurfaceNodes(bNodes, boundary);
1132  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
1133  charVec.rotatedWith(R, 't');
1134  }
1135 
1136  va.locationFromElementNodes(loc, *element, bNodes, s, & dofids);
1137  answer.assemble(charVec, loc);
1138 
1139  if ( eNorms ) {
1140  eNorms->assembleSquared(charVec, dofids);
1141  }
1142  }
1143  }
1144  }
1145  } else if ( ( eLoad = dynamic_cast< EdgeLoad * >(load) ) ) { // Edge load:
1146  const IntArray &edgeBoundaries = set->giveEdgeList();
1147  for ( int ibnd = 1; ibnd <= edgeBoundaries.giveSize() / 2; ++ibnd ) {
1148  Element *element = domain->giveElement( edgeBoundaries.at(ibnd * 2 - 1) );
1149  if ( element->isActivated(tStep) && this->isElementActivated(element) ) {
1150  int boundary = edgeBoundaries.at(ibnd * 2);
1151  charVec.clear();
1152  va.vectorFromEdgeLoad(charVec, *element, eLoad, boundary, tStep, mode);
1153 
1154  if ( charVec.isNotEmpty() ) {
1155  //element->giveInterpolation()->boundaryEdgeGiveNodes(bNodes, boundary);
1156  element->giveBoundaryEdgeNodes(bNodes, boundary);
1157  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
1158  charVec.rotatedWith(R, 't');
1159  }
1160 
1161  va.locationFromElementNodes(loc, *element, bNodes, s, & dofids);
1162  answer.assemble(charVec, loc);
1163 
1164  if ( eNorms ) {
1165  eNorms->assembleSquared(charVec, dofids);
1166  }
1167  }
1168  }
1169  }
1170  } else if ( ( nLoad = dynamic_cast< NodalLoad * >(load) ) ) { // Nodal load:
1171  const IntArray &nodes = set->giveNodeList();
1172  for ( int idman = 1; idman <= nodes.giveSize(); ++idman ) {
1173  DofManager *node = domain->giveDofManager( nodes.at(idman) );
1174  charVec.clear();
1175  va.vectorFromNodeLoad(charVec, *node, nLoad, tStep, mode);
1176 
1177  if ( charVec.isNotEmpty() ) {
1178  if ( node->computeM2LTransformation(R, nLoad->giveDofIDs()) ) {
1179  charVec.rotatedWith(R, 't');
1180  }
1181 
1182  node->giveLocationArray(nLoad->giveDofIDs(), loc, s);
1183  answer.assemble(charVec, loc);
1184 
1185  if ( eNorms ) {
1186  eNorms->assembleSquared(charVec, dofids);
1187  }
1188  }
1189  }
1190  }
1191  }
1192  }
1193 
1195 }
1196 
1197 
1199  const VectorAssembler &va, ValueModeType mode,
1200  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
1201 //
1202 // for each element in domain
1203 // and assembling every contribution to answer
1204 //
1205 {
1206  IntArray loc, dofids;
1207  FloatMatrix R;
1208  FloatArray charVec;
1209  int nelem = domain->giveNumberOfElements();
1210 
1211 
1214  if ( this->isParallel() ) {
1215  // Copies internal (e.g. Gauss-Point) data from remote elements to make sure they have all information necessary for nonlocal averaging.
1217  }
1218 
1221 #ifdef _OPENMP
1222  #pragma omp parallel for shared(answer, eNorms) private(R, charVec, loc, dofids)
1223 #endif
1224  for ( int i = 1; i <= nelem; i++ ) {
1225  Element *element = domain->giveElement(i);
1226 
1227  // skip remote elements (these are used as mirrors of remote elements on other domains
1228  // when nonlocal constitutive models are used. They introduction is necessary to
1229  // allow local averaging on domains without fine grain communication between domains).
1230  if ( element->giveParallelMode() == Element_remote ) {
1231  continue;
1232  }
1233 
1234  if ( !element->isActivated(tStep) || !this->isElementActivated(element) ) {
1235  continue;
1236  }
1237 
1238 
1239  va.vectorFromElement(charVec, *element, tStep, mode);
1240  if ( charVec.isNotEmpty() ) {
1241  if ( element->giveRotationMatrix(R) ) {
1242  charVec.rotatedWith(R, 't');
1243  }
1244  va.locationFromElement(loc, *element, s, & dofids);
1245 
1246 #ifdef _OPENMP
1247  #pragma omp critical
1248 #endif
1249  {
1250  answer.assemble(charVec, loc);
1251  if ( eNorms ) {
1252  eNorms->assembleSquared(charVec, dofids);
1253  }
1254  }
1255  }
1256 
1257 
1258  // obtain form element its body, surface, edge, and point loads
1259  const IntArray& list = element->giveBodyLoadList();
1260  if (!list.isEmpty()) {
1261  for (int iload=1; iload<=list.giveSize(); iload++) { // loop over body loads
1262  BodyLoad *bodyLoad;
1263  if ((bodyLoad = dynamic_cast< BodyLoad * >(domain->giveLoad(list.at(iload))))) {
1264  charVec.clear();
1265  va.vectorFromLoad(charVec, *element, bodyLoad, tStep, mode);
1266 
1267  if ( charVec.isNotEmpty() ) {
1268  if ( element->giveRotationMatrix(R) ) {
1269  charVec.rotatedWith(R, 't');
1270  }
1271 
1272  va.locationFromElement(loc, *element, s, & dofids);
1273  answer.assemble(charVec, loc);
1274 
1275  if ( eNorms ) {
1276  eNorms->assembleSquared(charVec, dofids);
1277  }
1278  }
1279  }
1280 
1281  } // loop over body load list
1282  } // if (!(list = element->giveBodyLoadList()).isEmpty())
1283 
1284  // obtain from element its boundaryloads (surface+edge)
1285  const IntArray& list2 = element->giveBoundaryLoadList();
1286  IntArray bNodes;
1287  if (!list2.isEmpty()) {
1288  for (int j=1; j<=list2.giveSize()/2; j++) { // loop over boundary loads
1289  int iload = list2.at(j * 2 - 1) ;
1290  int boundary = list2.at(j * 2);
1291  SurfaceLoad *sLoad;
1292  EdgeLoad *eLoad;
1293  if ((eLoad = dynamic_cast< EdgeLoad * >(domain->giveLoad(iload)))) {
1294  charVec.clear();
1295  va.vectorFromEdgeLoad(charVec, *element, eLoad, boundary, tStep, mode);
1296 
1297  if ( charVec.isNotEmpty() ) {
1298  //element->giveInterpolation()->boundaryEdgeGiveNodes(bNodes, boundary);
1299  element->giveBoundaryEdgeNodes(bNodes, boundary);
1300  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
1301  charVec.rotatedWith(R, 't');
1302  }
1303 
1304  va.locationFromElementNodes(loc, *element, bNodes, s, & dofids);
1305  answer.assemble(charVec, loc);
1306 
1307  if ( eNorms ) {
1308  eNorms->assembleSquared(charVec, dofids);
1309  }
1310  }
1311  } else if ((sLoad = dynamic_cast< SurfaceLoad * >(domain->giveLoad(iload)))) {
1312  charVec.clear();
1313  va.vectorFromSurfaceLoad(charVec, *element, sLoad, boundary, tStep, mode);
1314 
1315  if ( charVec.isNotEmpty() ) {
1316  //element->giveInterpolation()->boundaryGiveNodes(bNodes, boundary);
1317  element->giveBoundarySurfaceNodes(bNodes, boundary);
1318  if ( element->computeDofTransformationMatrix(R, bNodes, false) ) {
1319  charVec.rotatedWith(R, 't');
1320  }
1321 
1322  va.locationFromElementNodes(loc, *element, bNodes, s, & dofids);
1323  answer.assemble(charVec, loc);
1324 
1325  if ( eNorms ) {
1326  eNorms->assembleSquared(charVec, dofids);
1327  }
1328  }
1329  } else {
1330  OOFEM_ERROR ("Unsupported element boundary load type");
1331  }
1332  }
1333  } // end loop over lement boundary loads
1334 
1335  } // end loop over elements
1336 
1338 }
1339 
1340 void
1342 {
1343  // Simply assembles contributions from each element in domain
1344  IntArray loc;
1345  FloatArray charVec, delta_u;
1346  FloatMatrix charMatrix, R;
1347  int nelems = domain->giveNumberOfElements();
1349 
1351  answer.zero();
1352 
1354 
1355 #ifdef _OPENMP
1356  #pragma omp parallel for shared(answer) private(R, charMatrix, charVec, loc, delta_u)
1357 #endif
1358  for ( int i = 1; i <= nelems; i++ ) {
1359  Element *element = domain->giveElement(i);
1360 
1361  // Skip remote elements (these are used as mirrors of remote elements on other domains
1362  // when nonlocal constitutive models are used. Their introduction is necessary to
1363  // allow local averaging on domains without fine grain communication between domains).
1364  if ( element->giveParallelMode() == Element_remote ) {
1365  continue;
1366  }
1367 
1368  if ( !element->isActivated(tStep) || !this->isElementActivated(element) ) {
1369  continue;
1370  }
1371 
1372  element->giveLocationArray(loc, dn);
1373 
1374  // Take the tangent from the previous step
1377  element->giveCharacteristicMatrix(charMatrix, type, tStep);
1378  if ( charMatrix.isNotEmpty() ) {
1380 
1381 #if 0
1382  element->computeVectorOf(VM_Incremental, tStep, delta_u);
1383 #else
1384  element->computeVectorOf(VM_Total, tStep, delta_u);
1385  FloatArray tmp;
1386 
1387  if ( tStep->isTheFirstStep() ) {
1388  tmp = delta_u;
1389  tmp.zero();
1390  } else {
1391  element->computeVectorOf(VM_Total, tStep->givePreviousStep(), tmp);
1392  }
1393 
1394  delta_u.subtract(tmp);
1395 #endif
1396 
1397  charVec.beProductOf(charMatrix, delta_u);
1398  if ( element->giveRotationMatrix(R) ) {
1399  charVec.rotatedWith(R, 't');
1400  }
1401 
1403 #ifdef _OPENMP
1404  #pragma omp critical
1405 #endif
1406  {
1407  answer.assemble(charVec, loc);
1408  }
1409  }
1410  }
1411 
1413 }
1414 
1415 
1416 void
1418 {
1419  // Simply assembles contributions from each element in domain
1420  IntArray loc;
1421  FloatArray charVec, delta_u;
1422  FloatMatrix charMatrix, R;
1423  int nelems = domain->giveNumberOfElements();
1425 
1427  answer.zero();
1428 
1430 
1431 #ifdef _OPENMP
1432  #pragma omp parallel for shared(answer) private(R, charMatrix, charVec, loc, delta_u)
1433 #endif
1434  for ( int i = 1; i <= nelems; i++ ) {
1435  Element *element = domain->giveElement(i);
1436 
1437  // Skip remote elements (these are used as mirrors of remote elements on other domains
1438  // when nonlocal constitutive models are used. Their introduction is necessary to
1439  // allow local averaging on domains without fine grain communication between domains).
1440  if ( element->giveParallelMode() == Element_remote ) {
1441  continue;
1442  }
1443 
1444  if ( !element->isActivated(tStep) ) {
1445  continue;
1446  }
1447 
1448  element->giveLocationArray(loc, dn);
1449 
1450  // Take the tangent from the previous step
1453  element->giveCharacteristicMatrix(charMatrix, type, tStep);
1454  element->computeVectorOfPrescribed(VM_Incremental, tStep, delta_u);
1455  if ( charMatrix.isNotEmpty() ) {
1456  charVec.beProductOf(charMatrix, delta_u);
1457  if ( element->giveRotationMatrix(R) ) {
1458  charVec.rotatedWith(R, 't');
1459  }
1460 
1462  #ifdef _OPENMP
1463  #pragma omp critical
1464  #endif
1465  {
1466  answer.assemble(charVec, loc);
1467  }
1468  }
1469  }
1470 
1472 }
1473 
1474 void
1476  const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms)
1477 {
1478  if( domain->hasContactManager()) {
1479  domain->giveContactManager()->assembleVectorFromContacts(answer, tStep, type, mode, s, domain, eNorms);
1480  }
1481 }
1482 
1483 
1484 void
1486 //
1487 // updates some component, which is used by numerical method
1488 // to newly reached state
1489 //
1490 {
1491  OOFEM_ERROR("Unknown Type of component.");
1492 }
1493 
1494 
1495 void
1497 //
1498 // resets all temp data in elements and their gps so only
1499 // non temp variables remain.
1500 // this function can be used if called before this->terminate()
1501 // for current step restart, because it causes complete reset
1502 // of temp variables.
1503 //
1504 {
1505  for ( auto &domain: domainList ) {
1506  for ( auto &elem : domain->giveElements() ) {
1507  // skip remote elements (these are used as mirrors of remote elements on other domains
1508  // when nonlocal constitutive models are used. They introduction is necessary to
1509  // allow local averaging on domains without fine grain communication between domains).
1510  if ( elem->giveParallelMode() == Element_remote ) {
1511  continue;
1512  }
1513 
1514  elem->initForNewStep();
1515  }
1516  }
1517 }
1518 
1519 
1520 void
1522 {
1524 };
1525 
1526 
1528 //
1529 // this procedure is used mainly for two reasons:
1530 //
1531 // - to save context of current model in order to be able to backtrace
1532 // computational history (useful in nonlinear analysis, when you want
1533 // explore another, previously detected load path
1534 //
1535 // - to save context of current model in order to enable
1536 // possibility of post-processing.
1537 //
1538 // saving context means: (if needed may be enhanced)
1539 //
1540 // - save EngngModel state varialbles as displacement, velocity, .. vectors
1541 // - save Elements stress, strain and material history.
1542 //
1543 // This version saves only Element and Material properties.
1544 //
1545 {
1546  contextIOResultType iores;
1547 
1548  if ( !stream.write(giveCurrentStep()->giveNumber()) ) {
1550  }
1551 
1552  if ( ( iores = giveCurrentStep()->saveContext(stream, mode) ) != CIO_OK ) {
1553  THROW_CIOERR(iores);
1554  }
1555 
1556  if ( !stream.write(numberOfEquations) ) {
1558  }
1559 
1560  if ( ( iores = domainNeqs.storeYourself(stream) ) != CIO_OK ) {
1561  THROW_CIOERR(iores);
1562  }
1563 
1564  if ( !stream.write(numberOfPrescribedEquations) ) {
1566  }
1567 
1568  if ( ( iores = domainPrescribedNeqs.storeYourself(stream) ) != CIO_OK ) {
1569  THROW_CIOERR(iores);
1570  }
1571 
1572  if ( !stream.write(renumberFlag) ) {
1574  }
1575 
1576  for ( auto &domain: domainList ) {
1577  domain->saveContext(stream, mode);
1578  }
1579 
1580  // store nMethod
1581  NumericalMethod *nmethod = this->giveNumericalMethod( this->giveMetaStep( giveCurrentStep()->giveMetaStepNumber() ) );
1582  if ( nmethod ) {
1583  if ( ( iores = nmethod->saveContext(stream, mode) ) != CIO_OK ) {
1584  THROW_CIOERR(iores);
1585  }
1586  }
1587 
1588  return CIO_OK;
1589 }
1590 
1591 
1593 //
1594 // this procedure is used mainly for two reasons:
1595 //
1596 // - to restore context of current model in order to be able to backtrace
1597 // computational history (useful in nonlinear analysis, when you want
1598 // explore another, previously detected load path
1599 //
1600 // - to restore context of current model in order to enable
1601 // possibility of post-processing.
1602 //
1603 // restoring context means: (if needed may be enhanced)
1604 //
1605 // - rest. EngngModel state varialbles as displacement, velocity, .. vectors
1606 // - rest. Elements stress, strain and material history.
1607 //
1608 // This version loads only Element and Material properties.
1609 //
1610 // This function is inverse to the saveContext() member function
1611 {
1612  contextIOResultType iores;
1613 
1614  // restore solution step
1615  int istep;
1616  if ( !stream.read(istep) ) {
1618  }
1619 
1620  if ( !currentStep ) {
1621  currentStep.reset( new TimeStep(istep, this, 0, 0., 0., 0) );
1622  }
1623 
1624  if ( ( iores = currentStep->restoreContext(stream, mode) ) != CIO_OK ) {
1625  THROW_CIOERR(iores);
1626  }
1627 
1628  // this->updateAttributes (currentStep);
1629 
1630  int pmstep = currentStep->giveMetaStepNumber();
1631  if ( nMetaSteps ) {
1632  if ( !this->giveMetaStep(pmstep)->isStepValid(istep - 1) ) {
1633  pmstep--;
1634  }
1635  }
1636 
1637  previousStep.reset( new TimeStep(istep - 1, this, pmstep, currentStep->giveTargetTime ( ) - currentStep->giveTimeIncrement(),
1638  currentStep->giveTimeIncrement(), currentStep->giveSolutionStateCounter() - 1) );
1639 
1640  // restore numberOfEquations and domainNeqs array
1641  if ( !stream.read(numberOfEquations) ) {
1643  }
1644 
1645  if ( ( iores = domainNeqs.restoreYourself(stream) ) != CIO_OK ) {
1646  THROW_CIOERR(iores);
1647  }
1648 
1649  // restore numberOfPrescribedEquations and domainNeqs array
1650  if ( !stream.read(numberOfPrescribedEquations) ) {
1652  }
1653 
1654  if ( ( iores = domainPrescribedNeqs.restoreYourself(stream) ) != CIO_OK ) {
1655  THROW_CIOERR(iores);
1656  }
1657 
1658  // restore renumber flag
1659  if ( !stream.read(renumberFlag) ) {
1661  }
1662 
1663  for ( auto &domain: domainList ) {
1664  domain->restoreContext(stream, mode);
1665  }
1666 
1667  // restore nMethod
1668  NumericalMethod *nmethod = this->giveNumericalMethod( this->giveCurrentMetaStep() );
1669  if ( nmethod ) {
1670  if ( ( iores = nmethod->restoreContext(stream, mode) ) != CIO_OK ) {
1671  THROW_CIOERR(iores);
1672  }
1673  }
1674 
1675  this->updateDomainLinks();
1676  this->updateAttributes( this->giveCurrentMetaStep() );
1677  this->initStepIncrements();
1678 
1679  return CIO_OK;
1680 }
1681 
1682 
1683 MetaStep *
1685 {
1686  return this->giveMetaStep( this->giveCurrentStep()->giveMetaStepNumber() );
1687 }
1688 
1689 
1690 std ::string
1691 EngngModel :: giveContextFileName(int tStepNumber, int stepVersion) const
1692 {
1693  std :: string fname = this->coreOutputFileName;
1694  char fext [ 100 ];
1695  sprintf(fext, ".%d.%d.osf", tStepNumber, stepVersion);
1696  return fname + fext;
1697 }
1698 
1699 
1700 std :: string
1701 EngngModel :: giveDomainFileName(int domainNum, int domainSerNum) const
1702 {
1703  std :: string fname = this->coreOutputFileName;
1704  char fext [ 100 ];
1705  sprintf(fext, ".domain.%d.%d.din", domainNum, domainSerNum);
1706  return fname + fext;
1707 }
1708 
1709 std :: string
1710 EngngModel :: errorInfo(const char *func) const
1711 {
1712  if ( this->isParallel() ) {
1713  return std::string(this->giveClassName()) + "::" + func + ", Rank: " + std::to_string(rank);
1714  } else {
1715  return std::string(this->giveClassName()) + "::" + func;
1716  }
1717 }
1718 
1719 Domain *
1721 {
1722  if ( ( i > 0 ) && ( i <= (int)this->domainList.size() ) ) {
1723  return this->domainList[i-1].get();
1724  } else {
1725  OOFEM_ERROR("Undefined domain");
1726  }
1727 
1728  return NULL;
1729 }
1730 
1731 void
1732 EngngModel :: setDomain(int i, Domain *ptr, bool iDeallocateOld)
1733 {
1734  if ( i < 1 || i > (int)this->domainList.size() ) {
1735  OOFEM_ERROR("Domain index %d out of range [1,%d]", i, (int)this->domainList.size());
1736  }
1737  if ( !iDeallocateOld ) {
1738  this->domainList[i-1].release();
1739  }
1740  this->domainList[i-1].reset(ptr);
1741 }
1742 
1743 
1746 {
1747  if ( i > (int)parallelContextList.size() ) {
1748  OOFEM_ERROR("context not initialized for this problem");
1749  }
1750 
1751  return &this->parallelContextList[i-1];
1752 }
1753 
1754 void
1756 {
1757  parallelContextList.clear();
1758  for ( int i = 0; i < this->giveNumberOfDomains(); ++i ) {
1759  parallelContextList.emplace_back(this);
1760  }
1761 }
1762 
1763 
1764 MetaStep *
1766 {
1767  if ( ( i > 0 ) && ( i <= this->nMetaSteps ) ) {
1768  return &this->metaStepList[i-1];
1769  } else {
1770  OOFEM_ERROR("undefined metaStep (%d)", i);
1771  }
1772 
1773  return NULL;
1774 }
1775 
1776 void
1777 EngngModel :: letOutputBaseFileNameBe(const std :: string &src)
1778 {
1779  this->dataOutputFileName = src;
1780 
1781  if ( outputStream ) fclose(outputStream);
1782 
1783  if ( !suppressOutput ) {
1784  if ( ( outputStream = fopen(this->dataOutputFileName.c_str(), "w") ) == NULL ) {
1785  OOFEM_ERROR("Can't open output file %s", this->dataOutputFileName.c_str());
1786  }
1787  }
1788 }
1789 
1790 FILE *
1792 // Returns an output stream on the data file of the receiver.
1793 {
1794  if ( !outputStream ) {
1795  OOFEM_ERROR("No output stream opened!");
1796  }
1797 
1798  return outputStream;
1799 }
1800 
1801 double
1803 {
1805 }
1806 
1807 void
1808 EngngModel :: giveAnalysisTime(int &rhrs, int &rmin, int &rsec, int &uhrs, int &umin, int &usec)
1809 {
1812  rsec = rmin = rhrs = 0;
1813  usec = umin = uhrs = 0;
1814  this->timer.convert2HMS(rhrs, rmin, rsec, rtsec);
1815  this->timer.convert2HMS(uhrs, umin, usec, utsec);
1816 }
1817 
1818 void
1820 {
1821  int rsec = 0, rmin = 0, rhrs = 0;
1822  int usec = 0, umin = 0, uhrs = 0;
1823  time_t endTime = time(NULL);
1825 
1826 
1827  // compute real time consumed
1828  this->giveAnalysisTime(rhrs, rmin, rsec, uhrs, umin, usec);
1829 
1830  if(!suppressOutput) {
1831  FILE *out = this->giveOutputStream();
1832  fprintf(out, "\nFinishing analysis on: %s\n", ctime(& endTime) );
1833  fprintf(out, "Real time consumed: %03dh:%02dm:%02ds\n", rhrs, rmin, rsec);
1834  fprintf(out, "User time consumed: %03dh:%02dm:%02ds\n\n\n", uhrs, umin, usec);
1835  }
1836 
1837  OOFEM_LOG_FORCED("\n\nANALYSIS FINISHED\n\n\n");
1838  OOFEM_LOG_FORCED("Real time consumed: %03dh:%02dm:%02ds\n", rhrs, rmin, rsec);
1839  OOFEM_LOG_FORCED("User time consumed: %03dh:%02dm:%02ds\n", uhrs, umin, usec);
1841 }
1842 
1843 int
1845 {
1846  int result = 1;
1847 
1848  result &= this->checkConsistency();
1849 
1850  for ( auto &domain: domainList ) {
1851  result &= domain->checkConsistency();
1852  }
1853 
1854 # ifdef VERBOSE
1855  if ( result ) {
1856  OOFEM_LOG_DEBUG("Consistency check: OK\n");
1857  } else {
1858  VERBOSE_PRINTS("Consistency check", "failed")
1859  exit(1);
1860  }
1861 
1862 # endif
1863 
1864  return result;
1865 }
1866 
1867 
1868 void
1870 {
1871  // set meta step bounds
1872  int istep = this->giveNumberOfFirstStep(true);
1873  for ( auto &metaStep: metaStepList ) {
1874  istep = metaStep.setStepBounds(istep);
1875  }
1876 
1877  for ( auto &domain: domainList ) {
1878  domain->postInitialize();
1879  }
1880 }
1881 
1882 void
1884 {
1886 }
1887 
1888 
1889 void
1891 {
1892  #ifdef __USE_MPI
1893  int len;
1894  MPI_Get_processor_name(processor_name, & len);
1895  this->comm = MPI_COMM_WORLD;
1896  MPI_Comm_rank(this->comm, & this->rank);
1897  MPI_Comm_size(this->comm, & numProcs);
1898  #else
1899  OOFEM_ERROR("Can't do it, only compiled for sequential runs");
1900  #endif
1901  #ifdef __VERBOSE_PARALLEL
1902  OOFEM_LOG_RELEVANT("[%d/%d] Running on %s\n", rank, numProcs, processor_name);
1903  #endif
1904 }
1905 
1906 
1907 #ifdef __OOFEG
1909 {
1910  OGC_PlotModeType plotMode = gc.giveIntVarPlotMode();
1911 
1912  if ( ( plotMode == OGC_nodeAnnotation ) || ( plotMode == OGC_nodeGeometry ) || ( plotMode == OGC_essentialBC ) ||
1913  ( plotMode == OGC_naturalBC ) || ( plotMode == OGC_nodeScalarPlot ) || ( plotMode == OGC_nodeVectorPlot ) ) {
1914  this->drawNodes(gc);
1915  } else {
1916  this->drawElements(gc);
1917  }
1918 }
1919 
1921 {
1922  Domain *d = this->giveDomain( gc.getActiveDomain() );
1923  TimeStep *tStep = this->giveCurrentStep();
1924  for ( auto &elem : d->giveElements() ) {
1925  elem->drawYourself(gc, tStep);
1926  }
1927 }
1928 
1930 {
1931  Domain *d = this->giveDomain( gc.getActiveDomain() );
1932  TimeStep *tStep = this->giveCurrentStep();
1933  for ( auto &dman : d->giveDofManagers() ) {
1934  dman->drawYourself(gc, tStep);
1935  }
1936 }
1937 
1938 #endif
1939 
1940 
1941 void
1943 {
1944 #ifdef __PARALLEL_MODE
1945  // Set up communication patterns.
1946  communicator->setUpCommunicationMaps(this, true, forceInit);
1947  if ( nonlocalExt ) {
1948  nonlocCommunicator->setUpCommunicationMaps(this, true, forceInit);
1949  }
1950 #else
1951  OOFEM_ERROR("Can't set up comm maps, parallel support not compiled");
1952 #endif
1953 }
1954 
1955 
1956 int
1958 {
1959  if ( isParallel() ) {
1960 #ifdef __PARALLEL_MODE
1961  int result = 1;
1962  #ifdef __VERBOSE_PARALLEL
1963  VERBOSEPARALLEL_PRINT( "EngngModel :: updateSharedDofManagers", "Packing data", this->giveRank() );
1964  #endif
1965 
1966  ArrayWithNumbering tmp;
1967  tmp.array = & answer;
1968  tmp.numbering = & s;
1969  result &= communicator->packAllData(this, & tmp, & EngngModel :: packDofManagers);
1970 
1971  #ifdef __VERBOSE_PARALLEL
1972  VERBOSEPARALLEL_PRINT( "EngngModel :: updateSharedDofManagers", "Exchange started", this->giveRank() );
1973  #endif
1974 
1975  result &= communicator->initExchange(ExchangeTag);
1976 
1977  #ifdef __VERBOSE_PARALLEL
1978  VERBOSEPARALLEL_PRINT( "EngngModel :: updateSharedDofManagers", "Receiving and unpacking", this->giveRank() );
1979  #endif
1980 
1981  result &= communicator->unpackAllData(this, & tmp, & EngngModel :: unpackDofManagers);
1982  result &= communicator->finishExchange();
1983  return result;
1984 #else
1985  OOFEM_ERROR("Support for parallel mode not compiled in.");
1986  return 0;
1987 #endif
1988  } else {
1989  return 1;
1990  }
1991 
1992 }
1993 
1994 
1995 int
1997 {
1998 
1999  if ( isParallel() && nonlocalExt ) {
2000 #ifdef __PARALLEL_MODE
2001  int result = 1;
2002  #ifdef __VERBOSE_PARALLEL
2003  VERBOSEPARALLEL_PRINT( "EngngModel :: exchangeRemoteElementData", "Packing remote element data", this->giveRank() );
2004  #endif
2005 
2007 
2008  #ifdef __VERBOSE_PARALLEL
2009  VERBOSEPARALLEL_PRINT( "EngngModel :: exchangeRemoteElementData", "Remote element data exchange started", this->giveRank() );
2010  #endif
2011 
2012  result &= nonlocCommunicator->initExchange(ExchangeTag);
2013 
2014  #ifdef __VERBOSE_PARALLEL
2015  VERBOSEPARALLEL_PRINT( "EngngModel :: exchangeRemoteElementData", "Receiveng and Unpacking remote element data", this->giveRank() );
2016  #endif
2017 
2019  OOFEM_ERROR("Receiveng and Unpacking remote element data");
2020  }
2021 
2022  result &= nonlocCommunicator->finishExchange();
2023  return result;
2024 #else
2025  OOFEM_ERROR("Support for parallel mode not compiled in.");
2026  return 0;
2027 #endif
2028  } else {
2029  return 1;
2030  }
2031 }
2032 
2033 #ifdef __PARALLEL_MODE
2034 void
2036 {
2037  this->giveLoadBalancerMonitor();
2038  this->giveLoadBalancer();
2039  if ( !lb ) {
2040  OOFEM_WARNING("No load balancer found, skipping load balancing step");
2041  return;
2042  }
2043 
2044  //print statistics for current step
2045  lb->printStatistics();
2046 
2047  if ( tStep->isNotTheLastStep() ) {
2049  if ( ( _d == LoadBalancerMonitor :: LBD_RECOVER ) ||
2050  ( ( tStep->isTheFirstStep() ) && force_load_rebalance_in_first_step ) ) {
2052 
2053  // determine nwe partitioning
2055  // pack e-model solution data into dof dictionaries
2056  this->packMigratingData(tStep);
2057  // migrate data
2058  lb->migrateLoad( this->giveDomain(1) );
2059  // renumber itself
2060  this->forceEquationNumbering();
2061  // re-init export modules
2063  #ifdef __VERBOSE_PARALLEL
2064  // debug print
2066  int nnodes = giveDomain(1)->giveNumberOfDofManagers();
2067  int myrank = this->giveRank();
2068  fprintf(stderr, "\n[%d] Nodal Table\n", myrank);
2069  for ( int i = 1; i <= nnodes; i++ ) {
2070  if ( giveDomain(1)->giveDofManager(i)->giveParallelMode() == DofManager_local ) {
2071  fprintf( stderr, "[%d]: %5d[%d] local ", myrank, i, giveDomain(1)->giveDofManager(i)->giveGlobalNumber() );
2072  } else if ( giveDomain(1)->giveDofManager(i)->giveParallelMode() == DofManager_shared ) {
2073  fprintf( stderr, "[%d]: %5d[%d] shared ", myrank, i, giveDomain(1)->giveDofManager(i)->giveGlobalNumber() );
2074  }
2075 
2076  for ( Dof *dof: *giveDomain(1)->giveDofManager(i) ) {
2077  fprintf( stderr, "(%d)", dof->giveEquationNumber(dn) );
2078  }
2079 
2080  fprintf(stderr, "\n");
2081  }
2082 
2083  #endif
2084  // unpack (restore) e-model solution data from dof dictionaries
2085  this->unpackMigratingData(tStep);
2086 
2088  double _steptime = this->timer.getUtime(EngngModelTimer :: EMTT_LoadBalancingTimer);
2089  OOFEM_LOG_INFO("[%d] EngngModel info: user time consumed by load rebalancing %.2fs\n",
2090  this->giveRank(), _steptime);
2091  }
2092  }
2093 }
2094 
2095 
2096 int
2098 {
2099  int result = 1;
2100  IntArray const *toSendMap = processComm.giveToSendMap();
2101  CommunicationBuffer *send_buff = processComm.giveProcessCommunicatorBuff()->giveSendBuff();
2102  Domain *domain = this->giveDomain(1);
2103 
2104 
2105  for ( int i = 1; i <= toSendMap->giveSize(); i++ ) {
2106  result &= domain->giveElement( toSendMap->at(i) )->packUnknowns( * send_buff, this->giveCurrentStep() );
2107  }
2108 
2109  return result;
2110 }
2111 
2112 
2113 int
2115 {
2116  int result = 1;
2117  IntArray const *toRecvMap = processComm.giveToRecvMap();
2118  CommunicationBuffer *recv_buff = processComm.giveProcessCommunicatorBuff()->giveRecvBuff();
2119  Domain *domain = this->giveDomain(1);
2120 
2121 
2122  for ( int i = 1; i <= toRecvMap->giveSize(); i++ ) {
2123  Element *element = domain->giveElement( toRecvMap->at(i) );
2124  if ( element->giveParallelMode() == Element_remote ) {
2125  result &= element->unpackAndUpdateUnknowns( * recv_buff, this->giveCurrentStep() );
2126  } else {
2127  OOFEM_ERROR("element is not remote");
2128  }
2129  }
2130 
2131  return result;
2132 }
2133 
2134 
2135 int
2137 {
2138  FloatArray *src = srcData->array;
2139  const UnknownNumberingScheme &s = * srcData->numbering;
2140  int result = 1;
2141  Domain *domain = this->giveDomain(1);
2142  IntArray const *toSendMap = processComm.giveToSendMap();
2143  ProcessCommunicatorBuff *pcbuff = processComm.giveProcessCommunicatorBuff();
2144 
2147  for ( int i = 1; i <= toSendMap->giveSize(); i++ ) {
2148  DofManager *dman = domain->giveDofManager( toSendMap->at(i) );
2149  for ( Dof *jdof: *dman ) {
2150  if ( jdof->isPrimaryDof() ) {
2151  int eqNum = jdof->giveEquationNumber(s);
2152  if ( eqNum ) {
2153  result &= pcbuff->write( src->at(eqNum) );
2154  }
2155  }
2156  }
2157  }
2158 
2159  return result;
2160 }
2161 
2162 
2163 int
2165 {
2166  FloatArray *dest = destData->array;
2167  const UnknownNumberingScheme &s = * destData->numbering;
2168  int result = 1;
2169  Domain *domain = this->giveDomain(1);
2170  IntArray const *toRecvMap = processComm.giveToRecvMap();
2171  ProcessCommunicatorBuff *pcbuff = processComm.giveProcessCommunicatorBuff();
2172  double value;
2173 
2176  for ( int i = 1; i <= toRecvMap->giveSize(); i++ ) {
2177  DofManager *dman = domain->giveDofManager( toRecvMap->at(i) );
2178  dofManagerParallelMode dofmanmode = dman->giveParallelMode();
2179  for ( Dof *jdof: *dman ) {
2180  int eqNum = jdof->giveEquationNumber(s);
2181  if ( jdof->isPrimaryDof() && eqNum ) {
2182  result &= pcbuff->read(value);
2183  if ( dofmanmode == DofManager_shared ) {
2184  dest->at(eqNum) += value;
2185  } else if ( dofmanmode == DofManager_remote ) {
2186  dest->at(eqNum) = value;
2187  } else {
2188  OOFEM_ERROR("unknown dof namager parallel mode");
2189  }
2190  }
2191  }
2192  }
2193 
2194  return result;
2195 }
2196 
2197 #endif
2198 } // end namespace oofem
EngngModelTimer timer
E-model timer.
Definition: engngm.h:267
virtual void updateAttributes(MetaStep *mStep)
Update receiver attributes according to step metaStep attributes.
Definition: engngm.C:589
Class implementing a concentrated load (force, moment,...) that acts directly on a dof manager (node ...
Definition: nodalload.h:67
virtual bool isImposed(TimeStep *tStep)
Returns nonzero if receiver representing BC is imposed at given time, otherwise returns zero...
void initialize()
Initialize graph from domain description.
Definition: sloangraph.C:69
virtual bool isActivated(TimeStep *tStep)
Definition: element.C:793
contextIOResultType storeYourself(DataStream &stream) const
Stores array to output stream.
Definition: intarray.C:289
The representation of EngngModel default unknown numbering.
virtual void vectorFromElement(FloatArray &vec, Element &element, TimeStep *tStep, ValueModeType mode) const
void pauseTimer(EngngModelTimerType t)
Definition: timer.h:130
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Definition: floatarray.C:258
int initExchange(int tag)
Initializes data exchange with all problems.
Definition: communicator.C:104
FILE * outputStream
Output stream.
Definition: engngm.h:242
DofManager in active domain is shared only by remote elements (these are only introduced for nonlocal...
Definition: dofmanager.h:88
#define _IFT_EngngModel_profileOpt
Definition: engngm.h:71
std::string giveContextFileName(int tStepNumber, int stepVersion) const
Returns the filename for the context file for the given step and version.
Definition: engngm.C:1691
std::unique_ptr< TimeStep > currentStep
Current time step.
Definition: engngm.h:231
std::string simulationDescription
Definition: engngm.h:316
bool profileOpt
Profile optimized numbering flag (using Sloan&#39;s algorithm).
Definition: engngm.h:221
InputRecord * giveAttributesRecord()
Returns e-model attributes.
Definition: metastep.h:95
int giveNumberOfSteps()
Returns number of Steps it represent.
Definition: metastep.h:91
void initMetaStepAttributes(MetaStep *mStep)
Update e-model attributes attributes according to step metaStep attributes.
Definition: engngm.C:580
void askNewOptimalNumbering(TimeStep *tStep)
Numbers all the DOFs according to the optimal renumbering found.
Definition: sloangraph.C:542
Implementation of FileDataStream representing DataStream interface to file i/o.
Definition: datastream.h:136
char processor_name[PROCESSOR_NAME_LENGTH]
Processor name.
Definition: engngm.h:283
Class and object Domain.
Definition: domain.h:115
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)=0
Assembles sparse matrix from contribution of local elements.
void computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
Returns local vector of unknowns.
Definition: element.C:86
void assembleVectorFromDofManagers(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 into given vector.
Definition: engngm.C:1016
virtual bool requiresEquationRenumbering(TimeStep *tStep)
Returns true if equation renumbering is required for given solution step.
Definition: engngm.h:852
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
std::string dataOutputFileName
Path to output stream.
Definition: engngm.h:238
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
Definition: engngm.C:262
virtual IRResultType initializeFrom(InputRecord *ir)
Definition: nummet.h:101
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
enum fMode nonLinFormulation
Type of non linear formulation (total or updated formulation).
Definition: engngm.h:271
Class representing meta step.
Definition: metastep.h:62
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
Definition: domain.h:440
ContextOutputMode giveContextOutputMode()
Returns domain context output mode.
Definition: engngm.h:379
void startTimer(EngngModelTimerType t)
Definition: timer.h:128
int packAllData(T *ptr, int(T::*packFunc)(ProcessCommunicator &))
Pack all problemCommunicators data to their send buffers.
Definition: communicator.h:223
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
std::string coreOutputFileName
String with core output file name.
Definition: engngm.h:240
virtual void packMigratingData(TimeStep *tStep)
Packs receiver data when rebalancing load.
Definition: engngm.h:981
std::vector< std::unique_ptr< Domain > > domainList
List of problem domains.
Definition: engngm.h:207
virtual void doStepOutput(TimeStep *tStep)
Prints the ouput of the solution step (using virtual this->printOutputAtservice) to the stream detemi...
Definition: engngm.C:670
problemMode giveProblemMode()
Returns domain mode.
Definition: engngm.h:411
std::unique_ptr< TimeStep > previousStep
Previous time step.
Definition: engngm.h:233
ExportModuleManager * giveExportModuleManager()
Returns receiver&#39;s export module manager.
Definition: engngm.h:758
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
MetaStep * giveMetaStep(int i)
Returns the i-th meta step.
Definition: engngm.C:1765
void letOutputBaseFileNameBe(const std::string &src)
Sets the base output file name.
Definition: engngm.C:1777
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
EngngModel(int i, EngngModel *_master=NULL)
Constructor.
Definition: engngm.C:89
int nonlocalExt
Flag indicating if nonlocal extension active, which will cause data to be sent between shared element...
Definition: engngm.h:280
Class implementing element body load, acting over whole element volume (e.g., the dead weight)...
Definition: bodyload.h:49
const IntArray & giveBodyLoadList() const
Returns receiver list of bodyloads.
Definition: element.h:349
virtual const IntArray & giveDofIDs() const
Array with default dofs which b.c.
virtual void locationFromElement(IntArray &loc, Element &element, const UnknownNumberingScheme &s, IntArray *dofIds=nullptr) const
#define CM_State
Definition: contextmode.h:46
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
virtual ~EngngModel()
Destructor.
Definition: engngm.C:143
int contextOutputStep
Definition: engngm.h:247
This base class is an abstraction for numerical algorithm.
Definition: nummet.h:80
virtual void matrixFromElement(FloatMatrix &mat, Element &element, TimeStep *tStep) const
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual int instanciateYourself(DataReader &dr, InputRecord *ir)
Reads receiver description from input stream and creates corresponding modules components accordingly...
Definition: modulemanager.h:94
void outputElements(FILE *file, Domain &domain, TimeStep *tStep, int setNum)
Outputs all elements in the given set.
Definition: engngm.C:766
const IntArray & giveBoundaryLoadList() const
Returns receiver list of boundary loads.
Definition: element.h:353
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
time_t startTime
Solution start time.
Definition: engngm.h:259
int instanciateMetaSteps(DataReader &dr)
Instanciate problem meta steps by calling their instanciateYourself() service.
Definition: engngm.C:350
ErrorEstimator * defaultErrEstimator
Error estimator. Useful for adaptivity, or simply printing errors output.
Definition: engngm.h:273
int numProcs
Total number of collaborating processes.
Definition: engngm.h:278
void initTimer(EngngModelTimerType t)
Definition: timer.h:132
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
void doInit()
Performs the initialization of individual modules.
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
void doOutput(TimeStep *tStep, bool substepFlag=false)
Writes the output.
Abstract base class for all finite elements.
Definition: element.h:145
Unknown.
Definition: fmode.h:43
virtual void terminate(TimeStep *tStep)
Terminates the solution of time step.
Definition: engngm.C:656
virtual TimeStep * giveNextStep()
Returns next time step (next to current step) of receiver.
Definition: engngm.h:701
Base class for dof managers.
Definition: dofmanager.h:113
std::vector< std::unique_ptr< DofManager > > & giveDofManagers()
Definition: domain.h:400
General IO error.
virtual void solveYourself()
Starts solution process.
Definition: engngm.C:501
bool force_load_rebalance_in_first_step
Debug flag forcing load balancing after first step.
Definition: engngm.h:297
void stopTimer(EngngModelTimerType t)
Definition: timer.h:129
virtual void printDofOutputAt(FILE *stream, Dof *iDof, TimeStep *tStep)
DOF printing routine.
Definition: engngm.C:798
int giveNumber()
Returns domain number.
Definition: domain.h:266
CommunicationBuffer * giveRecvBuff()
Returns receive buffer of receiver.
Definition: processcomm.h:167
Class representing the abstraction for input data source.
Definition: datareader.h:50
int giveNumberOfElements() const
Returns number of elements in domain.
Definition: domain.h:434
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to stream, for given time step.
Definition: dofmanager.C:510
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
int unpackAndUpdateUnknowns(DataStream &buff, TimeStep *tStep)
Unpack and updates all necessary data of element (according to its parallel_mode) integration points ...
Definition: element.C:1560
The ProcessCommunicator and corresponding buffers (represented by this class) are separated in order ...
Definition: processcomm.h:64
#define _IFT_EngngModel_nonLinFormulation
Definition: engngm.h:73
void outputNodes(FILE *file, Domain &domain, TimeStep *tStep, int setNum)
Outputs all nodes in the given set.
Definition: engngm.C:739
int instanciateDomains(DataReader &dr)
Instanciate problem domains by calling their instanciateYourself() service.
Definition: engngm.C:336
#define OOFEM_LOG_DEBUG(...)
Definition: logger.h:128
void migrateLoad(Domain *d)
Definition: loadbalancer.C:99
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
virtual std::string giveReferenceName() const =0
Gives the reference file name (e.g. file name)
int givePartitionsConnectivitySize()
Returns number of partitions sharing given receiver (=number of shared partitions + local one)...
Definition: dofmanager.C:975
void terminate()
Terminates the receiver, the corresponding terminate module services are called.
virtual void setUpCommunicationMaps(EngngModel *emodel, bool excludeSelfCommFlag, bool forceReinit=false)=0
Service for setting up the communication patterns with other remote process.
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual IRResultType initializeFrom(InputRecord *ir)
Instanciates the receiver from input record.
dofManagerParallelMode
In parallel mode, this type indicates the mode of DofManager.
Definition: dofmanager.h:80
void rotatedWith(FloatMatrix &r, char mode)
Returns the receiver a rotated according the change-of-base matrix r.
Definition: floatarray.C:799
ErrorEstimatorType
Determines the type of error estimator.
const UnknownNumberingScheme * numbering
Definition: engngm.h:189
Class representing and implementing InitModuleManager.
int finishExchange()
Finishes the exchange.
Definition: communicator.C:115
#define OOFEM_LOG_RELEVANT(...)
Definition: logger.h:126
void saveStepContext(TimeStep *tStep, ContextMode mode)
Saves context of given solution step, if required (determined using this->giveContextOutputMode() met...
Definition: engngm.C:682
void setParallelMode(bool newParallelFlag)
Sets the problem to run in parallel (or not).
Definition: engngm.C:174
virtual void assembleFromActiveBC(FloatArray &answer, ActiveBoundaryCondition &bc, TimeStep *tStep, ValueModeType mode, const UnknownNumberingScheme &s, FloatArray *eNorms) const
void assembleExtrapolatedForces(FloatArray &answer, TimeStep *tStep, CharType type, Domain *domain)
Assembles the extrapolated internal forces vector, useful for obtaining a good initial guess in nonli...
Definition: engngm.C:1341
problemMode pMode
Domain mode.
Definition: engngm.h:255
GeneralBoundaryCondition * giveBc(int n)
Service for accessing particular domain bc.
Definition: domain.C:243
virtual void giveBoundarySurfaceNodes(IntArray &bNodes, int boundary)
Returns list of receiver boundary nodes for given surface.
Definition: element.C:866
const IntArray * giveToSendMap()
Returns receiver to send map.
Definition: processcomm.h:223
virtual void initStepIncrements()
Initializes solution of new time step.
Definition: engngm.C:1496
void computeVectorOfPrescribed(ValueModeType u, TimeStep *tStep, FloatArray &answer)
Returns local vector of prescribed unknowns.
Definition: element.C:181
InitModuleManager * initModuleManager
Initialization module manager.
Definition: engngm.h:252
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
bool isTheFirstStep()
Check if receiver is first step.
Definition: timestep.C:134
If required (for backtracking computation).
Class representing and implementing ExportModuleManager.
#define VERBOSE_PRINT0(str, number)
Definition: verbose.h:56
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
bool isNotEmpty() const
Tests for empty matrix.
Definition: floatmatrix.h:162
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
#define _IFT_EngngModel_parallelflag
Definition: engngm.h:75
#define VERBOSE_PRINTS(str, str1)
Definition: verbose.h:55
virtual void initParallelContexts()
Creates parallel contexts.
Definition: engngm.C:1755
bool loadBalancingFlag
If set to true, load balancing is active.
Definition: engngm.h:295
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to stream, for given time step.
Definition: element.C:759
MetaStep * giveCurrentMetaStep()
Returns current meta step.
Definition: engngm.C:1684
std::vector< std::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
Definition: domain.h:322
int giveSetNumber()
Gives the set number which boundary condition is applied to.
ProblemCommunicator * nonlocCommunicator
NonLocal Communicator. Necessary when nonlocal constitutive models are used.
Definition: engngm.h:306
void assembleVectorFromContacts(FloatArray &answer, TimeStep *tStep, CharType type, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Definition: engngm.C:1475
virtual void preInitializeNextStep()
Does a pre-initialization of the next time step (implement if necessarry)
Definition: engngm.h:716
int giveContextOutputStep()
Returns domain context output step.
Definition: engngm.h:383
virtual bool computeDofTransformationMatrix(FloatMatrix &answer, const IntArray &nodes, bool includeInternal)
Returns transformation matrix for DOFs from global coordinate system to local coordinate system in no...
Definition: element.C:303
int packDofManagers(ArrayWithNumbering *src, ProcessCommunicator &processComm)
Packing function for vector values of DofManagers.
Definition: engngm.C:2136
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
#define OOFEM_LOG_INFO(...)
Definition: logger.h:127
virtual NumericalMethod * giveNumericalMethod(MetaStep *mStep)
Returns reference to receiver&#39;s numerical method.
Definition: engngm.h:756
FILE * giveOutputStream()
Returns file descriptor of output file.
Definition: engngm.C:1791
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
Callback class for assembling specific types of vectors.
virtual int write(const int *data, int count)
Writes count integer values from array pointed by data.
Definition: processcomm.h:83
virtual int assembleBegin()
Starts assembling the elements.
Definition: sparsemtrx.h:235
void assembleVectorFromContacts(FloatArray &answer, TimeStep *tStep, CharType type, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Class CommunicationBuffer provides abstraction for communication buffer.
Definition: combuff.h:208
NumericalCmpn
Type representing numerical component.
Definition: numericalcmpn.h:46
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Definition: nummet.h:117
IntArray domainPrescribedNeqs
Number of prescribed equations per domain.
Definition: engngm.h:217
virtual void drawNodes(oofegGraphicContext &gc)
Definition: engngm.C:1929
#define OOFEM_ERROR(...)
Definition: error.h:61
EngngModelContext * giveContext()
Context requesting service.
Definition: engngm.h:1078
virtual void drawElements(oofegGraphicContext &gc)
Definition: engngm.C:1920
virtual double giveVariableScale(VarScaleType varId)
Returns the scale factor for given variable type.
Definition: engngm.h:1087
Callback class for assembling specific types of matrices.
void clear()
Clears the array (zero size).
Definition: intarray.h:177
int numberOfSteps
Total number of time steps.
Definition: engngm.h:209
int ndomains
Number of receiver domains.
Definition: engngm.h:205
double getWtime(EngngModelTimerType t)
Returns elapsed wall clock time.
Definition: timer.C:159
virtual void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d)
Updates components mapped to numerical method if necessary during solution process.
Definition: engngm.C:1485
virtual void vectorFromSurfaceLoad(FloatArray &vec, Element &element, SurfaceLoad *load, int boundary, TimeStep *tStep, ValueModeType mode) const
int rank
Domain rank in a group of collaborating processes (0..groupSize-1).
Definition: engngm.h:276
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Exchanges necessary remote DofManagers data.
Definition: engngm.C:1957
virtual void assembleFromActiveBC(SparseMtrx &k, ActiveBoundaryCondition &bc, TimeStep *tStep, const UnknownNumberingScheme &s_r, const UnknownNumberingScheme &s_c) const
virtual void balanceLoad(TimeStep *tStep)
Recovers the load balance between processors, if needed.
Definition: engngm.C:2035
EngngModelContext * context
Context.
Definition: engngm.h:265
ProcessCommunicatorBuff * giveProcessCommunicatorBuff()
Returns communication buffer.
Definition: processcomm.h:210
virtual int estimateError(EE_ErrorMode mode, TimeStep *tStep)=0
Estimates the error on associated domain at given time step.
#define VERBOSEPARALLEL_PRINT(service, str, rank)
Definition: parallel.h:50
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
const IntArray * giveToRecvMap()
Returns receiver to receive map.
Definition: processcomm.h:227
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
TimeStep * generateNextStep()
Generate new time step (and associate metastep).
Definition: engngm.C:559
virtual void matrixFromSurfaceLoad(FloatMatrix &mat, Element &element, SurfaceLoad *load, int boundary, TimeStep *tStep) const
void rotatedWith(const FloatMatrix &r, char mode= 'n')
Returns the receiver &#39;a&#39; transformed using give transformation matrix r.
Definition: floatmatrix.C:1557
const IntArray & giveNodeList()
Returns list of all nodes within set.
Definition: set.C:146
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
Definition: engngm.C:612
int giveNumberOfSteps(bool force=false)
Returns total number of steps.
Definition: engngm.h:744
ProblemCommunicator * communicator
Communicator.
Definition: engngm.h:303
Abstract base class representing an edge load (force, momentum, ...) that acts directly on a edge bou...
Definition: boundaryload.h:200
Class representing process communicator for engineering model.
Definition: processcomm.h:176
#define _IFT_EngngModel_suppressOutput
Definition: engngm.h:84
static void convert2HMS(int &nhrs, int &nmin, int &nsec, double tsec)
Converts total seconds into hours, mins, and seconds.
Definition: timer.C:164
Set * giveSet(int n)
Service for accessing particular domain set.
Definition: domain.C:363
virtual ParallelContext * giveParallelContext(int n)
Returns the parallel context corresponding to given domain (n) and unknown type Default implementatio...
Definition: engngm.C:1745
void giveCompleteMasterDofIDArray(IntArray &dofIDArray) const
Returns the full dof ID array of receiver.
Definition: dofmanager.C:249
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
Definition: floatarray.C:676
void setDomain(int i, Domain *ptr, bool iDeallocateOld=true)
Sets i-th domain of receiver.
Definition: engngm.C:1732
virtual void drawYourself(oofegGraphicContext &gc)
Definition: engngm.C:1908
EngngModel * master
Master e-model; if defined receiver is in maintained (slave) mode.
Definition: engngm.h:262
#define _IFT_EngngModel_contextoutputstep
Definition: engngm.h:69
virtual bool giveRotationMatrix(FloatMatrix &answer)
Transformation matrices updates rotation matrix between element-local and primary DOFs...
Definition: element.C:259
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
Abstract base class for all active boundary conditions.
Definition: activebc.h:63
Enable for post-processing.
Abstract base class for all boundary conditions of problem.
#define _IFT_EngngModel_nsteps
Definition: engngm.h:68
TimeStep * givePreviousStep()
Returns pointer to previous solution step.
Definition: timestep.C:114
virtual void postInitialize()
Performs post-initialization for all the problem contents (which is called after initializeFrom).
Definition: engngm.C:1869
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Definition: nummet.h:116
#define _IFT_EngngModel_renumberFlag
Definition: engngm.h:70
ExportModuleManager * exportModuleManager
Export module manager.
Definition: engngm.h:250
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
double giveSolutionStepTime()
Returns the user time of the current simulation step in seconds.
Definition: engngm.C:1802
Graph representing the undirected graph used for Sloan algorithm for symmetric matrix profile reducti...
Definition: sloangraph.h:77
ErrorEstimator * createErrorEstimator(ErrorEstimatorType type, int num, Domain *d)
Creates new instance of ErrorEstimator corresponding to given type.
Definition: classfactory.C:130
#define _IFT_EngngModel_forceloadBalancingFlag
Definition: engngm.h:77
contextIOResultType restoreYourself(DataStream &stream)
Restores array from image on stream.
Definition: intarray.C:305
#define _IFT_EngngModel_eetype
Definition: engngm.h:74
void terminateAnalysis()
Performs analysis termination after finishing analysis.
Definition: engngm.C:1819
virtual InputRecord * giveInputRecord(InputRecordType irType, int recordId)=0
Returns input record corresponding to given InputRecordType value and its record_id.
virtual void unpackMigratingData(TimeStep *tStep)
Unpacks receiver data when rebalancing load.
Definition: engngm.h:988
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
Definition: engngm.C:1527
virtual void vectorFromNodeLoad(FloatArray &vec, DofManager &dman, NodalLoad *load, TimeStep *tStep, ValueModeType mode) const
void printYourself()
Prints state of receiver. Useful for debugging.
Definition: engngm.C:791
virtual void locationFromElement(IntArray &loc, Element &element, const UnknownNumberingScheme &s, IntArray *dofIds=nullptr) const
Default implementation takes all the DOF IDs.
virtual int forceEquationNumbering()
Forces equation renumbering on all domains associated to engng model.
Definition: engngm.C:473
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
std::string giveDomainFileName(int domainNum, int domainSerNum) const
Returns the filename for the given domain (used by adaptivity and restore)
Definition: engngm.C:1701
Class representing vector of real numbers.
Definition: floatarray.h:82
int unpackAllData(T *ptr, int(T::*unpackFunc)(ProcessCommunicator &))
Unpack all problemCommuncators data from recv buffers.
Definition: communicator.h:262
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
Definition: element.h:1069
virtual int checkConsistency()
Allows programmer to test some receiver&#39;s internal data, before computation begins.
Definition: engngm.h:995
IntArray domainNeqs
Number of equations per domain.
Definition: engngm.h:215
virtual int checkProblemConsistency()
Allows programmer to test problem its internal data, before computation begins.
Definition: engngm.C:1844
virtual void calculateLoadTransfer()=0
Abstract base class representing a surface load (force, momentum, ...) that acts directly on a surfac...
Definition: boundaryload.h:218
Input attribute of domain (each n-th step).
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
virtual void locationFromElementNodes(IntArray &loc, Element &element, const IntArray &bNodes, const UnknownNumberingScheme &s, IntArray *dofIds=nullptr) const
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual int instanciateDefaultMetaStep(InputRecord *ir)
Instanciate default metastep, if nmsteps is zero.
Definition: engngm.C:374
virtual bool isDefault() const
Returns true, if receiver is the default engngModel equation numbering scheme; This is useful for som...
#define _IFT_EngngModel_loadBalancingFlag
Definition: engngm.h:76
virtual void initializeYourself(TimeStep *tStep)
Provides the opportunity to initialize state variables stored in element integration points according...
Definition: engngm.h:482
int unpackDofManagers(ArrayWithNumbering *dest, ProcessCommunicator &processComm)
Unpacking function for vector values of DofManagers .
Definition: engngm.C:2164
ContactManager * giveContactManager()
Definition: domain.C:393
void assembleVectorFromBC(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from boundary conditions.
Definition: engngm.C:1071
std::string errorInfo(const char *func) const
Returns string for prepending output (used by error reporting macros).
Definition: engngm.C:1710
void giveCompleteLocationArray(IntArray &locationArray, const UnknownNumberingScheme &s) const
Returns full location array of receiver containing equation numbers of all dofs of receiver...
Definition: dofmanager.C:229
virtual void init()
Initializes the receiver state.
Definition: engngm.C:1883
void assemble(const FloatArray &fe, const IntArray &loc)
Assembles the array fe (typically, the load vector of a finite element) into the receiver, using loc as location array.
Definition: floatarray.C:551
int giveStepRelativeNumber(int stepNumber)
Returns the step relative number to receiver.
Definition: metastep.h:107
virtual bool isElementActivated(int elemNum)
Definition: engngm.h:1118
virtual LoadBalancerDecisionType decide(TimeStep *)=0
Returns flag indicating whether rebalancing is necessary; should update node weights as well...
CharType
Definition: chartype.h:87
Class representing the general Input Record.
Definition: inputrecord.h:101
This class provides an communication context for distributed memory parallelism.
CommunicationBuffer * giveSendBuff()
Returns send buffer of receiver.
Definition: processcomm.h:163
virtual void vectorFromLoad(FloatArray &vec, Element &element, BodyLoad *load, TimeStep *tStep, ValueModeType mode) const
virtual void vectorFromEdgeLoad(FloatArray &vec, Element &element, EdgeLoad *load, int edge, TimeStep *tStep, ValueModeType mode) const
virtual void matrixFromEdgeLoad(FloatMatrix &mat, Element &element, EdgeLoad *load, int edge, TimeStep *tStep) const
fMode
Type representing the type of formulation (total or updated) of non-linear computation.
Definition: fmode.h:42
int parallelFlag
Flag indicating that the receiver runs in parallel.
Definition: engngm.h:269
MPI_Comm comm
Communication object for this engineering model.
Definition: engngm.h:286
int giveNumberOfDomains()
Returns number of domains in problem.
Definition: engngm.h:342
void resumeTimer(EngngModelTimerType t)
Definition: timer.h:131
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 assemblePrescribedExtrapolatedForces(FloatArray &answer, TimeStep *tStep, CharType type, Domain *domain)
Definition: engngm.C:1417
std::string referenceFileName
String with reference file name.
Definition: engngm.h:244
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to output domain stream, for given time step.
Definition: engngm.C:695
void assembleSquared(const FloatArray &fe, const IntArray &loc)
Assembles the array fe with each component squared.
Definition: floatarray.C:572
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Definition: engngm.h:1058
int giveNumber()
Returns receiver&#39;s number.
Definition: metastep.h:89
int giveMaxDofID()
Gives the current maximum dof ID used.
Definition: domain.h:600
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
Class EngngModelContext represents a context, which is shared by all problem engng sub-models...
Definition: engngm.h:123
void initializeCommMaps(bool forceInit=false)
Definition: engngm.C:1942
ClassFactory & classFactory
Definition: classfactory.C:59
virtual int instanciateYourself(DataReader &dr, InputRecord *ir, const char *outFileName, const char *desc)
Initializes whole problem according to its description stored in inputStream.
Definition: engngm.C:201
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
LoadBalancer * lb
Load Balancer.
Definition: engngm.h:292
virtual int assembleEnd()
Returns when assemble is completed.
Definition: sparsemtrx.h:237
void initParallel()
Request domain rank and problem size.
Definition: engngm.C:1890
#define CM_Definition
Definition: contextmode.h:47
Element in active domain is only mirror of some remote element.
Definition: element.h:102
IntArray * giveLoadArray()
Returns the array containing applied loadings of the receiver.
Definition: dofmanager.C:82
bool renumberFlag
Renumbering flag (renumbers equations after each step, necessary if Dirichlet BCs change)...
Definition: engngm.h:219
void initialize()
Initializes output manager.
bool hasContactManager()
Definition: domain.C:404
bool suppressOutput
Flag for suppressing output to file.
Definition: engngm.h:314
virtual int read(int *data, int count)
Reads count integer values into array pointed by data.
Definition: processcomm.h:91
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: loadbalancer.C:536
void setUDContextOutputMode(int cStep)
Sets user defined context output mode (it sets contextOutputMode to contextOutputMode), setting contextOutputStep to given value.
Definition: engngm.h:395
void giveAnalysisTime(int &rhrs, int &rmin, int &rsec, int &uhrs, int &umin, int &usec)
Returns the real and user time for the analysis.
Definition: engngm.C:1808
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
void assembleVectorFromElements(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from elements into given vector. ...
Definition: engngm.C:1198
virtual IRResultType initializeFrom(InputRecord *ir)
Instanciates the receiver from input record.
virtual void solveYourselfAt(TimeStep *tStep)
Solves problem for given time step.
Definition: engngm.h:451
Load is base abstract class for all loads.
Definition: load.h:61
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
DofManager in active domain is only mirror of some remote DofManager.
Definition: dofmanager.h:85
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int number
Receivers id.
Definition: engngm.h:235
#define OOFEM_LOG_FORCED(...)
Definition: logger.h:125
int unpackRemoteElementData(ProcessCommunicator &processComm)
Unpacks data for remote elements (which are mirrors of remote partition&#39;s local elements).
Definition: engngm.C:2114
virtual TimeStep * giveCurrentStep(bool force=false)
Returns current time step.
Definition: engngm.h:683
int giveSize() const
Definition: intarray.h:203
int exchangeRemoteElementData(int ExchangeTag)
Exchanges necessary remote element data with remote partitions.
Definition: engngm.C:1996
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
#define _IFT_EngngModel_nmsteps
Definition: engngm.h:72
the oofem namespace is to define a context or scope in which all oofem names are defined.
bool isNotEmpty() const
Returns true if receiver is not empty.
Definition: floatarray.h:220
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
void clear()
Sets size of receiver to be an empty matrix. It will have zero rows and zero columns size...
Definition: floatmatrix.h:516
problemScale pScale
Multiscale mode.
Definition: engngm.h:257
virtual void finish(bool wrn=true)=0
Terminates the current record session and if the flag is true, warning is printed for unscanned token...
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
int packRemoteElementData(ProcessCommunicator &processComm)
Packs data of local element to be received by their remote counterpart on remote partitions.
Definition: engngm.C:2097
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
virtual void matrixFromLoad(FloatMatrix &mat, Element &element, BodyLoad *load, TimeStep *tStep) const
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
int giveOptimalProfileSize()
Returns the optimal profile found.
Definition: sloangraph.h:140
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: loadbalancer.C:64
std::vector< MetaStep > metaStepList
List of problem metasteps.
Definition: engngm.h:227
ContextOutputMode contextOutputMode
Domain context output mode.
Definition: engngm.h:246
Load * giveLoad(int n)
Service for accessing particular domain load.
Definition: domain.C:222
bool isNotTheLastStep()
Check if solution step is not the last step.
Definition: timestep.C:127
void giveLocationArray(const IntArray &dofIDArry, IntArray &locationArray, const UnknownNumberingScheme &s) const
Returns location array (array containing for each requested dof related equation number) for given nu...
Definition: dofmanager.C:177
DofManager is local, there are no contribution from other domains to this DofManager.
Definition: dofmanager.h:81
virtual LoadBalancer * giveLoadBalancer()
Returns reference to receiver&#39;s load balancer.
Definition: engngm.h:1110
void startTimer()
Definition: timer.C:69
double getUtime(EngngModelTimerType t)
Returns total user time elapsed.
Definition: timer.C:154
double getUtime()
Returns total user time elapsed in seconds.
Definition: timer.C:105
int numberOfPrescribedEquations
Total number or prescribed equations in current time step.
Definition: engngm.h:213
virtual LoadBalancerMonitor * giveLoadBalancerMonitor()
Returns reference to receiver&#39;s load balancer monitor.
Definition: engngm.h:1112
std::vector< ParallelContext > parallelContextList
List where parallel contexts are stored.
Definition: engngm.h:311
#define OOFEM_WARNING(...)
Definition: error.h:62
virtual void giveBoundaryEdgeNodes(IntArray &bNodes, int boundary)
Returns list of receiver boundary nodes for given edge.
Definition: element.C:860
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
Helper struct to pass array and numbering scheme as a single argument.
Definition: engngm.h:187
Class representing solution step.
Definition: timestep.h:80
void tryParameters(int wdeg, int wdis)
Generates the new nodal numbering based on given parameters.
Definition: sloangraph.C:599
const IntArray & giveElementList()
Returns list of elements within set.
Definition: set.C:138
DofManager is shared by neighboring partitions, it is necessary to sum contributions from all contrib...
Definition: dofmanager.h:82
dofManagerParallelMode giveParallelMode() const
Return dofManagerParallelMode of receiver.
Definition: dofmanager.h:512
void stopTimer()
Definition: timer.C:77
virtual void printSingleOutputAt(FILE *file, TimeStep *tStep, char ch, ValueModeType mode, double scale=1.0)
Prints Dof output (it prints value of unknown related to dof at given timeStep).
Definition: dof.C:76
virtual void printStatistics() const
Print receiver statistics.
Definition: loadbalancer.C:505
virtual bool computeM2LTransformation(FloatMatrix &answer, const IntArray &dofIDArry)
Computes transformation matrix from local DOFs to master DOFs; .
Definition: dofmanager.C:905
void Instanciate_init()
Initialization of the receiver state (opening the default output stream, empty domain creation...
Definition: engngm.C:184
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631
int numberOfEquations
Total number of equation in current time step.
Definition: engngm.h:211
OGC_PlotModeType giveIntVarPlotMode()
virtual const char * giveClassName() const =0
Returns class name of the receiver.
virtual void locationFromElementNodes(IntArray &loc, Element &element, const IntArray &bNodes, const UnknownNumberingScheme &s, IntArray *dofIds=nullptr) const
Default implementation takes all the DOF IDs.
int equationNumberingCompleted
Equation numbering completed flag.
Definition: engngm.h:223

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:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011