main.C File Reference

Go to the source code of this file.


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

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 }
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_nullptr, 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;
58 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1545
const class libmesh_nullptr_t libmesh_nullptr
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_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
T & set(const std::string &)
Definition: parameters.h:469
Parameters parameters
Data structure holding arbitrary parameters.
const T_sys & get_system(const std::string &name) const
The ExplicitSystem provides only "right hand side" storage, which should be sufficient for solving mo...
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::LibMeshInit::comm(), 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);
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");
69 #else
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();
80  ExodusII_IO(from_mesh).write_equation_systems("from.e", from_es);
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();
90  DTKSolutionTransfer dtk_transfer(init.comm());
92  dtk_transfer.transfer(from_sys.variable(from_var), to_sys.variable(to_var));
94  to_es.update();
95  ExodusII_IO(to_mesh).write_equation_systems("to.e", to_es);
97 #endif
99  return 0;
100 }
This is the EquationSystems class.
virtual void transfer(const Variable &from_var, const Variable &to_var) libmesh_override
Transfer the values of a variable to another.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:52
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1101
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:62
void initialize(EquationSystems &es, const std::string &system_name)
Definition: main.C:52
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2114
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
void init(triangulateio &t)
Initializes the fields of t to NULL/0 as necessary.
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:1760
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_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
Implementation of a SolutionTransfer object that uses the 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 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.
The ExplicitSystem provides only "right hand side" storage, which should be sufficient for solving mo...