00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
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
00107
00108
00109
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 }
00119
00120 }
00121