CArl
Code Arlequin / C++ implementation
libmesh_assemble_lin_homogeneous__min_x_clamped.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Program used to assemble the rigidity matrix and the vectors of a linear, homogeneous elasticity model with a clamped $x_{\mbox{Min}}$ face. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Program used to assemble the rigidity matrix and the vectors of a linear, homogeneous elasticity model with a clamped $x_{\mbox{Min}}$ face.

Usage: ./libmesh_assemble_lin_homogeneous__min_x_clamped -i [input file]

The input file is parsed by the get_input_params(GetPot& field_parser, libmesh_assemble_input_params& input_params) function, and it contains the following parameters.

Required parameters:

  • Mesh : path to the mesh.
  • PhysicalParameters : physical parameters.
  • SystemType : parameter used to tell the assembler which weight functions must be used. Values: Micro or Macro.
  • MeshWeight : path to the mesh defining the domains of the Arlequin weight parameters.
  • WeightIndexes : path to the indices of the domains of the Arlequin weight parameters.

Optional parameter:

  • OutputBase or --output : base of the output files (including folders). Default: test_system.

Boolean flags:

  • ExportRBVectors : build and export the rigid body modes vectors.

Definition at line 23 of file libmesh_assemble_lin_homogeneous__min_x_clamped.cpp.

