Implementation of boundary condtitions

33 views
Skip to first unread message

Muhammad Adil

unread,
Sep 12, 2019, 4:53:56 AM9/12/19
to deal.II User Group
Hello,
I am trying to understand the MIT code written by Ross Kynch.
I am facing a problem to understand the implementation of boundary conditions.
As we know we impose boundary conditions to calcluate the unknown coefficients. I don't understand how is he implementing the code given below to determine the coefficients?

I don't know why he defined two functions:
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;

////////////////////Header File/////////////////////////////////////


template<int dim>
class curlFunction : public Function<dim>
{
public:
// curlFunction ();//unsigned int n_components = dim+dim);
virtual void curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const = 0;
//virtual void perturbed_field_value_list (const std::vector<Point<dim> > &points,
// std::vector<Vector<double> > &values) const = 0;
};

template<int dim>
class perturbedFunction : public curlFunction<dim>
{
public:
// perturbedFunction ();//unsigned int n_components = dim+dim);
virtual void curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const = 0;
virtual void perturbed_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const = 0;
};

// Base Function class for all EddyCurrent problems.
// The idea here is to allow implementation of boundary conditions of the type:
// n x E = f (Dirichlet) and n x curl(E) = g (Neumann)
//
// which can be handled through the vector_value_list and curl_value_list functions.
//
// The RHS of the equation can be handled through the rhs_value_list.
//
// The perturbed_field_value_list can be used for comparison with analytical/asymptotic formulae.
//
// We also include the boolean function zero_xxx() for each to return if the function is simply zero.
// this allows us to avoid wasted computation which are automatically zero (e.g. in RHS assembly).
//
// We also include the option of passing a material_id to the function. Since we are typically
// dealing with subdomains where we have conducting/non-conducting objects, this allows communication
// from structure in the mesh to the function, if required (default is off).
template<int dim>
class EddyCurrentFunction : public Function<dim>
{
public:
// Leave out constructor for now, we may need to create one which
// calls the Function constructor with n_components = dim+dim by default).
//EddyCurrentFunction (unsigned int n_components = dim+dim);
// We overload each member so that it implements the style found in Function<dim>
// as well as allowing the use of the material_id if required.
// The obvious way to do this is to implement the Function<dim>-style version by
// calling the material_id version with numbers::invalid_material_id,
// effectively making it the default value for that argument.
//
// Obviously derived classes an bypass this if required.
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;
virtual void curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;

virtual void curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;
virtual void perturbed_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;

virtual void perturbed_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;

virtual void rhs_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
virtual void rhs_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;
virtual void scattered_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
virtual void scattered_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const;

virtual bool zero_vector() const { return true; }
virtual bool zero_curl() const { return true; }
virtual bool zero_perturbed() const { return true; }
virtual bool zero_rhs() const { return true; }
virtual bool zero_scattered() const { return true; }
};

/////////////////////.CC File////////////////////////////////////////////////



// Implementation of the virtual functions for EddyCurrentFunction:
// In all cases we just return zero, and so set the zero_xxx boolean function to return true.
// This means that any derived classes will need to implement pairs of the appropriate xxx_value_list
// and zero_xxx (returning false) functions.
template<int dim>
void EddyCurrentFunction<dim>::vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const
{
vector_value_list(points, values, numbers::invalid_material_id);
}

template<int dim>
void EddyCurrentFunction<dim>::vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const
{
Assert(values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int k=0; k<points.size(); ++k)
{
values[k]=0;
}
}

template<int dim>
void EddyCurrentFunction<dim>::curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const
{
curl_value_list(points, values, numbers::invalid_material_id);
}

template<int dim>
void EddyCurrentFunction<dim>::curl_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const
{
Assert(values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int k=0; k<points.size(); ++k)
{
values[k]=0;
}
}

template<int dim>
void EddyCurrentFunction<dim>::perturbed_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const
{
perturbed_field_value_list(points, values, numbers::invalid_material_id);
}

template<int dim>
void EddyCurrentFunction<dim>::perturbed_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const
{
Assert(values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int k=0; k<points.size(); ++k)
{
values[k]=0;
}
}

template<int dim>
void EddyCurrentFunction<dim>::rhs_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const
{
rhs_value_list(points, values, numbers::invalid_material_id);
}

template<int dim>
void EddyCurrentFunction<dim>::rhs_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const
{
Assert(values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int k=0; k<points.size(); ++k)
{
values[k]=0;
}
}

template<int dim>
void EddyCurrentFunction<dim>::scattered_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const
{
scattered_field_value_list(points, values, numbers::invalid_material_id);
}

template<int dim>
void EddyCurrentFunction<dim>::scattered_field_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values,
const types::material_id &mat_id) const
{
Assert(values.size() == points.size(), ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int k=0; k<points.size(); ++k)
{
values[k]=0;
}
}

template class EddyCurrentFunction<3>;

David Wells

unread,
Sep 12, 2019, 2:29:31 PM9/12/19
to deal.II User Group
Dear Muhammad,

I think Ross implemented vector_value_list() this way so that he could use one function object to give correct values with multiple material IDs: see


to see where he uses an object inheriting from EddyCurrentFunction to do exactly this (though in that case he uses this function to set up the right-hand side instead of boundary values).

Several are implemented here:


Thanks,
David

--
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/71ee42b0-9a26-4e20-aa18-2d32c7fad207%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages