Here is my test problem with an initialization class that inherits from
FunctionBase. Thanks for the help!
-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 class for initilizing velocity
template <typename Output = Number>
class EqInit : public FunctionBase<Output>{
public:
// Returns the velocity by its components
virtual Number component(unsigned int index, const Point& p, Real time = 0){
if (index == 0){
return 1; // add some intensive calculation here
} else {
return 2; // add some intensive calculation here
}
}
// Do not use the scalar output version of the operator()
Output operator() (const Point& p, const Real t = 0.){
libmesh_not_implemented();
}
// Use the component member to build the vector output version of operator()
void operator() (const Point& p, const Real t, DenseVector<Output>& output){
output.resize(2);
output(0) = component(0,p,t);
output(1) = component(1,p,t);
return;
}
// Create a copy of the class
virtual AutoPtr<FunctionBase<Output> > clone () const{
return AutoPtr<FunctionBase<Output> > (new EqInit<Output>());
}
};
// 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);
// Initilize the equation system
eq_sys.get_system("test").init();
// Project the velocity using the EqInit class
EqInit<Number> init_velocity;
eq_sys.get_system("test").project_solution(&init_velocity);
// Test that values are correct for each point on the only element
DenseVector<Number> v(2);
Elem* elem = mesh.elem(0);
for (unsigned int i = 0; i < elem->n_nodes(); i++){
Point& p = elem->point(i);
v(0) = eq_sys.get_system("test").point_value(0,p);
v(1) = eq_sys.get_system("test").point_value(1,p);
printf("Point %g,%g; v = %f,%f\n", p(0),p(1),v(0),v(1));
}
// Done
return 0;
}
On Wed, Jun 27, 2012 at 9:20 PM, Andrew E Slaughter <
[email protected]> wrote:
> Paul,
> Thanks for linking the function, that is where I will head with
> my initialization. I will post my implementation when I am done in case
> anyone needs this in the future.
>
> One question, where is libmesh_not_implemented() defined, I can't seem to
> find any documentation on it, but it looks useful?
>
> Thanks,
> Andrew
>
>
> On Wed, Jun 27, 2012 at 8:31 PM, Paul T. Bauman <[email protected]>wrote:
>
>> On Wed, Jun 27, 2012 at 6:35 PM, Andrew E Slaughter <
>> [email protected]> wrote:
>>
>>> I just checkout out the trunk with the following and the folder you
>>> specify does not exist, only examples/vector_fe/vector_fe_ex1.C
>>>
>>
>> *facepalm*
>>
>> Sorry, that patch is still being discussed on libmesh-devel. You can grab
>> the function here (I also include the function that it calls for
>> posterity): http://users.ices.utexas.edu/~pbauman/bound_func/
>>
>> Sorry about that.
>>
>> Paul
>>
>
>
>
> --
> 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/
>
>
--
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