www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SlopeLimitingMultiDBase Class Referenceabstract

Base class for multi-dimensional slope limiting to limit the slopes of cell average variables. More...

#include <SlopeLimitingMultiDBase.h>

Inheritance diagram for SlopeLimitingMultiDBase:
[legend]

Public Member Functions

 SlopeLimitingMultiDBase (const InputParameters &parameters)
 
virtual void initialize ()
 
virtual void finalize ()
 
virtual void computeElement ()
 
virtual const std::vector< RealGradient > & getElementSlope (dof_id_type elementid) const
 accessor function call More...
 
virtual std::vector< RealGradient > limitElementSlope () const =0
 compute the slope of the cell More...
 
virtual void execute ()
 
virtual void pre ()
 
virtual void onElement (const Elem *elem)
 
virtual void onBoundary (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 
virtual void onInternalSide (const Elem *elem, unsigned int side)
 
virtual void onInterface (const Elem *elem, unsigned int side, BoundaryID bnd_id)
 
virtual void post ()
 
virtual void subdomainChanged ()
 
virtual bool keepGoing ()
 
virtual void meshChanged ()
 
void join (const ElementLoopUserObject &)
 

Protected Member Functions

virtual void serialize (std::string &serialized_buffer)
 
virtual void deserialize (std::vector< std::string > &serialized_buffers)
 
virtual void caughtMooseException (MooseException &e)
 
virtual void computeBoundary ()
 
virtual void computeInternalSide ()
 
virtual void computeInterface ()
 

Protected Attributes

const SlopeReconstructionBase_rslope
 slope reconstruction user object More...
 
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
 store the updated slopes into this map indexed by element ID More...
 
const bool _include_bc
 option whether to include BCs More...
 
const MooseArray< Point > & _q_point_face
 required data for face assembly More...
 
QBase *& _qrule_face
 
const MooseArray< Real > & _JxW_face
 
const MooseArray< Point > & _normals_face
 
unsigned int & _side
 current side of the current element More...
 
const Elem *& _side_elem
 
const Real & _side_volume
 
const Elem *& _neighbor_elem
 the neighboring element More...
 
MooseMesh & _mesh
 
const Elem * _current_elem
 
const Real & _current_elem_volume
 
unsigned int _current_side
 
const Elem * _current_neighbor
 
const MooseArray< Point > & _q_point
 
QBase *& _qrule
 
const MooseArray< Real > & _JxW
 
const MooseArray< Real > & _coord
 
bool _have_interface_elems
 true if we have cached interface elements, false if they need to be cached. We want to (re)cache only when mesh changed More...
 
std::set< dof_id_type > _interface_elem_ids
 List of element IDs that are on the processor boundary and need to be send to other processors. More...
 
SubdomainID _subdomain
 The subdomain for the current element. More...
 
SubdomainID _old_subdomain
 The subdomain for the last element. More...
 

Detailed Description

Base class for multi-dimensional slope limiting to limit the slopes of cell average variables.

Definition at line 25 of file SlopeLimitingMultiDBase.h.

Constructor & Destructor Documentation

◆ SlopeLimitingMultiDBase()

SlopeLimitingMultiDBase::SlopeLimitingMultiDBase ( const InputParameters &  parameters)

Definition at line 27 of file SlopeLimitingMultiDBase.C.

28  : SlopeLimitingBase(parameters),
29  _rslope(getUserObject<SlopeReconstructionBase>("slope_reconstruction"))
30 {
31 }
SlopeLimitingBase(const InputParameters &parameters)
const SlopeReconstructionBase & _rslope
slope reconstruction user object

Member Function Documentation

◆ caughtMooseException()

void ElementLoopUserObject::caughtMooseException ( MooseException &  e)
protectedvirtualinherited

Definition at line 253 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

254 {
255  std::string what(e.what());
256  _fe_problem.setException(what);
257 }

◆ computeBoundary()

void ElementLoopUserObject::computeBoundary ( )
protectedvirtualinherited

Definition at line 231 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::onBoundary().

232 {
233 }

◆ computeElement()

void SlopeLimitingBase::computeElement ( )
virtualinherited

Reimplemented from ElementLoopUserObject.

Definition at line 70 of file SlopeLimitingBase.C.

71 {
72  dof_id_type _elementID = _current_elem->id();
73 
74  _lslope[_elementID] = limitElementSlope();
75 }
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
store the updated slopes into this map indexed by element ID
virtual std::vector< RealGradient > limitElementSlope() const =0
compute the slope of the cell

◆ computeInterface()

void ElementLoopUserObject::computeInterface ( )
protectedvirtualinherited

Definition at line 241 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::onInterface().

242 {
243 }

◆ computeInternalSide()

void ElementLoopUserObject::computeInternalSide ( )
protectedvirtualinherited

Definition at line 236 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::onInternalSide().

237 {
238 }

◆ deserialize()

void SlopeLimitingBase::deserialize ( std::vector< std::string > &  serialized_buffers)
protectedvirtualinherited

Definition at line 97 of file SlopeLimitingBase.C.

Referenced by SlopeLimitingBase::finalize().

98 {
99  // The input string stream used for deserialization
100  std::istringstream iss;
101 
102  mooseAssert(serialized_buffers.size() == _app.n_processors(),
103  "Unexpected size of serialized_buffers: " << serialized_buffers.size());
104 
105  for (auto rank = decltype(_app.n_processors())(0); rank < serialized_buffers.size(); ++rank)
106  {
107  if (rank == processor_id())
108  continue;
109 
110  iss.str(serialized_buffers[rank]); // populate the stream with a new buffer
111  iss.clear(); // reset the string stream state
112 
113  // Load the communicated data into all of the other processors' slots
114 
115  unsigned int size = 0;
116  iss.read((char *)&size, sizeof(size));
117 
118  for (unsigned int i = 0; i < size; i++)
119  {
120  dof_id_type key;
121  loadHelper(iss, key, this);
122 
123  std::vector<RealGradient> value;
124  loadHelper(iss, value, this);
125 
126  // merge the data we received from other procs
127  _lslope.insert(std::pair<dof_id_type, std::vector<RealGradient>>(key, value));
128  }
129  }
130 }
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
store the updated slopes into this map indexed by element ID

◆ execute()

void ElementLoopUserObject::execute ( )
virtualinherited

Definition at line 69 of file ElementLoopUserObject.C.

70 {
71  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
72 
73  try
74  {
75  pre();
76 
77  _subdomain = std::numeric_limits<SubdomainID>::max();
78  ConstElemRange::const_iterator el = elem_range.begin();
79  for (el = elem_range.begin(); el != elem_range.end(); ++el)
80  {
81  if (!keepGoing())
82  break;
83 
84  const Elem * elem = *el;
85  unsigned int cur_subdomain = elem->subdomain_id();
86 
88  _subdomain = cur_subdomain;
89 
90  if (this->hasBlocks(_subdomain))
91  {
94 
95  onElement(elem);
96 
97  for (unsigned int side = 0; side < elem->n_sides(); side++)
98  {
99  std::vector<BoundaryID> boundary_ids = _mesh.getBoundaryIDs(elem, side);
100 
101  if (boundary_ids.size() > 0)
102  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
103  it != boundary_ids.end();
104  ++it)
105  onBoundary(elem, side, *it);
106 
107  if (elem->neighbor(side) != NULL)
108  {
109  if (this->hasBlocks(elem->neighbor(side)->subdomain_id()))
110  onInternalSide(elem, side);
111  if (boundary_ids.size() > 0)
112  for (std::vector<BoundaryID>::iterator it = boundary_ids.begin();
113  it != boundary_ids.end();
114  ++it)
115  onInterface(elem, side, *it);
116  }
117  } // sides
118  }
119  } // range
120 
121  post();
122  }
123  catch (MooseException & e)
124  {
126  }
127 }
virtual void onInterface(const Elem *elem, unsigned int side, BoundaryID bnd_id)
virtual void onInternalSide(const Elem *elem, unsigned int side)
virtual void caughtMooseException(MooseException &e)
virtual void onBoundary(const Elem *elem, unsigned int side, BoundaryID bnd_id)
SubdomainID _subdomain
The subdomain for the current element.
virtual void onElement(const Elem *elem)
SubdomainID _old_subdomain
The subdomain for the last element.

