OOFEM 3.0
Loading...
Searching...
No Matches
oofem::DataReader Class Referenceabstract

#include <datareader.h>

Inheritance diagram for oofem::DataReader:

Classes

class  RecordGuard
 RAII guard for DataReader::enterRecord and DataReader::leaveRecord. More...
class  GroupRecords
 Internal range-like class, return type for giveGroupRecords methods. More...

Public Types

enum  InputRecordType {
  IR_domainRec , IR_outManRec , IR_domainCompRec , IR_geometryRec ,
  IR_gbpmRec , IR_emodelRec , IR_mstepRec , IR_expModuleRec ,
  IR_dofmanRec , IR_elemRec , IR_crosssectRec , IR_matRec ,
  IR_nlocBarRec , IR_bcRec , IR_icRec , IR_funcRec ,
  IR_setRec , IR_xfemManRec , IR_enrichFuncRec , IR_geoRec ,
  IR_enrichItemRec , IR_enrichFrontRec , IR_propagationLawRec , IR_crackNucleationRec ,
  IR_fracManRec , IR_failCritRec , IR_contactSurfaceRec , IR_fieldRec ,
  IR_mpmVarRec , IR_mpmTermRec , IR_mpmIntegralRec , IR_unspecified
}
 Determines the type of input record. More...

Public Member Functions

 DataReader ()
virtual ~DataReader ()
virtual InputRecordgiveInputRecord (InputRecordType irType, int recordId)=0
virtual InputRecordgiveTopInputRecord ()
virtual bool peekNext (const std ::string &keyword)
virtual void finish ()=0
virtual std::string giveReferenceName () const =0
 Gives the reference file name (e.g. file name).
std::string giveOutputFileName ()
 Gives the output file name.
std::string giveDescription ()
 Gives the problem description.
virtual bool hasFlattenedStructure ()
virtual void enterGroup (const std::string &name)
virtual void leaveGroup (const std::string &name)
virtual void enterRecord (InputRecord *rec)
virtual void leaveRecord (InputRecord *rec)
virtual int giveGroupCount (const std::string &name)
bool hasGroup (const std::string &name)
 Predicate whether a named group exists (it can still be empty).
GroupRecords giveGroupRecords (const std::shared_ptr< InputRecord > &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional)
GroupRecords giveGroupRecords (const std::string &name, InputRecordType irType, int numRequired=-1)
InputRecordgiveChildRecord (const std::shared_ptr< InputRecord > &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional)
 Return pointer to subrecord of given type (must be exactly one); if not present, returns nullptr.

Static Public Attributes

static constexpr const char * InputRecordTags []
static const int NoSuchGroup =-1

Protected Attributes

std::string outputFileName
 Output file name (first line in OOFEM input files).
std::string description
 Description line (second line in OOFEM input files).

Detailed Description

Class representing the abstraction for input data source. Its role is to provide input records for particular components. The input records are identified by record type and component number. The order of input records is in fact determined by the coded sequence of component initialization. The input record identification facilitates the implementation of database readers with direct or random access.

Definition at line 54 of file datareader.h.

Member Enumeration Documentation

◆ InputRecordType

Determines the type of input record.

Enumerator
IR_domainRec 
IR_outManRec 
IR_domainCompRec 
IR_geometryRec 
IR_gbpmRec 
IR_emodelRec 
IR_mstepRec 
IR_expModuleRec 
IR_dofmanRec 
IR_elemRec 
IR_crosssectRec 
IR_matRec 
IR_nlocBarRec 
IR_bcRec 
IR_icRec 
IR_funcRec 
IR_setRec 
IR_xfemManRec 
IR_enrichFuncRec 
IR_geoRec 
IR_enrichItemRec 
IR_enrichFrontRec 
IR_propagationLawRec 
IR_crackNucleationRec 
IR_fracManRec 
IR_failCritRec 
IR_contactSurfaceRec 
IR_fieldRec 
IR_mpmVarRec 
IR_mpmTermRec 
IR_mpmIntegralRec 
IR_unspecified 

Definition at line 64 of file datareader.h.

Constructor & Destructor Documentation

◆ DataReader()

