Defining Boundary Condition Equations (Types) for Heat Flux

99 views
Skip to first unread message

gNSortino

unread,
Jan 21, 2013, 2:39:33 PM1/21/13
to herm...@googlegroups.com
Hi There

I’m just getting up and running on my first Heremes project. I’ve been using Agros2D for a few months now and now I want to define a Heat Flux type boundary condition in Hermes. I’m used to doing this in Agros2d by creating a boundary condition, specifying the boundary condition type (eg. equation) and then specifying the values of that equation. However, I’m having trouble figuring out how to do the same thing in Hermes. I see some of the examples defining a constant using the DefaultEssentialBCConst constructor but I don’t think this is what I need to be doing as it specifies a constant value rather than a function. Is there an example/tutorial I could reference that would show how to create a boundary condition function rather than a constant?

Thanks you very much in advance for your assistance.

Kind Regards,
Graham

Lukas Korous

unread,
Jan 21, 2013, 2:57:48 PM1/21/13
to herm...@googlegroups.com
Hi,

no problem.

The class you need to subclass from is DefaultEssentialBCNonConst. You need to pass the appropriate markers and ExactSolution instance.

I am looking for an example if we have one, if not, I will create one. I will get back to you soon.

Lukas


--
You received this message because you are subscribed to the Google Groups "hermes2d" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hermes2d/-/vKagprGMK8kJ.
To post to this group, send email to herm...@googlegroups.com.
To unsubscribe from this group, send email to hermes2d+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hermes2d?hl=en.



--
Lukas Korous

Lukas Korous

unread,
Jan 21, 2013, 3:06:34 PM1/21/13
to herm...@googlegroups.com
Right,

right in the main hermes repository, you can find the non-constant boundary condition implemented for the Navier-Stokes equations (the parabolic distribution of the velocity on the inlet).

https://github.com/hpfem/hermes/blob/master/hermes2d/test_examples/03-navier-stokes/main.cpp#L107

Regards,
Lukas
--
Lukas Korous

Graham Sortino

unread,
Jan 21, 2013, 4:33:27 PM1/21/13
to herm...@googlegroups.com
Thanks again very much for your help Lukas. Just reading through the code now... did you mean line 106? eg. -

  EssentialBCNonConst bc_left_vel_x(BDY_LEFT, VEL_INLET, H, STARTUP_TIME);

I can see this passes in a marker and 3 parameters.

   Line 107 is a call to DefaultEssentialBCConst.

Also, if I'm not troubling you too much could you tell me where the exact solution (I assume equation) is passed in? I traced through the code and couldn't quite spot this.

Kind Regards,
Graham

Lukas Korous

unread,
Jan 21, 2013, 7:04:46 PM1/21/13
to herm...@googlegroups.com
Hi, yes, you are right, 106, sorry.

About the exact solution:

