https://mooseframework.inl.gov
Classes | Functions
InterWrapper1PhaseProblem.C File Reference

Go to the source code of this file.

Classes

struct  problemInfo
 problem information to be used in the PETSc problem More...
 

Functions

PetscErrorCode formFunctionIW (SNES, Vec x, Vec f, void *info)
 creates the residual function to be used in the PETCs snes context More...
 

Function Documentation

◆ formFunctionIW()

PetscErrorCode formFunctionIW ( SNES  ,
Vec  x,
Vec  f,
void info 
)

creates the residual function to be used in the PETCs snes context

Definition at line 29 of file InterWrapper1PhaseProblem.C.

30 {
31  const PetscScalar * xx;
32  PetscScalar * ff;
33  PetscInt size;
34 
36  problemInfo * cc = static_cast<problemInfo *>(info);
37  LibmeshPetscCallQ(VecGetSize(x, &size));
38 
39  libMesh::DenseVector<Real> solution_seed(size, 0.0);
40  LibmeshPetscCallQ(VecGetArrayRead(x, &xx));
41  for (PetscInt i = 0; i < size; i++)
42  solution_seed(i) = xx[i];
43 
44  LibmeshPetscCallQ(VecRestoreArrayRead(x, &xx));
45 
46  libMesh::DenseVector<Real> Wij_residual_vector =
47  cc->schp->residualFunction(cc->iblock, solution_seed);
48 
49  LibmeshPetscCallQ(VecGetArray(f, &ff));
50  for (int i = 0; i < size; i++)
51  ff[i] = Wij_residual_vector(i);
52 
53  LibmeshPetscCallQ(VecRestoreArray(f, &ff));
54  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
55 }
MPI_Info info
PetscFunctionBegin
InterWrapper1PhaseProblem * schp
const std::vector< double > x
Real f(Real x)
Test function for Brents method.
problem information to be used in the PETSc problem
LibmeshPetscCallQ(DMShellGetContext(dm, &ctx))
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)
virtual libMesh::DenseVector< Real > residualFunction(int iblock, libMesh::DenseVector< Real > solution)
Computes Residual per gap for block iblock.