FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
CFSTRDB_Solver.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 /*
6  CFSTRDB_Solver Ver.1.0
7 */
8 
9 #include "CFSTRDB.h"
10 #include "CHECData.h"
11 
12 using namespace std;
13 using namespace hecd_util;
14 
16 
18 
20  strcpy(method, "CG");
21  precond = 1;
22  nset = 0;
23  iterlog = 1;
24  timelog = 1;
25  // 2nd line
26  nier = 10000;
27  iterPREmax = 2;
28  nrest = 10;
29  // 3rd line
30  resid = 1.0e-8;
31  fsigma_diag = 1.0;
32  sigma = 0.0;
33  // 4th line
34  thresh = 0.1;
35  filter = 0.1;
36 }
37 
39  const char YorN[][20] = {"NO", "YES"};
40  hecd->WriteHeader("!SOLVER", "SISS", "METHOD", method, "PRECOND", precond,
41  "ITERLOG", YorN[iterlog], "TIMELOG", YorN[timelog]);
42  // 2nd line ------------------------
43  hecd->WriteData("III", nier, iterPREmax, nrest);
44  // 3rd line ------------------------
45  hecd->WriteData("FFF", resid, fsigma_diag, sigma);
46  // 4th line ------------------------
47  hecd->WriteData("FF", thresh, filter);
48 }
49 
50 bool CFSTRDB_Solver::Read(CHECData *hecd, char *header_line) {
51  int rcode[10];
52  char is[256] = "";
53  char ts[256] = "";
54  char iterlog_s[256] = "";
55  char timelog_s[256] = "";
56 
57  if (!hecd->ParseHeader(header_line, rcode, "SISS", "METHOD", method,
58  "PRECOND", &precond, "ITERLOG", is, "TIMELOG", ts))
59  return false;
60 
61  cleanup_token(is, iterlog_s);
62  toupper(iterlog_s);
63  cleanup_token(ts, timelog_s);
64  toupper(timelog_s);
65 
66  if (strcmp(iterlog_s, "YES") == 0)
67  iterlog = 1;
68 
69  else if (strcmp(iterlog_s, "NO") == 0)
70  iterlog = 0;
71 
72  else if (iterlog_s[0] != 0)
73  return false;
74 
75  if (strcmp(timelog_s, "YES") == 0)
76  timelog = 1;
77 
78  else if (strcmp(timelog_s, "NO") == 0)
79  timelog = 0;
80 
81  else if (timelog_s[0] != 0)
82  return false;
83 
84  // 2nd line ------------------------
85 
86  if (!hecd->ReadData(rcode, "III", &nier, &iterPREmax, &nrest)) return true;
87 
88  // 3rd line ------------------------
89 
90  if (!hecd->ReadData(rcode, "FFF", &resid, &fsigma_diag, &sigma)) return true;
91 
92  // 4th line ------------------------
93 
94  if (!hecd->ReadData(rcode, "FF", &thresh, &filter)) return true;
95 
96  return true;
97 }
CHECData::ParseHeader
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:506
CHECData.h
hecd_util::toupper
void toupper(char *s)
Definition: hecd_util.cpp:40
CFSTRDB_Solver::method
char method[30]
Definition: CFSTRDB.h:84
CFSTRDB_Solver::iterPREmax
int iterPREmax
Definition: CFSTRDB.h:92
CFSTRDB.h
CFSTRDB_Solver::iterlog
int iterlog
Definition: CFSTRDB.h:87
CFSTRDB_Solver::nier
int nier
Definition: CFSTRDB.h:92
hecd_util::cleanup_token
void cleanup_token(char *s)
Definition: hecd_util.cpp:16
CHECData::WriteData
virtual void WriteData(const char *fmt,...)
Definition: CHECData.cpp:162
CFSTRDB_Solver::precond
int precond
Definition: CFSTRDB.h:85
CFSTRDB_Solver::CFSTRDB_Solver
CFSTRDB_Solver()
Definition: CFSTRDB_Solver.cpp:15
CFSTRDB_Solver::thresh
double thresh
Definition: CFSTRDB.h:100
CHECData::ReadData
virtual bool ReadData(int *rcode, const char *fmt,...)
Definition: CHECData.cpp:548
CFSTRDB_Solver::timelog
int timelog
Definition: CFSTRDB.h:88
CFSTRDB_Solver::nset
int nset
Definition: CFSTRDB.h:86
CHECData::WriteHeader
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
CFSTRDB_Solver::fsigma_diag
double fsigma_diag
Definition: CFSTRDB.h:96
CHECData
Definition: CHECData.h:25
CFSTRDB_Solver::nrest
int nrest
Definition: CFSTRDB.h:92
CFSTRDB_Solver::Read
virtual bool Read(class CHECData *hecd, char *header_line)
Definition: CFSTRDB_Solver.cpp:50
CFSTRDB_Solver::sigma
double sigma
Definition: CFSTRDB.h:96
hecd_util
Definition: hecd_util.cpp:11
FSTRDB_SOLVER
@ FSTRDB_SOLVER
Definition: CFSTRDB.h:30
CFSTRDB_Solver::~CFSTRDB_Solver
virtual ~CFSTRDB_Solver()
Definition: CFSTRDB_Solver.cpp:17
CFSTRDataBlock
Definition: CFSTRDB.h:58
CFSTRDB_Solver::filter
double filter
Definition: CFSTRDB.h:100
CFSTRDB_Solver::Clear
virtual void Clear()
Definition: CFSTRDB_Solver.cpp:19
CFSTRDB_Solver::Write
virtual void Write(class CHECData *hecd)
Definition: CFSTRDB_Solver.cpp:38
CFSTRDB_Solver::resid
double resid
Definition: CFSTRDB.h:96