Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
podlesny
dune-tectonic
Commits
e7805b84
Commit
e7805b84
authored
4 years ago
by
podlesny
Browse files
Options
Downloads
Patches
Plain Diff
move iohandler outside of try catch block
parent
cc4001ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/foam/foam.cc
+22
-12
22 additions, 12 deletions
src/foam/foam.cc
with
22 additions
and
12 deletions
src/foam/foam.cc
+
22
−
12
View file @
e7805b84
...
@@ -115,6 +115,14 @@ static std::atomic<bool> terminationRequested(false);
...
@@ -115,6 +115,14 @@ static std::atomic<bool> terminationRequested(false);
void
handleSignal
(
int
signum
)
{
terminationRequested
=
true
;
}
void
handleSignal
(
int
signum
)
{
terminationRequested
=
true
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
using
BlocksFactory
=
TwoBlocksFactory
<
Grid
,
Vector
>
;
using
ContactNetwork
=
typename
BlocksFactory
::
ContactNetwork
;
using
MyProgramState
=
ProgramState
<
Vector
,
ScalarVector
>
;
using
Assembler
=
MyAssembler
<
DefLeafGridView
,
dims
>
;
using
IOHandler
=
IOHandler
<
Assembler
,
ContactNetwork
,
MyProgramState
>
;
std
::
unique_ptr
<
IOHandler
>
ioHandler
;
try
{
try
{
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
...
@@ -141,15 +149,13 @@ int main(int argc, char *argv[]) {
...
@@ -141,15 +149,13 @@ int main(int argc, char *argv[]) {
std
::
streambuf
*
coutbuf
=
std
::
cout
.
rdbuf
();
//save old buffer
std
::
streambuf
*
coutbuf
=
std
::
cout
.
rdbuf
();
//save old buffer
std
::
cout
.
rdbuf
(
out
.
rdbuf
());
//redirect std::cout to log.txt
std
::
cout
.
rdbuf
(
out
.
rdbuf
());
//redirect std::cout to log.txt
using
Assembler
=
MyAssembler
<
DefLeafGridView
,
dims
>
;
using
field_type
=
Matrix
::
field_type
;
using
field_type
=
Matrix
::
field_type
;
// ----------------------
// ----------------------
// set up contact network
// set up contact network
// ----------------------
// ----------------------
using
BlocksFactory
=
TwoBlocksFactory
<
Grid
,
Vector
>
;
BlocksFactory
blocksFactory
(
parset
);
BlocksFactory
blocksFactory
(
parset
);
using
ContactNetwork
=
typename
BlocksFactory
::
ContactNetwork
;
blocksFactory
.
build
();
blocksFactory
.
build
();
ContactNetwork
&
contactNetwork
=
blocksFactory
.
contactNetwork
();
ContactNetwork
&
contactNetwork
=
blocksFactory
.
contactNetwork
();
...
@@ -165,14 +171,14 @@ int main(int argc, char *argv[]) {
...
@@ -165,14 +171,14 @@ int main(int argc, char *argv[]) {
const
auto
&
level
=
*
contactNetwork
.
level
(
i
);
const
auto
&
level
=
*
contactNetwork
.
level
(
i
);
for
(
size_t
j
=
0
;
j
<
level
.
nBodies
();
j
++
)
{
//
for (size_t j=0; j<level.nBodies(); j++) {
//writeToVTK(level.body(j)->gridView(), "../debug_print/bodies/", "body_" + std::to_string(j) + "_level_" + std::to_string(i));
//writeToVTK(level.body(j)->gridView(), "../debug_print/bodies/", "body_" + std::to_string(j) + "_level_" + std::to_string(i));
}
//
}
}
}
for
(
size_t
i
=
0
;
i
<
bodyCount
;
i
++
)
{
//
for (size_t i=0; i<bodyCount; i++) {
//writeToVTK(contactNetwork.body(i)->gridView(), "../debug_print/bodies/", "body_" + std::to_string(i) + "_leaf");
//writeToVTK(contactNetwork.body(i)->gridView(), "../debug_print/bodies/", "body_" + std::to_string(i) + "_leaf");
}
//
}
// ----------------------------
// ----------------------------
// assemble contactNetwork
// assemble contactNetwork
...
@@ -189,12 +195,12 @@ int main(int argc, char *argv[]) {
...
@@ -189,12 +195,12 @@ int main(int argc, char *argv[]) {
nVertices
[
i
]
=
contactNetwork
.
body
(
i
)
->
nVertices
();
nVertices
[
i
]
=
contactNetwork
.
body
(
i
)
->
nVertices
();
}
}
using
MyProgramState
=
ProgramState
<
Vector
,
ScalarVector
>
;
MyProgramState
programState
(
nVertices
);
MyProgramState
programState
(
nVertices
);
IO
Handler
<
Assembler
,
ContactNetwork
>
io
Handler
(
parset
.
sub
(
"io"
),
contactNetwork
);
io
Handler
=
std
::
make_unique
<
IO
Handler
>
(
parset
.
sub
(
"io"
),
contactNetwork
);
bool
restartRead
=
ioHandler
.
read
(
programState
);
bool
restartRead
=
ioHandler
->
read
(
programState
);
if
(
!
restartRead
)
{
if
(
!
restartRead
)
{
programState
.
setupInitialConditions
(
parset
,
contactNetwork
);
programState
.
setupInitialConditions
(
parset
,
contactNetwork
);
}
}
...
@@ -384,7 +390,7 @@ int main(int argc, char *argv[]) {
...
@@ -384,7 +390,7 @@ int main(int argc, char *argv[]) {
IterationRegister
iterationCount
;
IterationRegister
iterationCount
;
ioHandler
.
write
(
programState
,
contactNetwork
,
globalFriction
,
iterationCount
,
true
);
ioHandler
->
write
(
programState
,
contactNetwork
,
globalFriction
,
iterationCount
,
true
);
// -------------------
// -------------------
// Set up TNNMG solver
// Set up TNNMG solver
...
@@ -494,7 +500,7 @@ int main(int argc, char *argv[]) {
...
@@ -494,7 +500,7 @@ int main(int argc, char *argv[]) {
contactNetwork
.
setDeformation
(
programState
.
u
);
contactNetwork
.
setDeformation
(
programState
.
u
);
ioHandler
.
write
(
programState
,
contactNetwork
,
globalFriction
,
iterationCount
,
false
);
ioHandler
->
write
(
programState
,
contactNetwork
,
globalFriction
,
iterationCount
,
false
);
if
(
programState
.
timeStep
==
timeSteps
)
{
if
(
programState
.
timeStep
==
timeSteps
)
{
std
::
cout
<<
"limit of timeSteps reached!"
<<
std
::
endl
;
std
::
cout
<<
"limit of timeSteps reached!"
<<
std
::
endl
;
...
@@ -516,5 +522,9 @@ int main(int argc, char *argv[]) {
...
@@ -516,5 +522,9 @@ int main(int argc, char *argv[]) {
Dune
::
derr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
Dune
::
derr
<<
"Dune reported error: "
<<
e
<<
std
::
endl
;
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
std
::
cerr
<<
"Standard exception: "
<<
e
.
what
()
<<
std
::
endl
;
std
::
cerr
<<
"Standard exception: "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
}
}
ioHandler
.
reset
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment