Dear all,

While I'm still on the subset stuff (I had to do a couple of other things in the last weeks, but I'm on it again, and my application does not yet work as expected), I'd suddenly like to be able to disable the interpolation in the MeshFunction. That is, what I want is this: I pass a point to the MeshFunction, and the MeshFunction finds the element in which this point is and then finds the node of this element which is nearest to the point and then returns the dof value of that node.

I have implemented this, see attached patch. What I do is, I loop over all dofs, but instead of multiplying the dof value with the value of the shape function, I find out which shape function takes the largest value, and then I return the corresponding dof's value.

This does what I want in my situation. However, I would like to hear your comments, in particular:

* Would you like this functionality in the library?

* Do you like the API?

* Will this always do what I mean? (Actually, for me it is not really important that it's definitely the nearest node's value what I get. Rather, it suffices that in some reasonable neighborhood a node, I get that node's value. Possible, the name of the mode should be changed then.)

* What should this mode do to the gradient and the hessian?

Best Regards,

Tim

PS: I won't be here on Monday.

--
Dr. Tim Kroeger
CeVis -- Center of Complex Systems and Visualization
University of Bremen              [email protected]
Universitaetsallee 29             [email protected]
D-28359 Bremen                             Phone +49-421-218-7710
Germany                                    Fax   +49-421-218-4236
Index: include/mesh/mesh_function.h
===================================================================
--- include/mesh/mesh_function.h        (Revision 3964)
+++ include/mesh/mesh_function.h        (Arbeitskopie)
@@ -195,6 +195,15 @@
    */
   void disable_out_of_mesh_mode(void);
 
+  /**
+   * Enables or disables nearest-node-mode.  If this mode is enabled,
+   * the mesh function will not interpolate within an element, but
+   * rather return the value of the node which is nearest to the given
+   * point (within the element in which the point is located).  By
+   * default, this mode is disabled.
+   */
+  void set_nearest_node_mode(bool enable);
+
 protected:
 
 
@@ -238,6 +247,12 @@
    * See \p enable_out_of_mesh_mode() for more details.
    */
   DenseVector<Number> _out_of_mesh_value;
+
+  /**
+   * \p true if nearest-node-mesh mode is enabled.  See \p
+   * set_nearest_node_mode() for more details.  Default is \p false.
+   */
+  bool _nearest_node_mode;
 };
 
 
Index: src/numerics/mesh_function.C
===================================================================
--- src/numerics/mesh_function.C        (Revision 3964)
+++ src/numerics/mesh_function.C        (Arbeitskopie)
@@ -53,7 +53,8 @@
   _system_vars   (vars),
   _point_locator (NULL),
   _out_of_mesh_mode(false),
-  _out_of_mesh_value()
+  _out_of_mesh_value(),
+  _nearest_node_mode(false)
 {
 }
 
@@ -71,7 +72,8 @@
   _system_vars   (1,var),
   _point_locator (NULL),
   _out_of_mesh_mode(false),
-  _out_of_mesh_value()
+  _out_of_mesh_value(),
+  _nearest_node_mode(false)
 {
 //   std::vector<unsigned int> buf (1);
 //   buf[0] = var;
@@ -275,31 +277,52 @@
             */
            const unsigned int var = _system_vars[index];
            const FEType& fe_type = this->_dof_map.variable_type(var);
-           
-           /**
-            * Build an FEComputeData that contains both input and output data
-            * for the specific compute_data method.
-            */
-           {
-             FEComputeData data (this->_eqn_systems, mapped_point);
+
+           if(!_nearest_node_mode)
+             {
+               /**
+                * Build an FEComputeData that contains both input and
+                * output data for the specific compute_data method.
+                */
+               FEComputeData data (this->_eqn_systems, mapped_point);
              
-             FEInterface::compute_data (dim, fe_type, element, data);
+               FEInterface::compute_data (dim, fe_type, element, data);
              
-             // where the solution values for the var-th variable are stored
-             std::vector<unsigned int> dof_indices;
-             this->_dof_map.dof_indices (element, dof_indices, var);
+               // where the solution values for the var-th variable are stored
+               std::vector<unsigned int> dof_indices;
+               this->_dof_map.dof_indices (element, dof_indices, var);
              
-             // interpolate the solution
-             {
-               Number value = 0.;
+               // interpolate the solution
+               {
+                 Number value = 0.;
                
-               for (unsigned int i=0; i<dof_indices.size(); i++)
-                 value += this->_vector(dof_indices[i]) * data.shape[i];
-               
-               output(index) = value;
+                 for (unsigned int i=0; i<dof_indices.size(); i++)
+                   value += this->_vector(dof_indices[i]) * data.shape[i];
+                 
+                 output(index) = value;
+               }
+             
              }
-             
-           }
+           else
+             {
+               /* Do the same as above, but don't interpolate; rather
+                  select the dof index at which the shape function is
+                  highest.  */
+               FEComputeData data (this->_eqn_systems, mapped_point);
+               FEInterface::compute_data (dim, fe_type, element, data);
+               std::vector<unsigned int> dof_indices;
+               this->_dof_map.dof_indices (element, dof_indices, var);
+
+               unsigned int ii = 0;
+               for(unsigned int i=1; i<dof_indices.size(); i++)
+                 {
+                   if(data.shape[i]>data.shape[ii])
+                     {
+                       ii = i;
+                     }
+                 }
+               output(index) = this->_vector(dof_indices[ii]);
+             }
            
            // next variable
          }
@@ -519,5 +542,10 @@
   _out_of_mesh_mode = false;
 }
 
+void MeshFunction::set_nearest_node_mode(bool enable)
+{
+  _nearest_node_mode = enable;
+}
+
 } // namespace libMesh
 
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to