If I understand libmesh correctly, if you are solving a system that has a
vector solution (i.e., velocity) then you need to add variables such as
"vx" and "vy" for each component. Then solve the system using submatrices
and vectors etc. Therefore, the libmesh::System add_vector command is only
for storing supplement data. Is this correct libmesh logic?
If I am correct above, then how do a write an initialization function for
such a problem? I attached a sample program below that doesn't work because
the initial_velocity function is called for both and the first value of the
output vector is assigned to both vx and vy. How do I assign different
values for the different directions?
Thanks,
Andrew
// Standard library includes
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string>
using std::string;
// libMesh includes
#include "libmesh.h"
#include "mesh.h"
#include "mesh_generation.h"
#include "equation_systems.h"
#include "nonlinear_implicit_system.h"
#include "transient_system.h"
#include "explicit_system.h"
#include "analytic_function.h"
#include "exodusII_io.h"
// Bring in everything from the libMesh namespace
using namespace libMesh;
// A function for initializing, this d
void initial_velocity(DenseVector<Number>& output, const Point&, const
Real){
output(0) = 1; // x-dir
// output(1) = 2; // y-dir (this causes an error, but this is what seems
logical)
}
void init_cd (EquationSystems& es, const std::string&){
TransientNonlinearImplicitSystem& system =
es.get_system<TransientNonlinearImplicitSystem>("test");
AnalyticFunction<Number> fobj(initial_velocity);
system.project_solution(&fobj);
}
// The main function
int main (int argc, char** argv){
// Initialize libraries
LibMeshInit init (argc, argv);
// Generate a mesh
Mesh mesh;
MeshTools::Generation::build_square(mesh, 1, 1, -1., 1, -1, 1, QUAD4);
mesh.all_first_order();
// Create an equation system
EquationSystems eq_sys(mesh);
// Create a system and add two variables (x and y velocity components)
eq_sys.add_system<TransientNonlinearImplicitSystem>("test");
eq_sys.get_system("test").add_variable("vx", FIRST);
eq_sys.get_system("test").add_variable("vy", FIRST);
// Attach initilization function
eq_sys.get_system("test").attach_init_function(init_cd);
// Initilize the equation system storing the data
eq_sys.get_system("test").init();
// Export the solution
ExodusII_IO(mesh).write_equation_systems("example3b.ex2", eq_sys);
// Done
return 0;
}
--
Andrew E. Slaughter, PhD
[email protected]
Materials Process Design and Control Laboratory
Sibley School of Mechanical and Aerospace Engineering
169 Frank H. T. Rhodes Hall
Cornell University
Ithaca, NY 14853-3801
(607) 229-1829
http://aeslaughter.github.com/
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users