FrontISTR  5.7.1
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 }
@ FSTRDB_SOLVER
Definition: CFSTRDB.h:30
virtual void Clear()
double thresh
Definition: CFSTRDB.h:100
int iterPREmax
Definition: CFSTRDB.h:92
virtual bool Read(class CHECData *hecd, char *header_line)
virtual void Write(class CHECData *hecd)
virtual ~CFSTRDB_Solver()
double sigma
Definition: CFSTRDB.h:96
double filter
Definition: CFSTRDB.h:100
double fsigma_diag
Definition: CFSTRDB.h:96
char method[30]
Definition: CFSTRDB.h:84
double resid
Definition: CFSTRDB.h:96
virtual bool ReadData(int *rcode, const char *fmt,...)
Definition: CHECData.cpp:548
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:506
virtual void WriteData(const char *fmt,...)
Definition: CHECData.cpp:162
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
void toupper(char *s)
Definition: hecd_util.cpp:37
void cleanup_token(char *s)
Definition: hecd_util.cpp:13