53 "DarcyFlowMH_output_fields",
54 "Selection of output fields for Darcy Flow MH model.")
56 "DarcyMFOutput_output_fields",
57 "Auxiliary selection.").close())
62 return it::Record(
"DarcyMHOutput",
"Parameters of MH output.")
64 "Parameters of output stream.")
71 "SPECIAL PURPOSE. Computing errors pro non-compatible coupling.")
73 "Output file with raw data form MH module.")
124 auto corner_ptr = make_shared< FieldFE<3, FieldValue<3>::Scalar> >();
154 if (in_rec.
opt_val(
"raw_flow_output", raw_output_file_path)) {
155 xprintf(
Msg,
"Opening raw output: %s\n",
string(raw_output_file_path).c_str() );
220 START_TIMER(
"DarcyFlowMHOutput::make_element_scalar");
221 unsigned int sol_size;
241 START_TIMER(
"DarcyFlowMHOutput::make_element_vector");
251 for(
unsigned int j=0; j<3; j++)
ele_flux[3*i+j]=flux_in_center[j];
260 START_TIMER(
"DarcyFlowMHOutput::make_corner_scalar");
261 unsigned int ndofs = max(
dh->
fe<1>()->n_dofs(), max(
dh->
fe<2>()->n_dofs(),
dh->
fe<3>()->n_dofs()));
262 unsigned int indices[ndofs];
290 START_TIMER(
"DarcyFlowMHOutput::make_node_scalar_param");
302 int* sum_elements =
new int [n_nodes];
303 int* sum_sides =
new int [n_nodes];
304 double* sum_ele_dist =
new double [n_nodes];
305 double* sum_side_dist =
new double [n_nodes];
309 bool count_elements =
true;
310 bool count_sides =
true;
316 for (
int i = 0; i < n_nodes; i++){
319 sum_ele_dist[i] = 0.0;
320 sum_side_dist[i] = 0.0;
327 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
328 node = ele->node[li];
332 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
333 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
334 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
336 sum_ele_dist[node_index] += dist;
337 sum_elements[node_index]++;
342 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
343 node = side->node(li);
346 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
347 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
348 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
351 sum_side_dist[node_index] += dist;
352 sum_sides[node_index]++;
360 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
361 node = ele->node[li];
366 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
367 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
368 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
371 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
372 (sum_elements[node_index] + sum_sides[node_index] - 1);
377 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
378 node = side->node(li);
383 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
384 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
385 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
390 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
391 (sum_sides[node_index] + sum_elements[node_index] - 1);
397 delete [] sum_elements;
399 delete [] sum_ele_dist;
400 delete [] sum_side_dist;
424 unsigned int wl = 2*(w-5)+7;
426 string bc_head_format =
"# %-*s%-*s%-*s%-*s%-*s%-*s\n",
427 bc_format =
"%*s%-*d%-*s %-*g%-*g%-*g%-*g\n",
428 bc_total_format =
"# %-*s%-*g%-*g%-*g\n\n\n";
429 s << setw((w*c+wl-15)/2) << setfill(
'-') <<
"-";
435 w,
"[total_balance]",w,
"[total_outflow]",w,
"[total_inflow]",w,
"[time]");
437 s.str(std::string());
438 s << setw(w*c+wl) << setfill(
'-') <<
"-";
444 double flux = dh.
side_flux( *(bcd->side()) );
447 if (! r.
is_valid())
xprintf(
Msg,
"Invalid region, ele % d, edg: % d\n", bcd->bc_ele_idx_, bcd->edge_idx_);
449 bcd_balance[bc_region_idx] += flux;
451 if (flux > 0) bcd_plus_balance[bc_region_idx] += flux;
452 else bcd_minus_balance[bc_region_idx] += flux;
456 double total_balance = 0,
459 for( RegionSet::const_iterator reg = b_set.begin(); reg != b_set.end(); ++reg) {
460 total_balance += bcd_balance[reg->boundary_idx()];
461 total_outflow += bcd_plus_balance[reg->boundary_idx()];
462 total_inflow += bcd_minus_balance[reg->boundary_idx()];
464 w, bcd_balance[reg->boundary_idx()], w, bcd_plus_balance[reg->boundary_idx()],
470 w,total_balance, w, total_outflow, w, total_inflow);
473 string src_head_format =
"# %-*s%-*s%-*s%-*s%-*s\n",
474 src_format =
"%*s%-*d%-*s %-*g%-*s%-*g\n",
475 src_total_format =
"# %-*s%-*g\n\n\n";
479 w,
"[total_balance]",2*w,
"",w,
"[time]");
483 src_balance[elm->element_accessor().region().bulk_idx()] += elm->measure() *
491 for( RegionSet::const_iterator reg = bulk_set.begin(); reg != bulk_set.end(); ++reg)
493 total_balance += src_balance[reg->bulk_idx()];
496 reg->label().c_str(), w, src_balance[reg->bulk_idx()],2*w,
"", w,
darcy_flow->
time().
t());
510 START_TIMER(
"DarcyFlowMHOutput::output_internal_flow_data");
515 char dbl_fmt[ 16 ]=
"%.8g ";
517 xfprintf(
raw_output_file,
"// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n]\n");
527 for (i = 0; i < 3; i++)
531 for (i = 0; i < ele->n_sides(); i++)
533 for (i = 0; i < ele->n_sides(); i++)
560 double pressure_error[2], velocity_error[2], div_error[2];
592 for (
unsigned int li = 0; li < ele->n_sides(); li++) {
593 fluxes[li] = result.
dh->
side_flux( *(ele->side( li ) ) );
598 arma::vec analytical(5);
602 double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
606 double mean_x_squared=0;
607 for(
unsigned int i_node=0; i_node < ele->n_nodes(); i_node++ )
608 for(
unsigned int j_node=0; j_node < ele->n_nodes(); j_node++ )
610 mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim )
611 * arma::dot( ele->node[i_node]->point(), ele->node[j_node]->point());
614 for(
unsigned int i_point=0; i_point < fe_values.
n_points(); i_point++) {
618 analytical = anal_sol.
value(q_point, ele->element_accessor() );
619 for(
unsigned int i=0; i< 3; i++) anal_flux[i] = analytical[i+1];
623 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
626 diff += fluxes[ i_shape ] *
627 ( arma::dot( q_point, q_point )/ 2
629 - arma::dot( q_point, ele->node[oposite_node]->point() )
630 + arma::dot( ele->centre(), ele->node[oposite_node]->point() )
634 diff = - (1.0 / conductivity) * diff / dim / ele->measure() / cross + pressure_mean ;
635 diff = ( diff - analytical[0]);
636 pressure_diff += diff * diff * fe_values.
JxW(i_point);
640 flux_in_q_point.zeros();
641 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
642 flux_in_q_point += fluxes[ i_shape ]
647 flux_in_q_point -= anal_flux;
648 velocity_diff += dot(flux_in_q_point, flux_in_q_point) * fe_values.
JxW(i_point);
652 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) diff += fluxes[ i_shape ];
653 diff = ( diff / ele->measure() / cross - analytical[4]);
654 divergence_diff += diff * diff * fe_values.
JxW(i_point);
669 result.
div_error[dim-1] += divergence_diff;
679 DBGMSG(
"l2 norm output\n");
682 const unsigned int order = 4;
743 unsigned int solution_size;
752 switch (ele->dim()) {
755 l2_diff_local<1>( ele, fe_values_1d, fv_rt1d, anal_sol_1d, result);
758 l2_diff_local<2>( ele, fe_values_2d, fv_rt2d, anal_sol_2d, result);
763 os <<
"l2 norm output\n\n" 764 <<
"pressure error 1d: " << sqrt(result.
pressure_error[0]) << endl
765 <<
"pressure error 2d: " << sqrt(result.
pressure_error[1]) << endl
766 <<
"velocity error 1d: " << sqrt(result.
velocity_error[0]) << endl
767 <<
"velocity error 2d: " << sqrt(result.
velocity_error[1]) << endl
768 <<
"masked velocity error 2d: " << sqrt(result.
mask_vel_error) <<endl
769 <<
"div error 1d: " << sqrt(result.
div_error[0]) << endl
770 <<
"div error 2d: " << sqrt(result.
div_error[1]);
void set_python_field_from_file(const FilePath &file_name, const string &func_name)
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.
DarcyFlowMH_Steady * darcy_flow
#define FOR_ELEMENT_NODES(i, j)
Field< 3, FieldValue< 3 >::Scalar > water_source_density
unsigned int bulk_size() const
Field< 3, FieldValue< 3 >::Scalar > field_node_pressure
#define FOR_ELEMENTS(_mesh_, __i)
Field< 3, FieldValue< 3 >::Scalar > cross_section
VectorSeqDouble velocity_diff
void set_time(const TimeStep &time, LimitSide limit_side)
int xfclose(FILE *stream)
FCLOSE WITH ERROR HANDLING.
DarcyFlowMHOutput(DarcyFlowMH_Steady *flow, Input::Record in_rec)
int xfprintf(FILE *out, const char *fmt,...)
FPRINTF WITH ERROR HANDLING.
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
bool is_current(const TimeMark::Type &mask) const
FieldPython< 3, FieldValue< 3 >::Vector > ExactSolution
void make_element_vector()
const RegionDB & region_db() const
static const Input::Type::Record & get_input_type()
The specification of output stream.
Field< 3, FieldValue< 3 >::Integer > subdomain
const TimeStep & step(int index=-1) const
I/O functions with filename storing, able to track current line in opened file. All standard stdio fu...
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
static TimeMarks & marks()
std::shared_ptr< OutputTime > output_stream
unsigned int n_points()
Returns the number of quadrature points.
static const Input::Type::Selection & get_output_selection()
static const Input::Type::Record & get_input_type()
FiniteElement< dim, 3 > * fe() const
Returns finite element object for given space dimension.
static unsigned int oposite_node(unsigned int sid)
Symmetric Gauss-Legendre quadrature formulae on simplices.
DarcyFlowMH_Steady * darcy
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
unsigned int size() const
Returns size of the container. This is independent of the allocated space.
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
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.
FILE * raw_output_file
Raw data output file.
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
FILE * balance_output_file
Temporary solution for writing balance into separate file.
Input::Record in_rec_
Accessor to the input record for the DarcyFlow output.
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...
FieldSet fields_for_output
void output_internal_flow_data()
static std::shared_ptr< OutputTime > create_output_stream(const Input::Record &in_rec)
This method delete all object instances of class OutputTime stored in output_streams vector...
Dedicated class for storing path to input and output files.
Field< 3, FieldValue< 3 >::Scalar > field_ele_piezo_head
std::vector< AssemblyBase * > assembly_
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 > conductivity
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
unsigned int boundary_size() const
void output(std::shared_ptr< OutputTime > stream)
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
#define FOR_BOUNDARIES(_mesh_, i)
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
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.
const MH_DofHandler & get_mh_dofhandler()
void set_mesh(const Mesh &mesh)
DarcyFlowMH_Steady::EqData * data_
bool is_valid() const
Returns false if the region has undefined/invalid value.
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.
Input::Type::Selection make_output_field_selection(const string &name, const string &desc)
static UnitSI & dimensionless()
Returns dimensionless unit.
#define FOR_SIDES(_mesh_, it)
void l2_diff_local(ElementFullIter &ele, FEValues< dim, 3 > &fe_values, FEValues< dim, 3 > &fv_rt, ExactSolution &anal_sol, DiffData &result)
void make_node_scalar_param()
Calculate nodes scalar, store it in double* node_scalars instead of node->scalar. ...
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)
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
void make_element_scalar()
NodeVector node_vector
Vector of nodes of the mesh.
FILE * xfopen(const std::string &fname, const char *mode)
ElementVector element
Vector of elements of the mesh.
void output()
Calculate values for output.
Transformed quadrature weights.
void get_solution_vector(double *&vec, unsigned int &vec_size) override
arma::vec::fixed< spacedim > point(const unsigned int point_no)
Return coordinates of the quadrature point in the actual cell system.