OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
domain.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include "domain.h"
36 #include "element.h"
37 #include "timestep.h"
38 #include "node.h"
39 #include "elementside.h"
40 #include "material.h"
41 #include "crosssection.h"
42 #include "load.h"
43 #include "initialcondition.h"
44 #include "function.h"
45 #include "set.h"
46 #include "engngm.h"
48 #include "datastream.h"
49 #include "contextioerr.h"
50 #include "verbose.h"
51 #include "connectivitytable.h"
52 #include "outputmanager.h"
53 #include "octreelocalizer.h"
54 #include "nodalrecoverymodel.h"
55 #include "nonlocalbarrier.h"
56 #include "classfactory.h"
57 #include "logger.h"
58 #include "xfem/xfemmanager.h"
59 #include "topologydescription.h"
60 #include "errorestimator.h"
61 #include "range.h"
62 #include "fracturemanager.h"
63 #include "datareader.h"
64 #include "oofemtxtdatareader.h"
65 #include "initmodulemanager.h"
66 #include "exportmodulemanager.h"
67 #include "xfem/enrichmentitem.h"
70 #include "xfem/propagationlaw.h"
71 #include "contact/contactmanager.h"
72 #include "bctracker.h"
73 
74 #include "boundarycondition.h"
75 #include "activebc.h"
76 #include "simpleslavedof.h"
77 #include "masterdof.h"
78 
79 #ifdef __PARALLEL_MODE
80  #include "parallel.h"
81  #include "processcomm.h"
82  #include "datastream.h"
83  #include "communicator.h"
85 #endif
86 
87 #include <cstdarg>
88 #include <cstring>
89 #include <vector>
90 #include <set>
91 
92 namespace oofem {
93 Domain :: Domain(int n, int serNum, EngngModel *e) : defaultNodeDofIDArry(),
94  bcTracker(this)
95  // Constructor. Creates a new domain.
96 {
97  if ( !e->giveSuppressOutput() ) {
98  outputManager = std::unique_ptr<OutputManager> (new OutputManager(this) );
99  } else {
100  outputManager = NULL;
101  }
102 
103  this->engineeringModel = e;
104  this->number = n;
105  this->serialNumber = serNum;
106 
107  dType = _unknownMode;
108 
110 
111  nsd = 0;
112  axisymm = false;
114 
115 #ifdef __PARALLEL_MODE
117  transactionManager = NULL;
118 #endif
119 }
120 
122 
123 void
125 // Clear receiver
126 {
127  elementList.clear();
128  mElementPlaceInArray.clear();
129  mDofManPlaceInArray.clear();
130  dofManagerList.clear();
131  materialList.clear();
132  bcList.clear();
133  icList.clear();
134  functionList.clear();
135  crossSectionList.clear();
136  nonlocalBarrierList.clear();
137  setList.clear();
138  xfemManager.reset(NULL);
139  contactManager.reset(NULL);
140  if ( connectivityTable ) {
141  connectivityTable->reset();
142  }
143 
144  spatialLocalizer.reset(NULL);
145 
146  if ( smoother ) {
147  smoother->clear();
148  }
149 
151  topology.reset(NULL);
152 
153 #ifdef __PARALLEL_MODE
154  transactionManager.reset(NULL);
155 #endif
156 }
157 
158 
159 Element *
161 {
162 #ifdef DEBUG
163  if ( n < 1 || n > (int)elementList.size() ) {
164  OOFEM_ERROR("undefined element (%d)", n);
165  }
166 #endif
167  return this->elementList[n-1].get();
168 }
169 
170 Element *
172 {
173  for ( auto &el: elementList ) {
174  if ( el->giveGlobalNumber() == n ) {
175  return el.get();
176  }
177  }
178 
179  return NULL;
180 }
181 
182 int
183 Domain :: giveElementPlaceInArray(int iGlobalElNum) const
184 {
185  auto res = mElementPlaceInArray.find(iGlobalElNum);
186 
187  if ( res != mElementPlaceInArray.end() ) {
188  return res->second;
189  } else {
190  OOFEM_ERROR("returning -1 for iGlobalElNum: %d.", iGlobalElNum );
191  return -1;
192  }
193 }
194 
195 int
196 Domain :: giveDofManPlaceInArray(int iGlobalDofManNum) const
197 {
198  auto res = mDofManPlaceInArray.find(iGlobalDofManNum);
199 
200  if ( res != mDofManPlaceInArray.end() ) {
201  return res->second;
202  } else {
203  OOFEM_ERROR("returning -1 for iGlobalDofManNum: %d.", iGlobalDofManNum );
204  return -1;
205  }
206 }
207 
208 const IntArray &
210 {
211  auto res = mMapMaterialNum2El.find(iMaterialNum);
212 
213  if ( res != mMapMaterialNum2El.end() ) {
214  return res->second;
215  } else {
216  OOFEM_ERROR("Material not found.")
217  return res->second;
218  }
219 }
220 
221 Load *
223 {
224 #ifdef DEBUG
225  if ( n < 1 || n > (int)bcList.size() ) {
226  OOFEM_ERROR("undefined load (%d)", n);
227  }
228  Load *answer = dynamic_cast< Load * >( bcList[n-1].get() );
229  if ( answer ) {
230  return answer;
231  } else {
232  OOFEM_ERROR("cannot cast boundary condition %d to Load class", n);
233  return NULL;
234  }
235 #else
236  return static_cast< Load * >( bcList[n-1].get() );
237 
238 #endif
239 }
240 
241 
244 {
245 #ifdef DEBUG
246  if ( n < 1 || n > (int)bcList.size() ) {
247  OOFEM_ERROR("undefined bc (%d)", n);
248  }
249 #endif
250  return bcList[n-1].get();
251 }
252 
253 
256 {
257 #ifdef DEBUG
258  if ( n < 1 || n > (int)icList.size() ) {
259  OOFEM_ERROR("undefined ic (%d)", n);
260  }
261 #endif
262 
263  return icList[n-1].get();
264 }
265 
266 
267 Function *
269 {
270 #ifdef DEBUG
271  if ( n < 1 || n > (int)functionList.size() ) {
272  OOFEM_ERROR("undefined load-time function (%d)", n);
273  }
274 #endif
275 
276  return functionList[n-1].get();
277 }
278 
279 
280 Material *
282 {
283 #ifdef DEBUG
284  if ( n < 1 || n > (int)materialList.size() ) {
285  OOFEM_ERROR("undefined material (%d)", n);
286  }
287 #endif
288 
289  return materialList[n-1].get();
290 }
291 
292 ElementSide *
294 {
295 #ifdef DEBUG
296  if ( n < 1 || n > (int)dofManagerList.size() ) {
297  OOFEM_ERROR("undefined dofManager (%d)", n);
298  }
299 
300  ElementSide *side = dynamic_cast< ElementSide * >( dofManagerList[n-1].get() );
301  if ( !side ) {
302  OOFEM_ERROR("incompatible type of dofManager %d, can not convert", n);
303  }
304  return side;
305 
306 #else
307  return static_cast< ElementSide * >( dofManagerList[n-1].get() );
308 
309 #endif
310 }
311 
312 
313 DofManager *
315 {
316 #ifdef DEBUG
317  if ( n < 1 || n > (int)dofManagerList.size() ) {
318  OOFEM_ERROR("undefined dofManager (%d)", n);
319  }
320 #endif
321  return this->dofManagerList[n-1].get();
322 }
323 
324 
325 DofManager *
327 {
328  for ( auto &dman: dofManagerList ) {
329  if ( dman->giveGlobalNumber() == n ) {
330  return dman.get();
331  }
332  }
333 
334  return NULL;
335 }
336 
337 
338 CrossSection *
340 {
341 #ifdef DEBUG
342  if ( n < 1 || n > (int)crossSectionList.size() ) {
343  OOFEM_ERROR("undefined cross section (%d)", n);
344  }
345 #endif
346  return crossSectionList[n-1].get();
347 }
348 
349 
352 {
353 #ifdef DEBUG
354  if ( n < 1 || n > (int)nonlocalBarrierList.size() ) {
355  OOFEM_ERROR("undefined barrier (%d)", n);
356  }
357 #endif
358  return nonlocalBarrierList[n-1].get();
359 }
360 
361 
362 Set *
364 {
365 #ifdef DEBUG
366  if ( n < 1 || n > (int)setList.size() ) {
367  OOFEM_ERROR("undefined set (%d)", n);
368  }
369 #endif
370 
371  return setList[n-1].get();
372 }
373 
374 XfemManager *
376 {
377 #ifdef DEBUG
378  if ( !xfemManager ) {
379  OOFEM_ERROR("undefined xfem manager");
380  }
381 #endif
382  return xfemManager.get();
383 }
384 
385 bool
387 {
388  return xfemManager.get() != NULL;
389 }
390 
391 
394 {
395 #ifdef DEBUG
396  if ( !contactManager ) {
397  OOFEM_ERROR("undefined contact manager");
398  }
399 #endif
400  return contactManager.get();
401 }
402 
403 bool
405 {
406  return contactManager.get() != NULL;
407 }
408 
409 bool
411 {
412  return fracManager.get() != NULL;
413 }
414 
417 {
418 #ifdef DEBUG
419  if ( !fracManager ) {
420  OOFEM_ERROR("undefined fracture manager");
421  }
422 #endif
423  return fracManager.get();
424 }
425 
426 BCTracker*
428 {
429  return &bcTracker;
430 }
431 
432 EngngModel *
434 {
435 #ifdef DEBUG
436  if ( !engineeringModel ) {
437  OOFEM_ERROR("Not defined");
438  }
439 #endif
440 
441  return engineeringModel;
442 }
443 
444 void Domain :: resizeDofManagers(int _newSize) { dofManagerList.resize(_newSize); }
445 void Domain :: resizeElements(int _newSize) { elementList.resize(_newSize); }
446 void Domain :: resizeCrossSectionModels(int _newSize) { crossSectionList.resize(_newSize); }
447 void Domain :: resizeMaterials(int _newSize) { materialList.resize(_newSize); }
448 void Domain :: resizeNonlocalBarriers(int _newSize) { nonlocalBarrierList.resize(_newSize); }
449 void Domain :: resizeBoundaryConditions(int _newSize) { bcList.resize(_newSize); }
450 void Domain :: resizeInitialConditions(int _newSize) { icList.resize(_newSize); }
451 void Domain :: resizeFunctions(int _newSize) { functionList.resize(_newSize); }
452 void Domain :: resizeSets(int _newSize) { setList.resize(_newSize); }
453 
455 void Domain :: setElement(int i, Element *obj) { elementList[i-1].reset(obj); mElementPlaceInArray[obj->giveGlobalNumber()] = i;}
456 void Domain :: setCrossSection(int i, CrossSection *obj) { crossSectionList[i-1].reset(obj); }
457 void Domain :: setMaterial(int i, Material *obj) { materialList[i-1].reset(obj); }
459 void Domain :: setBoundaryCondition(int i, GeneralBoundaryCondition *obj) { bcList[i-1].reset(obj); }
460 void Domain :: setInitialCondition(int i, InitialCondition *obj) { icList[i-1].reset(obj); }
461 void Domain :: setFunction(int i, Function *obj) { functionList[i-1].reset(obj); }
462 void Domain :: setSet(int i, Set *obj) { setList[i-1].reset(obj); }
463 void Domain :: setXfemManager(XfemManager *ipXfemManager) { xfemManager.reset(ipXfemManager); }
464 
467 int
469 // Creates all objects mentioned in the data file.
470 {
471  IRResultType result; // Required by IR_GIVE_FIELD macro
472 
473  int num;
474  std :: string name, topologytype;
475  int nnode, nelem, nmat, nload, nic, nloadtimefunc, ncrossSections, nbarrier = 0, nset = 0;
476  bool nxfemman = false;
477  bool ncontactman = false;
478  bool nfracman = false;
479  //XfemManager *xMan;
480  // mapping from label to local numbers for dofmans and elements
481  std :: map< int, int >dofManLabelMap, elemLabelMap;
482 
483  // read type of Domain to be solved
485  IR_GIVE_FIELD(ir, name, _IFT_Domain_type); // This is inconsistent, "domain" isn't exactly a field, but the actual record keyword.
486 
487  mDomainType = name;
488 
489  ir->finish();
490 
491 # ifdef VERBOSE
492  VERBOSE_PRINT0("Instanciating domain ", this->number);
493 # endif
494 
495  resolveDomainDofsDefaults( name.c_str() );
496 
497  // read output manager record
498  std :: string tmp;
500  ir->giveRecordKeywordField(tmp);
501 
502  if(!giveEngngModel()->giveSuppressOutput()) {
503  outputManager->initializeFrom(ir);
504  }
505 
506  ir->finish();
507 
508  // read domain description
511  IR_GIVE_FIELD(ir, nelem, _IFT_Domain_nelem);
512  IR_GIVE_FIELD(ir, ncrossSections, _IFT_Domain_ncrosssect);
513  IR_GIVE_FIELD(ir, nmat, _IFT_Domain_nmat);
514  IR_GIVE_FIELD(ir, nload, _IFT_Domain_nbc);
515  IR_GIVE_FIELD(ir, nic, _IFT_Domain_nic);
516  IR_GIVE_FIELD(ir, nloadtimefunc, _IFT_Domain_nfunct);
520  IR_GIVE_OPTIONAL_FIELD(ir, topologytype, _IFT_Domain_topology);
521  this->nsd = -1;
526 
528  //_HeatTransferMode _HeatMass1Mode // Are these deprecated?
529  // set the number of spatial dimensions
530  if ( dType == _1dTrussMode ) {
531  nsd = 1;
532  } else if ( dType == _2dIncompressibleFlow || dType == _2dBeamMode || dType == _2dTrussMode || dType == _2dMindlinPlateMode || dType == _PlaneStrainMode || dType == _2dPlaneStressMode || dType == _2dPlaneStressRotMode || dType == _WarpingMode ) {
533  nsd = 2;
534  } else if ( dType == _3dIncompressibleFlow || dType == _3dShellMode || dType == _3dMode || dType == _3dDirShellMode ) {
535  nsd = 3;
536  } else if ( dType == _3dAxisymmMode ) {
537  nsd = 2;
538  axisymm = true;
539  }
540 
541  // read nodes
542  dofManagerList.clear();
543  dofManagerList.resize(nnode);
544  for ( int i = 1; i <= nnode; i++ ) {
546  // read type of dofManager
547  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
548 
549  // assign component number according to record order
550  // component number (as given in input record) becomes label
551  std :: unique_ptr< DofManager > dman( classFactory.createDofManager(name.c_str(), i, this) );
552  if ( !dman ) {
553  OOFEM_ERROR("Couldn't create node of type: %s\n", name.c_str());
554  }
555 
556  dman->initializeFrom(ir);
557  if ( dofManLabelMap.find(num) == dofManLabelMap.end() ) {
558  // label does not exist yet
559  dofManLabelMap [ num ] = i;
560  } else {
561  OOFEM_ERROR("iDofmanager entry already exist (label=%d)", num);
562  }
563 
564  dman->setGlobalNumber(num); // set label
565  dofManagerList[i - 1] = std :: move(dman);
566 
567  ir->finish();
568  }
569 
570 # ifdef VERBOSE
571  VERBOSE_PRINT0("Instanciated nodes & sides ", nnode)
572 # endif
573 
575 
576  // read elements
577  elementList.clear();
578  elementList.resize(nelem);
579  for ( int i = 1; i <= nelem; i++ ) {
581  // read type of element
582  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
583 
584  std :: unique_ptr< Element >elem( classFactory.createElement(name.c_str(), i, this) );
585  if ( !elem ) {
586  OOFEM_ERROR("Couldn't create element: %s", name.c_str());
587  }
588 
589  elem->initializeFrom(ir);
590 
591  if ( elemLabelMap.find(num) == elemLabelMap.end() ) {
592  // label does not exist yet
593  elemLabelMap [ num ] = i;
594  } else {
595  OOFEM_ERROR("Element entry already exist (label=%d)", num);
596  }
597 
598  elem->setGlobalNumber(num);
599  elementList[i - 1] = std :: move(elem);
600 
601  ir->finish();
602  }
603 
605 
606  // Support sets defined directly after the elements (special hack for backwards compatibility).
607  setList.clear();
608  if ( dr.peakNext("set") ) {
609  setList.resize(nset);
610  for ( int i = 1; i <= nset; i++ ) {
612  // read type of set
613  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
614  // Only one set for now (i don't see any need to ever introduce any other version)
615  std :: unique_ptr< Set > set(new Set(num, this)); //classFactory.createSet(name.c_str(), num, this)
616  if ( !set ) {
617  OOFEM_ERROR("Couldn't create set: %s", name.c_str());
618  }
619 
620  set->initializeFrom(ir);
621 
622  // check number
623  if ( num < 1 || num > nset ) {
624  OOFEM_ERROR("Invalid set number (num=%d)", num);
625  }
626 
627  if ( !setList[num - 1] ) {
628  setList[num - 1] = std :: move(set);
629  } else {
630  OOFEM_ERROR("Set entry already exist (num=%d)", num);
631  }
632 
633  ir->finish();
634  }
635  }
636 
637 # ifdef VERBOSE
638  VERBOSE_PRINT0("Instanciated elements ", nelem);
639 # endif
640 
641  // read cross sections
642  crossSectionList.clear();
643  crossSectionList.resize(ncrossSections);
644  for ( int i = 1; i <= ncrossSections; i++ ) {
646  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
647 
648  std :: unique_ptr< CrossSection >crossSection( classFactory.createCrossSection(name.c_str(), num, this) );
649  if ( !crossSection ) {
650  OOFEM_ERROR("Couldn't create crosssection: %s", name.c_str());
651  }
652 
653  crossSection->initializeFrom(ir);
654 
655  // check number
656  if ( ( num < 1 ) || ( num > ncrossSections ) ) {
657  OOFEM_ERROR("Invalid crossSection number (num=%d)", num);
658  }
659 
660  if ( !crossSectionList[num - 1] ) {
661  crossSectionList[num - 1] = std :: move(crossSection);
662  } else {
663  OOFEM_ERROR("crossSection entry already exist (num=%d)", num);
664  }
665 
666  ir->finish();
667  }
668 
669 # ifdef VERBOSE
670  VERBOSE_PRINT0("Instanciated cross sections ", ncrossSections)
671 # endif
672 
673  // read materials
674  materialList.clear();
675  materialList.resize(nmat);
676  for ( int i = 1; i <= nmat; i++ ) {
678  // read type of material
679  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
680 
681  std :: unique_ptr< Material >mat( classFactory.createMaterial(name.c_str(), num, this) );
682  if ( !mat ) {
683  OOFEM_ERROR("Couldn't create material: %s", name.c_str());
684  }
685 
686  mat->initializeFrom(ir);
687 
688  // check number
689  if ( ( num < 1 ) || ( num > nmat ) ) {
690  OOFEM_ERROR("Invalid material number (num=%d)", num);
691  }
692 
693  if ( !materialList[num - 1] ) {
694  materialList[num - 1] = std :: move(mat);
695  } else {
696  OOFEM_ERROR("material entry already exist (num=%d)", num);
697  }
698 
699  ir->finish();
700  }
701 
702 # ifdef VERBOSE
703  VERBOSE_PRINT0("Instanciated materials ", nmat)
704 # endif
705 
706  // read barriers
707  nonlocalBarrierList.clear();
708  nonlocalBarrierList.resize(nbarrier);
709  for ( int i = 1; i <= nbarrier; i++ ) {
711  // read type of load
712  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
713 
714  std :: unique_ptr< NonlocalBarrier >barrier( classFactory.createNonlocalBarrier(name.c_str(), num, this) );
715  if ( !barrier ) {
716  OOFEM_ERROR("Couldn't create barrier: %s", name.c_str());
717  }
718 
719  barrier->initializeFrom(ir);
720 
721  // check number
722  if ( ( num < 1 ) || ( num > nbarrier ) ) {
723  OOFEM_ERROR("Invalid barrier number (num=%d)", num);
724  }
725 
726  if ( !nonlocalBarrierList[num - 1] ) {
727  nonlocalBarrierList[num - 1] = std :: move(barrier);
728  } else {
729  OOFEM_ERROR("barrier entry already exist (num=%d)", num);
730  }
731 
732  ir->finish();
733  }
734 
735 # ifdef VERBOSE
736  if ( nbarrier ) {
737  VERBOSE_PRINT0("Instanciated barriers ", nbarrier);
738  }
739 # endif
740 
741  // read boundary conditions
742  bcList.clear();
743  bcList.resize(nload);
744  for ( int i = 1; i <= nload; i++ ) {
746  // read type of bc
747  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
748 
749  std :: unique_ptr< GeneralBoundaryCondition >bc( classFactory.createBoundaryCondition(name.c_str(), num, this) );
750  if ( !bc ) {
751  OOFEM_ERROR("Couldn't create boundary condition: %s", name.c_str());
752  }
753 
754  bc->initializeFrom(ir);
755 
756  // check number
757  if ( ( num < 1 ) || ( num > nload ) ) {
758  OOFEM_ERROR("Invalid boundary condition number (num=%d)", num);
759  }
760 
761  if ( !bcList[num - 1] ) {
762  bcList[num - 1] = std :: move(bc);
763  } else {
764  OOFEM_ERROR("boundary condition entry already exist (num=%d)", num);
765  }
766 
767  ir->finish();
768  }
769 
770 # ifdef VERBOSE
771  VERBOSE_PRINT0("Instanciated BCs ", nload)
772 # endif
773 
774  // read initial conditions
775  icList.clear();
776  icList.resize(nic);
777  for ( int i = 1; i <= nic; i++ ) {
779  // read type of load
780  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
781 
782  std :: unique_ptr< InitialCondition >ic( new InitialCondition(num, this) );
783  if ( !ic ) {
784  OOFEM_ERROR("Creation of IC no. %d failed", num);
785  }
786 
787  ic->initializeFrom(ir);
788 
789  // check number
790  if ( ( num < 1 ) || ( num > nic ) ) {
791  OOFEM_ERROR("Invalid initial condition number (num=%d)", num);
792  }
793 
794  if ( !icList[num - 1] ) {
795  icList[num - 1] = std :: move(ic);
796  } else {
797  OOFEM_ERROR("initial condition entry already exist (num=%d)", num);
798  }
799 
800  ir->finish();
801  }
802 
803 # ifdef VERBOSE
804  VERBOSE_PRINT0("Instanciated ICs ", nic)
805 # endif
806 
807 
808  // read load time functions
809  functionList.clear();
810  functionList.resize(nloadtimefunc);
811  for ( int i = 1; i <= nloadtimefunc; i++ ) {
813  // read type of func
814  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
815 
816  std :: unique_ptr< Function >func( classFactory.createFunction(name.c_str(), num, this) );
817  if ( !func ) {
818  OOFEM_ERROR("Couldn't create time function: %s", name.c_str());
819  }
820 
821  func->initializeFrom(ir);
822 
823  // check number
824  if ( ( num < 1 ) || ( num > nloadtimefunc ) ) {
825  OOFEM_ERROR("Invalid Function number (num=%d)", num);
826  }
827 
828  if ( !functionList[num - 1] ) {
829  functionList[num - 1] = std :: move(func);
830  } else {
831  OOFEM_ERROR("Function entry already exist (num=%d)", num);
832  }
833 
834  ir->finish();
835  }
836 
837 # ifdef VERBOSE
838  VERBOSE_PRINT0("Instanciated load-time fncts ", nloadtimefunc)
839 # endif
840 
841  // read sets
842  if ( setList.size() == 0 ) {
843  setList.resize(nset);
844  for ( int i = 1; i <= nset; i++ ) {
846  // read type of set
847  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
848  // Only one set for now (i don't see any need to ever introduce any other version)
849  std :: unique_ptr< Set > set(new Set(num, this)); //classFactory.createSet(name.c_str(), num, this)
850  if ( !set ) {
851  OOFEM_ERROR("Couldn't create set: %s", name.c_str());
852  }
853 
854  set->initializeFrom(ir);
855 
856  // check number
857  if ( ( num < 1 ) || ( num > nset ) ) {
858  OOFEM_ERROR("Invalid set number (num=%d)", num);
859  }
860 
861  if ( !setList[num - 1] ) {
862  setList[num - 1] = std :: move(set);
863  } else {
864  OOFEM_ERROR("Set entry already exist (num=%d)", num);
865  }
866 
867  ir->finish();
868  }
869  }
870 
871 # ifdef VERBOSE
872  if ( nset ) {
873  VERBOSE_PRINT0("Instanciated sets ", nset);
874  }
875 # endif
876 
877  if ( nxfemman ) {
879 
880  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
881  xfemManager.reset( classFactory.createXfemManager(name.c_str(), this) );
882  if ( !xfemManager ) {
883  OOFEM_ERROR("Couldn't create xfemmanager: %s", name.c_str());
884  }
885 
886  xfemManager->initializeFrom(ir);
887  xfemManager->instanciateYourself(dr);
888 # ifdef VERBOSE
889  VERBOSE_PRINT0("Instanciated xfem ", nxfemman);
890 # endif
891  }
892 
893 
894  if ( ncontactman ) {
895  // don't read any input yet
897 
898  IR_GIVE_RECORD_KEYWORD_FIELD(ir, name, num);
899  contactManager.reset( classFactory.createContactManager(name.c_str(), this) );
900  if ( !contactManager ) {
901  OOFEM_ERROR("Couldn't create contact manager: %s", name.c_str());
902  }
903 
904  contactManager->initializeFrom(ir);
905  contactManager->instanciateYourself(dr);
906  }
907 # ifdef VERBOSE
908  if ( ncontactman ) {
909  VERBOSE_PRINT0("Instanciated contact manager ", ncontactman);
910  }
911 # endif
912 
913 
914  this->topology = NULL;
915  if ( topologytype.length() > 0 ) {
916  this->topology.reset( classFactory.createTopology(topologytype.c_str(), this) );
917  if ( !this->topology ) {
918  OOFEM_ERROR("Couldn't create topology of type '%s'", topologytype.c_str());
919  }
920 
921  return this->topology->instanciateYourself(dr);
922 # ifdef VERBOSE
923  VERBOSE_PRINT0("Instanciated topologies ", topologytype.length());
924 # endif
925  }
926 
927 
928  if ( nfracman ) {
930  fracManager.reset( new FractureManager(this) );
931  fracManager->initializeFrom(ir);
932  fracManager->instanciateYourself(dr);
933 # ifdef VERBOSE
934  VERBOSE_PRINT0("Instanciated fracture manager ", nxfemman);
935 # endif
936  }
937 
938  // change internal component references from labels to assigned local numbers
939  MapBasedEntityRenumberingFunctor labelToLocNumFunctor(dofManLabelMap, elemLabelMap);
940  for ( auto &dman: this->dofManagerList ) {
941  dman->updateLocalNumbering(labelToLocNumFunctor);
942  }
943 
944  for ( auto &element: this->elementList ) {
945  element->updateLocalNumbering(labelToLocNumFunctor);
946  }
947 
948  for ( auto &set: setList ) {
949  set->updateLocalNumbering(labelToLocNumFunctor);
950  }
951 
952 
954 
955  return 1;
956 }
957 
958 
959 void
961 {
962  // New - in development /JB
963  // set element cross sections based on element set definition and set the corresponding
964  // material based on the cs
965  for ( int i = 1; i <= this->giveNumberOfCrossSectionModels(); i++ ) {
966  if ( int setNum = this->giveCrossSection(i)->giveSetNumber() ) {
967  Set *set = this->giveSet(setNum);
968  for ( int ielem: set->giveElementList() ) {
969  Element *element = this->giveElement( ielem );
970  element->setCrossSection(i);
971  }
972  }
973  }
974 
975  // Dofs must be created before dof managers due their post-initialization:
976  this->createDofs();
977 
978  for ( auto &dman: dofManagerList ) {
979  dman->postInitialize();
980  }
981 
982  if ( this->hasXfemManager() ) {
983  //this->giveXfemManager()->postInitialize();
984  }
985 
986  for ( auto &el: elementList ) {
987  el->postInitialize();
988  }
989 
990  for ( auto &bc: bcList ) {
991  bc->postInitialize();
992  }
993 }
994 
995 
996 std :: string
997 Domain :: errorInfo(const char *func) const
998 {
999  return std::string("Domain::") + func + ", number: " + std::to_string(number);
1000 }
1001 
1002 
1003 const IntArray &
1005 {
1006  // returns default DofID array, defining physical meaning of particular DOFs
1007  // in Node Dof collection
1008  if ( this->defaultNodeDofIDArry.giveSize() ) {
1009  return defaultNodeDofIDArry;
1010  }
1011 
1012  if ( dType == _2dPlaneStressRotMode ) {
1013  defaultNodeDofIDArry = {D_u, D_v, R_w};
1014  } else if ( dType == _2dPlaneStressMode ) {
1015  defaultNodeDofIDArry = {D_u, D_v};
1016  } else if ( dType == _PlaneStrainMode ) {
1017  defaultNodeDofIDArry = {D_u, D_v};
1018  } else if ( dType == _3dMode ) {
1019  defaultNodeDofIDArry = {D_u, D_v, D_w};
1020  } else if ( dType == _3dAxisymmMode ) {
1021  defaultNodeDofIDArry = {D_u, D_v, R_w};
1022  } else if ( dType == _2dMindlinPlateMode ) {
1023  defaultNodeDofIDArry = {D_w, R_u, R_v};
1024  } else if ( dType == _3dShellMode ) {
1025  defaultNodeDofIDArry = {D_u, D_v, D_w, R_u, R_v, R_w};
1026  } else if ( dType == _2dTrussMode ) {
1027  defaultNodeDofIDArry = {D_u, D_w};
1028  } else if ( dType == _1dTrussMode ) {
1029  defaultNodeDofIDArry = {D_u};
1030  } else if ( dType == _2dBeamMode ) {
1031  defaultNodeDofIDArry = {D_u, D_w, R_v};
1032  } else if ( dType == _2dLatticeMode ) {
1033  defaultNodeDofIDArry = {D_u, D_v, R_w};
1034  } else if ( dType == _HeatTransferMode ) {
1035  defaultNodeDofIDArry = {T_f};
1036  } else if ( dType == _Mass1TransferMode ) {
1037  defaultNodeDofIDArry = {C_1};
1038  } else if ( dType == _HeatMass1Mode ) {
1039  defaultNodeDofIDArry = {T_f, C_1};
1040  } else if ( dType == _2dIncompressibleFlow ) {
1041  defaultNodeDofIDArry = {V_u, V_v, P_f};
1042  } else if ( dType == _3dIncompressibleFlow ) {
1043  defaultNodeDofIDArry = {V_u, V_v, V_w, P_f};
1044  } else if ( dType == _3dDirShellMode ) {
1045  defaultNodeDofIDArry = {D_u, D_v, D_w, W_u, W_v, W_w, Gamma};
1046  } else if ( dType == _2dLatticeMassTransportMode ) {
1047  defaultNodeDofIDArry = {P_f};
1048  } else if ( dType == _3dLatticeMassTransportMode ) {
1049  defaultNodeDofIDArry = {P_f};
1050  } else if ( dType == _3dLatticeMode ) {
1051  defaultNodeDofIDArry = {D_u, D_v, D_w, R_u, R_v, R_w};
1052  } else if ( dType == _2dLatticeHeatTransferMode ) {
1053  defaultNodeDofIDArry = {T_f};
1054  } else if ( dType == _3dLatticeHeatTransferMode ) {
1055  defaultNodeDofIDArry = {T_f};
1056  } else if ( dType == _WarpingMode ) {
1057  defaultNodeDofIDArry = {D_w};
1058  } else {
1059  OOFEM_ERROR("unknown domainType (%s)", __domainTypeToString(dType));
1060  }
1061 
1062  return defaultNodeDofIDArry;
1063 }
1064 
1065 
1066 int
1068 {
1069  return nsd;
1070 }
1071 
1072 
1073 bool
1075 {
1076  return axisymm;
1077 }
1078 
1079 
1080 void
1082 //
1083 // resolves default number of dofs per node according to domain type name.
1084 // and also resolves default dof mask according to domain type.
1085 //
1086 {
1087  if ( !strncmp(typeName, "2dplanestressrot", 16) ) {
1088  dType = _2dPlaneStressRotMode;
1089  } else if ( !strncmp(typeName, "2dplanestress", 12) ) {
1090  dType = _2dPlaneStressMode;
1091  } else if ( !strncmp(typeName, "planestrain", 11) ) {
1092  dType = _PlaneStrainMode;
1093  } else if ( !strncmp(typeName, "3daxisymm", 9) ) {
1094  dType = _3dAxisymmMode;
1095  } else if ( !strncmp(typeName, "2dmindlinplate", 14) ) {
1096  dType = _2dMindlinPlateMode;
1097  } else if ( !strncmp(typeName, "3dshell", 7) ) {
1098  dType = _3dShellMode;
1099  } else if ( !strncmp(typeName, "2dtruss", 7) ) {
1100  dType = _2dTrussMode;
1101  } else if ( !strncmp(typeName, "1dtruss", 7) ) {
1102  dType = _1dTrussMode;
1103  } else if ( !strncmp(typeName, "2dbeam", 6) ) {
1104  dType = _2dBeamMode;
1105  } else if ( !strncmp(typeName, "2dlattice", 9) ) {
1106  dType = _2dLatticeMode;
1107  } else if ( !strncmp(typeName, "heattransfer", 12) ) {
1108  dType = _HeatTransferMode;
1109  } else if ( !strncmp(typeName, "mass1transfer", 13) ) {
1110  dType = _Mass1TransferMode;
1111  } else if ( !strncmp(typeName, "hema1", 5) ) {
1112  dType = _HeatMass1Mode;
1113  } else if ( !strncmp(typeName, "2dincompflow", 12) ) {
1114  dType = _2dIncompressibleFlow;
1115  } else if ( !strncmp(typeName, "3dincompflow", 12) ) {
1116  dType = _3dIncompressibleFlow;
1117  } else if ( !strncmp(typeName, "3ddirshell", 10) ) {
1118  dType = _3dDirShellMode;
1119  } else if ( !strncmp(typeName, "2dmasslatticetransport", 22) ) {
1120  dType = _2dLatticeMassTransportMode;
1121  } else if ( !strncmp(typeName, "3dlattice", 9) ) {
1122  dType = _3dLatticeMode;
1123  } else if ( !strncmp(typeName, "3dmasslatticetransport", 22) ) {
1124  dType = _3dLatticeMassTransportMode;
1125  } else if ( !strncmp(typeName, "2dheatlattice", 13) ) {
1126  dType = _3dLatticeMassTransportMode;
1127  } else if ( !strncmp(typeName, "3dheatlattice", 13) ) {
1128  dType = _3dLatticeMassTransportMode;
1129  } else if ( !strncmp(typeName, "3d", 2) ) {
1130  dType = _3dMode;
1131  } else if ( !strncmp(typeName, "warping", 7) ) {
1132  dType = _WarpingMode;
1133  } else {
1134  OOFEM_ERROR("unknown domainType (%s)", typeName);
1135  return;
1136  }
1137 }
1138 
1139 
1142 {
1143  return this->smoother.get();
1144 }
1145 
1146 
1147 void
1148 Domain :: setSmoother(NodalRecoveryModel *newSmoother, bool destroyOld)
1149 {
1150  if ( !destroyOld ) {
1151  this->smoother.release();
1152  }
1153 
1154  this->smoother.reset(newSmoother);
1155 }
1156 
1157 
1158 void
1160 {
1161  if ( !destroyOld ) {
1162  this->topology.release();
1163  }
1164 
1165  this->topology.reset(topo);
1166 }
1167 
1168 
1171 //
1172 // return connectivity Table - if no defined - creates new one
1173 //
1174 {
1175  if ( !connectivityTable ) {
1176  connectivityTable.reset( new ConnectivityTable(this) );
1177  }
1178 
1179  return connectivityTable.get();
1180 }
1181 
1182 
1185 //
1186 // return connectivity Table - if no defined - creates new one
1187 //
1188 {
1189  // if (spatialLocalizer == NULL) spatialLocalizer = new DummySpatialLocalizer(1, this);
1190  if ( !spatialLocalizer ) {
1191  spatialLocalizer.reset( new OctreeSpatialLocalizer(this) );
1192  }
1193 
1194  spatialLocalizer->init();
1195  return spatialLocalizer.get();
1196 }
1197 
1198 
1199 void
1201 {
1202 
1205  std :: vector< std :: set< int > > node_dofs( this->giveNumberOfDofManagers() );
1206  for ( auto &element: this->elementList ) {
1207  IntArray dofids;
1208  // Scan for all dofs needed by element.
1209  for ( int j = 1; j <= element->giveNumberOfNodes(); ++j ) {
1210  element->giveDofManDofIDMask(j, dofids);
1211  for ( int k = 1; k <= dofids.giveSize(); k++ ) {
1212  node_dofs [ element->giveNode(j)->giveNumber() - 1 ].insert( dofids.at(k) );
1213  }
1214  }
1215  }
1216  for ( auto &dman: this->dofManagerList ) {
1217  // Nodes can also contain their own list of dofs (typical usecase: RigidArmNode )
1218  const IntArray *dofids = dman->giveForcedDofIDs();
1219  if ( dofids ) {
1220  for ( int k = 1; k <= dofids->giveSize(); ++k ) {
1221  node_dofs [ dman->giveNumber() - 1 ].insert( dofids->at(k) );
1222  }
1223  }
1224  }
1225 
1227  // Step 2. Scan all Dirichlet b.c.s (or active dofs). For every node we store a map from the dofid to it's b.c. number.
1228  // This loop won't check for slave dofs or so, and will give a bc id for every single relevant dof.
1229  // This must be a separate step since we store the inverse mapping (bc->dof instead of dof->bc) so we want to loop over all b.c.s to invert this.
1230  std :: vector< std :: map< int, int > > dof_bc( this->giveNumberOfDofManagers() );
1231  for ( int i = 1; i <= this->giveNumberOfBoundaryConditions(); ++i ) {
1232  GeneralBoundaryCondition *gbc = this->giveBc(i);
1233  if ( gbc->giveSetNumber() > 0 ) {
1234  // Loop over nodes in set and store the bc number in each dof.
1235  Set *set = this->giveSet( gbc->giveSetNumber() );
1236  ActiveBoundaryCondition *active_bc = dynamic_cast< ActiveBoundaryCondition * >(gbc);
1237  BoundaryCondition *bc = dynamic_cast< BoundaryCondition * >(gbc);
1238  if ( bc || ( active_bc && active_bc->requiresActiveDofs() ) ) {
1239  const IntArray &appliedDofs = gbc->giveDofIDs();
1240  const IntArray &nodes = set->giveNodeList();
1241  for ( int inode = 1; inode <= nodes.giveSize(); ++inode ) {
1242  for ( int idof = 1; idof <= appliedDofs.giveSize(); ++idof ) {
1243  dof_bc [ nodes.at(inode) - 1 ] [ appliedDofs.at(idof) ] = i;
1244  }
1245  }
1246  }
1247  }
1248  }
1249  // Step 2b. This step asks nodes for their bc-vector, which is the old approach to dirichlet b.c.s (i.e. this is for backwards compatibility)
1251  for ( int i = 1; i <= this->giveNumberOfDofManagers(); ++i ) {
1252  DofManager *dman = this->giveDofManager(i);
1253  const std :: map< int, int > *dmanBcs = dman->giveBcMap();
1254  if ( dmanBcs ) {
1255  dof_bc [ i - 1 ].insert( dmanBcs->begin(), dmanBcs->end() ); // This will ignore duplicated dofiditems.
1256  }
1257  }
1258 
1260  // Step 3. Same for initial conditions as for boundary conditions in step 2.
1261  std :: vector< std :: map< int, int > > dof_ic( this->giveNumberOfDofManagers() );
1262  for ( int i = 1; i <= this->giveNumberOfInitialConditions(); ++i ) {
1263  InitialCondition *ic = this->giveIc(i);
1264  if ( ic->giveSetNumber() > 0 ) {
1265  // Loop over nodes in set and store the bc number in each dof.
1266  Set *set = this->giveSet( ic->giveSetNumber() );
1267  const IntArray &appliedDofs = ic->giveDofIDs();
1268  const IntArray &nodes = set->giveNodeList();
1269  for ( int inode = 1; inode <= nodes.giveSize(); ++inode ) {
1270  for ( int idof = 1; idof <= appliedDofs.giveSize(); ++idof ) {
1271  dof_ic [ nodes.at(inode) - 1 ] [ appliedDofs.at(idof) ] = i;
1272  }
1273  }
1274  }
1275  }
1276  // Step 3b. This step asks nodes for their bc-vector, which is the old approach to dirichlet b.c.s (i.e. this is for backwards compatibility)
1278  for ( int i = 1; i <= this->giveNumberOfDofManagers(); ++i ) {
1279  DofManager *dman = this->giveDofManager(i);
1280  const std :: map< int, int > *dmanIcs = dman->giveIcMap();
1281  if ( dmanIcs ) {
1282  dof_ic [ i - 1 ].insert( dmanIcs->begin(), dmanIcs->end() ); // This will ignore duplicated dofiditems.
1283  }
1284  }
1285 
1287  // Step 3. Create the dofs. This involves obtaining the correct
1288  for ( int i = 1; i <= this->giveNumberOfDofManagers(); ++i ) {
1289  DofManager *dman = this->giveDofManager(i);
1290  //printf("Dofs in node %d (of %d) = %d\n", i, this->giveNumberOfDofManagers(), node_dofs[i-1].size());
1291 
1292  /* do not delete existing DOFs; that may be created during adaptive solution scheme (mesh generator applies DOFs) */
1293  if (0) dman->setNumberOfDofs(0);
1294 
1295  for ( int id: node_dofs [ i - 1 ] ) {
1296  // Find bc and ic if there are any, otherwise zero.
1297  int bcid = dof_bc [ i - 1 ].find(id) != dof_bc [ i - 1 ].end() ? dof_bc [ i - 1 ] [ id ] : 0;
1298  int icid = dof_ic [ i - 1 ].find(id) != dof_ic [ i - 1 ].end() ? dof_ic [ i - 1 ] [ id ] : 0;
1299 
1300  // Determine the doftype:
1301  dofType dtype = DT_master;
1302  const std :: map< int, int > *dmanTypes = dman->giveDofTypeMap();
1303  if ( dmanTypes ) {
1304  std :: map< int, int > :: const_iterator it = dmanTypes->find(id);
1305  if ( it != dmanTypes->end() ) {
1306  dtype = ( dofType ) it->second;
1307  }
1308  }
1309  // Check if active dofs are needed:
1310  if ( bcid > 0 ) {
1311  // What should take precedence here if there is a slave node?
1312  // Right now the active b.c. overrides anything set prior, if necessary.
1313  // This seems like the most suitable choice, but it could possibly be changed.
1314  ActiveBoundaryCondition *active_bc = dynamic_cast< ActiveBoundaryCondition * >( this->giveBc(bcid) );
1315  if ( active_bc && active_bc->requiresActiveDofs() ) {
1316  dtype = DT_active;
1317  }
1318  }
1319 
1320  if ( !dman->isDofTypeCompatible(dtype) ) {
1321  OOFEM_ERROR("Incompatible dof type (%d) in node %d", dtype, i);
1322  }
1323 
1324  // Finally create the new DOF:
1325  //printf("Creating: node %d, id = %d, dofType = %d, bc = %d, ic = %d\n", i, id, dtype, bcid, icid);
1326  if ( !dman->hasDofID((DofIDItem)id) ) {
1327 
1328  Dof *dof = classFactory.createDof(dtype, (DofIDItem)id, dman);
1329  dof->setBcId(bcid); // Note: slave dofs and such will simple ignore this.
1330  dof->setIcId(icid);
1331  // Slave dofs obtain their weights post-initialization, simple slave dofs must have their master node specified.
1332  if ( dtype == DT_simpleSlave ) {
1333  static_cast< SimpleSlaveDof * >(dof)->setMasterDofManagerNum( ( * dman->giveMasterMap() ) [ id ] );
1334  }
1335  dman->appendDof(dof);
1336  }
1337  }
1338  }
1339 
1340  // XFEM manager create additional dofs themselves:
1341  if ( this->hasXfemManager() ) {
1342  xfemManager->createEnrichedDofs();
1343  }
1344 
1345  if ( this->hasContactManager() ) {
1346  contactManager->createContactDofs();
1347  }
1348 }
1349 
1350 
1351 int
1353 // this function transverse tree of all objects and invokes
1354 // checkConsistency on this objects
1355 // currently this function checks noly consistency
1356 // of internal object structures, mainly whether referenced other objects
1357 // are having required support
1358 //
1359 {
1360  int result = 1;
1361 
1362  for ( auto &dman: this->dofManagerList ) {
1363  result &= dman->checkConsistency();
1364  }
1365 
1366  for ( auto &element: this->elementList ) {
1367  result &= element->checkConsistency();
1368  }
1369 
1370  for ( auto &material: this->materialList ) {
1371  result &= material->checkConsistency();
1372  }
1373 
1374  return result;
1375 }
1376 
1377 double
1379 {
1380  double area = 0.0;
1381  for ( auto &element: this->elementList ) {
1382  area += element->computeArea();
1383  }
1384 
1385  return area;
1386 }
1387 
1388 double
1390 {
1391  double volume = 0.0;
1392  for ( auto &element: this->elementList ) {
1393  volume += element->computeVolume();
1394  }
1395 
1396  return volume;
1397 }
1398 
1399 double
1401 {
1402  double volume = 0.0;
1403  for ( auto &element: this->elementList ) {
1404  volume += element->computeVolumeAreaOrLength();
1405  }
1406 
1407  return volume;
1408 }
1409 
1410 int
1412 {
1413  if ( this->engineeringModel->isParallel() ) {
1414  OOFEM_ERROR("Additional dof id's not implemented/tested for parallel problems");
1415  }
1416 
1417  int freeID = this->freeDofID;
1418  this->freeDofID += increment;
1419  return freeID;
1420 }
1421 
1422 void
1424 {
1425  this->freeDofID = MaxDofID;
1426 }
1427 
1430 {
1432 }
1433 
1434 
1435 OutputManager *
1437 {
1438  return outputManager.get();
1439 }
1440 
1441 
1444 {
1445  return topology.get();
1446 }
1447 
1448 
1449 template< typename T >
1450 void save_components(T &list, DataStream &stream, ContextMode mode)
1451 {
1452  if ( !stream.write((int)list.size()) ) {
1454  }
1455  for ( const auto &object: list ) {
1456  if ( ( mode & CM_Definition ) != 0 ) {
1457  if ( stream.write( std :: string( object->giveInputRecordName() ) ) == 0 ) { \
1459  }
1460  }
1461  auto iores = object->saveContext(stream, mode);
1462  if ( iores != CIO_OK ) {
1463  THROW_CIOERR(iores);
1464  }
1465  }
1466 }
1467 
1468 
1469 template< typename T, typename C >
1470 void restore_components(T &list, DataStream &stream, ContextMode mode, const C &creator)
1471 {
1472  int size = 0;
1473  if ( !stream.read(size) ) {
1475  }
1476  if ( mode & CM_Definition ) {
1477  list.clear();
1478  list.resize(size);
1479  }
1480  for ( int i = 1; i <= size; i++ ) {
1481  if ( mode & CM_Definition ) {
1482  std :: string name;
1483  if ( !stream.read(name) ) {
1485  }
1486  auto object = creator(name, i);
1487  list[i-1].reset(object);
1488  }
1489  auto iores = list[i-1]->restoreContext(stream, mode);
1490  if ( iores != CIO_OK ) {
1491  THROW_CIOERR(iores);
1492  }
1493  }
1494 }
1495 
1496 
1499 {
1500  if ( !stream.write(this->giveSerialNumber()) ) {
1502  }
1503 
1504  if ( ( mode & CM_Definition ) ) {
1505  save_components(this->setList, stream, mode);
1506  save_components(this->materialList, stream, mode);
1507  save_components(this->crossSectionList, stream, mode);
1508  save_components(this->icList, stream, mode);
1509  save_components(this->functionList, stream, mode);
1510  save_components(this->nonlocalBarrierList, stream, mode);
1511  }
1512 
1513  save_components(this->dofManagerList, stream, mode);
1514  save_components(this->elementList, stream, mode);
1515  save_components(this->bcList, stream, mode);
1516 
1517  auto ee = this->giveErrorEstimator();
1518  if ( ee ) {
1519  contextIOResultType iores;
1520  if ( ( iores = ee->saveContext(stream, mode) ) != CIO_OK ) {
1521  THROW_CIOERR(iores);
1522  }
1523  }
1524 
1525  return CIO_OK;
1526 }
1527 
1528 
1531 {
1532  bool domainUpdated = false;
1533  int serNum = this->giveSerialNumber();
1534  // restore domain serial number
1535  if ( !stream.read(this->serialNumber) ) {
1537  }
1538 
1539  if ( ( mode & CM_Definition ) ) {
1540  // clear cached data:
1541  mElementPlaceInArray.clear();
1542  mDofManPlaceInArray.clear();
1543 
1545  xfemManager.reset(NULL);
1546 
1547  restore_components(this->setList, stream, mode,
1548  [this] (std::string &x, int i) { return new Set(i, this); });
1549  restore_components(this->materialList, stream, mode,
1550  [this] (std::string &x, int i) { return classFactory.createMaterial(x.c_str(), i, this); });
1551  restore_components(this->crossSectionList, stream, mode,
1552  [this] (std::string &x, int i) { return classFactory.createCrossSection(x.c_str(), i, this); });
1553  restore_components(this->icList, stream, mode,
1554  [this] (std::string &x, int i) { return classFactory.createInitialCondition(x.c_str(), i, this); });
1555  restore_components(this->functionList, stream, mode,
1556  [this] (std::string &x, int i) { return classFactory.createFunction(x.c_str(), i, this); });
1557  restore_components(this->nonlocalBarrierList, stream, mode,
1558  [this] (std::string &x, int i) { return classFactory.createNonlocalBarrier(x.c_str(), i, this); });
1559 
1560  domainUpdated = true;
1561  } else {
1562  if ( serNum != this->giveSerialNumber() ) {
1563  // read corresponding domain
1564  OOFEM_LOG_INFO("restoring domain %d.%d\n", this->number, this->giveSerialNumber());
1565  OOFEMTXTDataReader domainDr(this->engineeringModel->giveDomainFileName(1, this->giveSerialNumber()));
1566  this->clear();
1567 
1568  if ( !this->instanciateYourself(domainDr) ) {
1569  OOFEM_ERROR("domain Instanciation failed");
1570  }
1571 
1572  domainUpdated = true;
1573  }
1574  }
1575 
1576  restore_components(this->dofManagerList, stream, mode,
1577  [this] (std::string &x, int i) { return classFactory.createDofManager(x.c_str(), i, this); });
1578  restore_components(this->elementList, stream, mode,
1579  [this] (std::string &x, int i) { return classFactory.createElement(x.c_str(), i, this); });
1580  restore_components(this->bcList, stream, mode,
1581  [this] (std::string &x, int i) { return classFactory.createBoundaryCondition(x.c_str(), i, this); });
1582 
1583  auto ee = this->giveErrorEstimator();
1584  if ( ee ) {
1585  if ( domainUpdated ) {
1586  ee->setDomain(this);
1587  }
1588  contextIOResultType iores;
1589  if ( ( iores = ee->restoreContext(stream, mode) ) != CIO_OK ) {
1590  THROW_CIOERR(iores);
1591  }
1592  }
1593 
1594  if ( domainUpdated ) {
1595  if ( this->smoother ) {
1596  this->smoother->clear();
1597  }
1598  }
1599 
1600  return CIO_OK;
1601 }
1602 
1603 #ifdef __PARALLEL_MODE
1604 
1607 {
1608  if ( !transactionManager ) {
1609  transactionManager.reset( new DomainTransactionManager(this) );
1610  if ( !transactionManager ) {
1611  OOFEM_ERROR("allocation failed");
1612  }
1613  }
1614 
1615  return transactionManager.get();
1616 }
1617 
1618 
1620 {
1621  if ( tm->dofmanTransactions.empty() && tm->elementTransactions.empty() ) {
1622  return 1;
1623  }
1624 
1625  this->initGlobalDofManMap();
1626  for ( auto &dmanTrans: tm->dofmanTransactions ) {
1627  if ( dmanMap.find(dmanTrans.first) != dmanMap.end() ) {
1628  int lnum = dmanMap [ dmanTrans.first ]->giveNumber();
1629  DofManager *dman = dofManagerList[lnum-1].release();
1630  dmanMap.erase(dmanTrans.first);
1631  delete dman;
1632  }
1633 
1634  if ( dmanTrans.second ) {
1635  dmanMap [ dmanTrans.first ] = ( DofManager * ) dmanTrans.second;
1636  }
1637  }
1638 
1639  this->initGlobalElementMap();
1640  for ( auto elTrans: tm->elementTransactions ) {
1641  int gen = elTrans.first;
1642  if ( elementMap.find(gen) != elementMap.end() ) {
1643  int lnum = elementMap [ gen ]->giveNumber();
1644  Element *elem = elementList[lnum-1].release();
1645  elementMap.erase(gen);
1646  delete elem;
1647  }
1648 
1649  if ( elTrans.second ) {
1650  elementMap [ gen ] = ( Element * ) elTrans.second;
1651  }
1652  }
1653 
1654  /*
1655  * if (tm->transactions.empty()) return 1;
1656  *
1657  * // put existing domain dofman and element records into domain maps
1658  * this->initGlobalDofManMap ();
1659  * this->initGlobalElemMap();
1660  *
1661  * // commit all transactions
1662  * while (!tm->transactions.empty()) {
1663  * DTM_Transaction& t = tm->transactions.front();
1664  * if (t._ttype == DTT_Remove) {
1665  * if (t._ctype == DCT_DofManager) {
1666  * dmanMap.erase (t._num);
1667  * dman = dofManagerList.release (t._num-1);
1668  * delete dman;
1669  * } else if (t._ctype == DCT_Element) {
1670  * elem = elementList.release (t._num-1);
1671  * delete elem;
1672  * } else {
1673  * OOFEM_ERROR("unknown transaction component type");
1674  * }
1675  * } else if (t._ttype == DTT_ADD) {
1676  * if (t._ctype == DCT_DofManager) {
1677  * dmanMap[t._num] = (*DofManager) t._obj;
1678  * } else if (t._ctype == DCT_Element) {
1679  * elemMap[t._num] = (*Element) t._obj;
1680  * } else {
1681  * OOFEM_ERROR("unknown transaction component type");
1682  * }
1683  * } else {
1684  * OOFEM_ERROR("unknown transaction type");
1685  * }
1686  *
1687  * // Pop new transaction
1688  * tm->transactions.pop_front();
1689  * } // while (!tm->transactions.empty()) {
1690  *
1691  */
1692 
1693  this->renumberDofManagers();
1694  this->renumberDofManData(tm);
1695 
1696  this->renumberElements();
1697  this->renumberElementData(tm);
1698 
1700  // initialize new element list
1701  std :: vector< std :: unique_ptr< Element > > elementList_new;
1702  elementList_new.reserve(elementMap.size());
1703  for ( auto &map: elementMap ) {
1704  elementList_new.emplace_back(map.second);
1705  }
1706  for ( auto &el: this->elementList ) {
1707  el.release();
1708  }
1709  this->elementList = std :: move(elementList_new);
1710 
1711  // initialize new dofman list
1712  std :: vector< std :: unique_ptr< DofManager > > dofManagerList_new;
1713  dofManagerList_new.reserve(dmanMap.size());
1714  for ( auto &map: dmanMap ) {
1715  dofManagerList_new.emplace_back(map.second);
1716  }
1717  for ( auto &dman: this->dofManagerList ) {
1718  dman.release();
1719  }
1720  this->dofManagerList = std :: move(dofManagerList_new);
1721 
1724 
1725  tm->dofmanTransactions.clear();
1726  tm->elementTransactions.clear();
1727 
1728  this->giveConnectivityTable()->reset();
1729  this->giveSpatialLocalizer()->init(true);
1730  return 1;
1731 }
1732 
1733 
1734 void
1736 {
1737  /*
1738  * Renumber here the master node number for rigid and hanging dofs, etc;
1739  * existing local nodes need mapping from old_local to new numbering,
1740  * but received nodes need mapping from global to new numbering
1741  *
1742  * -> we need to keep the list of received nodes! (now they are only introduced into globally indexed dmanMap!);
1743  */
1744  if ( forceinit || !dmanMapInitialized ) {
1745  dmanMap.clear();
1746 
1747  for ( auto &dman: dofManagerList ) {
1748  int key = dman->giveGlobalNumber();
1749  dmanMap[key] = dman.get();
1750  }
1751  }
1752 }
1753 
1754 
1755 void
1757 {
1758  if ( forceinit || !elementMapInitialized ) {
1759  elementMap.clear();
1760 
1761  for ( auto &elem: elementList ) {
1762  int key = elem->giveGlobalNumber();
1763  elementMap[key] = elem.get();
1764  }
1765  }
1766 }
1767 
1768 
1769 void
1771 {
1774 
1775 
1776  for ( auto &map : dmanMap ) {
1777  if ( tm->dofmanTransactions.find(map.first) != tm->dofmanTransactions.end() ) {
1778  // received dof manager -> we map global numbers to new local number
1779  map.second->updateLocalNumbering(domainGToLFunctor); // g_to_l
1780  } else {
1781  // existing dof manager -> we map old local number to new local number
1782  map.second->updateLocalNumbering(domainLToLFunctor); // l_to_l
1783  }
1784  }
1785 }
1786 
1787 
1788 void
1790 {
1793 
1794  for ( auto &map : elementMap ) {
1795  if ( tm->elementTransactions.find(map.first) != tm->elementTransactions.end() ) {
1796  // received dof manager -> we map global numbers to new local number
1797  map.second->updateLocalNumbering(domainGToLFunctor); // g_to_l
1798  } else {
1799  // existing dof manager -> we map old local number to new local number
1800  map.second->updateLocalNumbering(domainLToLFunctor); // l_to_l
1801  }
1802  }
1803 }
1804 
1805 
1806 void
1808 {
1809  int _locnum = 1;
1810  for ( auto &map: dmanMap ) {
1811  map.second->setNumber(_locnum++);
1812  }
1813 }
1814 
1815 
1816 void
1818 {
1819  int _locnum = 1;
1820  for ( auto &map: elementMap ) {
1821  map.second->setNumber(_locnum++);
1822  }
1823 }
1824 
1825 
1826 int
1828 {
1829  if ( scheme == ERS_DofManager ) {
1830  auto dm = this->giveDofManager(num);
1831  if ( dm ) {
1832  return dm->giveNumber();
1833  } else {
1834  OOFEM_ERROR("dofman %d moved to remote partition, updated number not available", num);
1835  }
1836  } else {
1837  OOFEM_ERROR("unsuported renumbering scheme");
1838  }
1839 
1840  return 0;
1841 }
1842 
1843 
1844 int
1846 {
1847  if ( scheme == ERS_DofManager ) {
1848  auto dm = dmanMap [ num ];
1849  if ( dm ) {
1850  return dm->giveNumber();
1851  } else {
1852  OOFEM_ERROR("dofman [%d] not available on local partition, updated number not available", num);
1853  return 0;
1854  }
1855  } else {
1856  OOFEM_ERROR("unsuported renumbering scheme");
1857  }
1858 
1859  return 0;
1860 }
1861 
1862 
1863 int
1865 {
1866  if ( dmanMap.find(_globnum) != dmanMap.end() ) {
1867  // dofman is already available -> update only
1868  return ( dmanMap [ _globnum ]->giveNumber() );
1869  } else {
1870  return 0;
1871  }
1872 }
1873 
1874 
1875 int
1877 {
1878  if ( elementMap.find(_globnum) != elementMap.end() ) {
1879  // element is already available -> update only
1880  return ( elementMap [ _globnum ]->giveNumber() );
1881  } else {
1882  return 0;
1883  }
1884 }
1885 
1886 #endif
1887 
1889 {
1890  mElementPlaceInArray.clear();
1891 
1892  int nelem = giveNumberOfElements();
1893 
1894  for ( int i = 1; i <= nelem; i++ ) {
1895  Element *elem = this->giveElement(i);
1896  mElementPlaceInArray[ elem->giveGlobalNumber() ] = i;
1897  }
1898 }
1899 
1901 {
1902  mDofManPlaceInArray.clear();
1903 
1904  int ndman = giveNumberOfDofManagers();
1905 
1906  for ( int i = 1; i <= ndman; i++ ) {
1907  DofManager *dMan = this->giveDofManager(i);
1908  mDofManPlaceInArray[ dMan->giveGlobalNumber() ] = i;
1909  }
1910 }
1911 
1913 {
1914  mMapMaterialNum2El.clear();
1915 
1916  int nelem = giveNumberOfElements();
1917 
1918  for ( int i = 1; i <= nelem; i++ ) {
1919  Element *elem = this->giveElement(i);
1920  int matNum = elem->giveMaterialNumber();
1921  mMapMaterialNum2El[ matNum ].followedBy(i);
1922  }
1923 }
1924 
1925 } // end namespace oofem
TopologyDescription * createTopology(const char *name, Domain *domain)
Creates new instance of topology description corresponding to given keyword.
Definition: classfactory.C:269
The base class for all spatial localizers.
std::map< int, int > * giveMasterMap()
Returns map from DofIDItem to dofType.
Definition: dofmanager.h:402
Material * createMaterial(const char *name, int num, Domain *domain)
Creates new instance of material corresponding to given keyword.
Definition: classfactory.C:199
#define _IFT_Domain_nfunct
Definition: domain.h:63
#define _IFT_Domain_nic
Definition: domain.h:62
This class keeps track of applied boundary conditions on individual entities.
Definition: bctracker.h:53
const IntArray & giveDofIDs()
Gives the set number which initial condition is applied to.
void setCrossSection(int i, CrossSection *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:456
void resizeDofManagers(int _newSize)
Resizes the internal data structure to accommodate space for _newSize dofManagers.
Definition: domain.C:444
Function * createFunction(const char *name, int num, Domain *domain)
Creates new instance of load time function corresponding to given keyword.
Definition: classfactory.C:219
std::vector< std::unique_ptr< GeneralBoundaryCondition > > bcList
Boundary condition list.
Definition: domain.h:127
The implementation of spatial localizer based on octree technique.
void setBoundaryCondition(int i, GeneralBoundaryCondition *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:459
virtual bool requiresActiveDofs()
Checks to see if active boundary condition requires special DOFs.
Definition: activebc.h:152
Abstract base class for all nonlocal barriers.
int nsd
Number of spatial dimensions.
Definition: domain.h:171
TopologyDescription * giveTopology()
Returns receiver&#39;s associated topology description.
Definition: domain.C:1443
Class implementing general initial condition.
double giveVolume()
Gives the sum of the volume of all elements.
Definition: domain.C:1389
int giveGlobalNumber() const
Definition: dofmanager.h:501
void resizeSets(int _newSize)
Resizes the internal data structure to accommodate space for _newSize sets.
Definition: domain.C:452
InitialCondition * giveIc(int n)
Service for accessing particular domain ic.
Definition: domain.C:255
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition: domain.h:432
std::map< int, int > * giveBcMap()
Returns map from DofIDItem to dofType.
Definition: dofmanager.h:408
void reset()
reset receiver to an initial state (will force table update, when needed next time) ...
int giveSetNumber() const
Definition: crosssection.h:129
bool hasFractureManager()
Definition: domain.C:410
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
Definition: domain.h:440
void setNonlocalBarrier(int i, NonlocalBarrier *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:458
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
NonlocalBarrier * giveNonlocalBarrier(int n)
Service for accessing particular domain nonlocal barrier representation.
Definition: domain.C:351
std::unique_ptr< SpatialLocalizer > spatialLocalizer
Spatial Localizer.
Definition: domain.h:163
NonlocalBarrier * createNonlocalBarrier(const char *name, int num, Domain *domain)
Creates new instance of nonlocal barrier corresponding to given keyword.
Definition: classfactory.C:229
int giveGlobalNumber() const
Definition: element.h:1059
contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the domain state from output stream.
Definition: domain.C:1530
void postInitialize()
Performs post-initialization for all the domain contents (which is called after initializeFrom).
Definition: domain.C:960
virtual const IntArray & giveDofIDs() const
Array with default dofs which b.c.
#define _IFT_Domain_nxfemman
Definition: domain.h:67
bool giveSuppressOutput() const
Definition: engngm.h:346
int commitTransactions(DomainTransactionManager *tm)
Commits transactions recorded in transaction manager.
Definition: domain.C:1619
void initGlobalDofManMap(bool forceinit=false)
Initializes global dof man map according to domain dofman list.
Definition: domain.C:1735
BCTracker * giveBCTracker()
Definition: domain.C:427
int giveNumberOfInitialConditions() const
Returns number of initial conditions in domain.
Definition: domain.h:442
void resizeFunctions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize load time functions.
Definition: domain.C:451
ConnectivityTable * giveConnectivityTable()
Returns receiver&#39;s associated connectivity table.
Definition: domain.C:1170
std::unique_ptr< XfemManager > xfemManager
XFEM Manager.
Definition: domain.h:189
bool isAxisymmetric()
Returns true of axisymmetry is in effect.
Definition: domain.C:1074
void renumberElementData(DomainTransactionManager *tm)
Definition: domain.C:1789
std::unique_ptr< FractureManager > fracManager
Fracture Manager.
Definition: domain.h:192
ContactManager * createContactManager(const char *name, Domain *domain)
Definition: classfactory.C:385
EngngModel * giveEngngModel()
Returns engineering model to which receiver is associated.
Definition: domain.C:433
int elementGlobal2Local(int _globnum)
Definition: domain.C:1876
dofType
Dof Type, determines the type of DOF created.
Definition: doftype.h:48
const IntArray & giveDefaultNodeDofIDArry()
Returns default DofID array which defines physical meaning of particular DOFs.
Definition: domain.C:1004
virtual bool isDofTypeCompatible(dofType type) const
Returns true if dof of given type is allowed to be associated to receiver.
Definition: dofmanager.h:451
virtual bool hasField(InputFieldType id)=0
Returns true if record contains field identified by idString keyword.
#define _IFT_Domain_topology
Definition: domain.h:66
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
Abstract base class for all finite elements.
Definition: element.h:145
DofManager * createDofManager(const char *name, int num, Domain *domain)
Creates new instance of Dof manager corresponding to given keyword.
Definition: classfactory.C:169
std::vector< std::unique_ptr< Set > > setList
Set list.
Definition: domain.h:133
#define _IFT_Domain_nset
Definition: domain.h:64
Base class for dof managers.
Definition: dofmanager.h:113
General IO error.
contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the domain state to output stream.
Definition: domain.C:1498
CrossSection * createCrossSection(const char *name, int num, Domain *domain)
Creates new instance of cross section corresponding to given keyword.
Definition: classfactory.C:189
This class manages the fracture mechanics part.
FractureManager * giveFractureManager()
Definition: domain.C:416
Represents output manager.
Definition: outputmanager.h:81
int giveNumber()
Returns domain number.
Definition: domain.h:266
NodalRecoveryModel * giveSmoother()
Returns the actual Smoother associated to receiver.
Definition: domain.C:1141
void resizeElements(int _newSize)
Resizes the internal data structure to accommodate space for _newSize elements.
Definition: domain.C:445
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
GeneralBoundaryCondition * createBoundaryCondition(const char *name, int num, Domain *domain)
Creates new instance of boundary condition corresponding to given keyword.
Definition: classfactory.C:179
void save_components(T &list, DataStream &stream, ContextMode mode)
Definition: domain.C:1450
std::unique_ptr< NodalRecoveryModel > smoother
nodal recovery object associated to receiver.
Definition: domain.h:174
int giveNumberOfSpatialDimensions()
Returns number of spatial dimensions.
Definition: domain.C:1067
std::vector< std::unique_ptr< NonlocalBarrier > > nonlocalBarrierList
Nonlocal barrier list.
Definition: domain.h:135
#define _IFT_Domain_type
This is trouble, will not work with dynamic input record.
Definition: domain.h:56
std::map< int, DofManager * > dofmanTransactions
void renumberDofManData(DomainTransactionManager *tm)
Definition: domain.C:1770
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.
void setSmoother(NodalRecoveryModel *newSmoother, bool destroyOld=true)
Sets the given smoother as an actual smoother for receiver.
Definition: domain.C:1148
XfemManager * giveXfemManager()
Definition: domain.C:375
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
void restore_components(T &list, DataStream &stream, ContextMode mode, const C &creator)
Definition: domain.C:1470
IntArray defaultNodeDofIDArry
Default dofs for a node (depends on the domain type).
Definition: domain.h:138
void BuildMaterialToElementMap()
Construct map from a material number to elements with the given material number.
Definition: domain.C:1912
void BuildDofManPlaceInArrayMap()
Construct map from a dofman&#39;s global number to its place the dofman array.
Definition: domain.C:1900
#define _IFT_Domain_nfracman
Definition: domain.h:70
virtual void setBcId(int bcId)
Overwrites the boundary condition id (0-inactive BC), intended for specific purposes such as coupling...
Definition: dof.h:382
GeneralBoundaryCondition * giveBc(int n)
Service for accessing particular domain bc.
Definition: domain.C:243
Base abstract class representing cross section in finite element mesh.
Definition: crosssection.h:107
std::vector< std::unique_ptr< Material > > materialList
Material list.
Definition: domain.h:123
InitialCondition * createInitialCondition(const char *name, int num, Domain *d)
Creates new instance of Initial Condition corresponding to given type.
Definition: classfactory.C:140
bool axisymm
Definition: domain.h:172
ErrorEstimator * giveErrorEstimator()
Returns Error Estimator associated to receiver.
Definition: domain.C:1429
#define VERBOSE_PRINT0(str, number)
Definition: verbose.h:56
void BuildElementPlaceInArrayMap()
Construct map from an element&#39;s global number to its place the element array.
Definition: domain.C:1888
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
void setMaterial(int i, Material *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:457
ElementSide * giveSide(int n)
Service for accessing particular domain element side.
Definition: domain.C:293
CrossSection * giveCrossSection(int n)
Service for accessing particular domain cross section model.
Definition: domain.C:339
std::unique_ptr< TopologyDescription > topology
Topology description.
Definition: domain.h:219
std::unique_ptr< OutputManager > outputManager
Output manager, allowing to filter the produced output.
Definition: domain.h:165
const char * __domainTypeToString(domainType _value)
Definition: cltypes.C:310
std::map< int, DofManager * > dmanMap
Global dof manager map (index is global of man number).
Definition: domain.h:233
Class representing domain transaction manager.
Domain(int n, int serNum, EngngModel *e)
Constructor.
Definition: domain.C:93
EntityRenumberingScheme
Type allowing to specify the required renumbering scheme; One can have a renumbering scheme for dof m...
std::map< int, int > * giveDofTypeMap()
Returns map from DofIDItem to dofType.
Definition: dofmanager.h:396
int LB_giveUpdatedLocalNumber(int oldnum, EntityRenumberingScheme scheme)
Return updated local entity number after load balancing.
Definition: domain.C:1827
XfemManager * createXfemManager(const char *name, Domain *domain)
Definition: classfactory.C:351
int giveSetNumber()
Gives the set number which boundary condition is applied to.
#define _IFT_Domain_nmat
Definition: domain.h:59
#define _IFT_Domain_nelem
Definition: domain.h:58
Class implementing Dirichlet boundary condition on DOF (primary boundary condition).
#define OOFEM_LOG_INFO(...)
Definition: logger.h:127
DomainTransactionManager * giveTransactionManager()
Returns domain transaction manager.
Definition: domain.C:1606
Material * giveMaterial(int n)
Service for accessing particular domain material model.
Definition: domain.C:281
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
void setXfemManager(XfemManager *ipXfemManager)
Temporary function, sets xfemManager.
Definition: domain.C:463
virtual IRResultType giveRecordKeywordField(std::string &answer, int &value)=0
Reads the record id field (type of record) and its corresponding number.
virtual bool peakNext(const std::string &keyword)
Peak in advance into the record list.
Definition: datareader.h:84
#define OOFEM_ERROR(...)
Definition: error.h:61
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
std::vector< std::unique_ptr< DofManager > > dofManagerList
Dof manager list.
Definition: domain.h:121
#define _IFT_Domain_ndofman
Definition: domain.h:57
Set of elements, boundaries, edges and/or nodes.
Definition: set.h:66
SpatialLocalizer * giveSpatialLocalizer()
Returns receiver&#39;s associated spatial localizer.
Definition: domain.C:1184
#define _IFT_Domain_axisymmetric
Definition: domain.h:71
std::vector< std::unique_ptr< Function > > functionList
Load time function list.
Definition: domain.h:131
void renumberDofManagers()
Assigns new local number (stored as dofmanager number, so it can be requested) to all dofManagers ava...
Definition: domain.C:1807
#define IR_GIVE_RECORD_KEYWORD_FIELD(__ir, __name, __value)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:86
Renumbering functor based on provided maps.
DofManager * giveGlobalDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:326
int giveNumberOfCrossSectionModels() const
Returns number of cross section models in domain.
Definition: domain.h:438
Class representing connectivity table.
std::unique_ptr< DomainTransactionManager > transactionManager
Transaction manager.
Definition: domain.h:231
double giveSize()
Gives the sum of the volume or area of all elements.
Definition: domain.C:1400
Set * giveSet(int n)
Service for accessing particular domain set.
Definition: domain.C:363
virtual void setCrossSection(int csIndx)
Sets the cross section model of receiver.
Definition: element.h:653
void renumberElements()
Definition: domain.C:1817
Abstract base class for all active boundary conditions.
Definition: activebc.h:63
Abstract base class for all boundary conditions of problem.
Abstract base class for all material models.
Definition: material.h:95
void setFunction(int i, Function *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:461
#define _IFT_Domain_ncrosssect
Definition: domain.h:60
bool elementMapInitialized
dmanMap init flag.
Definition: domain.h:239
double giveArea()
Gives the sum of the area of all elements.
Definition: domain.C:1378
const IntArray & giveElementsWithMaterialNum(int iMaterialNum) const
Returns array with indices of elements that have a given material number.
Definition: domain.C:209
BCTracker bcTracker
BC tracker (keeps track of BCs applied wia sets to components)
Definition: domain.h:198
int serialNumber
Domain serial (version) number. Used for domain version identification during Adaptive computations...
Definition: domain.h:169
This class manages all the contacts in a domain.
int giveDofManPlaceInArray(int iGlobalDofManNum) const
Returns the array index of the dofman with global number iGlobalDofManNum, so that it can be fetched ...
Definition: domain.C:196
int checkConsistency()
Checks internal consistency of domain and all domain components.
Definition: domain.C:1352
void clearElements()
Clear all elements.
Definition: domain.C:466
void appendDof(Dof *dof)
Adds the given Dof into the receiver.
Definition: dofmanager.C:134
Function * giveFunction(int n)
Service for accessing particular domain load time function.
Definition: domain.C:268
The base class for all error estimation or error indicator algorithms.
virtual InputRecord * giveInputRecord(InputRecordType irType, int recordId)=0
Returns input record corresponding to given InputRecordType value and its record_id.
bool hasXfemManager()
Definition: domain.C:386
Element * giveGlobalElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:171
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
int giveNextFreeDofID(int increment=1)
Gives the next free dof ID.
Definition: domain.C:1411
std::map< int, Element * > elementTransactions
std::string giveDomainFileName(int domainNum, int domainSerNum) const
Returns the filename for the given domain (used by adaptivity and restore)
Definition: engngm.C:1701
void setNumberOfDofs(int _ndofs)
Sets number of dofs of the receiver; Deallocates existing DOFs; Resizes the dofArray accordingly...
Definition: dofmanager.C:286
int number
Domain number.
Definition: domain.h:167
Dof * createDof(dofType type, DofIDItem dofid, DofManager *dman)
Creates new instance of DOF corresponding to given keyword.
Definition: classfactory.C:115
void setInitialCondition(int i, InitialCondition *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:460
int giveSerialNumber()
Returns domain serial (version) number.
Definition: domain.h:270
int dofmanGlobal2Local(int _globnum)
Definition: domain.C:1864
virtual int init(bool force=false)
Initialize receiver data structure if not done previously If force is set to true, the initialization is enforced (useful if domain geometry has changed)
bool hasDofID(DofIDItem id) const
Checks if receiver contains dof with given ID.
Definition: dofmanager.C:166
void resizeMaterials(int _newSize)
Resizes the internal data structure to accommodate space for _newSize materials.
Definition: domain.C:447
std::vector< std::unique_ptr< CrossSection > > crossSectionList
Cross section list.
Definition: domain.h:125
Abstract base class representing a function with vector input and output.
Definition: function.h:88
void clearBoundaryConditions()
Clear all boundary conditions.
Definition: domain.C:465
This class manages the xfem part.
Definition: xfemmanager.h:109
void resizeNonlocalBarriers(int _newSize)
Resizes the internal data structure to accommodate space for _newSize nonlocal barriers.
Definition: domain.C:448
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
std::vector< std::unique_ptr< Element > > elementList
Element list.
Definition: domain.h:119
#define _IFT_Domain_ncontactman
Definition: domain.h:68
std::unordered_map< int, int > mDofManPlaceInArray
Map from a dofmans&#39;s global number to its place in the dofman array.
Definition: domain.h:210
ContactManager * giveContactManager()
Definition: domain.C:393
std::string mDomainType
Definition: domain.h:176
int LB_giveUpdatedGlobalNumber(int oldnum, EntityRenumberingScheme scheme)
Return updated local entity number after load balancing.
Definition: domain.C:1845
void setTopology(TopologyDescription *topo, bool destroyOld=true)
Sets receiver&#39;s associated topology description.
Definition: domain.C:1159
void resolveDomainDofsDefaults(const char *)
Definition: domain.C:1081
Class representing "slave" degree of freedom.
void setDofManager(int i, DofManager *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:454
int instanciateYourself(DataReader &dr)
Reads receiver description from input stream and creates corresponding components accordingly...
Definition: domain.C:468
virtual void setIcId(int icId)
Overwrites the initial condition id (0-inactive IC)
Definition: dof.h:384
EngngModel * engineeringModel
Associated Engineering model.
Definition: domain.h:152
Class representing the general Input Record.
Definition: inputrecord.h:101
Class implementing element side having some DOFs in finite element mesh.
Definition: elementside.h:60
bool dmanMapInitialized
dmanMap init flag.
Definition: domain.h:235
void resetFreeDofID()
Resets the free dof IDs.
Definition: domain.C:1423
#define _IFT_Domain_nbarrier
Definition: domain.h:65
std::unordered_map< int, int > mElementPlaceInArray
Map from an element&#39;s global number to its place in the element array.
Definition: domain.h:204
void createDofs()
Automatically detects necessary nodal dofs and creates them accordingly.
Definition: domain.C:1200
#define _IFT_Domain_nbc
Definition: domain.h:61
void setElement(int i, Element *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:455
Abstract class for topology description.
domainType dType
Domain type.
Definition: domain.h:147
ClassFactory & classFactory
Definition: classfactory.C:59
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
std::unique_ptr< ContactManager > contactManager
Contact Manager.
Definition: domain.h:195
#define CM_Definition
Definition: contextmode.h:47
int giveSetNumber()
Gives the set number which initial condition is applied to.
int giveElementPlaceInArray(int iGlobalElNum) const
Returns the array index of the element with global number iGlobalElNum, so that it can be fetched by ...
Definition: domain.C:183
virtual ErrorEstimator * giveDomainErrorEstimator(int n)
Service for accessing ErrorEstimator corresponding to particular domain.
Definition: engngm.h:349
OutputManager * giveOutputManager()
Returns domain output manager.
Definition: domain.C:1436
bool hasContactManager()
Definition: domain.C:404
std::vector< std::unique_ptr< InitialCondition > > icList
Initial condition list.
Definition: domain.h:129
int giveMaterialNumber() const
Definition: element.h:640
void resizeCrossSectionModels(int _newSize)
Resizes the internal data structure to accommodate space for _newSize cross section models...
Definition: domain.C:446
Load is base abstract class for all loads.
Definition: load.h:61
void resizeBoundaryConditions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize boundary conditions.
Definition: domain.C:449
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
std::string errorInfo(const char *func) const
Returns string for prepending output (used by error reporting macros).
Definition: domain.C:997
int giveSize() const
Definition: intarray.h:203
Class representing the implementation of plain text date reader.
std::map< int, int > * giveIcMap()
Returns map from DofIDItem to initial condition.
Definition: dofmanager.h:414
the oofem namespace is to define a context or scope in which all oofem names are defined.
void resizeInitialConditions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize initial conditions.
Definition: domain.C:450
StateCounterType nonlocalUpdateStateCounter
For nonlocal models of integral type it is necessary, mainly due to resulting efficiency, to compute variable(s) which are nonlocally averaged in advance, before average process begins.
Definition: domain.h:187
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
void clear()
Clear receiver.
Definition: domain.C:124
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
DofManager * giveDofManager(int n)
Service for accessing particular domain dof manager.
Definition: domain.C:314
The base class for all recovery models, which perform nodal averaging or projection processes for int...
Element * createElement(const char *name, int num, Domain *domain)
Creates new instance of element corresponding to given keyword.
Definition: classfactory.C:159
std::unordered_map< int, IntArray > mMapMaterialNum2El
Map from material number to elements that have the given material number.
Definition: domain.h:216
Load * giveLoad(int n)
Service for accessing particular domain load.
Definition: domain.C:222
~Domain()
Destructor.
Definition: domain.C:121
std::unique_ptr< ConnectivityTable > connectivityTable
Domain connectivity table.
Definition: domain.h:158
void setSet(int i, Set *obj)
Sets i-th component. The component will be further managed and maintained by domain object...
Definition: domain.C:462
int freeDofID
Keeps track of next free dof ID (for special Lagrange multipliers, XFEM and such) ...
Definition: domain.h:223
void initGlobalElementMap(bool forceinit=false)
Definition: domain.C:1756
std::map< int, Element * > elementMap
Global element map (index is global of man number).
Definition: domain.h:237
#define _IFT_Domain_numberOfSpatialDimensions
[in,optional] Specifies how many spatial dimensions the domain has.
Definition: domain.h:69

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