← Back to team overview

dolfin team mailing list archive

Re: [Question #116222]: MPI Problem

 

Pietro Maximoff <question116222@xxxxxxxxxxxxxxxxxxxxx> writes:

> Question #116222 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/116222
>
> Pietro Maximoff posted a new comment:
> Below's a simple test program. All it does is create a rectangular mesh
> and colours it. Any 2D UFL form file can be used for Test.h as the test
> program doesn't solve any PDE problem.
>
> I'm using DOLFIN version 0.9.7 .
>
> Many thanks
>
> Pietro
>

If I remember correctly, Vector v(N) creates a vector of global size
N. but mesh.num_vertices() returns the size of the local mesh.


Niclas


> ========================================
>
> #include <dolfin.h>
> #include "Test.h"
>
> using namespace dolfin;
>
> int main()
> {
> 	const int dim = 2;							// dimension
>
> 	// Create mesh
> 	
> 	Rectangle mesh(0.0, 0.0, 1.0, 1.0, 10, 10);
> 	
> 	// Create function space
> 	Test::FunctionSpace V(mesh);
> 	
> 	// Set up forms
> 	Test::BilinearForm a(V, V);
> 	Test::LinearForm L(V);
> 	
> 	// Access mesh geometry
> 	MeshGeometry& geometry = mesh.geometry();
> 		
> 	// Associate a vertex to a specific cell
> 	double x0, x1;
> 	Array<double> *xy;
> 	
> 	Vector volt(mesh.num_vertices());
> 	double block[mesh.num_vertices()];
> 	dolfin::uint rows[mesh.num_vertices()];
> 	
> 	int i = 0;
> 	 for (VertexIterator vertex(mesh); !vertex.end(); ++vertex) {
> 		xy = new Array<double>(dim, geometry.x(vertex->index()));
> 		x0 = (*xy)[0];
> 		x1 = (*xy)[1]; 
>
> 		if (x0 <= 0.4)
> 		   block[i] = 40;
> 		else
> 		  block[i] = -86;
>
> 		++i;
> 	}
>
> 	// Indices of the row of the vector to set
> 	for (unsigned int i = 0; i < mesh.num_vertices(); ++i)
>             rows[i] = i;
>         
> 	// Output file in VTK format
> 	File file("test_out.pvd");
> 	
> 	volt.set(block, mesh.num_vertices(), rows);
> 	Function u(V, volt);
>
>         file << u;
>
> 	plot(u);	
> }
>
> =================================================
>
> -- 
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References