https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
OptUtils Namespace Reference

Functions

void copyReporterIntoPetscVector (const std::vector< std::vector< Real > * > reporterVectors, libMesh::PetscVector< Number > &x)
 
void copyPetscVectorIntoReporter (const libMesh::PetscVector< Number > &x, std::vector< std::vector< Real > * > reporterVectors)
 
void copyReporterIntoPetscMatrix (const std::vector< std::vector< Real > * > reporterVectors, libMesh::PetscMatrix< Number > &x)
 
void copyPetscMatrixIntoReporter (const libMesh::PetscMatrix< Number > &x, std::vector< std::vector< Real > * > reporterVectors)
 

Function Documentation

◆ copyPetscMatrixIntoReporter()

void OptUtils::copyPetscMatrixIntoReporter ( const libMesh::PetscMatrix< Number > &  x,
std::vector< std::vector< Real > * >  reporterVectors 
)

Definition at line 53 of file OptUtils.C.

55{
56 for (const auto i : index_range(reporterVectors))
57 for (const auto j : index_range(*reporterVectors[i]))
58 (*reporterVectors[i])[j] = x(i, j);
59}
const std::vector< double > x
for(PetscInt i=0;i< nvars;++i)

◆ copyPetscVectorIntoReporter()

void OptUtils::copyPetscVectorIntoReporter ( const libMesh::PetscVector< Number > &  x,
std::vector< std::vector< Real > * >  reporterVectors 
)

Definition at line 33 of file OptUtils.C.

35{
36 dof_id_type j = 0;
37 for (auto & data : reporterVectors)
38 for (auto & val : *data)
39 val = x(j++);
40}

Referenced by OptimizationReporterBase::updateParameters().

◆ copyReporterIntoPetscMatrix()

void OptUtils::copyReporterIntoPetscMatrix ( const std::vector< std::vector< Real > * >  reporterVectors,
libMesh::PetscMatrix< Number > &  x 
)

Definition at line 42 of file OptUtils.C.

44{
45 for (const auto i : index_range(reporterVectors))
46 for (const auto j : index_range(*reporterVectors[i]))
47 x.set(i, j, (*reporterVectors[i])[j]);
48
49 x.close();
50}

Referenced by OptimizationReporterBase::computeEqualityGradient(), and OptimizationReporterBase::computeInequalityGradient().

◆ copyReporterIntoPetscVector()

void OptUtils::copyReporterIntoPetscVector ( const std::vector< std::vector< Real > * >  reporterVectors,
libMesh::PetscVector< Number > &  x 
)

Definition at line 21 of file OptUtils.C.

23{
24 dof_id_type n = 0;
25 for (const auto & data : reporterVectors)
26 for (const auto & val : *data)
27 x.set(n++, val);
28
29 x.close();
30}

Referenced by OptimizationReporterBase::computeEqualityConstraints(), OptimizationReporterBase::computeGradient(), OptimizationReporterBase::computeInequalityConstraints(), and OptimizationReporterBase::setInitialCondition().