33 #include "libmesh/petsc_nonlinear_solver.h" 34 #include "libmesh/petsc_vector.h" 35 #include "libmesh/dof_map.h" 58 sys.add_vector(
"old_solution");
65 PetscErrorCode ierr = SNESGetSolutionUpdate(snes, &dx);
66 libmesh_assert(!ierr);
69 std::unique_ptr<libMesh::NumericVector<Real> >
70 vec(
new libMesh::PetscVector<Real>(dx, sys.comm())),
71 vec_scaled(vec->clone().release());
75 vec_scaled->scale(-1.);
87 sys.get_vector(
"old_solution") = *sys.solution;
88 sys.get_vector(
"old_solution").close();
99 _intersection (nullptr),
100 _dof_handler (nullptr) {
131 libMesh::PetscNonlinearSolver<Real> &petsc_nonlinear_solver =
132 *(
dynamic_cast<libMesh::PetscNonlinearSolver<Real>*
> 137 if (libMesh::on_command_line(
"--solver_system_names"))
138 petsc_nonlinear_solver.
init((assembly.
system().name()+
"_").c_str());
141 SNES snes = petsc_nonlinear_solver.snes();
143 PetscErrorCode ierr =
149 libmesh_assert(!ierr);
160 libMesh::PetscNonlinearSolver<Real> &petsc_nonlinear_solver =
161 *(
dynamic_cast<libMesh::PetscNonlinearSolver<Real>*
> 165 SNES snes = petsc_nonlinear_solver.snes();
167 PetscErrorCode ierr =
168 SNESMonitorCancel(snes);
169 libmesh_assert(!ierr);
182 libMesh::NumericVector<Real>& dX) {
205 std::vector<libMesh::dof_id_type>
210 const libMesh::DofMap& dof_map = sys.get_dof_map();
212 std::unique_ptr<libMesh::NumericVector<Real> >
217 libMesh::MeshBase::const_element_iterator el =
218 sys.get_mesh().active_local_elements_begin();
219 const libMesh::MeshBase::const_element_iterator end_el =
220 sys.get_mesh().active_local_elements_end();
222 for ( ; el != end_el; ++el) {
224 const libMesh::Elem* elem = *el;
227 dof_map.dof_indices (elem, dof_indices);
230 unsigned int ndofs = (
unsigned int)dof_indices.size();
233 sub_elem_vec.setZero(ndofs);
235 sub_elem_mat.setZero(ndofs, ndofs);
236 jac.setZero(ndofs, ndofs);
238 for (
unsigned int i=0; i<dof_indices.size(); i++) {
239 sol(i) = (*localized_solution)(dof_indices[i]);
240 dsol(i) = (*localized_dsolution)(dof_indices[i]);
248 sys.get_mesh().max_elem_id(),
249 sys.get_mesh().max_node_id());
256 elem_ops.
init(geom_elem);
const MAST::NonlinearSystem & system() const
void update_factored_element_solution(const libMesh::Elem &elem, const RealMatrixX &res, const RealMatrixX &jac, const RealMatrixX &sol, const RealMatrixX &dsol, RealVectorX &updated_sol)
PetscErrorCode _snes_level_set_void_solution_assembly_monitor_function(SNES snes, PetscInt its, PetscReal norm2, void *ctx)
virtual void init(MAST::AssemblyBase &assembly)
This class implements a system for solution of nonlinear systems.
void solution_of_factored_element(const libMesh::Elem &elem, RealVectorX &elem_sol)
updates the components of the solution vector in elem_sol for the void domain using the stored soluti...
bool if_factor_element(const libMesh::Elem &elem) const
virtual void set_elem_solution(const RealVectorX &sol)
sets the element solution
void init(const MAST::FieldFunction< Real > &phi, const libMesh::Elem &e, const Real t, unsigned int max_elem_id, unsigned int max_node_id)
MAST::LevelSetIntersection * _intersection
virtual void elem_calculations(bool if_jac, RealVectorX &vec, RealMatrixX &mat)=0
performs the element calculations over elem, and returns the element vector and matrix quantities in ...
virtual void set_elem_data(unsigned int dim, const libMesh::Elem &ref_elem, MAST::GeomElem &elem) const =0
some analyses may want to set additional element data before initialization of the GeomElem...
void update_void_solution(libMesh::NumericVector< Real > &X, libMesh::NumericVector< Real > &dX)
Real get_positive_phi_volume_fraction() const
Matrix< Real, Dynamic, Dynamic > RealMatrixX
std::unique_ptr< libMesh::NumericVector< Real > > build_localized_vector(const libMesh::System &sys, const libMesh::NumericVector< Real > &global) const
localizes the parallel vector so that the local copy stores all values necessary for calculation of t...
This will compute the solution at the interface under the assumption of zero surface normal flux...
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void init(const MAST::GeomElem &elem)=0
initializes the object for calculation of element quantities for the specified elem.
MAST::LevelSetInterfaceDofHandler * _dof_handler
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
MAST::SystemInitialization & system_init()
void init(const MAST::SystemInitialization &sys_init, MAST::LevelSetIntersection &intersection, MAST::FieldFunction< Real > &phi)
virtual ~LevelSetVoidSolution()
MAST::AssemblyBase & get_assembly()
virtual void clear_elem()
clears the element initialization
MAST::AssemblyElemOperations & get_elem_ops()
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem.
MAST::NonlinearSystem::Operation operation()
MAST::FieldFunction< Real > & get_level_set_function()
MAST::AssemblyBase * _assembly
void clear()
clears the data structures