◆ finalize()

void SlopeLimitingBase::finalize ( )
virtualinherited

Reimplemented from ElementLoopUserObject.

Definition at line 133 of file SlopeLimitingBase.C.

134 {
136 
137  if (_app.n_processors() > 1)
138  {
139  std::vector<std::string> send_buffers(1);
140  std::vector<std::string> recv_buffers;
141 
142  recv_buffers.reserve(_app.n_processors());
143  serialize(send_buffers[0]);
144  comm().allgather_packed_range((void *)(nullptr),
145  send_buffers.begin(),
146  send_buffers.end(),
147  std::back_inserter(recv_buffers));
148  deserialize(recv_buffers);
149  }
150 }
virtual void serialize(std::string &serialized_buffer)
virtual void deserialize(std::vector< std::string > &serialized_buffers)

◆ getElementSlope()

const std::vector< RealGradient > & SlopeLimitingBase::getElementSlope ( dof_id_type  elementid) const
virtualinherited

accessor function call

Definition at line 58 of file SlopeLimitingBase.C.

Referenced by AEFVMaterial::computeQpProperties().

59 {
60  Threads::spin_mutex::scoped_lock lock(_mutex);
61  std::map<dof_id_type, std::vector<RealGradient>>::const_iterator pos = _lslope.find(elementid);
62 
63  if (pos == _lslope.end())
64  mooseError("Limited slope is not cached for element id '", elementid, "' in ", __FUNCTION__);
65 
66  return pos->second;
67 }
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
store the updated slopes into this map indexed by element ID
static Threads::spin_mutex _mutex