it goes like this
- you definitely need a class that is derived from EssentialBoundaryCondition<Scalar>
(https://github.com/hpfem/hermes/blob/master/hermes2d/include/boundary_conditions/essential_boundary_conditions.h#L35)

And for non-constant you may use
1) the one prepared called (including namespace for clarity)
Hermes::Hermes2D::DefaultEssentialBCNonConst
<Scalar>
(https://github.com/hpfem/hermes/blob/master/hermes2d/include/boundary_conditions/essential_boundary_conditions.h#L96)

and with this one, you need just to call the constructor
(https://github.com/hpfem/hermes/blob/master/hermes2d/include/boundary_conditions/essential_boundary_conditions.h#L99)

with ExactSolution<Scalar> being any descendant of this class
(https://github.com/hpfem/hermes/blob/master/hermes2d/include/function/exact_solution.h#L32)
- check the rest of the file for some pre-defined descendants.

2) your own, that would look like this:

namespace YourNamespace
{
  class MyOwnBCNonConstOrWhatever : public EssentialBoundaryCondition<e.g. double>  // Deriving from the base class.
  {
    and in this class you need to OVERRIDE the method EssentialBoundaryCondition::value(double x, double y, ....) with your own

    (https://github.com/hpfem/hermes/blob/master/hermes2d/include/boundary_conditions/essential_boundary_conditions.h#L56)
  }
}

- just like it is done in the example I sent you a link to, in the file definitions.cpp:
https://github.com/hpfem/hermes/blob/master/hermes2d/test_examples/03-navier-stokes/definitions.cpp#L604


I am not sure I am explaining it right, so feel free to ask more,

Best,
Lukas



--
You received this message because you are subscribed to the Google Groups "hermes2d" group.
To post to this group, send email to herm...@googlegroups.com.
To unsubscribe from this group, send email to hermes2d+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hermes2d?hl=en.



--
Lukas Korous

Graham Sortino

unread,
Jan 21, 2013, 9:08:08 PM1/21/13
to herm...@googlegroups.com
Thank you again. I will go through this and let you know if I have any questions.

KR, Graham

From: Lukas Korous <lukas....@gmail.com>
To: herm...@googlegroups.com
Sent: Monday, January 21, 2013 7:04 PM
Subject: Re: Defining Boundary Condition Equations (Types) for Heat Flux

Graham Sortino

unread,
Feb 3, 2013, 2:28:20 PM2/3/13
to herm...@googlegroups.com
Hi Lukas -
 
Thank you again very much for taking the time to answer my questions and apologies for taking so long to respond. This is a hobby project for me so I tend to only find time every now and then to work on it.
 
I’ve made some progress in Hermes by overriding the EssentialBoundaryCondition::value(...) function. I think this is what I wasn’t understanding before so thanks for that.
 
I have a few more questions on the API that I was hoping to get your help with if you have a chance.
 
For reference this is essentially the problem I’m attempting to solve in Hermes. The code below is from the Agros2D python script editor:
 

 
# model
newdocument("unnamed", "planar", "heat", 1, 2, "disabled", 1, 1, 0, "steadystate", 1, 1, 0)
 
# boundaries
addboundary("coldside", "heat_heat_flux", 0, 7000, 250)
addboundary("hotside", "heat_heat_flux", 0, 4000, 2975)
addboundary("insulated", "heat_heat_flux", 0, 0, 0)
 
# materials
addmaterial("material", 0, 28, 0, 0)
 
# edges
addedge(0.000508, 0, 0, 0, 0, "hotside")
addedge(0.000508, 0.000508, 0.000508, 0, 0, "insulated")
addedge(0.000254, 0.000508, 0.000508, 0.000508, 0, "coldside")
addedge(0.000254, 0.00127, 0.000254, 0.000508, 0, "coldside")
addedge(0.000508, 0.00127, 0.000254, 0.00127, 0, "coldside")
addedge(0.000508, 0.0017718, 0.000508, 0.00127, 0, "insulated")
addedge(0, 0.0017718, 0.000508, 0.0017718, 0, "insulated")
addedge(0, 0, 0, 0.0017718, 0, "insulated")
 
# labels
addlabel(1e-06, 0.000255, 0, 0, "material")
 
solve()
 
 
1)      1) The value function of the EssentialBoundaryCondition  class has 6 parameters that are passed in: x, y, n_x, t_x, and t_y. I couldn’t seem to find definitions for these parameters or information on how they should be used. Is there any information on these parameters that you could point me at?
 
2)      2) I’ve overridden the value function with the heat flux equation from Agros2D (eg.f0 + α(Text - T)) Is this correct? Currently written as follows:
 
      virtual double value(double x, double y, double n_x, double n_y, double t_x, double t_y) const {
              return heatFlux + htCoeff * temp;
      };
 
3)    3) For the material property I want to assign values of thermal conductivity and heat transfer. From looking at the 01-possion example I think I can just use the following custoWeakFormPossion that overrides Hermes::Hermes2D::WeakForm?
 
