OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
gpinitmodule.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 // Initialization module reading data related to Gauss points from a specified file
36 
37 #include "gpinitmodule.h"
38 #include "element.h"
39 #include "integrationrule.h"
40 #include "material.h"
41 #include "floatarray.h"
42 #include "domain.h"
43 #include "engngm.h"
44 #include "classfactory.h"
45 #include "gausspoint.h"
46 #include "crosssection.h"
47 #include <cassert>
48 
49 namespace oofem {
51 
52 GPInitModule :: GPInitModule(int n, EngngModel *e) : InitModule(n, e)
53 { }
54 
55 
57 { }
58 
59 
62 {
64 }
65 
66 
67 void
69 {
70  int ielem, nelem, ie, ig, nv, iv, nc, ic, varsize, vt;
71  InternalStateType vartype;
72  FloatArray value;
73 
74  double coords [ 3 ];
75 
76  Domain *d = emodel->giveDomain(1);
77  nelem = d->giveNumberOfElements();
78 
79  // loop over elements
80  for ( ielem = 1; ielem <= nelem; ielem++ ) {
81  Element *elem = d->giveElement(ielem);
82  // loop over Gauss points
83  for ( auto &gp: *elem->giveDefaultIntegrationRulePtr() ) {
84  Material *mat = elem->giveCrossSection()->giveMaterial(gp);
85  MaterialStatus *status = static_cast< MaterialStatus * >( gp->giveMaterialStatus() );
86  if ( fscanf(initStream, "%d %d", & ie, & ig) != 2 ) {
87  OOFEM_ERROR("initStream reading error");
88  }
89 
90  // check whether the element and GP number agree
91  assert(ielem == ie);
92  assert( gp->giveNumber() == ig );
93  // read coordinates
94  if ( fscanf(initStream, "%d", & nc) != 1 ) {
95  OOFEM_ERROR("initStream reading error");
96  }
97 
98  assert(nc >= 0 && nc <= 3);
99  for ( ic = 0; ic < nc; ic++ ) {
100  if ( fscanf(initStream, "%lg", & coords [ ic ]) != 1 ) {
101  OOFEM_ERROR("initStream reading error");
102  }
103  }
104 
105  if ( fscanf(initStream, "%d", & nv) != 1 ) {
106  OOFEM_ERROR("initStream reading error");
107  }
108 
109  assert(nv >= 0);
110  for ( iv = 1; iv <= nv; iv++ ) {
111  if ( fscanf(initStream, "%d %d", & vt, & varsize) != 2 ) {
112  OOFEM_ERROR("initStream reading error");
113  }
114 
115  vartype = ( InternalStateType ) vt;
116  value.resize(varsize);
117  for ( ic = 1; ic <= varsize; ic++ ) {
118  if ( fscanf( initStream, "%lg", & value.at(ic) ) != 1 ) {
119  OOFEM_ERROR("initStream reading error");
120  }
121  }
122 
123  mat->setIPValue(value, gp, vartype);
124  }
125  // restore consistency (compute dependent internal variables)
126  status->restoreConsistency();
127 
128  }
129  }
130 
131  fclose(initStream);
132 }
133 } // namespace oofem
CrossSection * giveCrossSection()
Definition: element.C:495
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
virtual int setIPValue(const FloatArray &value, GaussPoint *gp, InternalStateType type)
Sets the value of a certain variable at a given integration point to the given value.
Definition: material.h:200
Represents GP (Gauss point) initialization module.
Definition: gpinitmodule.h:50
Class and object Domain.
Definition: domain.h:115
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
virtual IRResultType initializeFrom(InputRecord *ir)=0
Initializes receiver according to object description stored in input record.
Definition: initmodule.C:51
virtual void restoreConsistency()
Restores consistency of the status, i.e., computes or corrects the values of certain status variables...
Definition: matstatus.h:138
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
Represents init module - a base class for all init modules.
Definition: initmodule.h:61
Abstract base class for all finite elements.
Definition: element.h:145
FILE * initStream
Initialization file.
Definition: initmodule.h:69
int giveNumberOfElements() const
Returns number of elements in domain.
Definition: domain.h:434
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: gpinitmodule.C:61
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
#define OOFEM_ERROR(...)
Definition: error.h:61
Abstract base class for all material models.
Definition: material.h:95
REGISTER_InitModule(GPInitModule)
Definition: gpinitmodule.C:50
Abstract base class representing a material status information.
Definition: matstatus.h:84
Class representing vector of real numbers.
Definition: floatarray.h:82
EngngModel * emodel
Problem pointer.
Definition: initmodule.h:67
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
virtual ~GPInitModule()
Destructor.
Definition: gpinitmodule.C:56
virtual void doInit()
Reads the input. Abstract service.
Definition: gpinitmodule.C:68
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631
virtual Material * giveMaterial(IntegrationPoint *ip)=0
Returns the material associated with the GP.

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