Skip to content
Snippets Groups Projects
Commit e7805b84 authored by podlesny's avatar podlesny
Browse files

move iohandler outside of try catch block

parent cc4001ad
No related branches found
No related tags found
No related merge requests found
......@@ -115,6 +115,14 @@ static std::atomic<bool> terminationRequested(false);
void handleSignal(int signum) { terminationRequested = true; }
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 {
Dune::MPIHelper::instance(argc, argv);
......@@ -141,15 +149,13 @@ int main(int argc, char *argv[]) {
std::streambuf *coutbuf = std::cout.rdbuf(); //save old buffer
std::cout.rdbuf(out.rdbuf()); //redirect std::cout to log.txt
using Assembler = MyAssembler<DefLeafGridView, dims>;
using field_type = Matrix::field_type;
// ----------------------
// set up contact network
// ----------------------
using BlocksFactory = TwoBlocksFactory<Grid, Vector>;
BlocksFactory blocksFactory(parset);
using ContactNetwork = typename BlocksFactory::ContactNetwork;
blocksFactory.build();
ContactNetwork& contactNetwork = blocksFactory.contactNetwork();
......@@ -165,14 +171,14 @@ int main(int argc, char *argv[]) {
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));
}
//}
}
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");
}
//}
// ----------------------------
// assemble contactNetwork
......@@ -189,12 +195,12 @@ int main(int argc, char *argv[]) {
nVertices[i] = contactNetwork.body(i)->nVertices();
}
using MyProgramState = ProgramState<Vector, ScalarVector>;
MyProgramState programState(nVertices);
IOHandler<Assembler, ContactNetwork> ioHandler(parset.sub("io"), contactNetwork);
ioHandler = std::make_unique<IOHandler>(parset.sub("io"), contactNetwork);
bool restartRead = ioHandler.read(programState);
bool restartRead = ioHandler->read(programState);
if (!restartRead) {
programState.setupInitialConditions(parset, contactNetwork);
}
......@@ -384,7 +390,7 @@ int main(int argc, char *argv[]) {
IterationRegister iterationCount;
ioHandler.write(programState, contactNetwork, globalFriction, iterationCount, true);
ioHandler->write(programState, contactNetwork, globalFriction, iterationCount, true);
// -------------------
// Set up TNNMG solver
......@@ -494,7 +500,7 @@ int main(int argc, char *argv[]) {
contactNetwork.setDeformation(programState.u);
ioHandler.write(programState, contactNetwork, globalFriction, iterationCount, false);
ioHandler->write(programState, contactNetwork, globalFriction, iterationCount, false);
if (programState.timeStep==timeSteps) {
std::cout << "limit of timeSteps reached!" << std::endl;
......@@ -516,5 +522,9 @@ int main(int argc, char *argv[]) {
Dune::derr << "Dune reported error: " << e << std::endl;
} catch (std::exception &e) {
std::cerr << "Standard exception: " << e.what() << std::endl;
} catch (...) {
}
ioHandler.reset();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment