void Database::initFacts(vector<Predicate> facts){ for(int i = 0; i < (int)facts.size(); i++){ Predicate r = facts[i]; string name = r.getID(); Tuple t; for(int j = 0; j < (int)r.getParameters().size(); j++) t.push_back(r.getParameters()[j].getValue()); addTuple(name, t); } }
ConstraintTree::ConstraintTree ( const LogVars& logVars, const Tuples& tuples) { root_ = new CTNode (0, 0); logVars_ = logVars; logVarSet_ = LogVarSet (logVars); for (size_t i = 0; i < tuples.size(); i++) { addTuple (tuples[i]); } }
/** * Linked List add method. * Adds the passed object pointer to the Linked List at position pos. **/ int LinkedList__add(LinkedList * ll,unsigned int pos,void * obj) { #ifdef DEBUG printf("LinkedList::LinkedList__add\t%u\t%u\t%u\n",ll,pos,obj); #endif if(pos > LinkedList__size(ll)) return ERROR_INDEX; addTuple(ll,pos,obj); #ifdef DEBUG printf("LinkedList::LinkedList__add\tadded: %u\n",obj); #endif return 0; };
//Add one layer of ghost elements void splitter::addLayer(const FEM_Ghost_Layer &g,const FEM_Partition &partition) { tupleTable table(g.nodesPerTuple); //Build table mapping node-tuples to lists of adjacent elements for (int t=0;t<mesh->elem.size();t++) if (mesh->elem.has(t)) { if (!g.elem[t].add) continue; //Don't add this kind of element to the layer //For every element of this type: int gElemCount=mesh->elem[t].size(); for (int gNo=0;gNo<gElemCount;gNo++) { const int *conn=mesh->elem[t].connFor(gNo); if (hasGhostNodes(conn,mesh->elem[t].getNodesPer())) { //Loop over this element's ghosts and tuples: for (chunkList *cur=&gElem[t][gNo];cur!=NULL;cur=cur->next) for (int u=0;u<g.elem[t].tuplesPerElem;u++) { int tuple[tupleTable::MAX_TUPLE]; FEM_Symmetries_t allSym; if (addTuple(tuple,&allSym, &g.elem[t].elem2tuple[u*g.nodesPerTuple], g.nodesPerTuple,conn)) { table.addTuple(tuple,new elemList(cur->chunk,cur->localNo,t,allSym)); } } } } } //Loop over all the tuples, connecting adjacent elements table.beginLookup(); elemList *l; while (NULL!=(l=table.lookupNext())) { if (l->next==NULL) //One-entry list: must be a symmetry addSymmetryGhost(*l); else { /* Several elements in list: normal case */ //Consider adding ghosts for all element pairs on this tuple: for (const elemList *a=l;a!=NULL;a=a->next) for (const elemList *b=l;b!=NULL;b=b->next) if (a!=b && a->localNo>=0) /* only add ghosts of real elements */ addGhostPair(*a,*b,g.addNodes); } } }
ConstraintTree::ConstraintTree (vector<vector<string>> names) { assert (names.empty() == false); assert (names.front().empty() == false); unsigned nrLvs = names[0].size(); for (size_t i = 0; i < nrLvs; i++) { logVars_.push_back (LogVar (i)); } root_ = new CTNode (0, 0); logVarSet_ = LogVarSet (logVars_); for (size_t i = 0; i < names.size(); i++) { Tuple t; for (size_t j = 0; j < names[i].size(); j++) { assert (names[i].size() == nrLvs); t.push_back (LiftedUtils::getSymbol (names[i][j])); } addTuple (t); } }