Foam::polyPatch::polyPatch ( const word& name, const label size, const label start, const label index, const polyBoundaryMesh& bm, const word& patchType ) : patchIdentifier(name, index), primitivePatch ( faceSubList(bm.mesh().faces(), size, start), bm.mesh().points() ), start_(start), boundaryMesh_(bm), faceCellsPtr_(NULL), gpuFaceCells(), mePtr_(NULL) { if ( patchType != word::null && constraintType(patchType) && findIndex(inGroups(), patchType) == -1 ) { inGroups().append(patchType); } }
Foam::polyPatch::polyPatch ( const word& name, const dictionary& dict, const label index, const polyBoundaryMesh& bm, const word& patchType ) : patchIdentifier(name, dict, index), primitivePatch ( faceSubList ( bm.mesh().faces(), readLabel(dict.lookup("nFaces")), readLabel(dict.lookup("startFace")) ), bm.mesh().points() ), start_(readLabel(dict.lookup("startFace"))), boundaryMesh_(bm), faceCellsPtr_(NULL), mePtr_(NULL) { if ( patchType != word::null && constraintType(patchType) && findIndex(inGroups(), patchType) == -1 ) { inGroups().append(patchType); } }
Foam::wordList Foam::polyPatch::constraintTypes() { wordList cTypes(dictionaryConstructorTablePtr_->size()); label i = 0; for ( dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->begin(); cstrIter != dictionaryConstructorTablePtr_->end(); ++cstrIter ) { if (constraintType(cstrIter.key())) { cTypes[i++] = cstrIter.key(); } } cTypes.setSize(i); return cTypes; }
ProblemInstance::ProblemInstance (RPHandle hndl, SharedPtr<ReaderPluginFunctionTable> functions) : handle(hndl), ftable(functions) { int i; m_variables = ftable->variables(handle); m_constraints = ftable->constraints(handle); m_objectives = ftable->objectives(handle); m_variableTypes = new char[variables()+2*constraints()+2*objectives()]; m_functionTypes = &m_variableTypes[variables()]; m_constraintTypes = &m_functionTypes[constraints()+objectives()]; m_objectiveTypes = &m_constraintTypes[constraints()]; for (i = 0; i < variables(); ++i) { m_variableTypes[i] = ftable->variableType(handle, i); } for (i = 0; i < constraints(); ++i) { m_functionTypes[i] = ftable->functionType(handle, 'c', i); } for (i = 0; i < objectives(); ++i) { m_functionTypes[constraints()+i] = ftable->functionType(handle, 'o', i); } for (i = 0; i < constraints(); ++i) { m_constraintTypes[i] = ftable->constraintType(handle, i); } for (i = 0; i < objectives(); ++i) { m_objectiveTypes[i] = ftable->objectiveType(handle, i); } int* tmp = new int[std::max(objectives()+constraints()+2, variables())]; m_presenceIndexes = new unsigned[2*variables()+constraints()+objectives()]; for (i = 0; i < variables(); ++i) { ftable->variablePresence(handle, i, tmp, &tmp[constraints()]); m_presences.reserve(m_presences.size()+2+tmp[0]+tmp[constraints()]); varConstrPresenceIndex(i) = m_presences.size(); m_presences.insert(m_presences.end(), tmp, &tmp[tmp[0]+1]); varObjPresenceIndex(i) = m_presences.size(); m_presences.insert(m_presences.end(), &tmp[constraints()], &tmp[constraints()+tmp[constraints()]+1]); } m_variableCounts = new int[4*(constraints()+objectives())]; std::fill(m_variableCounts, &m_variableCounts[4*(constraints()+objectives())], 0); for (i = 0; i < constraints(); ++i) { int vars = ftable->constraintVariables(handle, i, tmp); m_presences.reserve(m_presences.size()+1+vars); constraintPresenceIndex(i) = m_presences.size(); m_presences.push_back(vars); m_presences.insert(m_presences.end(), tmp, &tmp[vars]); unsigned offset = 4*i; m_variableCounts[offset] = vars; for (int j = 0; j < vars; ++j) { switch (variableType(tmp[j])) { case 'r': ++m_variableCounts[offset+1]; break; case 'b': ++m_variableCounts[offset+2]; break; case 'i': ++m_variableCounts[offset+3]; break; } } } for (i = 0; i < objectives(); ++i) { int vars = ftable->objectiveVariables(handle, i, tmp); m_presences.reserve(m_presences.size()+1+vars); objectivePresenceIndex(i) = m_presences.size(); m_presences.push_back(vars); m_presences.insert(m_presences.end(), tmp, &tmp[vars]); unsigned offset = 4*(constraints()+i); m_variableCounts[offset] = vars; for (int j = 0; j < vars; ++j) { switch (variableType(tmp[j])) { case 'r': ++m_variableCounts[offset+1]; break; case 'b': ++m_variableCounts[offset+2]; break; case 'i': ++m_variableCounts[offset+3]; break; } } } delete [] tmp; m_varBounds = new Real[2*(variables()+constraints())]; m_constrBounds = &m_varBounds[2*variables()]; for (i = 0; i < variables(); ++i) { ftable->variableBounds(handle, i, &m_varBounds[2*i], &m_varBounds[2*i+1]); } for (i = 0; i < constraints(); ++i) { ftable->constraintBounds(handle, i, &m_constrBounds[2*i], &m_constrBounds[2*i+1]); switch (constraintType(i)) { case 'l': m_constrBounds[2*i] = -std::numeric_limits<Real>::infinity(); break; case 'g': m_constrBounds[2*i+1] = std::numeric_limits<Real>::infinity(); break; case 'e': m_constrBounds[2*i] = m_constrBounds[2*i+1]; break; case 'u': m_constrBounds[2*i] = -std::numeric_limits<Real>::infinity(); m_constrBounds[2*i+1] = std::numeric_limits<Real>::infinity(); break; default: break; } } latestErrorType = 0; }