◆ initialize()

void SlopeLimitingBase::initialize ( )
virtualinherited

Reimplemented from ElementLoopUserObject.

Definition at line 50 of file SlopeLimitingBase.C.

51 {
53 
54  _lslope.clear();
55 }
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
store the updated slopes into this map indexed by element ID

◆ join()

void ElementLoopUserObject::join ( const ElementLoopUserObject )
inherited

Definition at line 221 of file ElementLoopUserObject.C.

222 {
223 }

◆ keepGoing()

virtual bool ElementLoopUserObject::keepGoing ( )
inlinevirtualinherited

Definition at line 80 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::execute().

80 { return true; }

◆ limitElementSlope()

virtual std::vector<RealGradient> SlopeLimitingBase::limitElementSlope ( ) const
pure virtualinherited

compute the slope of the cell

Implemented in AEFVSlopeLimitingOneD.

Referenced by SlopeLimitingBase::computeElement().

◆ meshChanged()

void ElementLoopUserObject::meshChanged ( )
virtualinherited

Reimplemented in SlopeReconstructionBase.

Definition at line 246 of file ElementLoopUserObject.C.

Referenced by SlopeReconstructionBase::meshChanged().

247 {
248  _interface_elem_ids.clear();
249  _have_interface_elems = false;
250 }
std::set< dof_id_type > _interface_elem_ids
List of element IDs that are on the processor boundary and need to be send to other processors...
bool _have_interface_elems
true if we have cached interface elements, false if they need to be cached. We want to (re)cache only...

◆ onBoundary()

void ElementLoopUserObject::onBoundary ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

Definition at line 153 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

154 {
155  _current_side = side;
156  computeBoundary();
157 }

◆ onElement()

void ElementLoopUserObject::onElement ( const Elem *  elem)
virtualinherited

Definition at line 146 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

147 {
148  _current_elem = elem;
149  computeElement();
150 }

◆ onInterface()

void ElementLoopUserObject::onInterface ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id 
)
virtualinherited

Definition at line 188 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

