Foam::scalar Foam::equationReader::getScalarSrcEquation ( const equationReader * eqnReader, const label equationIndex, const label equationOperationIndex, const label maxStoreIndex, const label storageOffset ) const { const equation& eqn(operator[](equationIndex)); const equationOperation& eqOp(eqn[equationOperationIndex]); label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1; dependents_.setSize(dependents_.size() + 1); dependents_[dependents_.size() - 1] = equationIndex; // Launch the reportEmbeddedDispatchFunction: // if (debug) // { // reportEmbeddedDispatchEnabled; // // or: Info << "Embedded equation dispatch." << endl; // } // else // { // reportEmbeddedDispatchDisabled(); // // does nothing // } (*this.*reportEmbeddedDispatchFunction_)(); scalar returnMe ( internalEvaluateScalar(zeroSourceIndex, maxStoreIndex + 1) ); // Launch the reportEmbeddedReturnFunction: // if (debug) // { // reportEmbeddedReturnEnabled; // // or: Info << "Return from equation equation." << endl; // } // else // { // reportEmbeddedReturnDisabled(); // // does nothing // } (*this.*reportEmbeddedReturnFunction_)(); //Move one level back up on the dependents_ list if (dependents_.size()) { dependents_.setSize(dependents_.size() - 1); } returnMe *= sign(eqOp.sourceIndex()); return returnMe; }
Foam::scalar Foam::equationReader::evaluateScalar ( const label equationIndex, const label cellIndex, const label geoIndex ) const { # ifdef FULLDEBUG const equation& eqn(operator[](equationIndex)); // Index checking const labelList& maxFieldSizes(eqn.maxFieldSizes()); if ((geoIndex < 0) || (cellIndex < 0)) { FatalErrorIn("equationReader::evaluateScalar") << "Evaluating " << eqn.name() << ": geoIndex (" << geoIndex << ") or cellIndex (" << cellIndex << ") cannot be negative." << abort(FatalError); } else if (maxFieldSizes.size() > 0) { if (geoIndex >= maxFieldSizes.size()) { FatalErrorIn("equationReader::evaluateScalar") << "Evaluating " << eqn.name() << ": geoIndex (" << geoIndex << ") out of range (0 .. " << maxFieldSizes.size() - 1 << ")." << abort(FatalError); } else if (cellIndex >= maxFieldSizes[geoIndex]) { FatalErrorIn("equationReader::evaluateScalar") << "Evaluating " << eqn.name() << ": cellIndex (" << cellIndex << ") out of range (0 .. " << maxFieldSizes[geoIndex] - 1 << ")." << abort(FatalError); } } # endif cellIndex_ = cellIndex; geoIndex_ = geoIndex; return internalEvaluateScalar(equationIndex, 0); }
Foam::scalar Foam::equationReader::getScalarSrcEquationCircRefDetect ( const equationReader * eqnReader, const label equationIndex, const label equationOperationIndex, const label maxStoreIndex, const label storageOffset ) const { const equation& eqn(operator[](equationIndex)); equationOperation& eqOp(eqn[equationOperationIndex]); label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1; // Check for circular references dependents_.setSize(dependents_.size() + 1); dependents_[dependents_.size() - 1] = equationIndex; forAll(dependents_, i) { if (dependents_[i] == zeroSourceIndex) { // Circular reference detected string dependencies; for (label j(i); j < dependents_.size(); j++) { dependencies.append ( operator[](dependents_[j]).name() ); dependencies.append("-->"); } dependencies.append(operator[](dependents_[i]).name()); FatalErrorIn("equationReader::getScalarSrcEquationCircRefDetect") << "Circular reference detected when evaluating " << "the equation for " << eqn.name() << ", given by:" << token::NL << token::TAB << eqn.rawText() << token::NL << "The circular " << "dependency is:" << token::NL << token::TAB << dependencies << abort(FatalError); } } // Launch the reportEmbeddedDispatchFunction: // if (debug) // { // reportEmbeddedDispatchEnabled; // // or: Info << "Embedded equation dispatch." << endl; // } // else // { // reportEmbeddedDispatchDisabled(); // // does nothing // } scalar returnMe ( internalEvaluateScalar(zeroSourceIndex, maxStoreIndex + 1) ); eqOp.assignSourceScalarFunction ( &Foam::equationReader::getScalarSrcEquation ); eqOp.assignSourceScalarFieldFunction ( &Foam::equationReader::getScalarFieldSrcEquation ); // Launch the reportEmbeddedReturnFunction: // if (debug) // { // reportEmbeddedReturnEnabled; // // or: Info << "Return from equation equation." << endl; // } // else // { // reportEmbeddedReturnDisabled(); // // does nothing // } (*this.*reportEmbeddedReturnFunction_)(); //Move one level back up on the dependents_ list if (dependents_.size()) { dependents_.setSize(dependents_.size() - 1); } returnMe *= sign(eqOp.sourceIndex()); return returnMe; }