◆ ~DataReader()

virtual oofem::DataReader::~DataReader ( )
inlinevirtual

Definition at line 88 of file datareader.h.

Member Function Documentation

◆ enterGroup()

virtual void oofem::DataReader::enterGroup ( const std::string & name)
inlinevirtual

Reimplemented in oofem::XMLDataReader.

Definition at line 122 of file datareader.h.

◆ enterRecord()

virtual void oofem::DataReader::enterRecord ( InputRecord * rec)
inlinevirtual

Reimplemented in oofem::XMLDataReader.

Definition at line 124 of file datareader.h.

◆ finish()

virtual void oofem::DataReader::finish ( )
pure virtual

Allows to detach all data connections.

Implemented in oofem::DynamicDataReader, oofem::OOFEMTXTDataReader, and oofem::XMLDataReader.

◆ giveChildRecord()

InputRecord * oofem::DataReader::giveChildRecord ( const std::shared_ptr< InputRecord > & ir,
InputFieldType ift,
const std::string & name,
InputRecordType irType,
bool optional )

Return pointer to subrecord of given type (must be exactly one); if not present, returns nullptr.

Definition at line 40 of file datareader.C.

References giveInputRecord().

Referenced by oofem::Delamination::instanciateYourself(), oofem::Domain::instanciateYourself(), and oofem::GeometryBasedEI::instanciateYourself().

◆ giveDescription()

std::string oofem::DataReader::giveDescription ( )
inline

Gives the problem description.

Definition at line 118 of file datareader.h.

Referenced by oofem::InstanciateProblem().

◆ giveGroupCount()

virtual int oofem::DataReader::giveGroupCount ( const std::string & name)
inlinevirtual

Return number of items in a named group

Parameters
namename of the group; if empty, current group is used
Returns
Number of items in the named group; returns 0 if the group is empty, and -1 (DatReader::NoSuchGroup) if the group does not exist at all.

Reimplemented in oofem::XMLDataReader.

Definition at line 170 of file datareader.h.

References NoSuchGroup.

Referenced by giveGroupRecords(), and hasGroup().

◆ giveGroupRecords() [1/2]

DataReader::GroupRecords oofem::DataReader::giveGroupRecords ( const std::shared_ptr< InputRecord > & ir,
InputFieldType ift,
const std::string & name,
InputRecordType irType,
bool optional )

Give range (provides begin(), end(), size()) to iterate over records. Some readers (text) specify the number of records in the InputRecord with the given input field type. Other readers (XML) find the number of records as number of elements in the subgroup enclosed with name tag.

Parameters
irInput record which may hold the number of subsequent entries to be read from the stream
iftField type in ir record specifying the number of records.
nameSubgroup name for tag-based readers.
irTypeExpected input record type for all records to be read.
optionalIf not optional and the number of records is not given, fail with error. Otherwise assume 0-sized subgroup.
Returns
Object providing begin(), end() iterators and size().

Definition at line 46 of file datareader.C.

Referenced by oofem::EngngModel::initializeFrom(), oofem::TimeStepController::initializeFrom(), oofem::EngngModel::instanciateMetaSteps(), oofem::TimeStepController::instanciateMetaSteps(), oofem::Delamination::instanciateYourself(), oofem::Domain::instanciateYourself(), oofem::FieldManager::instanciateYourself(), oofem::GeometryBasedEI::instanciateYourself(), oofem::ModuleManager< M >::instanciateYourself(), oofem::XfemManager::instanciateYourself(), and oofem::ErrorCheckingExportModule::readRulesFromRecords().

◆ giveGroupRecords() [2/2]

DataReader::GroupRecords oofem::DataReader::giveGroupRecords ( const std::string & name,
InputRecordType irType,
int numRequired = -1 )

Give range to iterate over records within a named group

Parameters
nameSubgroup name; if not given, give records within the current group
irTypeInput record type for records to be read
numRequiredif non-negative, this number is checked against number of records present (for readers which can determine that), and mismatch error is thrown when they are different
Returns
Object providing being(), end() iterators and size().

Definition at line 51 of file datareader.C.

References giveGroupCount(), giveReferenceName(), and OOFEM_ERROR.