189 {
190  _current_elem = elem;
191  // Pointer to the neighbor we are currently working on.
192  _current_neighbor = elem->neighbor(side);
193 
194  // Get the global id of the element and the neighbor
195  const dof_id_type elem_id = elem->id();
196  const dof_id_type neighbor_id = _current_neighbor->id();
197 
198  // TODO: add if-statement to check if this needs to be executed
199  if ((_current_neighbor->active() && (_current_neighbor->level() == elem->level()) &&
200  (elem_id < neighbor_id)) ||
201  (_current_neighbor->level() < elem->level()))
202  {
204  }
205 
206  if (!_have_interface_elems &&
207  (_current_elem->processor_id() != _current_neighbor->processor_id()))
208  {
209  // if my current neighbor is on another processor store the current element
210  // ID for later communication
211  _interface_elem_ids.insert(_current_elem->id());
212  }
213 }
std::set< dof_id_type > _interface_elem_ids
List of element IDs that are on the processor boundary and need to be send to other processors...
bool _have_interface_elems
true if we have cached interface elements, false if they need to be cached. We want to (re)cache only...

◆ onInternalSide()

void ElementLoopUserObject::onInternalSide ( const Elem *  elem,
unsigned int  side 
)
virtualinherited

Definition at line 160 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

161 {
162  _current_elem = elem;
163  // Pointer to the neighbor we are currently working on.
164  _current_neighbor = elem->neighbor(side);
165 
166  // Get the global id of the element and the neighbor
167  const dof_id_type elem_id = elem->id();
168  const dof_id_type neighbor_id = _current_neighbor->id();
169 
170  // TODO: add if-statement to check if this needs to be executed
171  if ((_current_neighbor->active() && (_current_neighbor->level() == elem->level()) &&
172  (elem_id < neighbor_id)) ||
173  (_current_neighbor->level() < elem->level()))
174  {
176  }
177 
178  if (!_have_interface_elems &&
179  (_current_elem->processor_id() != _current_neighbor->processor_id()))
180  {
181  // if my current neighbor is on another processor store the current element ID for later
182  // communication
183  _interface_elem_ids.insert(_current_elem->id());
184  }
185 }
virtual void computeInternalSide()
std::set< dof_id_type > _interface_elem_ids
List of element IDs that are on the processor boundary and need to be send to other processors...
bool _have_interface_elems
true if we have cached interface elements, false if they need to be cached. We want to (re)cache only...

◆ post()

void ElementLoopUserObject::post ( )
virtualinherited

Definition at line 216 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

217 {
218 }

◆ pre()

void ElementLoopUserObject::pre ( )
virtualinherited

Definition at line 136 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

137 {
138 }

◆ serialize()

void SlopeLimitingBase::serialize ( std::string &  serialized_buffer)
protectedvirtualinherited

Definition at line 78 of file SlopeLimitingBase.C.

Referenced by SlopeLimitingBase::finalize().

79 {
80  std::ostringstream oss;
81 
82  // First store the number of elements to send
83  unsigned int size = _interface_elem_ids.size();
84  oss.write((char *)&size, sizeof(size));
85 
86  for (auto it = _interface_elem_ids.begin(); it != _interface_elem_ids.end(); ++it)
87  {
88  storeHelper(oss, *it, this);
89  storeHelper(oss, _lslope[*it], this);
90  }
91 
92  // Populate the passed in string pointer with the string stream's buffer contents
93  serialized_buffer.assign(oss.str());
94 }
std::map< dof_id_type, std::vector< RealGradient > > & _lslope
store the updated slopes into this map indexed by element ID
std::set< dof_id_type > _interface_elem_ids
List of element IDs that are on the processor boundary and need to be send to other processors...

◆ subdomainChanged()

void ElementLoopUserObject::subdomainChanged ( )
virtualinherited

Definition at line 141 of file ElementLoopUserObject.C.

Referenced by ElementLoopUserObject::execute().

142 {
143 }

Member Data Documentation

◆ _coord

const MooseArray<Real>& ElementLoopUserObject::_coord
protectedinherited

Definition at line 99 of file ElementLoopUserObject.h.

◆ _current_elem

const Elem* ElementLoopUserObject::_current_elem
protectedinherited

◆ _current_elem_volume

