Hello,

I'm trying to optimize the stitching_helper() function in SerialMesh, which
is currently a bottleneck in the work I'm doing (stitching together a large
number of small components to assemble a full mesh).

I've found out that over 85% of the running time of this function is
actually spent in UnstructuredMesh::find_neighbors(). This function is
called twice:
once through  UnstructuredMesh::copy_nodes_and_elements() and a second time
through a call to MeshBase::prepare_for_use().

The first call doesn't seem to be necessary, since removing works perfectly
fine and doesn't alter the solution of a subsequent solve, while decreasing
the stitching time by 40%.

Do you believe the other call to find_neighbors() could be avoided somehow
by manually performing the required actions directly in stitch_meshes()
with the information available there? Chances are this would dramatically
improve the efficiency of mesh stitching in libMesh.

Thanks,
Dana

PS: The attached file stitches three cubes and can be used to investigate
the question.
// C++ include files that we need
#include <iostream>
#include <sstream>
#include <ctime>
#include <cstdlib>

//Basic include file needed for the mesh functionality.
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#include "libmesh/gmv_io.h"
#include "libmesh/libmesh_logging.h"
#include "libmesh/getpot.h"

// Include file that defines various mesh generation utilities
#include "libmesh/mesh_generation.h"

// Bring in everything from the libMesh namespace
using namespace libMesh;

int main (int argc, char** argv)
{
  // Initialization
  LibMeshInit init (argc, argv);

  // Skip this 2D example if libMesh was compiled as 1D-only.
  libmesh_example_assert(3 <= LIBMESH_DIM, "3D support");

  // A brief message to the user to inform her of the
  // exact name of the program being run, and its command line.
  std::cout << "Running " << argv[0];
  for (int i=1; i<argc; i++)
    std::cout << " " << argv[i];
  std::cout << std::endl << std::endl;

  GetPot command_line (argc, argv);
  unsigned int n = 0;
  if ( command_line.search(1, "-n") )
    n = command_line.next(n);

  // Create 3 meshes, with dimensions to be overridden later, distributed
  // across the default MPI communicator.
  SerialMesh mesh0(init.comm());
  SerialMesh mesh1(init.comm());
  SerialMesh mesh2(init.comm());

  // Use the MeshTools::Generation mesh generator to create uniform
  // 3D grids: one unit cube on [0,1]^3, another one shifted by 1 in
  // the +X direction and a third one shifted by 1 in both +X and +Z
  // (L-shape)
  MeshTools::Generation::build_cube(mesh0, n, n, n, 0., 1., 0., 1., 0., 1.);  
  MeshTools::Generation::build_cube(mesh1, n, n, n, 1., 2., 0., 1., 0., 1.);
  MeshTools::Generation::build_cube(mesh2, n, n, n, 1., 2., 0., 1., 1., 2.);

  // Stitch the second cube to the first one and the third one to the first one as well using the N^2 method
  START_LOG("Stitching", "main");
  mesh0.stitch_meshes(mesh1, 2, 4, TOLERANCE); 
  mesh0.stitch_meshes(mesh2, 5, 0, TOLERANCE);
  STOP_LOG("Stitching", "main");
  
  // Save the mesh to disk
  GMVIO(mesh0).write("stitched_mesh.gmv");
  //mesh0.write("stitched_mesh.exo");
 

  return 0;   
}

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to