MIDAS
0.75
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Friends
Macros
src
module_oofem.cpp
Go to the documentation of this file.
1
#include "
module_oofem.h
"
2
#include "
problem.h
"
3
4
#include "
librw.h
"
5
6
#ifdef __OOFEM_MODULE
7
#include "mainlib.h"
8
#endif
9
10
#include <stdio.h>
11
#include <stdlib.h>
12
#include <unistd.h>
13
#include <time.h>
14
15
16
namespace
midaspace {
17
18
void
FEM_solve_OOFEM
(
Problem
*pd)
19
{
20
char
*auxch;
21
22
double
sec = clock();
23
pd->
sodriver
()->
print_info_message
(
SODE_start_blue_arrow
,
"OOFEM analyse"
);
24
27
29
fflush(stdout);
30
//fpos_t pos; fgetpos(stdout, &pos);
31
int
fd_out = dup(fileno(stdout));
32
freopen(auxch =
strdupl
(pd->
give_OUT_moFILE
()->
give_name
(),
".oofem.log.stdout"
),
"w"
, stdout);
33
delete
[] auxch;
34
36
fflush(stderr);
37
//fpos_t pos; fgetpos(stderr, &pos);
38
int
fd_err = dup(fileno(stderr));
39
freopen(auxch =
strdupl
(pd->
give_OUT_moFILE
()->
give_name
(),
".oofem.log.stderr"
),
"w"
, stderr);
40
delete
[] auxch;
41
42
const
char
*solver = pd->
give_P_solverbinary
()->
give_name_or_null
();
43
44
int
status;
46
if
(solver) {
47
char
cmd[1000];
48
sprintf(cmd,
"%s"
, solver);
49
51
//argc = 1;
52
//argv[argc++] = strdupl ("-rn");
53
//argv[argc++] = strdupl ("-f");
54
//argv[argc++] = strdupl (this->OUT_moFILE->give_name(), ".oofem.in");
55
//argv[argc++] = strdupl ("-qo");
56
//argv[argc++] = strdupl (this->OUT_moFILE->give_name(), ".oofem.log");
57
//for (int i=1; i<argc; i++) { strcat(cmd, " "); strcat(cmd, args[i]); }
58
59
strcat(cmd,
" -rn"
);
60
strcat(cmd,
" -f "
); strcat(cmd, pd->
give_OUT_moFILE
()->
give_name
()); strcat(cmd,
".oofem.in"
);
61
strcat(cmd,
" -qo "
); strcat(cmd, pd->
give_OUT_moFILE
()->
give_name
()); strcat(cmd,
".oofem.log"
);
62
63
fflush(stdout); fflush(stderr);
64
status = system(cmd);
65
fprintf(stdout,
"\n"
);
66
}
67
else
{
68
#ifdef __OOFEM_MODULE
69
char
fname[256];
70
sprintf(fname,
"%s%s"
, pd->
give_OUT_moFILE
()->
give_name
(),
".oofem.in"
);
71
72
char
oname[256];
73
sprintf(oname,
"%s%s"
, pd->
give_OUT_moFILE
()->
give_name
(),
".oofem.log"
);
74
75
try
{
76
//oofem_main (, (char **)args, &pd->solver_file_ptr, &pd->solver_file_size);
77
oofem_main
(
true
, fname, oname);
78
status = 0;
79
}
80
catch
(...){
81
status = 1;
82
}
83
84
// int status = oofem_main (argc, (char **)args, &pd->solver_file_ptr, &pd->solver_file_size);
85
//if (status) _errorr("OOFEM ma problemy Houstone");
86
#else
87
_errorr
(
"OOFEM binary is given as \"-\", however the module __OOFEM_MODULE is not linked. Activate the module in Makefile please."
);
88
#endif
89
}
90
93
fflush(stdout);
94
dup2(fd_out, fileno(stdout));
95
close(fd_out);
96
clearerr(stdout);
97
//fsetpos(stdout, &pos);
98
100
fflush(stderr);
101
dup2(fd_err, fileno(stderr));
102
close(fd_err);
103
clearerr(stderr);
104
//fsetpos(stderr, &pos);
105
106
if
(status)
_errorr
(
"OOFEM ma problemy Houstone"
);
107
108
pd->
sodriver
()->
print_info_time_green_ok
(
SODE_end_green_ok
, (clock() - sec) / (
double
)CLOCKS_PER_SEC);
109
}
110
111
}
// namespace midaspace
midaspace::strdupl
char * strdupl(const char *src)
standard strdup - Memory for the new string is obtained with malloc(3), and can be freed with free(3)...
Definition:
librw.cpp:53
midaspace::SODE_start_blue_arrow
Definition:
taux.h:349
midaspace::Problem::give_P_solverbinary
const FiLe * give_P_solverbinary(void) const
Definition:
problem.h:177
midaspace::FEM_solve_OOFEM
void FEM_solve_OOFEM(Problem *pd)
Definition:
module_oofem.cpp:18
librw.h
Input / output function.
midaspace::StdoutDriver::print_info_message
void print_info_message(SODenum flag, const char *format,...) const
Definition:
taux.cpp:240
midaspace::SODE_end_green_ok
Definition:
taux.h:349
midaspace::FiLe::give_name
const char * give_name(void) const
Definition:
taux.h:146
oofem_main
int oofem_main(bool rn, const char *inputFileName, const char *oname)
Definition:
oofem_main.cpp:29
midaspace::StdoutDriver::print_info_time_green_ok
void print_info_time_green_ok(SODenum flag, double sec) const
Definition:
taux.cpp:266
module_oofem.h
Interface to library OOFEM.
midaspace::Problem::give_OUT_moFILE
const FiLe * give_OUT_moFILE(void) const
Definition:
problem.h:201
_errorr
#define _errorr(_1)
Definition:
gelib.h:151
midaspace::FiLe::give_name_or_null
const char * give_name_or_null(void) const
Definition:
taux.h:145
midaspace::Problem::sodriver
const StdoutDriver * sodriver(void) const
Definition:
problem.h:90
midaspace::Problem
Problem description.
Definition:
problem.h:74
problem.h
Class Problem.
This reference manual is part of the
MIDAS
documentation. Copyright (c) 2005-2013 Ladislav Termit Svoboda. Generated on Fri Mar 21 2014 11:39:44 for MIDAS by
1.8.6.