const Real& ElementLoopUserObject::_current_elem_volume
protectedinherited

Definition at line 92 of file ElementLoopUserObject.h.

◆ _current_neighbor

const Elem* ElementLoopUserObject::_current_neighbor
protectedinherited

◆ _current_side

unsigned int ElementLoopUserObject::_current_side
protectedinherited

Definition at line 93 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::onBoundary().

◆ _have_interface_elems

bool ElementLoopUserObject::_have_interface_elems
protectedinherited

true if we have cached interface elements, false if they need to be cached. We want to (re)cache only when mesh changed

Definition at line 102 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::finalize(), ElementLoopUserObject::meshChanged(), ElementLoopUserObject::onInterface(), and ElementLoopUserObject::onInternalSide().

◆ _include_bc

const bool SlopeLimitingBase::_include_bc
protectedinherited

option whether to include BCs

Definition at line 49 of file SlopeLimitingBase.h.

◆ _interface_elem_ids

std::set<dof_id_type> ElementLoopUserObject::_interface_elem_ids
protectedinherited

List of element IDs that are on the processor boundary and need to be send to other processors.

Definition at line 104 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::meshChanged(), ElementLoopUserObject::onInterface(), ElementLoopUserObject::onInternalSide(), SlopeLimitingBase::serialize(), and SlopeReconstructionBase::serialize().

◆ _JxW

const MooseArray<Real>& ElementLoopUserObject::_JxW
protectedinherited

Definition at line 98 of file ElementLoopUserObject.h.

◆ _JxW_face

const MooseArray<Real>& SlopeLimitingBase::_JxW_face
protectedinherited

Definition at line 54 of file SlopeLimitingBase.h.

◆ _lslope

std::map<dof_id_type, std::vector<RealGradient> >& SlopeLimitingBase::_lslope
protectedinherited

◆ _mesh

MooseMesh& ElementLoopUserObject::_mesh
protectedinherited

◆ _neighbor_elem

const Elem*& SlopeLimitingBase::_neighbor_elem
protectedinherited

the neighboring element

Definition at line 64 of file SlopeLimitingBase.h.

◆ _normals_face

const MooseArray<Point>& SlopeLimitingBase::_normals_face
protectedinherited

Definition at line 55 of file SlopeLimitingBase.h.

◆ _old_subdomain

SubdomainID ElementLoopUserObject::_old_subdomain
protectedinherited

The subdomain for the last element.

Definition at line 110 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::execute().

◆ _q_point

const MooseArray<Point>& ElementLoopUserObject::_q_point
protectedinherited

Definition at line 96 of file ElementLoopUserObject.h.

◆ _q_point_face

const MooseArray<Point>& SlopeLimitingBase::_q_point_face
protectedinherited

required data for face assembly

Definition at line 52 of file SlopeLimitingBase.h.

◆ _qrule

QBase*& ElementLoopUserObject::_qrule
protectedinherited

Definition at line 97 of file ElementLoopUserObject.h.

◆ _qrule_face

QBase*& SlopeLimitingBase::_qrule_face
protectedinherited

Definition at line 53 of file SlopeLimitingBase.h.

◆ _rslope

const SlopeReconstructionBase& SlopeLimitingMultiDBase::_rslope
protected

slope reconstruction user object

Definition at line 32 of file SlopeLimitingMultiDBase.h.

◆ _side

unsigned int& SlopeLimitingBase::_side
protectedinherited

current side of the current element

Definition at line 58 of file SlopeLimitingBase.h.

◆ _side_elem

const Elem*& SlopeLimitingBase::_side_elem
protectedinherited

Definition at line 60 of file SlopeLimitingBase.h.

◆ _side_volume

const Real& SlopeLimitingBase::_side_volume
protectedinherited

Definition at line 61 of file SlopeLimitingBase.h.

◆ _subdomain

SubdomainID ElementLoopUserObject::_subdomain
protectedinherited

The subdomain for the current element.

Definition at line 107 of file ElementLoopUserObject.h.

Referenced by ElementLoopUserObject::execute().


The documentation for this class was generated from the following files: