Ok, I'm not a guru but you can look in system_projection.C line 277
System::ProjectVector::operator().
Il giorno 21/ott/2009, alle ore 00.39, David Knezevic ha scritto:
> I had a look at getting SCALAR variables working with n_processors()
> > 1. The attached patches for dof_map take care of things, but I
> wanted to run them by the list before checking in since 0.6.4 is
> just around the corner.
>
> The change I made is to increment next_free_dof appropriately for
> SCALARs in distribute_local_dofs_*_major, so that now _n_dfs
> includes the SCALAR dofs.
>
> I think the only thing still not working for SCALARs is
> project_vector. In principle that should be easy; we just copy the
> SCALAR values directly from old_vec to new_vec --- if one of the
> project_vector gurus could point me to the right place to look at
> that, that'd be great.
>
> - Dave
> Index: include/base/dof_map.h
> ===================================================================
> --- include/base/dof_map.h (revision 3502)
> +++ include/base/dof_map.h (working copy)
> @@ -338,8 +338,8 @@
> /**
> * @returns the total number of degrees of freedom in the problem.
> */
> - unsigned int n_dofs() const { return _n_dfs + _n_SCALAR_dofs; }
>
> + unsigned int n_dofs() const { return _n_dfs; }
> /**
> * @returns the number of SCALAR dofs.
> */
> @@ -349,16 +349,13 @@
> * @returns the number of degrees of freedom on this processor.
> */
> unsigned int n_local_dofs () const
> - { return this->n_dofs_on_processor (libMesh::processor_id()) +
> _n_SCALAR_dofs; }
> -
> + { return this->n_dofs_on_processor (libMesh::processor_id()); }
> +
> /**
> * Returns the number of degrees of freedom on subdomain \p proc.
> - *
> - * This _n_SCALAR_dofs hack won't work in parallel, just test it
> out.
> - * Should store the number of SCALAR dofs on each processor...
> */
> unsigned int n_dofs_on_processor(const unsigned int proc) const
> - { libmesh_assert(proc < _first_df.size()); return (_end_df[proc]
> - _first_df[proc] + _n_SCALAR_dofs); }
> + { libmesh_assert(proc < _first_df.size()); return (_end_df[proc]
> - _first_df[proc]); }
>
> /**
> * Returns the first dof index that is local to subdomain \p proc.
> @@ -370,20 +367,16 @@
> * Returns the last dof index that is local to subdomain \p proc.
> * This function is now deprecated, because it returns nonsense in
> the rare
> * case where \p proc has no local dof indices. Use end_dof()
> instead.
> - *
> - * This _n_SCALAR_dofs hack won't work in parallel, just for
> testing...
> */
> unsigned int last_dof(const unsigned int proc =
> libMesh::processor_id()) const
> - { libmesh_deprecated(); libmesh_assert(proc < _end_df.size());
> return (_end_df[proc] - 1 + _n_SCALAR_dofs); }
> + { libmesh_deprecated(); libmesh_assert(proc < _end_df.size());
> return (_end_df[proc] - 1); }
>
> /**
> * Returns the first dof index that is after all indices local to
> subdomain \p proc.
> * Analogous to the end() member function of STL containers.
> - *
> - * This _n_SCALAR_dofs hack won't work in parallel, just for
> testing...
> */
> unsigned int end_dof(const unsigned int proc =
> libMesh::processor_id()) const
> - { libmesh_assert(proc < _end_df.size()); return _end_df[proc] +
> _n_SCALAR_dofs; }
> + { libmesh_assert(proc < _end_df.size()); return _end_df[proc]; }
>
> /**
> * Returns the first local degree of freedom index for variable \p
> var.
> @@ -398,15 +391,12 @@
> /**
> * Returns (one past) the last local degree of freedom index for
> variable \p var.
> * Analogous to the end() member function of STL containers.
> - *
> - * This _n_SCALAR_dofs hack won't work in parallel, just test it
> out.
> - * Should store the number of SCALAR dofs on each processor...
> */
> unsigned int variable_last_local_dof (const unsigned int var) const
> {
> libmesh_assert ((var+1) < _var_first_local_df.size());
> libmesh_assert (_var_first_local_df[var+1] !=
> DofObject::invalid_id);
> - return _var_first_local_df[var+1] + _n_SCALAR_dofs;
> + return _var_first_local_df[var+1];
> }
>
> /**
> Index: src/base/dof_map.C
> ===================================================================
> --- src/base/dof_map.C (revision 3502)
> +++ src/base/dof_map.C (working copy)
> @@ -361,13 +361,10 @@
> const System::Variable &var_description = this->variable(var);
> const FEType& base_fe_type = this->variable_type
> (var);
>
> - // Skip dof counting for a SCALAR variable
> + // Don't need to loop over elements for a SCALAR variable
> + // Just increment _n_SCALAR_dofs
> if(base_fe_type.family == SCALAR)
> {
> - // TODO: This only works in serial at the moment
> - if(libMesh::n_processors() > 1)
> - libmesh_not_implemented();
> -
> this->_n_SCALAR_dofs += base_fe_type.order;
> continue;
> }
> @@ -769,21 +766,6 @@
> _var_first_local_df.end(),
> DofObject::invalid_id);
>
> - // Set _n_SCALAR_dofs
> - this->_n_SCALAR_dofs = 0;
> - for (unsigned var=0; var<n_vars; var++)
> - {
> - if( this->variable(var).type().family == SCALAR )
> - {
> - // TODO: This only works in serial at the moment
> - if(libMesh::n_processors() > 1)
> - libmesh_not_implemented();
> -
> - this->_n_SCALAR_dofs += this->variable(var).type().order;
> - continue;
> - }
> - }
> -
> //-------------------------------------------------------------------------
> // First count and assign temporary numbers to local dofs
> MeshBase::element_iterator elem_it =
> mesh.active_local_elements_begin();
> @@ -841,6 +823,22 @@
> }
> } // done looping over elements
>
> + // Finally, count up the SCALAR dofs
> + this->_n_SCALAR_dofs = 0;
> + for (unsigned var=0; var<n_vars; var++)
> + {
> + if( this->variable(var).type().family == SCALAR )
> + {
> + this->_n_SCALAR_dofs += this->variable(var).type().order;
> + continue;
> + }
> + }
> +
> + // Only increment next_free_dof if we're on the processor
> + // that holds this SCALAR variable
> + if ( libMesh::processor_id() == (libMesh::n_processors()-1) )
> + next_free_dof += _n_SCALAR_dofs;
> +
> #ifdef DEBUG
> // Make sure we didn't miss any nodes
> MeshTools::libmesh_assert_valid_node_procids(mesh);
> @@ -878,9 +876,6 @@
> // We will cache the first local index for each variable
> _var_first_local_df.clear();
>
> - // Zero _n_SCALAR_dofs, we will set it below
> - this->_n_SCALAR_dofs = 0;
> -
> //-------------------------------------------------------------------------
> // First count and assign temporary numbers to local dofs
> for (unsigned var=0; var<n_vars; var++)
> @@ -889,16 +884,9 @@
>
> const System::Variable var_description = this->variable(var);
>
> - // Skip dof counting for a SCALAR variable
> + // Skip the SCALAR dofs
> if(var_description.type().family == SCALAR)
> - {
> - // TODO: This only works in serial at the moment
> - if(libMesh::n_processors() > 1)
> - libmesh_not_implemented();
> -
> - this->_n_SCALAR_dofs += var_description.type().order;
> continue;
> - }
>
> MeshBase::element_iterator elem_it =
> mesh.active_local_elements_begin();
> const MeshBase::element_iterator elem_end =
> mesh.active_local_elements_end();
> @@ -952,6 +940,22 @@
> } // end loop on elements
> } // end loop on variables
>
> + // Finally, count up the SCALAR dofs
> + this->_n_SCALAR_dofs = 0;
> + for (unsigned var=0; var<n_vars; var++)
> + {
> + if( this->variable(var).type().family == SCALAR )
> + {
> + this->_n_SCALAR_dofs += this->variable(var).type().order;
> + continue;
> + }
> + }
> +
> + // Only increment next_free_dof if we're on the processor
> + // that holds this SCALAR variable
> + if ( libMesh::processor_id() == (libMesh::n_processors()-1) )
> + next_free_dof += _n_SCALAR_dofs;
> +
> // Cache the last local dof number too
> _var_first_local_df.push_back(next_free_dof);
>
> @@ -1297,8 +1301,8 @@
> unsigned int tot_size = 0;
> #endif
>
> - // Create a vector to store the variable numbers
> - // of SCALAR variables that we've requested
> + // Create a vector to indicate which
> + // SCALAR variables have been requested
> std::vector<unsigned int> SCALAR_var_numbers;
> SCALAR_var_numbers.clear();
>
> @@ -1308,18 +1312,14 @@
> {
> if(this->variable(v).type().family == SCALAR)
> {
> - // TODO: This only works in serial at the moment
> - if(libMesh::n_processors() > 1)
> - libmesh_not_implemented();
> -
> // We asked for this variable, so add it to the vector.
> SCALAR_var_numbers.push_back(v);
>
> #ifdef DEBUG
> - FEType fe_type = this->variable_type(v);
> - tot_size += FEInterface::n_dofs(dim,
> - fe_type,
> - type);
> + FEType fe_type = this->variable_type(v);
> + tot_size += FEInterface::n_dofs(dim,
> + fe_type,
> + type);
> #endif
> }
> else
> @@ -1463,7 +1463,7 @@
> }
>
> #ifdef DEBUG
> - libmesh_assert (tot_size == di.size());
> + libmesh_assert (tot_size == di.size());
> #endif
>
> STOP_LOG("dof_indices()", "DofMap");
> @@ -1497,28 +1497,24 @@
> unsigned int tot_size = 0;
> #endif
>
> - // Create a vector to store the variable numbers
> - // of SCALAR variables that we've requested
> + // Create a vector to indicate which
> + // SCALAR variables have been requested
> std::vector<unsigned int> SCALAR_var_numbers;
> SCALAR_var_numbers.clear();
> -
> +
> // Get the dof numbers
> for (unsigned int v=0; v<n_vars; v++)
> if ((v == vn) || (vn == libMesh::invalid_uint))
> {
> if(this->variable(v).type().family == SCALAR)
> {
> - // TODO: This only works in serial at the moment
> - if(libMesh::n_processors() > 1)
> - libmesh_not_implemented();
> -
> // We asked for this variable, so add it to the vector.
> SCALAR_var_numbers.push_back(v);
>
> #ifdef DEBUG
> FEType fe_type = this->variable_type(v);
> tot_size += FEInterface::n_dofs(dim,
> - fe_type,
> + fe_type,
> type);
> #endif
> }
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference_______________________________________________
> Libmesh-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libmesh-devel
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users