void Foam::equationReader::evaluateTypeField
(
    Field<Type>& resultField,
    const word& componentName,
    const word& equationName,
    const label geoIndex
) const
{
    // Get equationIndex
    label equationIndex(lookup(equationName));
    if (equationIndex < 0)
    {
        FatalErrorIn("equationReader::evaluateTypeField")
            << "Equation name " << equationName << " not found."
            << abort(FatalError);
    }

    // Get componentIndex
    Type dummy;
    label componentIndex(-1);
    forAll(dummy, i)
    {
        if (Type::componentNames[i] == componentName)
        {
            componentIndex = i;
            break;
        }
    }
    if (componentIndex < 0)
    {
        wordList validNames(dummy.size());
        forAll(dummy, i)
        {
            validNames[i] = Type::componentNames[i];
        }
Esempio n. 2
0
 void LazyConstraintCallback::separateConnectedComponents( Graph          const & g
                                                         , GraphVariables const & vars
                                                         , Graph::Node    const & root
                                                         , NodeSetVector  const & nonZeroNodesComponents
                                                         , int                  & nCuts
                                                         ) {
   IloExpr rhs( getEnv() );

   for ( const NodeSet& S : nonZeroNodesComponents ) {
     // only consider the non-zero components that don't contain the root
     auto it = S.find( root );
     if ( it == S.end() || it->componentIndex() != root.componentIndex() ) {
       // determine dS
       NodeSet dS;
       for ( Graph::Node i : S ) {
         for ( Graph::Edge e : g.incEdges( i ) ) {
           Graph::Node j = g.oppositeNode( i, e );
           if ( S.find( j ) == S.end() )
           {
             dS.insert( j );
           }
         }
       }

       constructRHS( vars, dS, S, rhs );
       for ( Graph::Node i : S ) {
         assert( isValid( g, i, dS, S ) );
         add( vars.xVars[vars.nodeToIndex[i]] <= rhs, IloCplex::UseCutPurge ).end();
         ++nCuts;
       }
     }
   }

   rhs.end();
 }