https://mooseframework.inl.gov
stochastic_tools
include
utils
DistributedData.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 "libmesh/parallel_object.h"
13
#include "libmesh/parallel.h"
14
#include "
MooseTypes.h
"
15
16
namespace
StochasticTools
17
{
18
23
template
<
typename
T>
24
class
DistributedData
:
public
libMesh::ParallelObject
25
{
26
public
:
27
DistributedData
(
const
libMesh::Parallel::Communicator
& comm_in);
28
31
void
initializeContainer
(
unsigned
int
num_global_entries);
32
34
void
changeEntry
(
unsigned
int
glob_i,
const
T & sample);
35
37
void
addNewEntry
(
unsigned
int
glob_i,
const
T & sample);
38
41
void
closeContainer
() {
_closed
=
true
; };
42
44
bool
hasGlobalEntry
(
unsigned
int
glob_i)
const
;
45
47
typename
std::vector<T>::iterator
localEntryBegin
() {
return
_local_entries
.begin(); };
48
50
typename
std::vector<T>::iterator
localEntryEnd
() {
return
_local_entries
.end(); };
51
53
typename
std::vector<unsigned int>::iterator
localEntryIDBegin
()
54
{
55
return
_local_entry_ids
.begin();
56
};
57
59
typename
std::vector<unsigned int>::iterator
localEntryIDEnd
() {
return
_local_entry_ids
.end(); };
60
62
const
T &
getGlobalEntry
(
unsigned
int
glob_i)
const
;
63
65
const
T &
getLocalEntry
(
unsigned
int
loc_i)
const
;
66
68
const
std::vector<T> &
getLocalEntries
()
const
{
return
_local_entries
; };
69
71
const
std::vector<unsigned int> &
getLocalEntryIDs
()
const
{
return
_local_entry_ids
; };
72
74
unsigned
int
getNumberOfGlobalEntries
()
const
;
75
77
unsigned
int
getNumberOfLocalEntries
()
const
{
return
_n_local_entries
; };
78
80
unsigned
int
getLocalIndex
(
unsigned
int
glob_i)
const
;
81
83
unsigned
int
getGlobalIndex
(
unsigned
int
loc_i)
const
;
84
85
protected
:
87
std::vector<T>
_local_entries
;
88
90
std::vector<unsigned int>
_local_entry_ids
;
91
93
bool
_closed
;
94
96
unsigned
int
_n_local_entries
;
97
};
98
99
}
// StochasticTools namespace
libMesh::Parallel::Communicator
StochasticTools::DistributedData::localEntryEnd
std::vector< T >::iterator localEntryEnd()
Getting an iterator to the end of the locally owned samples.
Definition:
DistributedData.h:50
StochasticTools::DistributedData::DistributedData
DistributedData(const libMesh::Parallel::Communicator &comm_in)
Definition:
DistributedData.C:19
StochasticTools::DistributedData::_n_local_entries
unsigned int _n_local_entries
Number of local samples.
Definition:
DistributedData.h:96
StochasticTools::DistributedData::closeContainer
void closeContainer()
Closes the container meaning that no new samples can be added or the already existing samples canot b...
Definition:
DistributedData.h:41
StochasticTools::DistributedData::_local_entries
std::vector< T > _local_entries
The vector where the samples are stored.
Definition:
DistributedData.h:87
StochasticTools::DistributedData::getLocalIndex
unsigned int getLocalIndex(unsigned int glob_i) const
Getting the local index of a global sample if locally owned.
Definition:
DistributedData.C:129
StochasticTools::DistributedData::getNumberOfGlobalEntries
unsigned int getNumberOfGlobalEntries() const
Getting the number of global samples.
Definition:
DistributedData.C:109
MooseTypes.h
StochasticTools::DistributedData::getGlobalEntry
const T & getGlobalEntry(unsigned int glob_i) const
Getting a sample using its global index.
Definition:
DistributedData.C:84
StochasticTools
Enum for batch type in stochastic tools MultiApp.
Definition:
StochasticToolsTypes.h:13
StochasticTools::DistributedData::hasGlobalEntry
bool hasGlobalEntry(unsigned int glob_i) const
Checking of sample with global ID is locally owned ot not.
Definition:
DistributedData.C:118
StochasticTools::DistributedData::_closed
bool _closed
Flag which shows if the container is closed or not.
Definition:
DistributedData.h:93
libMesh::ParallelObject
StochasticTools::DistributedData::getLocalEntryIDs
const std::vector< unsigned int > & getLocalEntryIDs() const
Getting the vector of sample IDs for locally owned samples.
Definition:
DistributedData.h:71
StochasticTools::DistributedData::localEntryIDBegin
std::vector< unsigned int >::iterator localEntryIDBegin()
Getting an iterator to the beginning of the locally owned sample IDs.
Definition:
DistributedData.h:53
StochasticTools::DistributedData::changeEntry
void changeEntry(unsigned int glob_i, const T &sample)
Changing a sample with a global index if it is owned locally.
Definition:
DistributedData.C:71
StochasticTools::DistributedData::getLocalEntry
const T & getLocalEntry(unsigned int loc_i) const
Getting a sample using its local index.
Definition:
DistributedData.C:95
StochasticTools::DistributedData::localEntryBegin
std::vector< T >::iterator localEntryBegin()
Getting an itertor to the beginning of the local samples.
Definition:
DistributedData.h:47
StochasticTools::DistributedData::initializeContainer
void initializeContainer(unsigned int num_global_entries)
Initialize the container with a given number of samples.
Definition:
DistributedData.C:26
StochasticTools::DistributedData::localEntryIDEnd
std::vector< unsigned int >::iterator localEntryIDEnd()
Getting an iterator to the end of the locally owned sample IDs.
Definition:
DistributedData.h:59
StochasticTools::DistributedData::getGlobalIndex
unsigned int getGlobalIndex(unsigned int loc_i) const
Getting the global index of a locally owned sample.
Definition:
DistributedData.C:140
StochasticTools::DistributedData::_local_entry_ids
std::vector< unsigned int > _local_entry_ids
The vector where the global sample IDs are stored.
Definition:
DistributedData.h:90
StochasticTools::DistributedData::getLocalEntries
const std::vector< T > & getLocalEntries() const
Getting all of the locally owned samples.
Definition:
DistributedData.h:68
StochasticTools::DistributedData
Templated class that specifies a distributed storage of a vector of given objects.
Definition:
DistributedData.h:24
StochasticTools::DistributedData::getNumberOfLocalEntries
unsigned int getNumberOfLocalEntries() const
Getting the number of locally owned samples.
Definition:
DistributedData.h:77
StochasticTools::DistributedData::addNewEntry
void addNewEntry(unsigned int glob_i, const T &sample)
Adding a new sample locally with a global index.
Definition:
DistributedData.C:56
Generated on Fri Jul 18 2025 11:57:28 for https://mooseframework.inl.gov by
1.8.14