OOFEM 3.0
Loading...
Searching...
No Matches
datareader.h
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#ifndef datareader_h
36#define datareader_h
37
38#include "oofemenv.h"
39#include "inputrecord.h"
40#include "error.h"
41
42#include<iostream>
43#include<fstream>
44
45namespace oofem {
55{
56protected:
58 std :: string outputFileName;
60 std :: string description;
61
62public:
75 /* XML tags corresponding to record types; those with "" are just enumeration group where arbitrary tags may be used */
76 static constexpr const char* InputRecordTags[]={
77 "Domain","OutputManager","DomainComp","Geometry","GBPM",
78 "Analysis","Metastep",/*ExportModule*/"",/*Node*/"",/*Element*/"",
79 /*CrossSection*/"",/*Material*/"",/*"NonlocalBarrier"*/"",/*BoundaryCondition*/"","InitialCondition",/*TimeFunction*/"","Set",
80 "XFemManager","EnrichmentFunction","EnrichmentGeometry",/*EnrichmentItem*/"",
81 /*EnrichmentFront*/"","PropagationLaw","CrackNucleation","FractureManager","FailCriterion",
82 /*ContactSurface*/"","Field",
83 "MPMVariable",/*"MPMTerm"*/"","MPMIntegral",
84 "UNSPECIFIED"
85 };
86
88 virtual ~DataReader() { }
89
96 virtual InputRecord &giveInputRecord(InputRecordType irType, int recordId) = 0;
100 virtual InputRecord* giveTopInputRecord(){ return nullptr; }
101
106 virtual bool peekNext(const std :: string &keyword) { return false; }
107
111 virtual void finish() = 0;
112
114 virtual std :: string giveReferenceName() const = 0;
116 std :: string giveOutputFileName() { return this->outputFileName; }
118 std :: string giveDescription() { return this->description; }
119
120 virtual bool hasFlattenedStructure() { return false; }
121
122 virtual void enterGroup(const std::string& name) {};
123 virtual void leaveGroup(const std::string& name) {};
124 virtual void enterRecord(InputRecord* rec) {};
125 virtual void leaveRecord(InputRecord* rec) {};
126
131 public:
132 RecordGuard(DataReader& reader_, InputRecord* rec_): reader(reader_), rec(rec_) { reader.enterRecord(rec); }
133 ~RecordGuard() { reader.leaveRecord(rec); }
134 };
135
139 std::string group;
141 int size_;
142 public:
143 class Iterator {
145 std::string group;
147 int size;
148 int index;
150 bool entered=false;
151 public:
152 Iterator( DataReader &dr_, const std::string &group_, InputRecordType irType_, int size_, int index_ );
155 bool operator!=(const Iterator& other){ return this->index!=other.index; }
156 int index1() const { return index+1; }
157 };
158 GroupRecords( DataReader &dr_, const std::string &group_, InputRecordType irType_, int size );
160 Iterator end(){ return Iterator(dr,group,irType,size_,std::max(size_,0)); }
161 int size(){ return size_; }
162 };
163
164 static const int NoSuchGroup=-1;
170 virtual int giveGroupCount(const std::string& name){ return NoSuchGroup; }
172 bool hasGroup(const std::string& name){ return giveGroupCount(name)>=0; }
184 GroupRecords giveGroupRecords(const std::shared_ptr<InputRecord> &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional );
192 GroupRecords giveGroupRecords(const std::string& name, InputRecordType irType, int numRequired=-1);
194 InputRecord *giveChildRecord( const std::shared_ptr<InputRecord> &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional );
195
196
197};
198} // end namespace oofem
199#endif // datareader_h
bool operator!=(const Iterator &other)
Definition datareader.h:155
Iterator(DataReader &dr_, const std::string &group_, InputRecordType irType_, int size_, int index_)
Definition datareader.C:58
Internal range-like class, return type for giveGroupRecords methods.
Definition datareader.h:137
GroupRecords(DataReader &dr_, const std::string &group_, InputRecordType irType_, int size)
Definition datareader.C:93
RecordGuard(DataReader &reader_, InputRecord *rec_)
Definition datareader.h:132
virtual std::string giveReferenceName() const =0
Gives the reference file name (e.g. file name).
virtual void leaveRecord(InputRecord *rec)
Definition datareader.h:125
std::string outputFileName
Output file name (first line in OOFEM input files).
Definition datareader.h:58
std::string giveOutputFileName()
Gives the output file name.
Definition datareader.h:116
virtual bool peekNext(const std ::string &keyword)
Definition datareader.h:106
virtual InputRecord * giveTopInputRecord()
Definition datareader.h:100
virtual void enterGroup(const std::string &name)
Definition datareader.h:122
virtual void enterRecord(InputRecord *rec)
Definition datareader.h:124
InputRecordType
Determines the type of input record.
Definition datareader.h:64
std::string description
Description line (second line in OOFEM input files).
Definition datareader.h:60
static const int NoSuchGroup
Definition datareader.h:164
virtual void finish()=0
virtual InputRecord & giveInputRecord(InputRecordType irType, int recordId)=0
static constexpr const char * InputRecordTags[]
Definition datareader.h:76
std::string giveDescription()
Gives the problem description.
Definition datareader.h:118
virtual int giveGroupCount(const std::string &name)
Definition datareader.h:170
bool hasGroup(const std::string &name)
Predicate whether a named group exists (it can still be empty).
Definition datareader.h:172
virtual bool hasFlattenedStructure()
Definition datareader.h:120
virtual void leaveGroup(const std::string &name)
Definition datareader.h:123
virtual ~DataReader()
Definition datareader.h:88
const char * InputFieldType
Identifier of fields in input records.
Definition inputrecord.h:59
#define OOFEM_EXPORT
Definition oofemcfg.h:7

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