CustomWeakFormPoisson wf("material", new Hermes::Hermes1DFunction<double>(LAMBDA_AL),
              new Hermes::Hermes2DFunction<double>(-VOLUME_HEAT_SRC));
 
Kind Regards,
Graham

Lukas Korous

unread,
Feb 4, 2013, 6:40:44 AM2/4/13
to herm...@googlegroups.com
Hi Graham,

some answers in the body below. Btw. in the following week or two, Hermes 2.0 will be out, and I will greatly improve the documentation concerning creating your own subclasses, overriding the methods etc.


There probably is no documentation at the moment (sorry for that), but in the version that I will announce in a week or two, there will be for sure.

For the meantime:

n_x is the x-component of the unit outer normal,
n_y is the y-component of the unit outer normal,
t_x is the x-component of the tangent(perpendicular to normal),
t_y is the y-component of the tangent(perpendicular to normal),

 
 
2)      2) I’ve overridden the value function with the heat flux equation from Agros2D (eg.f0 + α(Text - T)) Is this correct? Currently written as follows:
 
      virtual double value(double x, double y, double n_x, double n_y, double t_x, double t_y) const {
              return heatFlux + htCoeff * temp;
      };
 

This looks good to me, you probably don't need the 'virtual' keyword, and of course it depends on what heatFlux, htCoeff, and temp are, but it looks fine. Also, this has to be a method of a class derived from EssentialBoundaryCondition<double>, but I'm sure you know.


 
3)    3) For the material property I want to assign values of thermal conductivity and heat transfer. From looking at the 01-possion example I think I can just use the following custoWeakFormPossion that overrides Hermes::Hermes2D::WeakForm?
 
CustomWeakFormPoisson wf("material", new Hermes::Hermes1DFunction<double>(LAMBDA_AL),
              new Hermes::Hermes2DFunction<double>(-VOLUME_HEAT_SRC));

In this case, you need to create your own class:

class CustomWeakFormPoisson : public Hermes::Hermes2D::WeakForm<double>
{
    // class body (i.e. methods' headers, and attributes declaration) goes here:
public:
  CustomWeakFormPoisson();
  ...
  ...
  int "some parameter for thermal conductivity and heat transfer.."
  std::map<something, somethingElse> "another parameter for thermal conductivity and heat transfer or anything you need.."
}

... pretty much just like you create any other class.

And then you need to implement the constructor (its body):


CustomWeakFormPoisson::CustomWeakFormPoisson() : Hermes::Hermes2D::WeakForm<double>(1)
{
  // Jacobian forms.
  add_matrix_form(new Hermes::Hermes2D::ConstantWeakFormsH1::ConstantMatrixFormDx<double>(0, 0));
  ...
  ...  anything you need to do..
  ...


}

Hope this helps,
Feel free to ask more,

Lukas
 
 
Kind Regards,
Graham

--
You received this message because you are subscribed to the Google Groups "hermes2d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hermes2d+u...@googlegroups.com.

To post to this group, send email to herm...@googlegroups.com.



--
Lukas Korous

Graham Sortino

unread,
Feb 4, 2013, 3:24:31 PM2/4/13
to herm...@googlegroups.com
Thank you again. That's great news about the new release. Right now I'm able to generate a solution, however, the results are orders of magnitude off from what I expect them to be. I suspect I'm struggling a bit because I can't quite figure out where I'm going wrong. As the new documentation/release is set to come out in a few weeks I think its worthwhile for me to wait until this is finished to see if it helps resolve any of my issues.


Fro-m: Lukas Korous <lukas....@gmail.com>
To: herm...@googlegroups.com
Sent: Monday, February 4, 2013 6:40 AM

Subject: Re: Defining Boundary Condition Equations (Types) for Heat Flux
Reply all
Reply to author
Forward
0 new messages