www.mooseframework.org
MutableCoefficientsInterface.h
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 
10 #pragma once
11 
12 #include <vector>
13 
14 #include "InputParameters.h"
15 #include "MooseTypes.h"
16 #include "Restartable.h"
17 
19 class ConsoleStream;
20 
21 template <>
23 
30 class MutableCoefficientsInterface : public Restartable
31 {
32 public:
33  MutableCoefficientsInterface(const MooseObject * moose_object,
34  const InputParameters & parameters);
35 
36  // Coefficient access
40  Real operator[](std::size_t index) const;
44  const std::vector<std::size_t> & getCharacteristics() const;
48  const std::vector<Real> & getCoefficients() const;
52  std::vector<Real> & getCoefficients();
56  std::string getCoefficientsTable() const;
57 
58  // Current state
62  std::size_t getSize() const;
66  bool isCompatibleWith(const MutableCoefficientsInterface & other) const;
70  bool isSizeEnforced() const;
74  void enforceSize(bool enforce);
75 
76  // Mutable aspect
84  void resize(std::size_t size, Real fill = 0.0, bool fill_out_to_size = true);
88  void setCharacteristics(const std::vector<std::size_t> & new_characteristics);
92  void setCoefficients(const std::vector<Real> & new_coefficients);
96  void setCoefficients(std::vector<Real> && dropin_coefficients);
97 
101  friend std::ostream & operator<<(std::ostream & stream, const MutableCoefficientsInterface & me);
102 
103 protected:
107  virtual void coefficientsChanged(){};
108 
110  std::vector<std::size_t> & _characteristics;
111 
113  std::vector<Real> & _coefficients;
114 
117 
120 
121 private:
123  const ConsoleStream & _console;
124 };
125 
MutableCoefficientsInterface::getCharacteristics
const std::vector< std::size_t > & getCharacteristics() const
Get a reference to the characteristics array.
Definition: MutableCoefficientsInterface.C:51
MutableCoefficientsInterface::_print_coefficients
const bool _print_coefficients
Boolean to flag if the coefficients should be printed when set.
Definition: MutableCoefficientsInterface.h:119
MutableCoefficientsInterface::setCharacteristics
void setCharacteristics(const std::vector< std::size_t > &new_characteristics)
Sets the characteristics array.
Definition: MutableCoefficientsInterface.C:149
MutableCoefficientsInterface::resize
void resize(std::size_t size, Real fill=0.0, bool fill_out_to_size=true)
Resize the array, using the value for fill if the new size is larger.
Definition: MutableCoefficientsInterface.C:131
MutableCoefficientsInterface::_console
const ConsoleStream & _console
MooseObject instance of this to provide access to _console
Definition: MutableCoefficientsInterface.h:123
MutableCoefficientsInterface::importCoefficients
void importCoefficients(const MutableCoefficientsInterface &other)
Import the coefficients from another instance.
Definition: MutableCoefficientsInterface.C:117
MutableCoefficientsInterface::getCoefficients
const std::vector< Real > & getCoefficients() const
Get a read-only reference to the vector of coefficients.
Definition: MutableCoefficientsInterface.C:57
MutableCoefficientsInterface::_coefficients
std::vector< Real > & _coefficients
The coefficient array.
Definition: MutableCoefficientsInterface.h:113
MutableCoefficientsInterface::_characteristics
std::vector< std::size_t > & _characteristics
An array of integer characteristics that can be used to check compatibility.
Definition: MutableCoefficientsInterface.h:107
MutableCoefficientsInterface::getCoefficientsTable
std::string getCoefficientsTable() const
Get a formatted string of the coefficients.
Definition: MutableCoefficientsInterface.C:69
MutableCoefficientsInterface::getSize
std::size_t getSize() const
Get the size, aka number of coefficients.
Definition: MutableCoefficientsInterface.C:80
MutableCoefficientsInterface::operator<<
friend std::ostream & operator<<(std::ostream &stream, const MutableCoefficientsInterface &me)
Friend operator to easily print out the array of coefficients.
Definition: MutableCoefficientsInterface.C:186
validParams< MutableCoefficientsInterface >
InputParameters validParams< MutableCoefficientsInterface >()
Definition: MutableCoefficientsInterface.C:19
MutableCoefficientsInterface::enforceSize
void enforceSize(bool enforce)
Toggle whether the size of the coefficient array can be changed.
Definition: MutableCoefficientsInterface.C:111
MutableCoefficientsInterface::coefficientsChanged
virtual void coefficientsChanged()
Called when the coefficients have been changed.
Definition: MutableCoefficientsInterface.h:107
MutableCoefficientsInterface::operator[]
Real operator[](std::size_t index) const
Get the value of the coefficient at the corresponding index.
Definition: MutableCoefficientsInterface.C:45
MutableCoefficientsInterface::setCoefficients
void setCoefficients(const std::vector< Real > &new_coefficients)
Set the coefficients using a copy operation.
Definition: MutableCoefficientsInterface.C:156
MutableCoefficientsInterface::MutableCoefficientsInterface
MutableCoefficientsInterface(const MooseObject *moose_object, const InputParameters &parameters)
Definition: MutableCoefficientsInterface.C:31
MutableCoefficientsInterface
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
Definition: MutableCoefficientsInterface.h:30
MutableCoefficientsInterface::isCompatibleWith
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
Definition: MutableCoefficientsInterface.C:86
MutableCoefficientsInterface::isSizeEnforced
bool isSizeEnforced() const
Returns true if the size of the coefficient array is fixed and enforced.
Definition: MutableCoefficientsInterface.C:105
MutableCoefficientsInterface::_enforce_size
bool _enforce_size
Boolean that locks or allows resizing of the coefficient array.
Definition: MutableCoefficientsInterface.h:116