Greetings everyone,

I want to express my gratitude for your assistance with my question, which 
has evolved into something more profound.

Regarding the function "VectorFucntionFromScalarFunctionObject," I have 
observed that it works for computing the L2 norm of the error. However, 
when I attempted to compute the H1_seminorm of the error, I noticed that 
the gradient was not implemented for this function. Please let me know if 
my understanding is incorrect, as I referred to the 
<deal.II/base/function.h> for this.

I am curious if there is a way to resolve this issue. My idea is to obtain 
the gradient of the "FeFeildFunction" since I know that the gradient is 
implemented for this function, as per 
<deal.II/numerics/fe_field_function.h>. Afterward, I can define a new 
function within a class, based on "VectorFucntionFromScalarFunctionObject," 
where the gradient of that function would be the gradient of the 
"FeFeildFunction."

Could you kindly advise me on the simplest way to accomplish this? 

On a side note, although "VectorFucntionFromScalarFunctionObject" works 
with the L2 norm of the error, it is quite computationally intensive.

Best regards,
Najwa
On Sunday, July 23, 2023 at 4:47:50 PM UTC+3 Najwa Alshehri wrote:

> Dear Luca,
>
> This is interesting. I am exited to try this out. 
>
> Thank you so much,
> Najwa
>
> On Sunday, July 23, 2023 at 3:39:05 PM UTC+3 luca....@gmail.com wrote:
>
>> FEFieldFunction has the same number of components of the underlying 
>> dofhandler. If that has one component, then so does the FEFieldFunction. 
>> What you could do is wrap the FEFieldFunction into another function, e.g.
>>
>> The deal.II Library: VectorFunctionFromScalarFunctionObject< dim, 
>> RangeNumberType > Class Template Reference 
>> <https://www.dealii.org/current/doxygen/deal.II/classVectorFunctionFromScalarFunctionObject.html>
>> dealii.org 
>> <https://www.dealii.org/current/doxygen/deal.II/classVectorFunctionFromScalarFunctionObject.html>
>> [image: deal.ico] 
>> <https://www.dealii.org/current/doxygen/deal.II/classVectorFunctionFromScalarFunctionObject.html>
>>  
>> <https://www.dealii.org/current/doxygen/deal.II/classVectorFunctionFromScalarFunctionObject.html>
>>
>> You could pass a lambda function as an argument to the constructor of the 
>> function, that uses your FEFieldFunction object, I.e.,
>>
>> VectorFucntionFromScalarFuncObj<dim> my_fun([&](const auto &p){ return 
>> fe_field_func.value(p);}, 0, 2);
>>
>> Luca
>>
>> Il giorno 21 lug 2023, alle ore 22:05, Najwa Alshehri <
>> najwaa...@gmail.com> ha scritto:
>>
>> Dear Daniel, your answer makes sense, Finally it worked.
>>
>>
>> Dear Luca, thank you for your answer. Indeed, the ExactSolution is a 
>> class I built myself. I followed your suggestion and it was the magic line 
>> that solved the issue. *However,* say that I have in another code 
>> instead of using a ExactSolution that I build myself, I used an 
>> FeFieldFunction for a reference solution, how would I make this function 
>> allocate two components?
>>
>> Best,
>> Najwa
>>
>> On Friday, July 21, 2023 at 1:54:42 PM UTC+3 luca....@gmail.com wrote:
>>
>>> Dear Najwa, 
>>>
>>> how many components do the `ExactSolution2<dim>` function has? 
>>>
>>> The error complains about `exact_solution.n_components, n_components` 
>>> not being equal, in particular it tells you that `ExactSolution2<dim>` only 
>>> has one component. 
>>>
>>> If you built the ExactSolution class yourself, make sure at construction 
>>> time you tell Function<dim> to allocate two components: 
>>>
>>> ExactSolution2<dim>::ExactSolution2<dim>( … ) 
>>> : Functions::Function<dim>(2) 
>>>
>>> Best, 
>>> Luca. 
>>>
>>>
>>> > On 20 Jul 2023, at 12:15, Najwa Alshehri <najwaa...@gmail.com> wrote: 
>>> > 
>>> > Hello again, 
>>> > 
>>> > I have a follow-up question. Does this ComponentSelectFunction work 
>>> also with vectors that are not written as blocked vectors? I have applied 
>>> it before when I was dealing with blocked vectors and it worked perfectly. 
>>> > 
>>> > So, I did this, 
>>> > const ComponentSelectFunction<dim> primal_mask(0,2); 
>>> > Later, 
>>> > VectorTools::integrate_difference(omega2_dh, 
>>> > u_omega2, 
>>> > ExactSolution2<dim>(), 
>>> > cellwise_errors2, 
>>> > quadrature, 
>>> > VectorTools::L2_norm 
>>> > ,&primal_mask); 
>>> > const double u2_l2_error = 
>>> > VectorTools::compute_global_error(triangulation_omega2, 
>>> > cellwise_errors2, 
>>> > VectorTools::L2_norm); 
>>> > 
>>> > And I got the following error!! 
>>> > An error occurred in line <455> of file 
>>> <../include/deal.II/numerics/vector_tools_integrate_difference.templates.h> 
>>> in function 
>>> > void dealii::VectorTools::internal::do_integrate_difference(const 
>>> dealii::hp::MappingCollection<dim, spacedim>&, const 
>>> dealii::DoFHandler<dim, spacedim>&, const InVector&, const 
>>> dealii::Function<spacedim, typename InVector::value_type>&, OutVector&, 
>>> const dealii::hp::QCollection<dim>&, const dealii::VectorTools::NormType&, 
>>> const dealii::Function<spacedim>*, double) [with int dim = 2; int spacedim 
>>> = 2; InVector = dealii::Vector<double>; OutVector = dealii::Vector<double>; 
>>> typename InVector::value_type = double] 
>>> > The violated condition was: 
>>> > 
>>> ::dealii::deal_II_exceptions::internals::compare_for_equality(exact_solution.n_components,
>>>  
>>> n_components) 
>>> > Additional information: 
>>> > Dimension 1 not equal to 2. 
>>> > 
>>> > Obviously, we have dimensionality mismatching between u_omega2 and the 
>>> exact solution. which means that the mask is not really picking up the 
>>> first component of the solution u_omega2. Do you have any suggestions to 
>>> fix this issue? 
>>> > 
>>> > Appreciate your help, 
>>> > Najwa 
>>> > On Thursday, July 20, 2023 at 11:48:04 AM UTC+3 Najwa Alshehri wrote: 
>>> > Thank you Daniel for the clear quick answer. I will follow it. 
>>> > 
>>> > Best, 
>>> > Najwa 
>>> > 
>>> > On Wednesday, July 19, 2023 at 5:16:14 PM UTC+3 d.arnd...@gmail.com 
>>> wrote: 
>>> > Najwa, 
>>> > 
>>> > The documentation of VectorTools::integrate_difference(
>>> https://www.dealii.org/current/doxygen/deal.II/namespaceVectorTools.html#a676190d2c897ac5da68a9c460fa95832)
>>>  
>>> says 
>>> > 
>>> > 
>>> > The additional argument weight allows to evaluate weighted norms. The 
>>> weight function may be scalar, establishing a spatially variable weight in 
>>> the domain for all components equally. This may be used, for instance, to 
>>> only integrate over parts of the domain. The weight function may also be 
>>> vector-valued, with as many components as the finite element: Then, 
>>> different components get different weights. A typical application is when 
>>> the error with respect to only one or a subset of the solution variables is 
>>> to be computed, in which case the other components would have weight values 
>>> equal to zero. The ComponentSelectFunction class is particularly useful for 
>>> this purpose as it provides such a "mask" weight. The weight function is 
>>> expected to be positive, but negative values are not filtered. The default 
>>> value of this function, a null pointer, is interpreted as "no weighting 
>>> function", i.e., weight=1 in the whole domain for all vector components 
>>> uniformly. 
>>> > 
>>> > Best, 
>>> > Daniel 
>>> > 
>>> > On Wed, Jul 19, 2023 at 8:01 AM Najwa Alshehri <najwaa...@gmail.com> 
>>> wrote: 
>>> > Dear group members, 
>>> > 
>>> > I have one question, 
>>> > 
>>> > I am trying to calculate the L2 norm of the error of a solution. In 
>>> particular, I have a vector of the solution u_omega and a FeSystem with two 
>>> fes. 
>>> > I am interested in computing the L2 norm of the error related to the 
>>> first fe using integrate_difference function. (Note here u_omega is not a 
>>> blocked vector, however, it has two solutions stacked together in one 
>>> vector). Can I extract the solution of the first part from u_omega? 
>>> > 
>>> > 
>>> > Thank you in advance for your help. 
>>> > Best, 
>>> > Najwa 
>>> > 
>>> > -- 
>>> > 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+un...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/dealii/9741338e-2a31-418b-815d-277a5d7cb573n%40googlegroups.com.
>>>  
>>>
>>> > 
>>> > -- 
>>> > 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+un...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/dealii/c2544a5b-16b0-4d3d-8ccc-22e77ccf3038n%40googlegroups.com.
>>>  
>>>
>>>
>>> -- 
>> 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+un...@googlegroups.com.
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/697c9d76-0969-4c32-bd57-58371d02c21dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/dealii/697c9d76-0969-4c32-bd57-58371d02c21dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
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/8b136f02-02a6-4214-a89b-bf236b5e0e24n%40googlegroups.com.

Reply via email to