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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 3 of file libmesh_apply_solution_homogeneous.cpp.

3  {
4 
5  // --- Initialize libMesh
6  libMesh::LibMeshInit init(argc, argv);
7 
8  // Do performance log?
9  libMesh::PerfLog perf_log("Main program");
10 
11  // libMesh's C++ / MPI communicator wrapper
12  libMesh::Parallel::Communicator& WorldComm = init.comm();
13 
14  // --- Set up inputs
15 
16  // Command line parser
17  GetPot command_line(argc, argv);
18 
19  // File parser
20  GetPot field_parser;
21 
22  // If there is an input file, parse it to get the parameters. Else, parse the command line
23  std::string input_filename;
24  if (command_line.search(2, "--inputfile", "-i")) {
25  input_filename = command_line.next(input_filename);
26  field_parser.parse_input_file(input_filename, "#", "\n", " \t\n");
27  } else {
28  field_parser = command_line;
29  }
30 
32  carl::get_input_params(field_parser, input_params);
33 
34  // Check libMesh installation dimension
35  const unsigned int dim = 3;
36 
37  libmesh_example_requires(dim == LIBMESH_DIM, "3D support");
38 
39  // - Parallelized meshes A
40  libMesh::Mesh system_mesh(WorldComm, dim);
41  system_mesh.read(input_params.input_mesh);
42  system_mesh.prepare_for_use();
43 
44  // Set the equation systems object
45  libMesh::EquationSystems equation_systems(system_mesh);
46 
47  // Add linear elasticity and stress
48  libMesh::LinearImplicitSystem& elasticity_system
49  = add_elasticity(equation_systems);
50  add_stress(equation_systems);
51 
52  // Initialize the equation systems
53  equation_systems.init();
54 
55  // Homogeneous physical properties
56  set_homogeneous_physical_properties(equation_systems, input_params.physical_params_file);
57 
58  // Read the solution vector
59  libMesh::PetscVector<libMesh::Real> * sol_vec_ptr = libMesh::cast_ptr<libMesh::PetscVector<libMesh::Real> * >(elasticity_system.solution.get());
60  carl::read_PETSC_vector(sol_vec_ptr->vec(),input_params.input_vector, WorldComm.get());
61 
62  // Close it and update
63  elasticity_system.solution->close();
64  elasticity_system.update();
65 
66  // Calculate the stress
67  compute_stresses(equation_systems);
68 
69  // Export solution
70 #ifdef LIBMESH_HAVE_EXODUS_API
71  libMesh::ExodusII_IO exo_io_interface(system_mesh, /*single_precision=*/true);
72 
73  std::set<std::string> system_names;
74  system_names.insert("Elasticity");
75  exo_io_interface.write_equation_systems(input_params.output_mesh,equation_systems,&system_names);
76  exo_io_interface.write_element_data(equation_systems);
77 #endif
78 
79  return 0;
80 }
void set_homogeneous_physical_properties(libMesh::EquationSystems &es, std::string &physicalParamsFile)
Set the homogeneous physical properties from a file.
void get_input_params(GetPot &field_parser, feti_iterate_params &input_params)
Parser function for the coupled solver test programs.
std::string input_vector
Path to the input vector containing the displacements.
std::string input_mesh
Path to the mesh that will be deformed.
libMesh::ExplicitSystem & add_stress(libMesh::EquationSystems &input_systems)
Add a stress libMesh::ExplicitSystem to the input libMesh::EquationSystems.
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...
void compute_stresses(libMesh::EquationSystems &es)
Compute the stress (based on one of libMesh's examples)
void read_PETSC_vector(libMesh::PetscVector< libMesh::Number > &input_vec, const std::string &filename)