OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
util.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 "util.h"
36 #include "engngm.h"
37 #include "classfactory.h"
38 #include "inputrecord.h"
39 #include "datareader.h"
40 #include "error.h"
41 
42 #include <cstring>
43 
44 namespace oofem {
45 EngngModel *InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
46 {
47  IRResultType result; // Required by IR_GIVE_FIELD macro
48  EngngModel *problem;
49  std :: string problemName, dataOutputFileName, desc;
50 
51  dataOutputFileName = dr.giveOutputFileName();
52  desc = dr.giveDescription();
53 
54  /* here we need copy of input record. The pointer returned by dr.giveInputRecord can (and will)
55  * be updated as reading e-model components (nodes, etc). But we need this record being available
56  * through the whole e-model instanciation
57  */
59  result = emodelir->giveRecordKeywordField(problemName);
60  if ( result != IRRT_OK ) {
61  emodelir->report_error("", __func__, "", result, __FILE__, __LINE__);
62  }
63 
64  problem = classFactory.createEngngModel(problemName.c_str(), 1, _master);
65  if ( !problem ) {
66  OOFEM_WARNING( "Failed to construct engineering model of type \"%s\".\n", problemName.c_str() );
67  return NULL;
68  }
69 
70  problem->setProblemMode(mode);
71  problem->setParallelMode(parallelFlag);
72 
73  if ( contextFlag ) {
75  }
76 
77  problem->instanciateYourself( dr, emodelir, dataOutputFileName.c_str(), desc.c_str() );
78 
79  delete emodelir;
80 
81  return problem;
82 }
83 } // end namespace oofem
std::string giveDescription()
Gives the problem description.
Definition: datareader.h:96
std::string giveOutputFileName()
Gives the output file name.
Definition: datareader.h:94
Class representing the abstraction for input data source.
Definition: datareader.h:50
virtual void report_error(const char *_class, const char *proc, InputFieldType id, IRResultType result, const char *file, int line)=0
Prints the error message.
void setProblemMode(problemMode pmode)
Sets domain mode to given mode.
Definition: engngm.h:404
void setParallelMode(bool newParallelFlag)
Sets the problem to run in parallel (or not).
Definition: engngm.C:174
EngngModel * InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
Instanciates the new problem.
Definition: util.C:45
virtual IRResultType giveRecordKeywordField(std::string &answer, int &value)=0
Reads the record id field (type of record) and its corresponding number.
Enable for post-processing.
virtual InputRecord * GiveCopy()=0
Creates a newly allocated copy of the receiver.
virtual InputRecord * giveInputRecord(InputRecordType irType, int recordId)=0
Returns input record corresponding to given InputRecordType value and its record_id.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
ClassFactory & classFactory
Definition: classfactory.C:59
virtual int instanciateYourself(DataReader &dr, InputRecord *ir, const char *outFileName, const char *desc)
Initializes whole problem according to its description stored in inputStream.
Definition: engngm.C:201
void setContextOutputMode(ContextOutputMode contextMode)
Sets context output mode of receiver.
Definition: engngm.h:388
problemMode
Definition: problemmode.h:39
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.
#define OOFEM_WARNING(...)
Definition: error.h:62
EngngModel * createEngngModel(const char *name, int num, EngngModel *master)
Creates new instance of engng model corresponding to given keyword.
Definition: classfactory.C:209

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