https://mooseframework.inl.gov
Loading...
Searching...
No Matches
UpdateErrorVectorsThread.C
Go to the documentation of this file.
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
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)
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)
43 : ThreadedElementLoop<ConstElemRange>(x, 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
53void
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 // Must obey the block restriction of the indicator (error vector is global)
62 // we have to check here because the loop is over all indicators, and other indicators
63 // might have larger block restrictions.
64 if (_aux_sys.getVariable(_tid, var_num).hasBlocks(elem->subdomain_id()))
65 {
66 dof_id_type dof_number = elem->dof_number(_system_number, var_num, 0);
67 Real value = _solution(dof_number);
68 ev[elem->id()] = value;
69 }
70 else
71 ev[elem->id()] = 0;
72 }
73}
74
75void
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:91
Base class for assembly-like calculations.
NumericVector< Number > & _solution
UpdateErrorVectorsThread(FEProblemBase &fe_problem, const std::map< std::string, std::unique_ptr< libMesh::ErrorVector > > &indicator_field_to_error_vector)
std::map< unsigned int, libMesh::ErrorVector * > _indicator_field_number_to_error_vector
Map from indicator variable number to error vectors (markers solution vector)
void join(const UpdateErrorVectorsThread &)
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange