29 #include "petsc_utils.h"
30 #include "constitutive_model.h"
31 #include "constitutive_model_library.h"
44 SF::petsc_vector<int, double> * position =
reinterpret_cast<SF::petsc_vector<int, double> *
>(solver->
position);
48 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
49 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
50 ierr = VecAXPY(position->data, 1.0, du); CHKERRQ(ierr);
51 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
52 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
66 for (
int nmbc_idx = 0; nmbc_idx < param_globals::num_mech_nbcs; nmbc_idx++) {
69 SF::petsc_vector<int, double> * f_internal =
reinterpret_cast<SF::petsc_vector<int, double> *
>(solver->
f_internal);
70 SF::petsc_vector<int, double> * residuum =
reinterpret_cast<SF::petsc_vector<int, double> *
>(solver->
residuum);
71 SF::petsc_vector<int, double> * f_external =
reinterpret_cast<SF::petsc_vector<int, double> *
>(solver->
f_external);
73 residuum->add_scaled(*f_internal, 1.0);
74 residuum->add_scaled(*f_external, -1.0);
75 ierr = VecAssemblyBegin(resid); CHKERRQ(ierr);
76 ierr = VecAssemblyEnd(resid); CHKERRQ(ierr);
77 ierr = VecCopy(residuum->data, resid); CHKERRQ(ierr);
78 ierr = VecAssemblyBegin(resid); CHKERRQ(ierr);
79 ierr = VecAssemblyEnd(resid); CHKERRQ(ierr);
82 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
83 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
84 ierr = VecAXPY(position->data, -1.0, du); CHKERRQ(ierr);
85 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
86 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
87 ierr = VecAssemblyBegin(resid); CHKERRQ(ierr);
88 ierr = VecAssemblyEnd(resid); CHKERRQ(ierr);
91 PetscScalar resid_norm;
92 VecNorm(resid, NORM_2, &resid_norm);
93 printf(
"\n Residuum on rank %d: %e", PetscGlobalRank, resid_norm);
94 ierr = VecAssemblyBegin(resid); CHKERRQ(ierr);
95 ierr = VecAssemblyEnd(resid); CHKERRQ(ierr);
108 SF::petsc_vector<int, double> * position =
reinterpret_cast<SF::petsc_vector<int, double> *
>(solver->
position);
109 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
110 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
111 ierr = VecAXPY(position->data, 1.0, du); CHKERRQ(ierr);
112 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
113 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
117 SF::petsc_matrix<mesh_int_t, mesh_real_t> * K_eq =
reinterpret_cast<SF::petsc_matrix<mesh_int_t, mesh_real_t> *
>(solver->
K_eq);
118 ierr = MatAssemblyBegin(preconditioner_mat, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
119 ierr = MatAssemblyEnd(preconditioner_mat, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
120 ierr = MatCopy(K_eq->data, preconditioner_mat, DIFFERENT_NONZERO_PATTERN); CHKERRQ(ierr);
121 ierr = MatAssemblyBegin(preconditioner_mat, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
122 ierr = MatAssemblyEnd(preconditioner_mat, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
125 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
126 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
127 ierr = VecAXPY(position->data, -1.0, du); CHKERRQ(ierr);
128 ierr = VecAssemblyBegin(du); CHKERRQ(ierr);
129 ierr = VecAssemblyEnd(du); CHKERRQ(ierr);
134 if(jacobian != preconditioner_mat)
136 ierr = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
137 ierr = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
153 logger =
f_open(
"mechanics.log", param_globals::experiment != 4 ?
"w" :
"r");
159 param_globals::dt, 0,
"elec::ref_dt",
"TS");
173 register_material_model();
188 void Mechanics::setup_mappings()
191 assert(mech_mesh_exits);
197 log_msg(
logger, 0, 0,
"%s: Setting up mechanics algebraic-to-nodal scattering.", __func__);
201 log_msg(
logger, 0, 0,
"%s: Setting up mechanics PETSc to canonical permutation.", __func__);
228 for (
int nmbc_idx = 0; nmbc_idx < param_globals::num_mech_nbcs; nmbc_idx++) {
260 void Mechanics::setup_output()
269 void Mechanics::dump_matrices()
271 std::string bsname = param_globals::dump_basename;
301 void Mechanics::setup_solvers()
311 void Mechanics::checkpointing()
320 void Mechanics::register_material_model()
322 mtype.
regions.resize(param_globals::num_mech_mat_regions);
324 for (std::size_t mreg = 0; mreg < param_globals::num_mech_mat_regions; mreg++) {
325 mechMaterial* mMat =
new mechMaterial();
327 mMat->set_constitutive_model(param_globals::mech_mat_region[mreg].constitutive_model);
328 reg[mreg].material = mMat;
338 log_msg(logger, 0, 0,
"Equilibrium solver initialized.");
368 K_eq->
init(mechanics_mesh, dpn, dpn, max_row_entries);
376 std::size_t loc_node;
381 for(std::size_t i = 0; i < alg_nod.
size(); i++){
382 loc_node = alg_nod[i];
383 for(std::size_t k = 0; k < dpn; k++){
384 pos[3 * i + k] = mechanics_mesh.
xyz_Euler[loc_node * 3 + k];
385 ref_pos[3 * i + k] = mechanics_mesh.
xyz[loc_node * 3 + k];
392 std::size_t num_mnbcs = param_globals::num_mech_nbcs;
393 std::size_t num_mdbcs = param_globals::num_mech_dbcs;
418 case mech_bcs::dbc_t::all:
419 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
420 std::size_t gidx = nbr[alg_nod[lidx]];
423 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
429 for(
size_t k = 0; k < dpn; k++)
431 dbc_ptr[3 * lidx + k] = 0;
432 dbc1_ptr[3 * lidx + k] = 1;
437 case mech_bcs::dbc_t::x:
438 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
439 std::size_t gidx = nbr[alg_nod[lidx]];
442 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
449 dbc_ptr[3 * lidx] = 0;
450 dbc1_ptr[3 * lidx] = 1;
454 case mech_bcs::dbc_t::y:
455 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
456 std::size_t gidx = nbr[alg_nod[lidx]];
459 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
466 dbc_ptr[3 * lidx + 1] = 0;
467 dbc1_ptr[3 * lidx + 1] = 1;
471 case mech_bcs::dbc_t::z:
472 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
473 std::size_t gidx = nbr[alg_nod[lidx]];
476 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
483 dbc_ptr[3 * lidx + 2] = 0;
484 dbc1_ptr[3 * lidx + 2] = 1;
488 case mech_bcs::dbc_t::xy:
489 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
490 std::size_t gidx = nbr[alg_nod[lidx]];
493 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
500 dbc_ptr[3 * lidx] = 0;
501 dbc_ptr[3 * lidx + 1] = 0;
502 dbc1_ptr[3 * lidx] = 1;
503 dbc1_ptr[3 * lidx + 1] = 1;
507 case mech_bcs::dbc_t::xz:
508 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
509 std::size_t gidx = nbr[alg_nod[lidx]];
512 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
519 dbc_ptr[3 * lidx] = 0;
520 dbc_ptr[3 * lidx + 2] = 0;
521 dbc1_ptr[3 * lidx] = 1;
522 dbc1_ptr[3 * lidx + 2] = 1;
526 case mech_bcs::dbc_t::yz:
527 for (std::size_t lidx = 0; lidx < alg_nod.
size(); lidx++) {
528 std::size_t gidx = nbr[alg_nod[lidx]];
531 while (!found && (vtx <
dmbcs[
dbc_idx].vertices.size()))
538 dbc_ptr[3 * lidx + 1] = 0;
539 dbc_ptr[3 * lidx + 2] = 0;
540 dbc1_ptr[3 * lidx + 1] = 1;
541 dbc1_ptr[3 * lidx + 2] = 1;
547 log_msg(logger, 0, 0,
"No direction type defined. Default option to fix displacement in all directions at given nodes");
555 setup_nonlinear_solver(logger);
575 int log_flag = param_globals::output_level > 1 ?
ECHO : 0;
619 log_msg(logger, 0, 0,
"Applying external forces based on Neumann boundary conditions using a constant pressure for all elements");
620 double time = tm.
time + param_globals::dt;
621 double pressure =
nmbcs.
scaling[1] * time / param_globals::tend;
626 bool bc0, bc1, bc2, bc3;
639 for(
size_t eidx = 0; eidx < surfmesh.
l_numelem; eidx++)
652 if(bc0 && bc1 && bc2)
657 for(std::size_t iidx =0; iidx < nint; iidx++)
664 for(std::size_t a = 0; a < view.
num_nodes(); a++)
666 std::size_t walker = 0;
667 bool alg_nod_dx_found = FALSE;
668 while(walker < alg_nod.
size() && !alg_nod_dx_found)
670 alg_nod_dx_found = (alg_nod[walker] == view.
node(a));
673 double sa = shape[0][a];
676 f_ext[3 * (walker - 1)] += sa * w[iidx] * area * pressure * normal.
x;
677 f_ext[3 * (walker - 1) + 1] += sa * w[iidx] * area * pressure * normal.
y;
678 f_ext[3 * (walker - 1) + 2] += sa * w[iidx] * area * pressure * normal.
z;
691 if(bc0 && bc1 && bc2 && bc3)
696 for(std::size_t iidx =0; iidx < nint; iidx++)
703 for(std::size_t a = 0; a < view.
num_nodes(); a++)
705 std::size_t walker = 0;
706 bool alg_nod_dx_found = FALSE;
707 while(walker < alg_nod.
size() && !alg_nod_dx_found)
709 alg_nod_dx_found = (alg_nod[walker] == view.
node(a));
712 double sa = shape[0][a];
715 f_ext[3 * (walker - 1)] += sa * w[iidx] * area * pressure * normal.
x;
716 f_ext[3 * (walker - 1) + 1] += sa * w[iidx] * area * pressure * normal.
y;
717 f_ext[3 * (walker - 1) + 2] += sa * w[iidx] * area * pressure * normal.
z;
750 void equilibrium_solver::setup_nonlinear_solver(
FILE_SPEC logger)
752 tol = param_globals::cg_tol_eq;
753 max_it = param_globals::cg_maxit_eq;
754 std::string solver_file;
755 solver_file = param_globals::eq_options_file;
759 bool has_nullspace =
true;
760 nonlin_solver->
setup_solver(*
residuum, *
K_eq,
tol,
max_it, param_globals::cg_norm_eq,
"equilibrium PDE", has_nullspace, logger, solver_file.c_str(),
"",
equilibrium_solver_internal_forces_petsc_helperfunction,
equilibrium_solver_jacobian_petsc_helperfunction, (
void *)
this);
770 const mech_nbcs & cur_mnbc = param_globals::mech_nbc[idx];
779 bool vertex_file_given = strlen(cur_mnbc.vtx_file) > 0;
780 bool tag_index_given = cur_mnbc.geomID > -1;
784 if(vertex_file_given && tag_index_given)
785 log_msg(0,3,0,
"%s warning: More than one region definitions set in Neumann boundary conditions %d", __func__, idx);
787 if(vertex_file_given) {
790 log_msg(logger, 0, 0,
"Neumann bcs region %d: Selecting vertices from file %s", idx,
input_filename.c_str());
800 log_msg(logger, 0, 0,
"Trying to read a vertex file with scaled Neumann boundary conditions but specified pressure type! Aborting!");
812 log_msg(0, 5, 0,
"Neumann bcs region %d: Specified vertices are not in domain! Aborting!", idx);
816 else if(tag_index_given) {
818 int tag = cur_mnbc.geomID;
819 log_msg(logger, 0, 0,
"Neumann bc region %d: Selecting vertices from tag %d", idx, tag);
826 log_msg(logger, 0, 0,
"Neumann bc region %d: Selecting vertices from shape.", idx);
830 shape.
p0 = cur_mnbc.p0;
831 shape.
p1 = cur_mnbc.p1;
832 shape.
radius = cur_mnbc.radius;
841 log_msg(0,5,0,
"error: Empty Neumann bc region [%d] def! Aborting!", idx);
846 if(cur_mnbc.dump_vtx_file) {
848 mesh.
pl.globalize(glob_idx);
860 char dump_name[1024];
861 sprintf(dump_name,
"NBCs_%d.vtx", idx);
863 f =
f_open(dump_name,
"w");
866 fprintf(f->
fd,
"%zd\nextra\n", num_vtx);
873 log_msg(0, 4, 0,
"error: Neumann bc region [%d] cannot be dumped!");
883 const mech_dbcs & cur_mdbc = param_globals::mech_dbc[idx];
886 switch (cur_mdbc.dbc_type) {
917 bool vertex_file_given = strlen(cur_mdbc.vtx_file) > 0;
918 bool tag_index_given = cur_mdbc.geomID > -1;
922 if(vertex_file_given && tag_index_given)
923 log_msg(0,3,0,
"%s warning: More than one region definitions set in Dirichlet boundary conditions %d", __func__, idx);
925 if(vertex_file_given) {
928 log_msg(logger, 0, 0,
"Dirichlet bcs region %d: Selecting vertices from file %s", idx,
input_filename.c_str());
941 log_msg(0, 5, 0,
"Dirichlet bcs region %d: Specified vertices are not in domain! Aborting!", idx);
945 else if(tag_index_given) {
947 int tag = cur_mdbc.geomID;
948 log_msg(logger, 0, 0,
"Dirichlet bc region %d: Selecting vertices from tag %d", idx, tag);
955 log_msg(logger, 0, 0,
"Dirichlet bc region %d: Selecting vertices from shape.", idx);
959 shape.
p0 = cur_mdbc.p0;
960 shape.
p1 = cur_mdbc.p1;
961 shape.
radius = cur_mdbc.radius;
970 log_msg(0,5,0,
"error: Empty Dirichlet bc region [%d] def! Aborting!", idx);
974 if(cur_mdbc.dump_vtx_file) {
976 mesh.
pl.globalize(glob_idx);
988 char dump_name[1024];
989 sprintf(dump_name,
"DBCs_%d.vtx", idx);
991 f =
f_open(dump_name,
"w");
994 fprintf(f->
fd,
"%zd\nextra\n", num_vtx);
1001 log_msg(0, 4, 0,
"error: Dirichlet bc region [%d] cannot be dumped!");
#define SF_MAX_ELEM_NODES
max #nodes defining an element
virtual void finish_assembly()=0
virtual void init(T iNRows, T iNCols, T ilrows, T ilcols, T loc_offset, T mxent)
virtual void release_ptr(S *&p)=0
virtual void set(const vector< T > &idx, const vector< S > &vals, const bool additive=false)=0
virtual void add_scaled(const abstract_vector< T, S > &vec, S k)=0
virtual void init(const meshdata< mesh_int_t, mesh_real_t > &imesh, int idpn, ltype inp_layout)=0
void set_size(const short irows, const short icols)
set the matrix dimensions
Comfort class. Provides getter functions to access the mesh member variables more comfortably.
const T & node(short nidx) const
Access the connectivity information.
void integration_points(const short order, Point *ip, double *w, int &nint) const
void set_elem(size_t eidx)
Set the view to a new element.
elem_t type() const
Getter function for the element type.
Point coord_upd(short nidx) const
Access updated vertex coordinates.
T num_nodes() const
Getter function for the number of nodes.
overlapping_layout< T > pl
nodal parallel layout
size_t g_numpts
global number of points
size_t l_numelem
local number of elements
std::map< SF_nbr, vector< T > > nbr
container for different numberings
vector< S > xyz_Euler
node coordinates in Euler formulation
vector< S > xyz
node coordinates in Lagrange formulation
size_t l_numpts
local number of points
size_t g_numelem
global number of elements
MPI_Comm comm
the parallel mesh is defined on a MPI world
vector< T > & get_numbering(SF_nbr nbr_type)
Get the vector defining a certain numbering.
size_t size() const
The current size of the vector.
void assign(InputIterator s, InputIterator e)
Assign a memory range.
int timer_idx
the timer index received from the timer manager
FILE_SPEC logger
The logger of the physic, each physic should have one.
void destroy()
Currently we only need to close the file logger.
std::string timer_unit(const int timer_id)
figure out units of a signal linked to a given timer
double timer_val(const int timer_id)
figure out current value of a signal linked to a given timer
equilibrium_solver eq_solver
void initialize()
Initialize the Mechanics.
igb_output_manager output_manager
class handling the igb output
void compute_step()
Main function for every compute step.
void calc_internal_forces(MaterialType mtype, FILE_SPEC logger)
Calculation of the internal forces based on the deformation.
void rebuild_stiffness(MaterialType mtype, FILE_SPEC logger)
rebuild stiffness matrix
sf_vec * dirichlet_bcs_1
Dirichlet boundary conditions but with 1 = dbc exists.
sf_vec * position
position x
sf_vec * du
incremental displacement du
sf_mat * K_eq
stiffness matrix for static equilibrium solver K
int max_it
maximum number of iterations
double tol
CG stopping tolerance.
sf_vec * residuum
residuum r
sf_vec * displacement
absolute displacement u
void apply_external_forces(MaterialType mtype, FILE_SPEC logger, sf_mesh surfmesh, mech_bcs nmbcs)
Applying external forces from Neumann boundary conditions.
sf_vec * f_internal
internal forces f_int
sf_vec * dirichlet_bcs
Dirichlet boundary conditions, 0 = dbc exists.
SF::vector< mesh_int_t > dbc_idx
Indices for Dirichlet boundary conditions.
sf_nl_sol * nonlin_solver
the nonlinear solver
void update_node_coords()
void rebuild_matrices(MaterialType mtype, FILE_SPEC logger)
rebuild the matrices
SF::vector< mesh_int_t > nbc_idx
Indices for Neumann boundary conditions.
void apply_bcs_jacobian()
sf_vec * initial_guess
needed for initial guess for nonlinear solver
mech_bcs nmbcs[10]
Neumann boundary conditions.
mech_bcs dmbcs[10]
Dirichlet boundary condtions.
void init()
Initialize equlibirum solver.
sf_vec * reference_pos
reference position X
sf_vec * f_external
external forces f_ext
class to store shape definitions
void write_data()
write registered data to disk
void register_output(sf_vec *inp_data, const mesh_t inp_meshid, const int dpn, const char *name, const char *units, const SF::vector< mesh_int_t > *idx=NULL, bool elem_data=false)
Register a data vector for output.
void setup(int idx)
Setup of both Neumann and Dirichlet mechanics boundary conditions.
SF::Point direction
direction in which the bc is applied
dbc_t dbc_type
fixed coordinates
SF::vector< mesh_int_t > vertices
list of nodes that bc is active on
std::string input_filename
filename with list of nodes
SF::vector< SF_real > scaling
scaling for Neumann bcs
nbc_t nbc_type
pressure given for elements, force given for nodes
def_t definition
type of boundary condition
Used to integrate the internal nodel forces per element.
centralize time managment and output triggering
int add_eq_timer(double istart, double iend, int ntrig, double iintv, double idur, const char *iname, const char *poolname=nullptr)
Add a equidistant step timer to the array of timers.
#define EP_MAX_LPOINTS
maximum supported number of points in a local element
#define EP_MAX_IPOINTS
maximum supported number of integration points
Tissue level mechanics, main Mechanics physics class.
void get_transformed_pts(const element_view< T, S > &view, Point *loc_pts, Point &trsf_fibre)
void init_solver(SF::abstract_linear_solver< T, S > **sol)
void compute_surface_mesh(const meshdata< T, S > &mesh, const SF_nbr numbering, const hashmap::unordered_set< T > &tags, meshdata< T, S > &surfmesh)
Compute the surface of a given mesh.
void print_vector(MPI_Comm comm, const vector< T > &vec, const short dpn, FILE *fd)
void assemble_vector(abstract_vector< T, S > &vec, meshdata< mesh_int_t, mesh_real_t > &domain, vector_integrator< mesh_int_t, mesh_real_t > &integrator)
Generalized vector assembly.
void sort_parallel(MPI_Comm comm, const vector< T > &idx, vector< T > &out_idx)
Sort index values parallel ascending across the ranks.
void assemble_matrix(abstract_matrix< T, S > &mat, meshdata< mesh_int_t, mesh_real_t > &domain, matrix_integrator< mesh_int_t, mesh_real_t > &integrator)
Generalized matrix assembly.
int max_nodal_edgecount(const meshdata< T, S > &mesh)
Compute the maximum number of node-to-node edges for a mesh.
void restrict_to_set(vector< T > &v, const hashmap::unordered_set< T > &set)
void init_vector(SF::abstract_vector< T, S > **vec)
void init_matrix(SF::abstract_matrix< T, S > **mat)
void reference_shape(const elem_t type, const Point ip, dmat< double > &rshape)
Compute shape function and its derivatives on a reference element.
@ NBR_PETSC
PETSc numbering of nodes.
@ NBR_ELEM_REF
The element numbering of the reference mesh (the one stored on HD).
@ NBR_REF
The nodal numbering of the reference mesh (the one stored on HD).
timer_manager * tm_manager
a manager for the various physics timers
std::map< physic_t, Basic_physic * > physics_reg
the physics
PetscErrorCode equilibrium_solver_internal_forces_petsc_helperfunction(SNES snes, Vec du, Vec resid, void *solver_pointer)
Helpferfunction necessary for the petsc snes solver to solve the nonlinear problem.
vec3< V > normalize(vec3< V > a)
SF::scattering * get_scattering(const int from, const int to, const SF::SF_nbr nbr, const int dpn)
Get a scattering from the global scatter registry.
sf_mesh & get_mesh(const mesh_t gt)
Get a mesh by specifying the gridID.
SF::scattering * register_scattering(const int from, const int to, const SF::SF_nbr nbr, const int dpn)
Register a scattering between to grids, or between algebraic and nodal representation of data on the ...
SF::scattering * get_permutation(const int mesh_id, const int perm_id, const int dpn)
Get the PETSC to canonical permutation scattering for a given mesh and number of dpn.
vec3< V > cross(const vec3< V > &a, const vec3< V > &b)
int get_rank(MPI_Comm comm=PETSC_COMM_WORLD)
T get_global(T in, MPI_Op OP, MPI_Comm comm=PETSC_COMM_WORLD)
Do a global reduction on a variable.
FILE_SPEC f_open(const char *fname, const char *mode)
Open a FILE_SPEC.
SF::scattering * register_permutation(const int mesh_id, const int perm_id, const int dpn)
Register a permutation between two orderings for a mesh.
V mag(const vec3< V > &vect)
PetscErrorCode equilibrium_solver_jacobian_petsc_helperfunction(SNES snes, Vec du, Mat jacobian, Mat preconditioner_mat, void *solver_pointer)
Helpferfunction necessary for the petsc snes solver to compute the jacobian.
void indices_from_region_tag(SF::vector< mesh_int_t > &idx, const sf_mesh &mesh, const int tag)
Populate vertex data with the vertices of a given tag region.
void indices_from_geom_shape(SF::vector< mesh_int_t > &idx, const sf_mesh &mesh, const geom_shape shape, const bool nodal)
Populate vertex data with the vertices inside a defined box shape.
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
void get_time(double &tm)
bool mesh_is_registered(const mesh_t gt)
check wheter a SF mesh is set
Basic_physic * get_physics(physic_t p, bool error_if_missing)
Convinience function to get a physics.
void read_indices_with_data(SF::vector< T > &idx, SF::vector< S > &dat, const std::string filename, const hashmap::unordered_map< mesh_int_t, mesh_int_t > &dd_map, const int dpn, MPI_Comm comm)
like read_indices, but with associated data for each index
V timing(V &t2, const V &t1)
void read_indices(SF::vector< T > &idx, const std::string filename, const hashmap::unordered_map< mesh_int_t, mesh_int_t > &dd_map, MPI_Comm comm)
Read indices from a file.
void f_close(FILE_SPEC &f)
Close a FILE_SPEC.
#define PETSC_TO_CANONICAL
Permute algebraic data from PETSC to canonical ordering.
#define ALG_TO_NODAL
Scatter algebraic to nodal.
virtual void setup_solver(abstract_vector< T, S > &residuum, abstract_matrix< T, S > &mat, double tol, int max_it, short norm, const char *name, bool has_nullspace, void *logger, const char *solver_opts_file, const char *default_opts, PetscErrorCode function(SNES, Vec, Vec, void *), PetscErrorCode jacobian(SNES, Vec, Mat, Mat, void *), void *solver_pointer=NULL)=0
description of materal properties in a mesh
SF::vector< RegionSpecs > regions
array with region params