Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Manav Bhatia
I added an member to my class by the name “linear_solver” and initialize it in 
the init_data() method using this snippet: 

linear_solver.reset(new libMesh::PetscLinearSolver(this->comm()));
if (libMesh::on_command_line("--solver_system_names")) {

std::string nm = this->name() + "_";
linear_solver->init(nm.c_str());
}


Seems to be working fine so far. 

-Manav


> On Jan 29, 2018, at 3:12 PM, Roy Stogner  wrote:
> 
> 
> On Mon, 29 Jan 2018, Manav Bhatia wrote:
> 
>> I ended up creating a function similar to the one in LInearImplicitSystem to 
>> get around this issue.
>> 
>> Working out fine now.
> 
> Good to hear.
> 
> Is your get_linear_solver() anything general enough to move upstream
> to NonlinearImplicitSystem?  The lack of a get_linear_solver()
> overload there might be because I was going to add one and realized
> some good reason why I couldn't, but a more likely scenario is just
> that I wasn't using (or testing with, therefore) that class and didn't
> want to implement something blind.
> ---
> Roy

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Roy Stogner


On Mon, 29 Jan 2018, Manav Bhatia wrote:


I ended up creating a function similar to the one in LInearImplicitSystem to 
get around this issue.

Working out fine now.


Good to hear.

Is your get_linear_solver() anything general enough to move upstream
to NonlinearImplicitSystem?  The lack of a get_linear_solver()
overload there might be because I was going to add one and realized
some good reason why I couldn't, but a more likely scenario is just
that I wasn't using (or testing with, therefore) that class and didn't
want to implement something blind.
---
Roy

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Manav Bhatia
I ended up creating a function similar to the one in LInearImplicitSystem to 
get around this issue. 

Working out fine now. 

Thanks!
Manav


> On Jan 29, 2018, at 1:59 PM, John Peterson  wrote:
> 
> 
> 
> On Mon, Jan 29, 2018 at 11:42 AM, Manav Bhatia  > wrote:
> Except for a sensitivity solve. 
> 
> Hmm... so you are referring to the get_linear_solver() calls in 
> 
> ImplicitSystem::adjoint_solve()
> ImplicitSystem::sensitivity_solve() 
> ImplicitSystem::weighted_sensitivity_adjoint_solve()
> ImplicitSystem::weighted_sensitivity_solve()
> 
> ?
> 
> If I understand correctly, those should all be calling the derived class 
> LinearImplicitSystem::get_linear_solver() method in practice.
> 
> In the class you are writing that is derived from NonlinearImplicitSystem, if 
> you hang on to your own LinearSolver object, you could write a function 
> similar to the one above to provide access to it.
> 
> -- 
> John

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread John Peterson
On Mon, Jan 29, 2018 at 11:42 AM, Manav Bhatia 
wrote:

> Except for a sensitivity solve.
>

Hmm... so you are referring to the get_linear_solver() calls in

ImplicitSystem::adjoint_solve()
ImplicitSystem::sensitivity_solve()
ImplicitSystem::weighted_sensitivity_adjoint_solve()
ImplicitSystem::weighted_sensitivity_solve()

?

If I understand correctly, those should all be calling the derived class
LinearImplicitSystem::get_linear_solver() method in practice.

In the class you are writing that is derived from NonlinearImplicitSystem,
if you hang on to your own LinearSolver object, you could write a function
similar to the one above to provide access to it.

-- 
John
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Manav Bhatia
Except for a sensitivity solve. 

> On Jan 29, 2018, at 12:41 PM, John Peterson  wrote:
> 
> 
> 
> On Mon, Jan 29, 2018 at 11:09 AM, Manav Bhatia  > wrote:
> I see. 
> 
> So, I am defining a class that inherits from nonlinear_implicit_system, and 
> calling  get_linear_solver() on that.  This gets to the implementation in 
> implicit_system, since the nonlinear_implicit_system does not define an 
> overriding function. 
> 
> Instead, there is one defined in  linear_implicit_system, but that is a 
> different code path. 
> 
> 
> Right, the NonlinearImplicitSystem has a public nonlinear_solver member, but 
> it doesn't really make sense to call get_linear_solver() on a 
> NonlinearImplicitSystem, since it doesn't really have one to hand back.
> 
> -- 
> John

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread John Peterson
On Mon, Jan 29, 2018 at 11:09 AM, Manav Bhatia 
wrote:

> I see.
>
> So, I am defining a class that inherits from nonlinear_implicit_system,
> and calling  get_linear_solver() on that.  This gets to the implementation
> in implicit_system, since the nonlinear_implicit_system does not define an
> overriding function.
>
> Instead, there is one defined in  linear_implicit_system, but that is a
> different code path.
>


Right, the NonlinearImplicitSystem has a public nonlinear_solver member,
but it doesn't really make sense to call get_linear_solver() on a
NonlinearImplicitSystem, since it doesn't really have one to hand back.

-- 
John
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Manav Bhatia
I see. 

So, I am defining a class that inherits from nonlinear_implicit_system, and 
calling  get_linear_solver() on that.  This gets to the implementation in 
implicit_system, since the nonlinear_implicit_system does not define an 
overriding function. 

Instead, there is one defined in  linear_implicit_system, but that is a 
different code path. 

-Manav


> On Jan 29, 2018, at 11:12 AM, John Peterson  wrote:
> 
> 
> 
> On Mon, Jan 29, 2018 at 9:59 AM, Manav Bhatia  > wrote:
> Hi,
> 
>  The source code says that the following method is deprecated:
> 
>  ImplicitSystem::get_linear_solver()
> 
>  This is, however, extensively being used in implicit_system.C.
> 
>   Is there a different method that I should be looking to use?
> 
> 
> Hmm... "deprecated" is a bit of a misnomer here, I think what will eventually 
> happen is that the base class implementation will be changed into a 
> libmesh_error() to prevent it from being accidentally called.
> 
> The usage you are referring to in implicit_system.C therefore represents 
> calls to derived class implementations, and should remain as-is.
> 
> If you are currently seeing a deprecation message from calling this function, 
> you are probably doing something wrong and need to fix your code, but I doubt 
> that's the case?
> 
> -- 
> John

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


Re: [Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread John Peterson
On Mon, Jan 29, 2018 at 9:59 AM, Manav Bhatia  wrote:

> Hi,
>
>  The source code says that the following method is deprecated:
>
>  ImplicitSystem::get_linear_solver()
>
>  This is, however, extensively being used in implicit_system.C.
>
>   Is there a different method that I should be looking to use?
>


Hmm... "deprecated" is a bit of a misnomer here, I think what will
eventually happen is that the base class implementation will be changed
into a libmesh_error() to prevent it from being accidentally called.

The usage you are referring to in implicit_system.C therefore represents
calls to derived class implementations, and should remain as-is.

If you are currently seeing a deprecation message from calling this
function, you are probably doing something wrong and need to fix your code,
but I doubt that's the case?

-- 
John
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users


[Libmesh-users] ImplicitSystem::get_linear_solver()

2018-01-29 Thread Manav Bhatia
Hi, 

 The source code says that the following method is deprecated:

 ImplicitSystem::get_linear_solver()

 This is, however, extensively being used in implicit_system.C. 

  Is there a different method that I should be looking to use? 

Thanks,
Manav

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users