parallelization-howto
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
parallelization-howto [2010/03/20 17:13] – bp | parallelization-howto [2012/12/17 19:39] (current) – [Example] mikael.ohman | ||
---|---|---|---|
Line 55: | Line 55: | ||
===== Example ===== | ===== Example ===== | ||
+ | Fist, we have to create an instance of // | ||
+ | <code cpp> | ||
+ | IRResultType | ||
+ | MyEngngModel :: initializeFrom(InputRecord *ir) | ||
+ | { | ||
+ | // problem specific part here | ||
+ | |||
+ | // initialize communicator if in parallel mode | ||
+ | #ifdef __PARALLEL_MODE | ||
+ | // first create send and receive communication buffers, here we use fix-length | ||
+ | // static buffers (CBT_static) (size needs to be determined) | ||
+ | commBuff = new CommunicatorBuff(this-> | ||
+ | // and create communicator, | ||
+ | communicator = new ProblemCommunicator(this, | ||
+ | | ||
+ | | ||
+ | |||
+ | #endif | ||
+ | } | ||
+ | </ | ||
+ | |||
Following method illustrates how the assembly method for vector (load vector) is changed to support parallel assembly. It uses communicator, | Following method illustrates how the assembly method for vector (load vector) is changed to support parallel assembly. It uses communicator, | ||
Line 77: | Line 98: | ||
#ifdef __PARALLEL_MODE | #ifdef __PARALLEL_MODE | ||
- | // parallel section (compiles only when --enable-poofem configure option used | + | // parallel section (compiles only when parallel support is configured) |
// pack all data, need to pass pointer to engngModel, local vector, and packing method | // pack all data, need to pass pointer to engngModel, local vector, and packing method | ||
// this will call pack method for each remote partition | // this will call pack method for each remote partition | ||
Line 181: | Line 202: | ||
</ | </ | ||
+ | Provided that the suitable sparse matrix representation is used (SMT_PetscMtrx, | ||
+ | <code cpp> | ||
+ | void | ||
+ | MyEngngModel :: solveYourselfAt(TimeStep *tStep) { | ||
+ | |||
+ | // create components of characteristic equation | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | // initialize profile of stiffness matrix | ||
+ | | ||
+ | |||
+ | // assemble stiffness and load vector | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | // get numerical method to solve the problem | ||
+ | | ||
+ | // solve the problem (yes, this solves linear system in parallel!) | ||
+ | | ||
+ | // postprocess results update nodes, elements, compute strains, stresses, etc | ||
+ | | ||
+ | // and we are done! | ||
+ | } | ||
+ | </ | ||
====== Further reading ====== | ====== Further reading ====== |
parallelization-howto.1269101635.txt.gz · Last modified: 2010/03/20 17:13 by bp