Re: [deal.II] interpolate_boundary_values and multiple scalar components

2023-10-15 Thread Chad Balen
Hi Wolfgang,


*> Are you running your program in debug mode? You should have gotten an
error message with the code above.*

I wasn't b/c it typically runs slower than release mode... Ok I just
finished installing a debug version and it gives an error message. Wow,
that would've really helped me solve this problem sooner.

Thanks for the help,
Chad


On Sun, Oct 15, 2023 at 7:28 PM Wolfgang Bangerth 
wrote:

> On 10/14/23 21:01, Chad wrote:
> >
> > dealii::VectorTools::interpolate_boundary_values(dof_handler, 1,
> > dealii::Functions::ConstantFunction(1.0), boundary_values,
> var1Mask);
> > dealii::VectorTools::interpolate_boundary_values(dof_handler, 1,
> > dealii::Functions::ConstantFunction(2.0), boundary_values,
> var2Mask);
> >
> > Var1 displays the correct BC in the vtu file but Var2 displays results
> as if a
> > BC of 0.0 was used instead of 2.0.
>
> I am surprised this actually works. The boundary value function needs to
> have
> the same number of vector components as the finite element in use. Are you
> running your program in debug mode? You should have gotten an error
> message
> with the code above.
>
> > The fix seems to be that you need to
> > actually use:
> >
> > dealii::VectorTools::interpolate_boundary_values(dof_handler, 1,
> > dealii::Functions::ConstantFunction(2.0, *X*), boundary_values,
> var2Mask);
> >
> > where X >= (varIndex+1); i.e. 1 & 2 for var1 & var2 respectively.
> Looking at
> > the documentation for ConstantFunction
> > <
> https://www.dealii.org/current/doxygen/deal.II/classFunctions_1_1ConstantFunction.html#a97c9eeab728d22be4b3dddb351d8e754>
> I'd assume that the default value of 1 along with the ComponentMask would
> be sufficient to apply the BC since I only need a ConstantFunction of size
> 1 and the ComponentMask would then determine which component(s) to apply
> this value to. However, it appears you need a ConstantFunction with a size
> of ComponentMask+1 so the mask can access the ConstantFunction component(s)
> matching the ComponentMask(s).
>
> The general rule is that you need to pass function objects that have the
> same
> number of components as the finite element in question -- regardless of
> whether or not you are only evaluating some of the components. That's
> because
> oftentimes you create function objects that will be used in a variety of
> contexts (for boundary values of different kinds, computing the error,
> evaluating error estimators, etc.) where sometimes you might apply a mask
> and
> othertimes you don't.
>
> Best
>   W.
>
> --
> 
> Wolfgang Bangerth  email: bange...@colostate.edu
> www: http://www.math.colostate.edu/~bangerth/
>
>
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "deal.II User Group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/dealii/XaO4TZYrhCQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> dealii+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/9f8d708a-053d-5ee3-eee1-d17380509a79%40colostate.edu
> .
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAJ93qFjRSmCYEGLdzRaOjrAYmDp7dJVQmXGc%3DzY-uuSvyYg-_A%40mail.gmail.com.


Re: [deal.II] interpolate_boundary_values and multiple scalar components

2023-10-15 Thread Wolfgang Bangerth

On 10/14/23 21:01, Chad wrote:


dealii::VectorTools::interpolate_boundary_values(dof_handler, 1, 
dealii::Functions::ConstantFunction(1.0), boundary_values, var1Mask);
dealii::VectorTools::interpolate_boundary_values(dof_handler, 1, 
dealii::Functions::ConstantFunction(2.0), boundary_values, var2Mask);


Var1 displays the correct BC in the vtu file but Var2 displays results as if a 
BC of 0.0 was used instead of 2.0.


I am surprised this actually works. The boundary value function needs to have 
the same number of vector components as the finite element in use. Are you 
running your program in debug mode? You should have gotten an error message 
with the code above.


The fix seems to be that you need to 
actually use:


dealii::VectorTools::interpolate_boundary_values(dof_handler, 1, 
dealii::Functions::ConstantFunction(2.0, *X*), boundary_values, var2Mask);


where X >= (varIndex+1); i.e. 1 & 2 for var1 & var2 respectively. Looking at 
the documentation for ConstantFunction 
 I'd assume that the default value of 1 along with the ComponentMask would be sufficient to apply the BC since I only need a ConstantFunction of size 1 and the ComponentMask would then determine which component(s) to apply this value to. However, it appears you need a ConstantFunction with a size of ComponentMask+1 so the mask can access the ConstantFunction component(s) matching the ComponentMask(s).


The general rule is that you need to pass function objects that have the same 
number of components as the finite element in question -- regardless of 
whether or not you are only evaluating some of the components. That's because 
oftentimes you create function objects that will be used in a variety of 
contexts (for boundary values of different kinds, computing the error, 
evaluating error estimators, etc.) where sometimes you might apply a mask and 
othertimes you don't.


Best
 W.

--

Wolfgang Bangerth  email: bange...@colostate.edu
   www: http://www.math.colostate.edu/~bangerth/


--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/9f8d708a-053d-5ee3-eee1-d17380509a79%40colostate.edu.


Re: [deal.II] Compilation of deal.II fails due to conversion error from std::complex to double

2023-10-15 Thread Wolfgang Bangerth

