UltraScan III
us_thread_worker.cpp
Go to the documentation of this file.
1 #include "us_thread_worker.h"
3 #include "us_util.h"
4 #include "us_settings.h"
5 #include "us_astfem_math.h"
6 #include "us_astfem_rsa.h"
7 #include "us_lamm_astfvm.h"
8 #include "us_model.h"
9 #include "us_sleep.h"
10 #include "us_math2.h"
11 #include "us_constants.h"
12 #include "us_memory.h"
13 
14 
15 // Construct worker thread
17  US_DataIO::RawData& simda, US_Buffer& a_buff, int thr )
18  : QObject(), model( a_model ), simparams( params ),
19  simdat( simda ), buffer( a_buff )
20 {
21  thrn = thr;
23 DbgLv(1) << "THRWRK: Thread created" << thrn;
24 }
25 
26 
27 // Do the real work of a thread: simulation solution from model
29 {
30 DbgLv(1) << "THRWRK:CLCRES threadid" << QThread::currentThreadId();
31 DbgLv(1) << " THRWRK:" << thrn << "simdat scans radii"
32  << simdat.scanData.size() << simdat.xvalues.size();
33 DbgLv(1) << " THRWRK:" << thrn << "model components"
34  << model.components.size();
35 DbgLv(1) << " THRWRK:" << thrn << "model-0 s k" << model.components[0].s*1.e13
36  << model.components[0].f_f0;
37  double compress = buffer.compressibility;
38 
39  if ( model.components[ 0 ].sigma == 0.0 &&
40  model.components[ 0 ].delta == 0.0 &&
41  model.coSedSolute < 0.0 &&
42  compress == 0.0 )
43  {
44  US_Astfem_RSA* astfem_rsa = new US_Astfem_RSA( model, simparams );
45 
46  connect( astfem_rsa, SIGNAL( current_component( int ) ),
47  this, SLOT( forward_progress ( int ) ) );
48 
49 qint64 stim=QDateTime::currentDateTime().toMSecsSinceEpoch();
50 DbgLv(1) << " THRWRK:" << thrn << "calc START" << stim;
51  astfem_rsa->calculate( simdat );
52 qint64 etim=QDateTime::currentDateTime().toMSecsSinceEpoch();
53 DbgLv(1) << " THRWRK:" << thrn << "calc END" << etim;
54  }
55 
56  else
57  {
58  US_LammAstfvm *astfvm = new US_LammAstfvm( model, simparams );
59 
60  connect( astfvm, SIGNAL( comp_progress ( int ) ),
61  this, SLOT ( forward_progress( int ) ) );
62 
63  astfvm->set_buffer( buffer );
64  astfvm->calculate( simdat );
65  }
66 
67  emit work_complete( thrn );
68  qApp->processEvents();
69  return;
70 }
71 
72 // Slot to forward a progress signal
74 {
75  emit work_progress( thrn, steps );
76  qApp->processEvents();
77 qint64 etim=QDateTime::currentDateTime().toMSecsSinceEpoch();
78 DbgLv(1) << " THRWRK:" << thrn << " progress TM" << etim;
79 }
80