On Wed, 18 Jun 2008, John Peterson wrote:

We would need a little more info before we could say for sure.  I
don't think I've personally used grid2grid ever, and other than
maintenance I don't think Roy has either.  I'm pretty sure Ben is the
original author.  I think a few people have actually coded up what you
are trying to do with MeshFunction, see for example the
ExactErrorEstimator.

The code I've used is attached.  It's obviously not up to date (it
hasn't been modified at least since exceptions were added to libMesh
and we changed init() from a method to an object) but it may be in
better shape than grid2grid.
---
Roy
// Open the two solution files named on standard input, find all
// variables they have in common, and output the Hilbert norms of the
// differences between them.

#include "libmesh.h"

#include "mesh.h"
#include "equation_systems.h"
#include "exact_solution.h"

unsigned int dim = 2;

int main(int argc, char** argv)
{
  libMesh::init (argc, argv);
  {
    Mesh mesh1(dim), mesh2(dim);
    EquationSystems es1(mesh1), es2(mesh2);

    std::cout << "Usage: " << argv[0]
              << " coarsemesh coarsesolution finemesh finesolution" << 
std::endl;

    mesh1.read(argv[1]);
    std::cout << "Loaded mesh " << argv[1] << std::endl;
    es1.read(argv[2], libMeshEnums::READ);
    std::cout << "Loaded solution " << argv[2] << std::endl;
    mesh2.read(argv[3]);
    std::cout << "Loaded mesh " << argv[3] << std::endl;
    es2.read(argv[4], libMeshEnums::READ);
    std::cout << "Loaded solution " << argv[4] << std::endl;

    ExactSolution exact_sol(es1);
    exact_sol.attach_reference_solution(&es2);

    std::vector<std::string> sysnames;
    sysnames.reserve(es1.n_systems());

    for (unsigned int i = 0; i != es1.n_systems(); ++i)
      if (es2.has_system(es1.get_system(i).name()))
        sysnames.push_back(es1.get_system(i).name());

    for (unsigned int i = 0; i != sysnames.size(); ++i)
      {
        std::string sysname = sysnames[i];
        System &sys1 = es1.get_system(sysname);
        System &sys2 = es2.get_system(sysname);

        for (unsigned int j = 0; j != sys1.n_vars(); ++j)
          {
            std::string varname = sys1.variable_name(j);

            if (!sys2.has_variable(varname))
              continue;

            exact_sol.compute_error(sysname, varname);

            std::cout << "Errors in system " << sysname << ", variable " << 
varname << ":" << std::endl;
            std::cout << "L2 error: " << exact_sol.l2_error(sysname, varname) 
<< std::endl;
            std::cout << "H1 error: " << exact_sol.h1_error(sysname, varname) 
<< std::endl;
            std::cout << "H2 error: " << exact_sol.h2_error(sysname, varname) 
<< std::endl;
          }
      }
  }
  return libMesh::close();
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to