Example #1
0
// function used to combine the contributions from solution components to the total error 
double error_total( double (*efn)(MeshFunction*, MeshFunction*, RefMap*, RefMap*), 
                    double (*nfn)(MeshFunction*, RefMap*), 
                    Hermes::vector<Solution*>& slns1, 
                    Hermes::vector<Solution*>& slns2 )
{
  double error = 0.0, norm = 0.0;

  std::vector<Solution*>::iterator it1, it2;
  for (it1=slns1.begin(), it2=slns2.begin(); it1 < slns1.end(); it1++, it2++) {
    assert(it2 < slns2.end());
    error += sqr(calc_abs_error(efn, *it1, *it2));
    if (nfn) norm += sqr(calc_norm(nfn, *it2));
  }
  
  /* Alternatively, without iterators:
  double error = 0.0, norm = 0.0;

  for (int i=0; i < slns1.size(); i++) {
    error += sqr(calc_abs_error(efn, slns1[i], slns2[i]));
    if (nfn) norm += sqr(calc_norm(nfn, slns2[i]));
  }
  */

  return (nfn ? sqrt(error/norm) : sqrt(error));
}
    void EssentialBCs<Scalar>::add_boundary_conditions(Hermes::vector<EssentialBoundaryCondition<Scalar> *> boundary_conditions)
    {
      for(typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::iterator it = boundary_conditions.begin(); it != boundary_conditions.end(); it++)
        all.push_back(*it);

      this->markers.clear();
      create_marker_cache();
    }
Example #3
0
 void NeighborSearch<Scalar>::Transformations::apply_on(const Hermes::vector<Transformable*>& tr) const
 {
   for(Hermes::vector<Transformable*>::const_iterator it = tr.begin(); it != tr.end(); ++it)
     for(unsigned int i = 0; i < num_levels; i++)
       (*it)->push_transform(transf[i]);
 }