Giter VIP home page Giter VIP logo

Comments (6)

anne-glerum avatar anne-glerum commented on September 22, 2024

I'm going through all my notifications, so I'm randomly commenting here, but I just wanted to mention to @mfmweerdesteijn that if you only use a minimum refinement function and set Time steps between mesh refinement = 0, there will be no time-dependent mesh refinement, so you skip all that set up as well.

from aspect.

bangerth avatar bangerth commented on September 22, 2024

@tjhei When you say that it is easy to detect that the mesh didn't change, I assume that you want to loop over all cells and see whether any flags are actually set? And if the answer is no, just bail out of the mesh refinement function early?

from aspect.

bangerth avatar bangerth commented on September 22, 2024

In core.cc, we already have this in refine_mesh():

      exchange_refinement_flags();

      triangulation.prepare_coarsening_and_refinement();
      bool any_flags_set = false;
      {
        for (const auto &cell:dof_handler.active_cell_iterators())
          {
            if (cell->refine_flag_set() || cell->coarsen_flag_set())
              {
                any_flags_set = true;
                break;
              }
          }
      }
      const bool mesh_changed = Utilities::MPI::max(any_flags_set?1:0,mpi_communicator) == 1 ? true : false;
      if (!mesh_changed)
        {
          pcout << "Skipping mesh refinement, because the mesh did not change.\n" << std::endl;
          return;
        }

The only place where we do not have this check before execute_coarsening_and_refinement() is in the pre-refinement:

  template <int dim>
  void Simulator<dim>::run ()
  {
    CitationInfo::print_info_block(pcout);

    unsigned int max_refinement_level = parameters.initial_global_refinement +
                                        parameters.initial_adaptive_refinement;
    pre_refinement_step = 0;

    // if we want to resume a computation from an earlier point
    // then reload it from a snapshot. otherwise do the basic
    // start-up
    if (parameters.resume_computation == true)
      {
        resume_from_snapshot();
        // we need to remove additional_refinement_times that are in the past
        // and adjust max_refinement_level which is not written to file
        while ((parameters.additional_refinement_times.size() > 0)
               &&
               (parameters.additional_refinement_times.front () < time+time_step))
          {
            ++max_refinement_level;
            parameters.additional_refinement_times
            .erase (parameters.additional_refinement_times.begin());
          }
      }
    else
      {
        time = parameters.start_time;

        // Instead of calling global_refine(n) we flag all cells for
        // refinement and then allow the mesh refinement plugins to unflag
        // the cells if desired. This procedure is repeated n times. If there
        // is no plugin that modifies the flags, it is equivalent to
        // refine_global(n).
        for (unsigned int n=0; n<parameters.initial_global_refinement; ++n)
          {
            for (const auto &cell : triangulation.active_cell_iterators())
              if (cell->is_locally_owned())
                cell->set_refine_flag ();

            mesh_refinement_manager.tag_additional_cells ();

            exchange_refinement_flags();

            triangulation.execute_coarsening_and_refinement();
            if (MappingQCache<dim> *map = dynamic_cast<MappingQCache<dim>*>(&(*mapping)))
              map->initialize(MappingQGeneric<dim>(4), triangulation);
          }

        setup_dofs();

But here, we work only on the mesh. We haven't called setup_dofs() yet.

So I'm not sure where you think we would save much time.

from aspect.

mfmweerdesteijn avatar mfmweerdesteijn commented on September 22, 2024

From the point of view of the GIA application: I don't have boundary traction at t=0, but have at the following step. When using a free surface, and adaptive mesh refinement with the 'strain rate' strategy, the mesh will refine for t=0 quite randomly. When then boundary traction is applied, the more refined mesh area will move towards the region where boundary traction is applied. This initial, sort of random, mesh refinement where it is not necessary, is a waste of resources.

from aspect.

bangerth avatar bangerth commented on September 22, 2024

Perhaps, but the mesh changes and so we have to set up data structures for the new mesh.

The issue with the random mesh is due to the fact that the solution is initially the solution is very smooth, and so there is no "obvious" area to refine. Only once you applied a load does the solution change in a way that makes it obvious where refinement is necessary. I get that the initial steps are a waste of resources, but it's hard to avoid: What I suspect you want is that the mesh is refinement where it will need to be fine in the future, but it's of course hard to predict where that is going to be :-)

from aspect.

tjhei avatar tjhei commented on September 22, 2024

This can be closed I think, as I implemented it in #5070.

from aspect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.