OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
49namespace oofem {
51
52GPInitModule :: GPInitModule(int n, EngngModel *e) : InitModule(n, e)
53{ }
54
55
56GPInitModule :: ~GPInitModule()
57{ }
58
59
60void
61GPInitModule :: initializeFrom(InputRecord &ir)
62{
63 InitModule :: initializeFrom(ir);
64}
65
66
67void
68GPInitModule :: doInit()
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 if ( fscanf(initStream, "%d %d", & ie, & ig) != 2 ) {
86 OOFEM_ERROR("initStream reading error");
87 }
88
89 // check whether the element and GP number agree
90 assert(ielem == ie);
91 assert( gp->giveNumber() == ig );
92 // read coordinates
93 if ( fscanf(initStream, "%d", & nc) != 1 ) {
94 OOFEM_ERROR("initStream reading error");
95 }
96
97 assert(nc >= 0 && nc <= 3);
98 for ( ic = 0; ic < nc; ic++ ) {
99 if ( fscanf(initStream, "%lg", & coords [ ic ]) != 1 ) {
100 OOFEM_ERROR("initStream reading error");
101 }
102 }
103
104 if ( fscanf(initStream, "%d", & nv) != 1 ) {
105 OOFEM_ERROR("initStream reading error");
106 }
107
108 assert(nv >= 0);
109 for ( iv = 1; iv <= nv; iv++ ) {
110 if ( fscanf(initStream, "%d %d", & vt, & varsize) != 2 ) {
111 OOFEM_ERROR("initStream reading error");
112 }
113
114 vartype = ( InternalStateType ) vt;
115 value.resize(varsize);
116 for ( ic = 1; ic <= varsize; ic++ ) {
117 if ( fscanf( initStream, "%lg", & value.at(ic) ) != 1 ) {
118 OOFEM_ERROR("initStream reading error");
119 }
120 }
121
122 mat->setIPValue(value, gp, vartype);
123 }
124 // restore consistency (compute dependent internal variables)
125 mat->restoreConsistency(gp);
126
127 }
128 }
129
130 fclose(initStream);
131}
132} // namespace oofem
#define REGISTER_InitModule(class)
virtual Material * giveMaterial(IntegrationPoint *ip) const =0
hidden by virtual oofem::Material* TransportCrossSection::giveMaterial() const
int giveNumberOfElements() const
Returns number of elements in domain.
Definition domain.h:463
Element * giveElement(int n)
Definition domain.C:165
CrossSection * giveCrossSection()
Definition element.C:534
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Definition element.h:886
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
EngngModel * emodel
Problem pointer.
Definition initmodule.h:67
FILE * initStream
Initialization file.
Definition initmodule.h:69
virtual int setIPValue(const FloatArray &value, GaussPoint *gp, InternalStateType type)
Definition material.h:214
virtual void restoreConsistency(GaussPoint *gp)
Definition material.h:262
#define OOFEM_ERROR(...)
Definition error.h:79

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011