23  {
24 
25  // [USER] Fixed boudary
27 
28  // --- Initialize libMesh
29  libMesh::LibMeshInit init(argc, argv);
30 
31  // Do performance log?
32  const bool MASTER_bPerfLog_carl_libmesh = true;
33  libMesh::PerfLog perf_log("Main program", MASTER_bPerfLog_carl_libmesh);
34 
35  // libMesh's C++ / MPI communicator wrapper
36  libMesh::Parallel::Communicator& WorldComm = init.comm();
37 
38  // Number of processors and processor rank.
39  int rank = WorldComm.rank();
40  int nodes = WorldComm.size();
41 
42  // --- Set up inputs
43 
44  // Command line parser
45  GetPot command_line(argc, argv);
46 
47  // File parser
48  GetPot field_parser;
49 
50  // If there is an input file, parse it to get the parameters. Else, parse the command line
51  std::string input_filename;
52  if (command_line.search(2, "--inputfile", "-i")) {
53  input_filename = command_line.next(input_filename);
54  field_parser.parse_input_file(input_filename, "#", "\n", " \t\n");
55  } else {
56  field_parser = command_line;
57  }
58 
59  libmesh_assemble_input_params input_params;
60  get_input_params(field_parser, input_params);
61 
62  // Check libMesh installation dimension
63  const unsigned int dim = 3;
64 
65  libmesh_example_requires(dim == LIBMESH_DIM, "3D support");
66 
67  // --- Declare the three meshes to be intersected
68 
69  // - Parallelized meshes: A, B, mediator and weight
70  perf_log.push("Meshes - Parallel","Read files:");
71  libMesh::Mesh system_mesh(WorldComm, dim);
72  system_mesh.read(input_params.mesh_file);
73  system_mesh.prepare_for_use();
74 
75  libMesh::Mesh mesh_weight(WorldComm, dim);
76  mesh_weight.allow_renumbering(false);
77  mesh_weight.read(input_params.mesh_weight_file);
78  mesh_weight.prepare_for_use();
79 
80  perf_log.pop("Meshes - Parallel","Read files:");
81 
82  // --- Generate the equation systems
83  perf_log.push("System setup:");
84 
85  // Set the equation systems object
86  libMesh::EquationSystems equation_systems(system_mesh);
87 
88  // Add linear elasticity and physical parameters systems
89  libMesh::LinearImplicitSystem& elasticity_system
90  = add_elasticity(equation_systems);
91 
92  // Set clamped border
93  set_clamped_border(elasticity_system, fixed_bound_id);
94 
95  // Initialize the equation systems
96  equation_systems.init();
97 
98  // Homogeneous properties for the macro system
99  set_homogeneous_physical_properties(equation_systems, input_params.physical_params_file);
100 
101  // Set the weight function object
102  weight_parameter_function system_weight(mesh_weight);
103  system_weight.set_parameters(input_params.weight_domain_idx_file);
104 
105  perf_log.pop("System setup:");
106 
107  // Assemble!
108  assemble_elasticity_with_weight(equation_systems,"Elasticity",system_weight,
109  input_params.system_type);
110 
111 // Print MatLab debugging output? Variable defined at "carl_headers.h"
112 #ifdef PRINT_MATLAB_DEBUG
113  elasticity_system.matrix->print_matlab(input_params.output_base + "_sys_mat.m");
114  elasticity_system.rhs->print_matlab(input_params.output_base + "_sys_rhs_vec.m");
115 #endif
116 
117  // Export matrix and vector
118  libMesh::PetscMatrix<libMesh::Number> * temp_mat_ptr = libMesh::cast_ptr<libMesh::PetscMatrix<libMesh::Number> * >(elasticity_system.matrix);
119  libMesh::PetscVector<libMesh::Number> * temp_vec_ptr = libMesh::cast_ptr<libMesh::PetscVector<libMesh::Number> * >(elasticity_system.rhs);
120 
121  carl::write_PETSC_matrix(*temp_mat_ptr, input_params.output_base + "_sys_mat.petscmat");
122  carl::write_PETSC_vector(*temp_vec_ptr, input_params.output_base + "_sys_rhs_vec.petscvec");
123 
124  // If needed, print rigid body vectors
125  if(input_params.bCalculateRBVectors)
126  {
127  MatNullSpace nullsp_sys;
128  build_rigid_body_vectors(elasticity_system,nullsp_sys);
129  write_rigid_body_vectors(nullsp_sys,input_params.output_base,WorldComm.rank());
130  MatNullSpaceDestroy(&nullsp_sys);
131  }
132 
133  return 0;
134 }
void set_homogeneous_physical_properties(libMesh::EquationSystems &es, std::string &physicalParamsFile)
Set the homogeneous physical properties from a file.
void write_rigid_body_vectors(MatNullSpace &nullsp_sys, const std::string output_base, int rank)
Export the rigid body mode vectors to a folder.
std::string mesh_weight_file
Path to the mesh containing the weight region indices.
void get_input_params(GetPot &field_parser, feti_iterate_params &input_params)
Parser function for the coupled solver test programs.
bool bCalculateRBVectors
Build and export the rigid body modes vectors?
void write_PETSC_vector(libMesh::PetscVector< libMesh::Number > &input_vec, const std::string &filename, int dim=1)
std::string physical_params_file
Physical parameters.
void build_rigid_body_vectors(libMesh::ImplicitSystem &input_system, MatNullSpace &nullsp_sys)
Build the rigid body modes associated to a given system.
void set_clamped_border(libMesh::ImplicitSystem &elasticity_system, int boundary_id)
Set a clamped border.
libMesh::ImplicitSystem & add_elasticity(libMesh::EquationSystems &input_systems, libMesh::Order order=libMesh::FIRST, libMesh::FEFamily family=libMesh::LAGRANGE)
Add a linear elasticity libMesh::LinearImplicitSystem to the input libMesh::EquationSystems& input_sy...
boundary_id_cube
Small enumerate defining a cube's boundary ID's.
std::string weight_domain_idx_file
Path to the file identifying the weight function regions.
void assemble_elasticity_with_weight(libMesh::EquationSystems &es, const std::string &system_name, weight_parameter_function &weight_mask, WeightFunctionSystemType system_type)
Assemble homogeneous elasticity with domain weights.
WeightFunctionSystemType system_type
Indicates if the system to be assembled is a micro or a macro system (used to choose the proper weigh...
std::string mesh_file
Path to the system mesh.
std::string output_base
Output filename base.
void write_PETSC_matrix(Mat input_mat, const std::string &filename, int rank, MPI_Comm comm=PETSC_COMM_WORLD, int dim=1)