示例#1
0
double BGMBase::get_nodal_value(const MVertex *v,
                                const DoubleStorageType &data) const
{
  DoubleStorageType::const_iterator itfind = data.find(v);
  if(itfind == data.end()) {
    Msg::Error("Unknown vertex %d in BGMBase::get_nodal_value", v->getNum());
    return 0.;
  }
  return itfind->second;
}
示例#2
0
std::vector<double>
BGMBase::get_nodal_values(const MElement *element,
                          const DoubleStorageType &data) const
{
  std::vector<double> res(element->getNumVertices(), 0.);

  for(std::size_t i = 0; i < element->getNumVertices(); i++)
    // res[i] = (data.find(const_cast<MVertex*>(e->getVertex(i))))->second;
    res[i] = data.find(element->getVertex(i))->second;
  return res;
}
示例#3
0
void backgroundMesh2D::computeSizeField()
{
    GFace *face = dynamic_cast<GFace*>(gf);
    if(!face) {
        Msg::Error("Entity is not a face in background mesh");
        return;
    }

    list<GEdge*> e;
    replaceMeshCompound(face, e);
    list<GEdge*>::const_iterator it = e.begin();
    DoubleStorageType sizes;

    for( ; it != e.end(); ++it ) {
        if (!(*it)->isSeam(face)) {
            for(unsigned int i = 0; i < (*it)->lines.size(); i++ ) {
                MVertex *v1 = (*it)->lines[i]->getVertex(0);
                MVertex *v2 = (*it)->lines[i]->getVertex(1);
                if (v1 != v2) {
                    double d = sqrt((v1->x() - v2->x()) * (v1->x() - v2->x()) +
                                    (v1->y() - v2->y()) * (v1->y() - v2->y()) +
                                    (v1->z() - v2->z()) * (v1->z()  -v2->z()));
                    for (int k=0; k<2; k++) {
                        MVertex *v = (*it)->lines[i]->getVertex(k);
                        DoubleStorageType::iterator itv = sizes.find(v);
                        if (itv == sizes.end())
                            sizes[v] = log(d);
                        else
                            itv->second = 0.5 * (itv->second + log(d));
                    }
                }
            }
        }
    }

    simpleFunction<double> ONE(1.0);
    propagateValues(sizes,ONE);

    std::map<MVertex*,MVertex*>::iterator itv2 = _2Dto3D.begin();
    for ( ; itv2 != _2Dto3D.end(); ++itv2) {
        MVertex *v_2D = itv2->first;
        MVertex *v_3D = itv2->second;
        sizeField[v_2D] = exp(sizes[v_3D]);
    }
}