Dear Roy:
I am sorry to further bother you. Howeve, I have read the patch you provided
to me. I think I didn't demonstrate my problem detailedly.
I need to dynamically add vectors after System::init(). However, regarding
the patch, I think it only is for before System::init(), right?
Because if System::init() is implemented, the program will generate errors
in the following codes to my knowledge
"
- // We can only add new vectors before initializing...
- if (!_can_add_vectors)
- {
- std::cerr << "ERROR: Too late. Cannot add vectors to the system after
initialization"
- << std::endl
- << " any more. You should have done this earlier."
- << std::endl;
- libmesh_error();
- }
"
thanks a lot.
Regards,
Yujie
On Fri, Nov 21, 2008 at 1:05 PM, Roy Stogner <[EMAIL PROTECTED]>wrote:
>
> On Thu, 20 Nov 2008, Yujie wrote:
>
> I notice that if i need to add vectors in LinearImplicitSystem using
>> System::add_vector() it must be done before System::init(). However, I
>> can't
>> confirm the vector number at the beginning. How to dynamically add
>> vectors?
>>
>
> Try the following patch, and let me know if it works; if so I'll commit it
> to SVN.
>
>
> Index: src/solvers/system.C
> ===================================================================
> --- src/solvers/system.C (revision 3160)
> +++ src/solvers/system.C (working copy)
> @@ -493,21 +493,17 @@
> return *(_vectors[vec_name]);
> }
>
> - // We can only add new vectors before initializing...
> - if (!_can_add_vectors)
> - {
> - std::cerr << "ERROR: Too late. Cannot add vectors to the system
> after initialization"
> - << std::endl
> - << " any more. You should have done this earlier."
> - << std::endl;
> - libmesh_error();
> - }
> -
> - // Otherwise build the vector and return it.
> + // Otherwise build the vector
> NumericVector<Number>* buf = NumericVector<Number>::build().release();
> _vectors.insert (std::make_pair (vec_name, buf));
> _vector_projections.insert (std::make_pair (vec_name, projections));
>
> + // Initialize it if necessary
> + if (!_can_add_vectors)
> + {
> + buf->init (this->n_dofs(), this->n_local_dofs());
> + }
> +
> return *buf;
> }
>
>
> In addition, In the same LinearImplicitSystem, the vectors added by
>> add_vector() have similar characteristics with the variable added by
>> add_variable(), such as parallel distribution, same Dofs? thanks a lot.
>>
>
> Every vector added to a system has dofs for every variable in that system.
> All
> vectors have the same indexing and the same parallel distribution. (In
> particular they're all parallelized like solution, and if you want ghost
> dof
> coefficients you'll need to create a local vector to hold them)
> ---
> Roy
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users