OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
problemsequence.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 "problemsequence.h"
36 #include "inputrecord.h"
37 #include "classfactory.h"
38 #include "util.h"
39 #include "inputrecord.h"
40 #include "datastream.h"
41 #include "oofemtxtdatareader.h"
42 
43 #include <memory>
44 
45 namespace oofem {
46 
48 
49 ProblemSequence :: ProblemSequence(int i, EngngModel *master): EngngModel(i, master) {}
50 
52 
53 
55 {
56  for ( auto &emodel : emodelList ) {
57  emodel->solveYourself();
59  // Options:
60  // 1. Use initial conditions (for both primary and internal fields!)
61  // 2. Copy domains over to the subsequent analysis
62  // 2 might be easier, but 1 has advantages outside of this type of analysis.
63  }
64 }
65 
66 
67 int ProblemSequence :: instanciateYourself(DataReader &dr, InputRecord *ir, const char *outFileName, const char *desc)
68 {
69  int result = EngngModel :: instanciateYourself(dr, ir, dataOutputFileName.c_str(), desc);
70  ir->finish();
71 
72  for ( auto &s : inputStreamNames ) {
73  OOFEMTXTDataReader dr( inputStreamNames [ i - 1 ] );
74  std :: unique_ptr< EngngModel >prob( InstanciateProblem(dr, this->pMode, this->contextOutputMode, NULL) );
75  emodelList.emplace_back(std :: move(prob));
76  if ( prob ) {
77  return 0;
78  }
79  }
80 
81  return result;
82 }
83 
84 
86 {
89  return ret;
90 }
91 
92 
94 {
95  int ret = 1;
96  for (auto &emodel : emodelList) {
97  ret *= emodel->checkConsistency();
98  }
99  return ret;
100 }
101 
102 
104 {
106 
107  stream.write(activeModel);
108 
109  for (auto &emodel : emodelList) {
110  emodel->saveContext(stream, mode);
111  }
112  return ret;
113 }
114 
115 
117 {
119 
120  stream.read(activeModel);
121 
122  for (auto &emodel : emodelList) {
123  emodel->restoreContext(stream, mode);
124  }
125  return ret;
126 }
127 
128 
129 #ifdef __OOFEG
133 
134 #endif
135 
136 }
virtual void solveYourself()
Starts solution process.
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
int activeModel
Keeps track of the active model in the analysis sequence.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
virtual int instanciateYourself(DataReader &dr, InputRecord *ir, const char *outFileName, const char *desc)
Initializes whole problem according to its description stored in inputStream.
std::vector< std::string > inputStreamNames
virtual void drawNodes(oofegGraphicContext &gc)
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual void drawYourself(oofegGraphicContext &gc)
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
Class representing the abstraction for input data source.
Definition: datareader.h:50
REGISTER_EngngModel(ProblemSequence)
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
problemMode pMode
Domain mode.
Definition: engngm.h:255
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
EngngModel * InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
Instanciates the new problem.
Definition: util.C:45
Meta-engineering problem used to solve a sequence off different problems, all using the same domain...
#define _IFT_ProblemSequence_engineeringModels
virtual int checkProblemConsistency()
Allows programmer to test problem its internal data, before computation begins.
virtual void drawElements(oofegGraphicContext &gc)
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode)
Stores the state of model to output stream.
Definition: engngm.C:1527
std::vector< std::unique_ptr< EngngModel > > emodelList
List of engineering models to solve sequentially.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
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
virtual ~ProblemSequence()
Destructor.
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
Class representing the implementation of plain text date reader.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
Definition: engngm.C:1592
the oofem namespace is to define a context or scope in which all oofem names are defined.
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
ContextOutputMode contextOutputMode
Domain context output mode.
Definition: engngm.h:246

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