LCOV - code coverage report
Current view: top level - src/multiapps - QuadraturePointMultiApp.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 33 35 94.3 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : // MOOSE includes
      11             : #include "QuadraturePointMultiApp.h"
      12             : #include "MooseMesh.h"
      13             : #include "FEProblem.h"
      14             : 
      15             : // libMesh includes
      16             : #include "libmesh/parallel_algebra.h"
      17             : #include "libmesh/mesh.h"
      18             : #include "libmesh/elem.h"
      19             : #include "libmesh/fe.h"
      20             : 
      21             : using namespace libMesh;
      22             : 
      23             : registerMooseObject("MooseApp", QuadraturePointMultiApp);
      24             : // TODO: Deprecate and use Positions system
      25             : 
      26             : InputParameters
      27       14289 : QuadraturePointMultiApp::validParams()
      28             : {
      29       14289 :   InputParameters params = TransientMultiApp::validParams();
      30       14289 :   params += BlockRestrictable::validParams();
      31       14289 :   params.addClassDescription(
      32             :       "Automatically generates sub-App positions from the elemental quadrature points, with the "
      33             :       "default quadrature, in the parent mesh.");
      34       14289 :   params.suppressParameter<std::vector<Point>>("positions");
      35       14289 :   params.suppressParameter<std::vector<FileName>>("positions_file");
      36       14289 :   params.suppressParameter<std::vector<PositionsName>>("positions_objects");
      37       14289 :   return params;
      38           0 : }
      39             : 
      40          12 : QuadraturePointMultiApp::QuadraturePointMultiApp(const InputParameters & parameters)
      41          12 :   : TransientMultiApp(parameters), BlockRestrictable(this)
      42             : {
      43          12 : }
      44             : 
      45             : void
      46          12 : QuadraturePointMultiApp::fillPositions()
      47             : {
      48          12 :   MooseMesh & main_mesh = _fe_problem.mesh();
      49          12 :   auto & mesh = main_mesh.getMesh();
      50         120 :   for (auto & elem : mesh.active_local_element_ptr_range())
      51             :   {
      52             :     // FEType is local to the element, supporting mixed order meshes
      53          54 :     const FEFamily mapping_family = FEMap::map_fe_type(*elem);
      54          54 :     FEType fe_type(elem->default_order(), mapping_family);
      55          54 :     const auto qrule = fe_type.default_quadrature_rule(elem->dim());
      56             : 
      57             :     // Build a Finite Element object of the specified type
      58          54 :     std::unique_ptr<FEBase> fe(FEBase::build(elem->dim(), fe_type));
      59             : 
      60             :     // Tell the finite element object to use our quadrature rule.
      61          54 :     fe->attach_quadrature_rule(qrule.get());
      62             : 
      63             :     // The physical XY locations of the quadrature points on the element.
      64             :     // These might be useful for evaluating spatially varying material
      65             :     // properties at the quadrature points.
      66          54 :     const std::vector<Point> & q_points = fe->get_xyz();
      67          54 :     fe->reinit(elem);
      68             : 
      69          54 :     if (hasBlocks(elem->subdomain_id()))
      70         270 :       for (const auto & q : q_points)
      71         216 :         _positions.push_back(q);
      72          66 :   }
      73             : 
      74             :   // Remove local duplicates from the vector of positions as transfers will not handle them
      75          12 :   std::sort(_positions.begin(), _positions.end());
      76          12 :   _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
      77             : 
      78             :   // Use the comm from the problem this MultiApp is part of
      79          12 :   libMesh::ParallelObject::comm().allgather(_positions);
      80             : 
      81             :   // Remove duplicates occurring at process boundaries
      82          12 :   std::sort(_positions.begin(), _positions.end());
      83          12 :   _positions.erase(std::unique(_positions.begin(), _positions.end()), _positions.end());
      84             : 
      85          12 :   if (_positions.empty())
      86           0 :     mooseError("No positions found for QuadraturePointMultiApp ", _name);
      87          12 : }

Generated by: LCOV version 1.14