https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SolutionHandle.h
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
10#pragma once
11
12#include "SystemBase.h"
14#include "libmesh/system.h"
15#include "libmesh/enum_norm_type.h"
16#include "libmesh/petsc_vector.h"
17
22{
23public:
25 : _var(const_cast<MooseVariableFieldBase &>(variable)),
26 _soln(_var.sys().solution()),
27 _soln_old(_var.sys().solutionOld())
28 {
29 }
30
34 Number operator()(const Node * node) const
35 {
36 // The 0 assumes linear Lagrange (I think)
37 dof_id_type dof = node->dof_number(_var.sys().number(), _var.number(), 0);
38 return _soln(dof);
39 }
43 Number old(const Node * node) const
44 {
45 // The 0 assumes linear Lagrange (I think)
46 dof_id_type dof = node->dof_number(_var.sys().number(), _var.number(), 0);
47 return _soln_old(dof);
48 }
52 void set(const Node * node, Number val)
53 {
54 dof_id_type dof = node->dof_number(_var.sys().number(), _var.number(), 0);
55 _soln.set(dof, val);
56 }
57
58 Real L2norm() const
59 {
60 return _var.sys().system().calculate_norm(_soln, _var.number(), DISCRETE_L2);
61 }
62
63 void close() { _soln.close(); }
64
65private:
67 NumericVector<Number> & _soln;
68 const NumericVector<Number> & _soln_old;
69};
SystemBase & sys()
unsigned int number() const
Provide a simple RAII interface for linear lagrange solution variables.
MooseVariableFieldBase & _var
Real L2norm() const
Number old(const Node *node) const
Get a value from the old solution vector.
Number operator()(const Node *node) const
Get a value from the solution vector.
SolutionHandle(const MooseVariableFieldBase &variable)
NumericVector< Number > & _soln
void set(const Node *node, Number val)
Set a value in the solution vector.
const NumericVector< Number > & _soln_old
unsigned int number() const
virtual libMesh::System & system()=0
virtual void set(const numeric_index_type i, const T value)=0
virtual void close()=0
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const