-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMainKratos.py
32 lines (23 loc) · 1.18 KB
/
MainKratos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7
import KratosMultiphysics
from KratosMultiphysics.FluidDynamicsApplication.fluid_dynamics_analysis import FluidDynamicsAnalysis
import sys
import time
class FluidDynamicsAnalysisWithFlush(FluidDynamicsAnalysis):
def __init__(self,model,project_parameters,flush_frequency=10.0):
super(FluidDynamicsAnalysisWithFlush,self).__init__(model,project_parameters)
self.flush_frequency = flush_frequency
self.last_flush = time.time()
def FinalizeSolutionStep(self):
super(FluidDynamicsAnalysisWithFlush,self).FinalizeSolutionStep()
if self.parallel_type == "OpenMP":
now = time.time()
if now - self.last_flush > self.flush_frequency:
sys.stdout.flush()
self.last_flush = now
if __name__ == "__main__":
with open("ProjectParameters.json",'r') as parameter_file:
parameters = KratosMultiphysics.Parameters(parameter_file.read())
model = KratosMultiphysics.Model()
simulation = FluidDynamicsAnalysisWithFlush(model,parameters)
simulation.Run()