MechanicalMatrixVisitor.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #include <sofa/simulation/common/MechanicalMatrixVisitor.h>
00026 #include <sofa/simulation/common/Node.h>
00027 #include <iostream>
00028 using std::cerr;
00029 using std::endl;
00030 
00031 namespace sofa
00032 {
00033 
00034 namespace simulation
00035 {
00036 
00037 
00038 Visitor::Result MechanicalMatrixVisitor::processNodeTopDown(simulation::Node* node)
00039 {
00040     Result res = RESULT_CONTINUE;
00041     
00042 
00043     for (unsigned i=0; i<node->solver.size() && res!=RESULT_PRUNE; i++ ) {
00044       ctime_t t0 = begin(node, node->solver[i]);
00045       res = this->fwdOdeSolver(node, node->solver[i]);
00046       end(node, node->solver[i], t0);
00047     }
00048     if (res != RESULT_PRUNE) {
00049         if (node->mechanicalState != NULL) {
00050             if (node->mechanicalMapping != NULL) {
00051                 //cerr<<"MechanicalAction::processNodeTopDown, node "<<node->getName()<<" is a mapped model"<<endl;
00052                 Result res2;
00053                 ctime_t t0 = begin(node, node->mechanicalMapping);
00054                 res = this->fwdMechanicalMapping(node, node->mechanicalMapping);
00055                 end(node, node->mechanicalMapping, t0);
00056                 t0 = begin(node, node->mechanicalState);
00057                 res2 = this->fwdMappedMechanicalState(node, node->mechanicalState);
00058                 end(node, node->mechanicalState, t0);
00059                 if (res2 == RESULT_PRUNE)
00060                         res = res2;
00061             } else {
00062                 //cerr<<"MechanicalAction::processNodeTopDown, node "<<node->getName()<<" is a no-map model"<<endl;
00063                 ctime_t t0 = begin(node, node->mechanicalState);
00064                 res = this->fwdMechanicalState(node, node->mechanicalState);
00065                 end(node, node->mechanicalState, t0);
00066             }
00067         }
00068     }
00069     if (res != RESULT_PRUNE) {
00070         if (node->mass != NULL) {
00071             ctime_t t0 = begin(node, node->mass);
00072             res = this->fwdMass(node, node->mass);
00073             end(node, node->mass, t0);
00074         }
00075     }
00076     if (res != RESULT_PRUNE) {
00077         res = for_each_r(this, node, node->forceField, &MechanicalMatrixVisitor::fwdForceField);
00078     }
00079     if (res != RESULT_PRUNE) {
00080         res = for_each_r(this, node, node->interactionForceField, &MechanicalMatrixVisitor::fwdInteractionForceField);
00081     }
00082     if (res != RESULT_PRUNE) {
00083         res = for_each_r(this, node, node->constraint, &MechanicalMatrixVisitor::fwdConstraint);
00084     }
00085 
00086     offsetOnEnter = offsetOnExit;
00087     return res;
00088 }
00089 
00090 void MechanicalMatrixVisitor::processNodeBottomUp(simulation::Node* node)
00091 {
00092     if (node->mechanicalState != NULL) {
00093         if (node->mechanicalMapping != NULL) {
00094             ctime_t t0 = begin(node, node->mechanicalState);
00095             this->bwdMappedMechanicalState(node, node->mechanicalState);
00096             end(node, node->mechanicalState, t0);
00097             t0 = begin(node, node->mechanicalMapping);
00098             this->bwdMechanicalMapping(node, node->mechanicalMapping);
00099             end(node, node->mechanicalMapping, t0);
00100         } else {
00101             ctime_t t0 = begin(node, node->mechanicalState);
00102             this->bwdMechanicalState(node, node->mechanicalState);
00103             end(node, node->mechanicalState, t0);
00104         }
00105     }
00106 /*    if (node->solver != NULL) {
00107         ctime_t t0 = begin(node, node->solver);
00108         this->bwdOdeSolver(node, node->solver);
00109         end(node, node->solver, t0);
00110     }*/
00111         for (unsigned i=0; i<node->solver.size(); i++ ) {
00112           ctime_t t0 = begin(node, node->solver[i]);
00113           this->bwdOdeSolver(node, node->solver[i]);
00114           end(node, node->solver[i], t0);
00115         }
00116 }
00117 
00118 } // namespace simulation
00119 
00120 } // namespace sofa
00121 

Generated on Sun Nov 23 04:05:46 2008 for Sofa by  doxygen 1.5.7.1