libMesh
Functions
main.C File Reference

Go to the source code of this file.

Functions

Number initial_value (const Point &p, const Parameters &, const std::string &, const std::string &)
 
void initialize (EquationSystems &es, const std::string &system_name)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ initial_value()

Number initial_value ( const Point p,
const Parameters ,
const std::string &  ,
const std::string &   
)

Definition at line 44 of file main.C.

Referenced by initialize().

48 {
49  return p(0)*p(0) + 1; // x^2 + 1
50 }

◆ initialize()

void initialize ( EquationSystems es,
const std::string &  system_name 
)

Definition at line 52 of file main.C.

References libMesh::EquationSystems::get_system(), initial_value(), libMesh::EquationSystems::parameters, libMesh::System::project_solution(), libMesh::Real, libMesh::Parameters::set(), and libMesh::System::time.

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), and main().

54 {
55  ExplicitSystem & system = es.get_system<ExplicitSystem>(system_name);
56  es.parameters.set<Real> ("time") = system.time = 0;
57  system.project_solution(initial_value, nullptr, es.parameters);
58 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1595
const T_sys & get_system(std::string_view name) const
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Number initial_value(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: main.C:44
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T & set(const std::string &)
Definition: parameters.h:469
Parameters parameters
Data structure holding arbitrary parameters.
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 60 of file main.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::System::attach_init_function(), libMesh::MeshTools::Generation::build_cube(), libMesh::HEX8, libMesh::TriangleWrapper::init(), libMesh::EquationSystems::init(), initialize(), libMesh::TET4, libMesh::DTKSolutionTransfer::transfer(), libMesh::EquationSystems::update(), libMesh::System::variable(), and libMesh::MeshOutput< MT >::write_equation_systems().

61 {
62  LibMeshInit init (argc, argv);
63 
64 #if !defined(LIBMESH_TRILINOS_HAVE_DTK)
65  // Skip this example (and use a different return code) if libMesh
66  // was compiled without Trilinos+DTK support.
67  libmesh_example_requires(false, "--enable-trilinos");
68 
69 #else
70 
71  Mesh from_mesh(init.comm());
72  MeshTools::Generation::build_cube(from_mesh, 4, 4, 4, 0, 1, 0, 1, 0, 1, HEX8);
73  from_mesh.print_info();
74  EquationSystems from_es(from_mesh);
75  System & from_sys = from_es.add_system<ExplicitSystem>("From");
76  unsigned int from_var = from_sys.add_variable("from");
78  from_es.init();
79 
80  ExodusII_IO(from_mesh).write_equation_systems("from.e", from_es);
81 
82  Mesh to_mesh(init.comm());
83  MeshTools::Generation::build_cube(to_mesh, 5, 5, 5, 0, 1, 0, 1, 0, 1, TET4);
84  to_mesh.print_info();
85  EquationSystems to_es(to_mesh);
86  System & to_sys = to_es.add_system<ExplicitSystem>("To");
87  unsigned int to_var = to_sys.add_variable("to");
88  to_es.init();
89 
90  DTKSolutionTransfer dtk_transfer(init.comm());
91 
92  dtk_transfer.transfer(from_sys.variable(from_var), to_sys.variable(to_var));
93 
94  to_es.update();
95  ExodusII_IO(to_mesh).write_equation_systems("to.e", to_es);
96 
97 #endif
98 
99  return 0;
100 }
This is the EquationSystems class.
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: mesh_output.C:31
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:52
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:90
void initialize(EquationSystems &es, const std::string &system_name)
Definition: main.C:52
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1305
virtual void transfer(const Variable &from_var, const Variable &to_var) override
Transfer the values of a variable to another.
Implementation of a SolutionTransfer object that uses the DataTransferKit (https://github.com/CNERG/DataTransferKit) to transfer variables back and forth between systems.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in initializing the system.
Definition: system.C:2078
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...