User Tools

Site Tools


parallelization-howto

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
parallelization-howto [2010/03/20 17:26] bpparallelization-howto [2012/12/17 19:39] (current) – [Example] mikael.ohman
Line 98: 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 202: Line 202:
  
 </code> </code>
 +Provided that the suitable sparse matrix representation is used (SMT_PetscMtrx, for example) and solver (ST_Petsc, for example), no modification to the sparse matrix assembly procedure and linear system solution is necessary. We can simply pass sparse matrix, local load vector, and solution vector to the solver and get results!
 +<code cpp>
 +void
 +MyEngngModel :: solveYourselfAt(TimeStep *tStep) {
 +
 +   // create components of characteristic equation
 +   stiffnessMatrix = CreateUsrDefSparseMtrx(sparseMtrxType);
 +   loadVector.resize(this->giveNumberOfEquations(EID_MomentumBalance));
 +   displacementVector.resize(this->giveNumberOfEquations(EID_MomentumBalance));
 +   loadVector.zero(); displacementVector.zero();
 +   
 +   // initialize profile of stiffness matrix
 +   stiffnessMatrix->buildInternalStructure(this, di, EID_MomentumBalance, EModelDefaultEquationNumbering());
 +   
 +   // assemble stiffness and load vector
 +   stiffnessMatrix->zero(); // zero stiffness matrix
 +   this->assemble( stiffnessMatrix, tStep, EID_MomentumBalance, ElasticStiffnessMatrix,
 +                   EModelDefaultEquationNumbering(), this->giveDomain(di) );
 +   this->assembleLoadVector (loadVector,this->giveDomain(di),
 +                             EID_MomentumBalance, tStep);                                 
 +                                    
 +   // get numerical method to solve the problem
 +   this->giveNumericalMethod(tStep);
 +   // solve the problem (yes, this solves linear system in parallel!)
 +   nMethod->solve(stiffnessMatrix, & loadVector, & displacementVector);
 +   // postprocess results update nodes, elements, compute strains, stresses, etc
 +   this->updateYourself( this->giveCurrentStep() );
 +   // and we are done!
 +}
 +</code> 
  
 ====== Further reading ====== ====== Further reading ======
parallelization-howto.1269102396.txt.gz · Last modified: 2010/03/20 17:26 by bp