◆ giveInputRecord()

virtual InputRecord & oofem::DataReader::giveInputRecord ( InputRecordType irType,
int recordId )
pure virtual

Returns input record corresponding to given InputRecordType value and its record_id. The returned InputRecord reference is valid only until the next call.

Parameters
irTypeDetermines type of record to be returned.
recordIdDetermines the record number corresponding to component number.

Implemented in oofem::DynamicDataReader, oofem::OOFEMTXTDataReader, and oofem::XMLDataReader.

Referenced by giveChildRecord(), oofem::EngngModel::instanciateDomains(), oofem::InstanciateProblem(), oofem::Delamination::instanciateYourself(), oofem::Domain::instanciateYourself(), oofem::Domain::instanciateYourself(), oofem::FractureManager::instanciateYourself(), and oofem::NucleationCriterion::instanciateYourself().

◆ giveOutputFileName()

std::string oofem::DataReader::giveOutputFileName ( )
inline

Gives the output file name.

Definition at line 116 of file datareader.h.

Referenced by oofem::InstanciateProblem().

◆ giveReferenceName()

virtual std::string oofem::DataReader::giveReferenceName ( ) const
pure virtual

Gives the reference file name (e.g. file name).

Implemented in oofem::DynamicDataReader, oofem::OOFEMTXTDataReader, and oofem::XMLDataReader.

Referenced by giveGroupRecords(), and oofem::EngngModel::instanciateYourself().

◆ giveTopInputRecord()

virtual InputRecord * oofem::DataReader::giveTopInputRecord ( )
inlinevirtual

Returns top input record, for readers which support it; others return empty pointer

Reimplemented in oofem::XMLDataReader.

Definition at line 100 of file datareader.h.

Referenced by oofem::EngngModel::instanciateYourself().

◆ hasFlattenedStructure()

virtual bool oofem::DataReader::hasFlattenedStructure ( )
inlinevirtual

◆ hasGroup()

bool oofem::DataReader::hasGroup ( const std::string & name)
inline

Predicate whether a named group exists (it can still be empty).

Definition at line 172 of file datareader.h.

References giveGroupCount().

◆ leaveGroup()

virtual void oofem::DataReader::leaveGroup ( const std::string & name)
inlinevirtual

Reimplemented in oofem::XMLDataReader.

Definition at line 123 of file datareader.h.

◆ leaveRecord()

virtual void oofem::DataReader::leaveRecord ( InputRecord * rec)
inlinevirtual

Reimplemented in oofem::XMLDataReader.

Definition at line 125 of file datareader.h.

◆ peekNext()

virtual bool oofem::DataReader::peekNext ( const std ::string & keyword)
inlinevirtual

Peak in advance into the record list.

Returns
True if next keyword is a set.

Reimplemented in oofem::DynamicDataReader, oofem::OOFEMTXTDataReader, and oofem::XMLDataReader.

Definition at line 106 of file datareader.h.

Referenced by oofem::Domain::instanciateYourself().

Member Data Documentation

◆ description

std::string oofem::DataReader::description
protected

◆ InputRecordTags

const char* oofem::DataReader::InputRecordTags[]
staticconstexpr
Initial value:
={
"Domain","OutputManager","DomainComp","Geometry","GBPM",
"Analysis","Metastep","","","",
"","","","","InitialCondition","","Set",
"XFemManager","EnrichmentFunction","EnrichmentGeometry","",
"","PropagationLaw","CrackNucleation","FractureManager","FailCriterion",
"","Field",
"MPMVariable","","MPMIntegral",
"UNSPECIFIED"
}

Definition at line 76 of file datareader.h.

Referenced by oofem::XMLDataReader::giveInputRecord(), oofem::Delamination::instanciateYourself(), oofem::Domain::instanciateYourself(), and oofem::GeometryBasedEI::instanciateYourself().

◆ NoSuchGroup

const int oofem::DataReader::NoSuchGroup =-1
static

Definition at line 164 of file datareader.h.

Referenced by giveGroupCount().

◆ outputFileName

std::string oofem::DataReader::outputFileName
protected

The documentation for this class was generated from the following files:

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