64ErrorCheckingRule :: checkValue(
double computedValue)
70NodeErrorCheckingRule :: NodeErrorCheckingRule(
const std :: string &line,
double tol) :
91 int ret = std :: sscanf(line.c_str(),
"#NODE tStep %d number %d dof %d unknown %c value %le tolerance %le",
94 ret = std :: sscanf(line.c_str(),
"#NODE tStep %d tStepVer %d number %d dof %d unknown %c value %le tolerance %le",
98 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
106 mode = VM_Acceleration;
126 mode = VM_Acceleration;
128 OOFEM_ERROR(
"Can't recognize unknown '%s' (must be one of: d, v, a)",
unknown.c_str());
133NodeErrorCheckingRule :: getValue(
double &answer,
Domain *domain,
TimeStep *tStep)
182 OOFEM_WARNING(
"Check failed in %s: tstep %d, node %d, dof %d, mode %d:\n"
183 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
195 int ret = std :: sscanf(line.c_str(),
"#ELEMENTNODE tStep %d number %d dofman %d dof %d unknown %c value %le tolerance %le",
198 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
206 mode = VM_Acceleration;
223 else OOFEM_ERROR(
"Can't recognize unknown '%s' (must be one of: d, v, a)",
unknown.c_str());
258 OOFEM_WARNING(
"Check failed in %s: tstep %d, node %d, dof %d, mode %d:\n"
259 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
267InternalElementDofManErrorCheckingRule :: getValue(
double &answer,
Domain *domain,
TimeStep *tStep)
293ElementErrorCheckingRule :: ElementErrorCheckingRule(
const std :: string &line,
double tol) :
297 int ret = std :: sscanf(line.c_str(),
"#ELEMENT tStep %d number %d irule %d gp %d keyword %d component %d value %le tolerance %le",
300 ret = std :: sscanf(line.c_str(),
"#ELEMENT tStep %d tStepVer %d number %d irule %d gp %d keyword %d component %d value %le tolerance %le",
303 ret = std :: sscanf(line.c_str(),
"#ELEMENT tStep %d tStepVer %d number %d gp %d keyword %d component %d value %le tolerance %le",
306 }
else if ( ret < 3 ) {
307 ret = std :: sscanf(line.c_str(),
"#ELEMENT tStep %d number %d gp %d keyword %d component %d value %le tolerance %le",
311 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
358 OOFEM_WARNING(
"Check failed in %s: element %d, gpnum %d, ist %d, component %d:\n"
359 "Component not found!",
368 OOFEM_WARNING(
"Check failed in %s: tstep %d, element %d, gpnum %d, ist %d, component %d:\n" "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
378ElementErrorCheckingRule :: getValue(
double & answer,
Domain *domain,
TimeStep *tStep)
399 OOFEM_WARNING(
"Check failed in %s: element %d, gpnum %d, ist %d, component %d:\n"
400 "Component not found!",
411BeamElementErrorCheckingRule :: BeamElementErrorCheckingRule(
const std :: string &line,
double tol) :
415 int ret = std :: sscanf(line.c_str(),
"#BEAM_ELEMENT tStep %d number %d keyword %d component %d value %le tolerance %le",
418 ret = std :: sscanf(line.c_str(),
"#BEAM_ELEMENT tStep %d tStepVer %d number %d keyword %d component %d value %le tolerance %le",
422 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
465 if(
Beam2d* b =
dynamic_cast<Beam2d*
>(element)) b->giveEndForcesVector(val, tStep);
466 else if(
Beam3d* b =
dynamic_cast<Beam3d*
>(element)) b->giveEndForcesVector(val, tStep);
478 OOFEM_WARNING(
"Check failed in %s: beam_element %d, ist %d, component %d:\n"
479 "Component not found!",
488 OOFEM_WARNING(
"Check failed in %s: tstep %d, beam_element %d, ist %d, component %d:\n"
489 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
499BeamElementErrorCheckingRule :: getValue(
double& answer,
Domain *domain,
TimeStep *tStep)
519 if(
Beam2d* b =
dynamic_cast<Beam2d*
>(element)) b->giveEndForcesVector(val, tStep);
520 else if(
Beam3d* b =
dynamic_cast<Beam3d*
>(element)) b->giveEndForcesVector(val, tStep);
532 OOFEM_WARNING(
"Check failed in %s: beam_element %d, ist %d, component %d:\n"
533 "Component not found!",
544ReactionErrorCheckingRule :: ReactionErrorCheckingRule(
const std :: string &line,
double tol) :
547 int ret = std :: sscanf(line.c_str(),
"#REACTION tStep %d number %d dof %d value %le tolerance %le",
550 ret = std :: sscanf(line.c_str(),
"#REACTION tStep %d tStepVer %d number %d dof %d value %le tolerance %le",
554 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
583 IntArray restrDofMans, restrDofs, eqn;
589 for ( index = 1; index <= restrDofs.
giveSize(); ++index ) {
604 double reactionForce = reactionForces.
at(index);
607 OOFEM_WARNING(
"Check failed in %s: tstep %d, reaction forces number %d, dof %d:\n"
608 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
614 OOFEM_WARNING(
"Reaction forces only supported for structural problems yet");
620ReactionErrorCheckingRule :: getValue(
double &answer,
Domain *domain,
TimeStep *tStep)
631 IntArray restrDofMans, restrDofs, eqn;
637 for ( index = 1; index <= restrDofs.
giveSize(); ++index ) {
652 answer = reactionForces.
at(index);
655 OOFEM_WARNING(
"Reaction forces only supported for structural problems yet");
660LoadLevelErrorCheckingRule :: LoadLevelErrorCheckingRule(
const std :: string &line,
double tol) :
663 int ret = std :: sscanf(line.c_str(),
"#LOADLEVEL tStep %d value %le tolerance %le",
666 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
689 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
697LoadLevelErrorCheckingRule :: getValue(
double& answer,
Domain *domain,
TimeStep *tStep)
704EigenValueErrorCheckingRule :: EigenValueErrorCheckingRule(
const std :: string &line,
double tol) :
707 int ret = std :: sscanf(line.c_str(),
"#EIGVAL tStep %d EigNum %d value %le tolerance %le",
710 OOFEM_ERROR(
"Something wrong in the error checking rule: %s\n", line.c_str());
732 OOFEM_WARNING(
"Check failed in %s: tstep %d, eigen value %d:\n"
733 "value is %.8e, but should be %.8e ( error is %e but tolerance is %e )",
740EigenValueErrorCheckingRule :: getValue(
double&answer,
Domain *domain,
TimeStep *tStep)
746TimeCheckingRule :: TimeCheckingRule(
const std :: string &line,
double tol) :
777 ExportModule :: initializeFrom(ir);
805 OOFEM_WARNING(
"No rules found (possibly wrong file or syntax).");
813 std :: ifstream inputStream(this->
filename);
814 if ( !inputStream ) {
820 std :: unique_ptr< ErrorCheckingRule > rule = this->
giveErrorCheck(inputStream, tol);
833 for(
auto& rir: ruleRecs){
835 rir.giveRecordKeywordField(n);
837 std::unique_ptr<ErrorCheckingRule> rule;
838 if (n==
"NODE") { rule=std::make_unique<NodeErrorCheckingRule>(rir,tol); }
839 if (n==
"ELEMENT") { rule=std::make_unique<ElementErrorCheckingRule>(rir,tol); }
840 if (n==
"REACTION") { rule=std::make_unique<ReactionErrorCheckingRule>(rir,tol); }
841 if (n==
"BEAM_ELEMENT") { rule=std::make_unique<BeamElementErrorCheckingRule>(rir,tol); }
842 if (n==
"EIGVAL") { rule=std::make_unique<EigenValueErrorCheckingRule>(rir,tol); }
843 if (n==
"LOADLEVEL") { rule=std::make_unique<LoadLevelErrorCheckingRule>(rir,tol); }
844 if (n==
"TIME") { rule=std::make_unique<TimeCheckingRule>(rir,tol); }
845 if (n==
"ELEMENTNODE") { rule=std::make_unique<InternalElementDofManErrorCheckingRule>(rir,tol); }
847 else { std::cerr<<
"No rule for "<<n<<
" created (not yet implemented for XML?)."<<std::endl; }
853ErrorCheckingExportModule :: doOutput(
TimeStep *tStep,
bool forcedOutput)
867 this->
allPassed &= rule->check(domain, tStep);
872 OOFEM_ERROR(
"Rule not passed, exiting with error");
886 bool result = rule->getValue(value, domain, tStep);
902 sprintf(
filename,
"%s.m%d", this->
emodel->giveOutputBaseFileName().c_str(), this->number);
919 std :: cout <<
"#%BEGIN_CHECK% tolerance 1.e-3\n";
923 for (
Dof *dof: *dman ) {
924 if ( dof->giveEqn() < 0 ) {
927 std :: cout <<
"#NODE tStep " << tStep->
giveNumber();
928 std :: cout <<
" number " << dman->giveNumber();
929 std :: cout <<
" dof " << dof->giveDofID();
930 std :: cout <<
" unknown " <<
'd';
931 std :: cout <<
" value " << dof->giveUnknown(VM_Total, tStep);
932 std :: cout << std :: endl;
943 for (
int component = 1; component <= ipval.
giveSize(); ++component ) {
944 std :: cout <<
"#ELEMENT tStep " << tStep->
giveNumber();
945 std :: cout <<
" number " << element->giveNumber();
946 std :: cout <<
" gp " << gpnum+1;
947 std :: cout <<
" keyword " << ist;
948 std :: cout <<
" component " << component;
949 std :: cout <<
" value " << ipval.
at(component);
950 std :: cout << std :: endl;
957 std :: cout <<
"#%END_CHECK%" << std :: endl;
963ErrorCheckingExportModule :: scanToErrorChecks(std :: ifstream &stream,
double &errorTolerance)
965 while ( !stream.eof() ) {
967 std :: getline(stream, line);
968 if ( line.compare(0, 14,
"#%BEGIN_CHECK%") == 0 ) {
969 errorTolerance = 1e-6;
970 if ( line.size() >= 25 ) {
971 errorTolerance = std :: stod( line.substr(25) );
979std::unique_ptr<ErrorCheckingRule>
980ErrorCheckingExportModule :: giveErrorCheck(std :: ifstream &stream,
double errorTolerance)
983 while ( !stream.eof() ) {
984 std :: getline(stream, line);
985 if ( line.compare(0, 12,
"#%END_CHECK%") == 0 ) {
988 if (line.size() > 2 && line[0] ==
'#' && line[1] !=
'#') {
994 if ( line.compare(0, 5,
"#NODE") == 0 ) {
995 return std::make_unique<NodeErrorCheckingRule>(line, errorTolerance);
996 }
else if ( line.compare(0, 12,
"#ELEMENTNODE") == 0 ) {
997 return std::make_unique<InternalElementDofManErrorCheckingRule>(line, errorTolerance);
998 }
else if ( line.compare(0, 8,
"#ELEMENT") == 0 ) {
999 return std::make_unique<ElementErrorCheckingRule>(line, errorTolerance);
1000 }
else if ( line.compare(0, 13,
"#BEAM_ELEMENT") == 0 ) {
1001 return std::make_unique<BeamElementErrorCheckingRule>(line, errorTolerance);
1002 }
else if ( line.compare(0, 9,
"#REACTION") == 0 ) {
1003 return std::make_unique<ReactionErrorCheckingRule>(line, errorTolerance);
1004 }
else if ( line.compare(0, 10,
"#LOADLEVEL") == 0 ) {
1005 return std::make_unique<LoadLevelErrorCheckingRule>(line, errorTolerance);
1006 }
else if ( line.compare(0, 7,
"#EIGVAL") == 0 ) {
1007 return std::make_unique<EigenValueErrorCheckingRule>(line, errorTolerance);
1008 }
else if ( line.compare(0, 5,
"#TIME") == 0 ) {
1009 return std::make_unique<TimeCheckingRule>(line, errorTolerance);
1011 OOFEM_ERROR(
"Unsupported rule '%s'", line.c_str());
#define REGISTER_ExportModule(class)
bool check(Domain *domain, TimeStep *tStep) override
@ BET_localEndDisplacement
Internal range-like class, return type for giveGroupRecords methods.
GroupRecords giveGroupRecords(const std::shared_ptr< InputRecord > &ir, InputFieldType ift, const std::string &name, InputRecordType irType, bool optional)
Dof * giveDofWithID(int dofID) const
dofManagerParallelMode giveParallelMode() const
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
DofManager * giveGlobalDofManager(int n)
Element * giveGlobalElement(int n)
int giveNumber()
Returns domain number.
std ::vector< std ::unique_ptr< DofManager > > & giveDofManagers()
EngngModel * giveEngngModel()
std ::vector< std ::unique_ptr< Element > > & giveElements()
bool check(Domain *domain, TimeStep *tStep) override
bool check(Domain *domain, TimeStep *tStep) override
void computeVectorOf(ValueModeType u, TimeStep *tStep, FloatArray &answer)
virtual IntegrationRule * giveIntegrationRule(int i)
elementParallelMode giveParallelMode() const
virtual DofManager * giveInternalDofManager(int i) const
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
std::string giveOutputBaseFileName()
virtual double giveLoadLevel()
Returns the current load level.
virtual double giveEigenValue(int eigNum)
Only relevant for eigen value analysis. Otherwise returns zero.
bool isParallel() const
Returns true if receiver in parallel mode.
std::unique_ptr< ErrorCheckingRule > giveErrorCheck(std ::ifstream &stream, double errorTolerance)
void writeCheck(Domain *domain, TimeStep *tStep)
void readRulesFromRecords(DataReader &dr, InputRecord &ir)
void readRulesFromTextFile(InputRecord &ir)
void initialize() override
void terminate() override
std ::vector< std ::unique_ptr< ErrorCheckingRule > > errorCheckingRules
bool scanToErrorChecks(std ::ifstream &stream, double &errorTolerance)
bool checkValue(double computedValue)
ErrorCheckingRule(double tol)
ExportModule(int n, EngngModel *e)
Constructor. Creates empty Output Manager with number n.
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
Index giveSize() const
Returns the size of receiver.
virtual void printYourself() const
int giveNumberOfIntegrationPoints() const
GaussPoint * getIntegrationPoint(int n)
bool check(Domain *domain, TimeStep *tStep) override
InternalElementDofManErrorCheckingRule(const std ::string &line, double tol)
bool check(Domain *domain, TimeStep *tStep) override
bool check(Domain *domain, TimeStep *tStep) override
bool check(Domain *domain, TimeStep *tStep) override
void buildReactionTable(IntArray &restrDofMans, IntArray &restrDofs, IntArray &eqn, TimeStep *tStep, int di)
void computeReaction(FloatArray &answer, TimeStep *tStep, int di)
TimeCheckingRule(const std ::string &line, double tol)
int giveVersion()
Returns receiver's version.
double giveTargetTime()
Returns target time.
int giveNumber()
Returns receiver's number.
#define OOFEM_WARNING(...)
#define _IFT_ErrorCheckingExportModule_writeIST
Which internal state types to write rules for.
#define _IFT_ErrorCheckingExportModule_filename
Filename where rules are defined (normally the input file).
#define _IFT_ErrorCheckingExportModule_extractormode
#define OOFEM_LOG_INFO(...)
@ Element_local
Element is local, there are no contributions from other domains to this element.
std::pair< FloatArrayF< N >, FloatMatrixF< N, N > > eig(const FloatMatrixF< N, N > &mat, int nf=9)