55 output_fields += eq_data;
61 return it::Record(
"Output_DarcyMHSpecific",
"Specific Darcy flow MH output.")
63 "SPECIAL PURPOSE. Computing errors pro non-compatible coupling.")
65 "Output file with raw data form MH module.")
102 output_fields.set_mesh(*
mesh_);
117 auto corner_ptr = make_shared< FieldFE<3, FieldValue<3>::Scalar> >();
143 if (in_rec_specific) {
148 if (in_rec_specific->opt_val(
"raw_flow_output", raw_output_file_path)) {
149 MessageOut() <<
"Opening raw output: " << raw_output_file_path <<
"\n";
229 START_TIMER(
"DarcyFlowMHOutput::make_element_scalar");
230 unsigned int sol_size;
235 for(
unsigned int i_ele : element_indices) {
249 START_TIMER(
"DarcyFlowMHOutput::make_element_vector");
253 auto multidim_assembler = AssemblyBase::create< AssemblyMH >(
darcy_flow->
data_);
255 for(
unsigned int i_ele : element_indices) {
258 flux_in_center = multidim_assembler[ele->dim() -1]->make_element_vector(ele);
261 for(
unsigned int j=0; j<3; j++)
ele_flux[3*i_ele + j]=flux_in_center[j];
268 START_TIMER(
"DarcyFlowMHOutput::make_corner_scalar");
269 unsigned int ndofs = max(
dh->
fe<1>()->n_dofs(), max(
dh->
fe<2>()->n_dofs(),
dh->
fe<3>()->n_dofs()));
270 unsigned int indices[ndofs];
298 START_TIMER(
"DarcyFlowMHOutput::make_node_scalar_param");
310 int* sum_elements =
new int [n_nodes];
311 int* sum_sides =
new int [n_nodes];
312 double* sum_ele_dist =
new double [n_nodes];
313 double* sum_side_dist =
new double [n_nodes];
317 bool count_elements =
true;
318 bool count_sides =
true;
324 for (
int i = 0; i < n_nodes; i++){
327 sum_ele_dist[i] = 0.0;
328 sum_side_dist[i] = 0.0;
335 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
336 node = ele->node[li];
340 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
341 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
342 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
344 sum_ele_dist[node_index] += dist;
345 sum_elements[node_index]++;
350 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
351 node = side->node(li);
354 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
355 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
356 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
359 sum_side_dist[node_index] += dist;
360 sum_sides[node_index]++;
368 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
369 node = ele->node[li];
374 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
375 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
376 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
379 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
380 (sum_elements[node_index] + sum_sides[node_index] - 1);
385 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
386 node = side->node(li);
391 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
392 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
393 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
398 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
399 (sum_sides[node_index] + sum_elements[node_index] - 1);
405 delete [] sum_elements;
407 delete [] sum_ele_dist;
408 delete [] sum_side_dist;
419 START_TIMER(
"DarcyFlowMHOutput::output_internal_flow_data");
426 raw_output_file <<
"// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n]\n";
434 for (
unsigned int i = 0; i < 3; i++)
443 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
444 unsigned int i_new_side = old_to_new_side[ele->dim()-1][i];
447 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
448 unsigned int i_new_side = old_to_new_side[ele->dim()-1][i];
476 double pressure_error[2], velocity_error[2], div_error[2];
508 for (
unsigned int li = 0; li < ele->n_sides(); li++) {
509 fluxes[li] = result.
dh->
side_flux( *(ele->side( li ) ) );
514 arma::vec analytical(5);
518 double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
522 double mean_x_squared=0;
523 for(
unsigned int i_node=0; i_node < ele->n_nodes(); i_node++ )
524 for(
unsigned int j_node=0; j_node < ele->n_nodes(); j_node++ )
526 mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim )
527 * arma::dot( ele->node[i_node]->point(), ele->node[j_node]->point());
530 for(
unsigned int i_point=0; i_point < fe_values.
n_points(); i_point++) {
534 analytical = anal_sol.
value(q_point, ele->element_accessor() );
535 for(
unsigned int i=0; i< 3; i++) anal_flux[i] = analytical[i+1];
539 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
542 diff += fluxes[ i_shape ] *
543 ( arma::dot( q_point, q_point )/ 2
545 - arma::dot( q_point, ele->node[oposite_node]->point() )
546 + arma::dot( ele->centre(), ele->node[oposite_node]->point() )
550 diff = - (1.0 / conductivity) * diff / dim / ele->measure() / cross + pressure_mean ;
551 diff = ( diff - analytical[0]);
552 pressure_diff += diff * diff * fe_values.
JxW(i_point);
556 flux_in_q_point.zeros();
557 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
558 flux_in_q_point += fluxes[ i_shape ]
563 flux_in_q_point -= anal_flux;
564 velocity_diff += dot(flux_in_q_point, flux_in_q_point) * fe_values.
JxW(i_point);
568 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) diff += fluxes[ i_shape ];
569 diff = ( diff / ele->measure() / cross - analytical[4]);
570 divergence_diff += diff * diff * fe_values.
JxW(i_point);
585 result.
div_error[dim-1] += divergence_diff;
598 const unsigned int order = 4;
663 unsigned int solution_size;
672 switch (ele->dim()) {
675 l2_diff_local<1>( ele, fe_values_1d, fv_rt1d, anal_sol_1d, result);
678 l2_diff_local<2>( ele, fe_values_2d, fv_rt2d, anal_sol_2d, result);
683 os <<
"l2 norm output\n\n" 684 <<
"pressure error 1d: " << sqrt(result.
pressure_error[0]) << endl
685 <<
"pressure error 2d: " << sqrt(result.
pressure_error[1]) << endl
686 <<
"velocity error 1d: " << sqrt(result.
velocity_error[0]) << endl
687 <<
"velocity error 2d: " << sqrt(result.
velocity_error[1]) << endl
688 <<
"masked velocity error 2d: " << sqrt(result.
mask_vel_error) <<endl
689 <<
"div error 1d: " << sqrt(result.
div_error[0]) << endl
690 <<
"div error 2d: " << sqrt(result.
div_error[1]);
void set_python_field_from_file(const FilePath &file_name, const string &func_name)
void get_solution_vector(double *&vec, unsigned int &vec_size) override
Field< 3, FieldValue< 3 >::VectorFixed > field_ele_flux
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
Field< 3, FieldValue< 3 >::Scalar > velocity_diff
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point...
VectorSeqDouble ele_pressure
static auto subdomain(Mesh &mesh) -> IndexField
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
Output class for darcy_flow_mh model.
void get_dof_indices(const CellIterator &cell, unsigned int indices[]) const override
Returns the global indices of dofs associated to the cell.
#define FOR_ELEMENT_NODES(i, j)
Field< 3, FieldValue< 3 >::Scalar > field_node_pressure
#define FOR_ELEMENTS(_mesh_, __i)
#define MessageOut()
Macro defining 'message' record of log.
VectorSeqDouble velocity_diff
void set_time(const TimeStep &time, LimitSide limit_side)
void output(TimeStep step)
void make_element_vector(ElementSetRef element_indices)
std::string format(CStringRef format_str, ArgList args)
RegionSet get_region_set(const string &set_name) const
void compute_l2_difference()
void distribute_dofs(FiniteElement< 1, 3 > &fe1d, FiniteElement< 2, 3 > &fe2d, FiniteElement< 3, 3 > &fe3d, const unsigned int offset=0)
Distributes degrees of freedom on the mesh needed for the given finite elements.
Fields computed from the mesh data.
void make_corner_scalar(vector< double > &node_scalar)
Class FEValues calculates finite element data on the actual cells such as shape function values...
VectorSeqDouble pressure_diff
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
FieldPython< 3, FieldValue< 3 >::Vector > ExactSolution
const RegionDB & region_db() const
Field< 3, FieldValue< 3 >::Integer > subdomain
const TimeStep & step(int index=-1) const
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
std::vector< unsigned int > all_element_idx_
std::shared_ptr< OutputTime > output_stream
std::shared_ptr< EqData > data_
unsigned int n_points()
Returns the number of quadrature points.
FiniteElement< dim, 3 > * fe() const
Returns finite element object for given space dimension.
void make_node_scalar_param(ElementSetRef element_indices)
Calculate nodes scalar, store it in double* node_scalars instead of node->scalar. ...
static unsigned int oposite_node(unsigned int sid)
Symmetric Gauss-Legendre quadrature formulae on simplices.
unsigned int size() const
Returns size of the container. This is independent of the allocated space.
void open_stream(Stream &stream) const
Discontinuous Lagrangean finite element on dim dimensional simplex.
Field< 3, FieldValue< 3 >::Scalar > field_ele_pressure
Transformed quadrature points.
Global macros to enhance readability and debugging, general constants.
unsigned int n_elements() const
const MH_DofHandler & get_mh_dofhandler()
OutputFields output_fields
double element_scalar(ElementFullIter &ele) const
temporary replacement for DofHandler accessor, scalar (pressure) on element
VectorSeqDouble ele_piezo_head
Raviart-Thomas element of order 0.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
static auto region_id(Mesh &mesh) -> IndexField
void resize(unsigned int size)
Create shared pointer and PETSC vector with given size.
const Element * slave_iter() const
#define START_TIMER(tag)
Starts a timer with specified tag.
Provides the numbering of the finite element degrees of freedom on the computational mesh...
unsigned int index(const T *pointer) const
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
static const Input::Type::Instance & get_input_type()
ofstream raw_output_file
Raw data output file.
static const Input::Type::Record & get_input_type_specific()
arma::vec::fixed< spacedim > shape_vector(const unsigned int function_no, const unsigned int point_no)
Return the value of the function_no-th shape function at the point_no-th quadrature point...
void output_internal_flow_data()
Dedicated class for storing path to input and output files.
Field< 3, FieldValue< 3 >::Scalar > field_ele_piezo_head
static std::shared_ptr< OutputTime > create_output_stream(const std::string &equation_name, Mesh &mesh, const Input::Record &in_rec)
This method delete all object instances of class OutputTime stored in output_streams vector...
Field< 3, FieldValue< 3 >::Integer > region_id
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
bool compute_errors_
Specific experimental error computing.
void set_field(const RegionSet &domain, FieldBasePtr field, double time=0.0)
void reinit(ElementFullIter &cell)
Update cell-dependent data (gradients, Jacobians etc.)
std::vector< int > velocity_mask
vector< Intersection > intersections
std::shared_ptr< FieldElementwise< spacedim, Value > > create_field(unsigned int n_comp)
Create and return shared pointer to FieldElementwise object.
Definitions of particular quadrature rules on simplices.
FieldCommon & name(const string &name)
Field< 3, FieldValue< 3 >::Scalar > div_diff
unsigned int n_nodes() const
vector< double > corner_pressure
mixed-hybrid model of linear Darcy flow, possibly unsteady.
void set_mesh(const Mesh &mesh)
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
const Input::Type::Instance & make_output_type(const string &equation_name, const string &aditional_description="")
Field< 3, FieldValue< 3 >::Scalar > cross_section
Field< 3, FieldValue< 3 >::Scalar > conductivity
FieldCommon & flags(FieldFlag::Flags::Mask mask)
double side_scalar(const Side &side) const
temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side ...
Class for representation SI units of Fields.
DarcyFlowMHOutput(DarcyMH *flow, Input::Record in_rec)
static UnitSI & dimensionless()
Returns dimensionless unit.
#define FOR_SIDES(_mesh_, it)
#define DebugOut()
Macro defining 'debug' record of log.
void make_element_scalar(ElementSetRef element_indices)
void l2_diff_local(ElementFullIter &ele, FEValues< dim, 3 > &fe_values, FEValues< dim, 3 > &fv_rt, ExactSolution &anal_sol, DiffData &result)
Definitions of Raviart-Thomas finite elements.
const unsigned int n_global_dofs() const
Getter for the number of all mesh dofs required by the given finite element.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
NodeVector node_vector
Vector of nodes of the mesh.
FieldSet error_fields_for_output
ElementVector element
Vector of elements of the mesh.
void output()
Calculate values for output.
Transformed quadrature weights.
Mixed-hybrid of steady Darcy flow with sources and variable density.
arma::vec::fixed< spacedim > point(const unsigned int point_no)
Return coordinates of the quadrature point in the actual cell system.