www.mooseframework.org
UpdateErrorVectorsThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 
12 // MOOSE includes
13 #include "AuxiliarySystem.h"
14 #include "FEProblem.h"
15 #include "Marker.h"
16 #include "MooseVariableFE.h"
17 #include "Problem.h"
18 
19 #include "libmesh/threads.h"
20 #include "libmesh/error_vector.h"
21 
23  FEProblemBase & fe_problem,
24  const std::map<std::string, std::unique_ptr<ErrorVector>> & indicator_field_to_error_vector)
25  : ThreadedElementLoop<ConstElemRange>(fe_problem),
26  _indicator_field_to_error_vector(indicator_field_to_error_vector),
27  _aux_sys(fe_problem.getAuxiliarySystem()),
28  _system_number(_aux_sys.number()),
29  _adaptivity(fe_problem.adaptivity()),
30  _solution(_aux_sys.solution())
31 {
32  // Build up this map once so we don't have to do these lookups over and over again
33  for (const auto & it : _indicator_field_to_error_vector)
34  {
35  unsigned int var_num = _aux_sys.getVariable(0, it.first).number();
36  _indicator_field_number_to_error_vector.emplace(var_num, it.second.get());
37  }
38 }
39 
40 // Splitting Constructor
42  Threads::split split)
44  _indicator_field_to_error_vector(x._indicator_field_to_error_vector),
45  _aux_sys(x._aux_sys),
46  _system_number(x._system_number),
47  _adaptivity(x._adaptivity),
48  _solution(x._solution),
49  _indicator_field_number_to_error_vector(x._indicator_field_number_to_error_vector)
50 {
51 }
52 
53 void
55 {
56  for (const auto & it : _indicator_field_number_to_error_vector)
57  {
58  unsigned int var_num = it.first;
59  ErrorVector & ev = *(it.second);
60 
61  dof_id_type dof_number = elem->dof_number(_system_number, var_num, 0);
62  Real value = _solution(dof_number);
63  ev[elem->id()] = value;
64  }
65 }
66 
67 void
69 {
70 }
Base class for assembly-like calculations.
unsigned int number() const
Get variable number coming from libMesh.
NumericVector< Number > & _solution
void join(const UpdateErrorVectorsThread &)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
UpdateErrorVectorsThread(FEProblemBase &fe_problem, const std::map< std::string, std::unique_ptr< ErrorVector >> &indicator_field_to_error_vector)
tbb::split split
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::map< std::string, std::unique_ptr< ErrorVector > > & _indicator_field_to_error_vector
std::map< unsigned int, ErrorVector * > _indicator_field_number_to_error_vector
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:86
uint8_t dof_id_type