dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #12710
Re: Dimension of function space too large for application to linear system
Martin,
Thank you very much for pointing that out. Now at least my code runs (I still needs to get the convergence right). I didn't realize the MeshFunction part is problematic, because the exact same code had worked in dolfin-0.8.1.
Thank you again for your help.
Best,
Chong
________________________________
From: Martin Sandve Alnæs <martinal@xxxxxxxxx>
To: Chong Luo <luo.chong@xxxxxxxxx>
Cc: dolfin-dev@xxxxxxxxxx
Sent: Friday, March 13, 2009 12:49:38 PM
Subject: Re: [DOLFIN-dev] Dimension of function space too large for application to linear system
You create a MeshFunction locally in the constructor to MyNonlinearProblem,
and pass a pointer to it to DirichletBC constructors to objects that
live on after
the constructor finishes. At the end of the constructor, the MeshFunction is
deleted, but DirichletBC objects still point to the old memory which can later
be filled with other stuff.
Martin
On Fri, Mar 13, 2009 at 5:40 PM, Chong Luo <luo.chong@xxxxxxxxx> wrote:
> OK. I've deleted several other lines. Now it's really minimal, otherwise it
> cannot reproduce the problem.
>
> We still need to modify dolfin-0.9.1/dolfin/fem/DirichletBC.cpp and
> dolfin-0.9.1/dolfin/fem/DirichletBC.h, though.
>
> Best,
> Chong
> ________________________________
> From: Garth N. Wells <gnw20@xxxxxxxxx>
> To: Chong Luo <luo.chong@xxxxxxxxx>
> Cc: dolfin-dev@xxxxxxxxxx
> Sent: Friday, March 13, 2009 11:31:54 AM
> Subject: Re: [DOLFIN-dev] Dimension of function space too large for
> application to linear system
>
>
>
> Chong Luo wrote:
>> Attached is the minimal code that can reproduce the problem.
>>
>
> You need to make the code shorter for anyone to take a look at.
>
> Garth
>
>
>> However, I also modified /dolfin-0.9.1/dolfin/fem/DirichletBC.cpp to add
>> the following function:
>> void DirichletBC::dim() const
>> {
>> cout << "dim of the subspace is " << V->dim() << endl;
>> }
>> And /dolfin-0.9.1/dolfin/fem/DirichletBC.h is changed accordingly to add
>> the declaration of that function:
>> /// report the dimension of the subspace
>> void dim() const;
>>
>> Thank you for your attention!
>>
>> Best,
>> Chong
>>
>> ------------------------------------------------------------------------
>> *From:* Garth N. Wells <gnw20@xxxxxxxxx>
>> *To:* Chong Luo <luo.chong@xxxxxxxxx>
>> *Cc:* dolfin-dev@xxxxxxxxxx
>> *Sent:* Friday, March 13, 2009 11:09:26 AM
>> *Subject:* Re: [DOLFIN-dev] Dimension of function space too large for
>> application to linear system
>>
>> Trying sending the simplest possible piece of code (simpler than that
>> below) that compiles and reproduces the error to the mailing list.
>>
>> Garth
>>
>> Chong Luo wrote:
>> > After some debuggin, I have found a weird problem. Let me try to
>> explain.
>> >
>> > I've modified /dolfin-0.9.1/dolfin/fem/DirichletBC.cpp to add the
>> following function to check the dimension of the function space.
>> > void DirichletBC::dim() const
>> > {
>> > cout << "dim of the subspace is " << V->dim() << endl;
>> > }
>> >
>> > I have defined a NonlinearProblem of my own "class MyNonlinearProblem :
>> public NonlinearProblem", which have two pointers to DirichletBC.
>> > // Pointers to boundary conditions
>> > DirichletBC* bcDsp;
>> > DirichletBC* bcOrt;
>> > I've made both of them public, so that they are available for
>> debugging.
>> >
>> > Here is how I created bcDsp and bcOrt in the constructor of class
>> MyNonlinearProblem:
>> > // Create boundary conditions
>> > MeshFunction<unsigned int> sub_domains(mesh, mesh.topology().dim()
>> -1);
>> > sub_domains = 2;
>> > dirichlet_boundary.mark(sub_domains, 5);
>> > // Define sub systems for boundary
>> > std::vector<unsigned int> u12lev(3);
>> > for(int i=0; i<3; ++i){
>> > u12lev[i] = 0;
>> > }
>> > SubSpace u12(*V, u12lev);
>> > bcDsp = new DirichletBC(u12, uD, sub_domains, 5);
>> > std::vector<unsigned int> n12lev(3);
>> > for(int i=0; i<3; ++i){
>> > n12lev[i] = 0;
>> > }
>> > n12lev[2] = 1;
>> > SubSpace n12(*V, n12lev);
>> > bcOrt = new DirichletBC(n12, nD, sub_domains, 5);
>> > bcDsp->dim(); //(*)
>> > bcOrt->dim(); //(**)
>> > cout << "init is fine" << endl << endl;
>> > Then in the main() function, I also checked bcDsp->dim() and
>> bcOrt->dim() like this:
>> > MyNonlinearProblem nonlinear_problem(mesh, dirichlet_boundary, u,
>> uD, nD, c10, alpha, beta);
>> > cout << "check bcDsp after initialization" << endl;
>> > nonlinear_problem.bcDsp->dim(); //(***)
>> > cout << "check bcOrt after initialization" << endl;
>> > nonlinear_problem.bcOrt->dim(); //(****)
>> >
>> > Here is the program output:
>> > dim of the subspace is 2178
>> > dim of the subspace is 2178
>> > init is fine
>> >
>> > check bcDsp after initialization
>> > dim of the subspace is 2178
>> > check bcOrt after initialization
>> > [0]PETSC ERROR:
>> ------------------------------------------------------------------------
>> > [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation
>> Violation, probably memory access out of range
>> > ....
>> >
>> > From the output, we can see the weird problem is that, bcDsp and bcOrt
>> are perfectly fine in the first three places (*), (**), and (***). However,
>> bcOrt became corrupted at (****) right after the creation of the object
>> "MyNonlinearProblem nonlinear_problem".
>> >
>> > I'm really confused why this should happen. Do you have any idea?
>> >
>> > Thank you!
>> >
>> > Best,
>> > Chong
>> >
>> ------------------------------------------------------------------------
>> > *From:* Anders Logg <logg@xxxxxxxxx <mailto:logg@xxxxxxxxx>>
>> > *To:* dolfin-dev@xxxxxxxxxx <mailto:dolfin-dev@xxxxxxxxxx>
>> > *Sent:* Sunday, March 1, 2009 3:21:21 PM
>> > *Subject:* Re: [DOLFIN-dev] Fw: [FEniCS-dev] Dimension of function
>> space too large for application to linear system
>> >
>> > On Sun, Mar 01, 2009 at 01:03:54PM -0800, Chong Luo wrote:
>> > > I sent the email before I subscribed to the mailing list, so I try
>> again.
>> > >
>> > > Best,
>> > > Chong
>> > > ----- Forwarded Message ----
>> > > From: Chong Luo <luo.chong@xxxxxxxxx <mailto:luo.chong@xxxxxxxxx>
>> <mailto:luo.chong@xxxxxxxxx <mailto:luo.chong@xxxxxxxxx>>>
>> > > To: dolfin-dev@xxxxxxxxxx <mailto:dolfin-dev@xxxxxxxxxx>
>> <mailto:dolfin-dev@xxxxxxxxxx <mailto:dolfin-dev@xxxxxxxxxx>>
>> > > Sent: Sunday, March 1, 2009 2:58:46 PM
>> > > Subject: Re: [FEniCS-dev] Dimension of function space too large for
>> application
>> > > to linear system
>> > >
>> > > Yes, I'm sure I have 4 levels of nested sub spaces. The function
>> space is
>> > > defined as follows:
>> > >
>> > > vector = VectorElement("Lagrange", "triangle", 2)
>> > > scalar = FiniteElement("Lagrange", "triangle", 1)
>> > > mixed = vector+vector+scalar+scalar #
>> > > displacement+orientation+pressure+lambda
>> >
>> > What does this last line do? It just adds stuff. Do you use it for
>> > anything?
>> >
>> > Also, lambda is not a good name as it is in conflict with a Python
>> > keyword. I'm surprised it compiles at all.
>> >
>> > > v = TestFunction(mixed) u = TrialFunction(mixed)
>> > >
>> > > Thus u12 corresponds to the subspace of displacement, and n12
>> corresponds to
>> > > the subspace of the orientation.
>> >
>> > The way you write it above, the mixed space will actually have 4
>> levels:
>> >
>> > mixed = ((vector + vector) + scalar) + scalar
>> >
>> > In particular, the first component of the original vector space will
>> > be subspace (0, 0, 0, 0). Is this what you intend? Note the order of
>> > nesting from left to right above.
>> >
>> > If this is what you intend, can you post a minimal example that breaks?
>> > With minimal, I mean less than 10 lines of code. The simpler it is,
>> > the greater the chance that someone will find time to track down the
>> > bug.
>> >
>> > -- Anders
>> >
>> >
>> >
>> ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > DOLFIN-dev mailing list
>> > DOLFIN-dev@xxxxxxxxxx <mailto:DOLFIN-dev@xxxxxxxxxx>
>>> http://www.fenics.org/mailman/listinfo/dolfin-dev
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> DOLFIN-dev mailing list
>> DOLFIN-dev@xxxxxxxxxx
>> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>
>
References