On 10/15/23 10:04, Daniel Arndt wrote:


Using PETSc with complex values is pretty niche and there isn't much CI in 
place for this case.

It looks like

   boost::serialization::array_wrapper wrapper(

should be replaced with

   boost::serialization::array_wrapper wrapper(

and similarly in VectorBase::load.


Now also here:
  https://github.com/dealii/dealii/issues/16146
Patches are, as always, very much welcome!

Best
 W.

--

Wolfgang Bangerth  email: bange...@colostate.edu
   www: http://www.math.colostate.edu/~bangerth/


--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/457a7932-dbc6-37d5-e158-aa24ade9c690%40colostate.edu.


Re: [deal.II] Compilation of deal.II fails due to conversion error from std::complex to double

2023-10-15 Thread Daniel Arndt
Roland,

Using PETSc with complex values is pretty niche and there isn't much CI in
place for this case.
It looks like

  boost::serialization::array_wrapper wrapper(

should be replaced with

  boost::serialization::array_wrapper wrapper(

and similarly in VectorBase::load.

Best,
Daniel

On Sat, Oct 14, 2023 at 1:01 PM 'develo...@googlemail.com' via deal.II User
Group  wrote:

> Hei,
> I'm currently trying to compile deal.II on my local machine, but encounter
> the following compilation error:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *[  0%] Built target expand_instantiations_exe[  0%] Built target
> doxygen_headers[  0%] Built target object_arborx_inst[  0%] Built target
> object_arborx_debug[  4%] Built target object_numerics_instConsolidate
> compiler generated dependencies of target object_numerics_debug[  4%]
> Building CXX object
> source/numerics/CMakeFiles/object_numerics_debug.dir/unity_0.cc.oIn file
> included from
> /home/user/Downloads/git-files/dealii/build/source/numerics/unity_0.cc:5:In
> file included from
> /home/user/Downloads/git-files/dealii/source/numerics/data_out.cc:16:In
> file included from
> /home/user/Downloads/git-files/dealii/include/deal.II/base/work_stream.h:20:In
> file included from
> /home/user/Downloads/git-files/dealii/build/include/deal.II/base/config.h:584:/home/user/Downloads/git-files/dealii/include/deal.II/base/numbers.h:533:12:
> warning: explicit comparison with NaN in fast floating point mode
> [-Wtautological-constant-compare]return std::isnan(x);
>  ^In file included from
> /home/user/Downloads/git-files/dealii/build/source/numerics/unity_0.cc:10:In
> file included from
> /home/user/Downloads/git-files/dealii/source/numerics/dof_output_operator.cc:23:In
> file included from
> /home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_block_vector.h:27:In
> file included from
> /home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_vector.h:29:/home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_vector_base.h:1324:55:
> error: no matching constructor for initialization of
> 'boost::serialization::array_wrapper'
> boost::serialization::array_wrapper wrapper(
>
> ^/media/storage/local_opt/boost/include/boost/serialization/array_wrapper.hpp:46:5:
> note: candidate constructor not viable: no known conversion from 'const
> PetscScalar *' (aka 'const complex *') to 'const double *' for 1st
> argumentarray_wrapper(T * t, std::size_t s) :
> ^/media/storage/local_opt/boost/include/boost/serialization/array_wrapper.hpp:41:5:
> note: candidate constructor not viable: requires single argument 'rhs', but
> 2 arguments were providedarray_wrapper(const array_wrapper & rhs) :
> ^In file included from
> /home/user/Downloads/git-files/dealii/build/source/numerics/unity_0.cc:10:In
> file included from
> /home/user/Downloads/git-files/dealii/source/numerics/dof_output_operator.cc:23:In
> file included from
> /home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_block_vector.h:27:In
> file included from
> /home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_vector.h:29:/home/user/Downloads/git-files/dealii/include/deal.II/lac/petsc_vector_base.h:1363:49:
> error: no matching constructor for initialization of
> 'boost::serialization::array_wrapper'
> boost::serialization::array_wrapper velocity_wrapper(
>
> ^/media/storage/local_opt/boost/include/boost/serialization/array_wrapper.hpp:46:5:
> note: candidate constructor not viable: no known conversion from
> 'PetscScalar *' (aka 'complex *') to 'double *' for 1st argument
> array_wrapper(T * t, std::size_t s) :
> ^/media/storage/local_opt/boost/include/boost/serialization/array_wrapper.hpp:41:5:
> note: candidate constructor not viable: requires single argument 'rhs', but
> 2 arguments were providedarray_wrapper(const array_wrapper & rhs) :
> ^1 warning and 2 errors generated.make[2]: ***
> [source/numerics/CMakeFiles/object_numerics_debug.dir/build.make:76:
> source/numerics/CMakeFiles/object_numerics_debug.dir/unity_0.cc.o] Error
> 1make[1]: *** [CMakeFiles/Makefile2:1805:
> source/numerics/CMakeFiles/object_numerics_debug.dir/all] Error 2make: ***
> [Makefile:136: all] Error 2*
>
> PETSc was configured to use complex values. The same for deal.II, but I
> still get that error. CMakeCache is attached, but how can I fix that
> problem?
> Thanks!
> Regards,
> Roland Richter
>
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/ddde2d6a-3423-4d56-88ff-dfe7473236e1n%40googlegroups.com
>