63 .
copy_values(OutputFields().make_output_field_selection(
"").close())
67 =
it::Record(
"DarcyMHOutput",
"Parameters of MH output.")
69 "Parameters of output stream.")
75 "SPECIAL PURPOSE. Computing errors pro non-compatible coupling.")
77 "Output file with raw data form MH module.");
126 auto corner_ptr = make_shared< FieldFE<3, FieldValue<3>::Scalar> >();
159 if (in_rec.
opt_val(
"raw_flow_output", raw_output_file_path)) {
160 xprintf(
Msg,
"Opening raw output: %s\n",
string(raw_output_file_path).c_str() );
224 unsigned int sol_size;
250 flux_in_centre.zeros();
257 for (
unsigned int li = 0; li < ele->n_sides(); li++) {
258 flux_in_centre += dh.
side_flux( *(ele->side( li ) ) )
259 * fe_values.
RT0_value( ele, ele->centre(), li )
263 for(
unsigned int j=0; j<3; j++)
264 ele_flux[3*i_side+j]=flux_in_centre[j];
274 unsigned int ndofs = max(
dh->
fe<1>()->n_dofs(), max(
dh->
fe<2>()->n_dofs(),
dh->
fe<3>()->n_dofs()));
275 unsigned int indices[ndofs];
314 int* sum_elements =
new int [n_nodes];
315 int* sum_sides =
new int [n_nodes];
316 double* sum_ele_dist =
new double [n_nodes];
317 double* sum_side_dist =
new double [n_nodes];
321 bool count_elements =
true;
322 bool count_sides =
true;
328 for (
int i = 0; i < n_nodes; i++){
331 sum_ele_dist[i] = 0.0;
332 sum_side_dist[i] = 0.0;
339 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
340 node = ele->node[li];
344 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
345 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
346 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
348 sum_ele_dist[node_index] += dist;
349 sum_elements[node_index]++;
354 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
355 node = side->node(li);
358 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
359 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
360 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
363 sum_side_dist[node_index] += dist;
364 sum_sides[node_index]++;
372 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
373 node = ele->node[li];
378 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
379 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
380 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
383 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
384 (sum_elements[node_index] + sum_sides[node_index] - 1);
389 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
390 node = side->node(li);
395 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
396 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
397 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
402 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
403 (sum_sides[node_index] + sum_elements[node_index] - 1);
409 delete [] sum_elements;
411 delete [] sum_ele_dist;
412 delete [] sum_side_dist;
436 unsigned int wl = 2*(w-5)+7;
438 string bc_head_format =
"# %-*s%-*s%-*s%-*s%-*s%-*s\n",
439 bc_format =
"%*s%-*d%-*s %-*g%-*g%-*g%-*g\n",
440 bc_total_format =
"# %-*s%-*g%-*g%-*g\n\n\n";
441 s << setw((w*c+wl-15)/2) << setfill(
'-') <<
"-";
447 w,
"[total_balance]",w,
"[total_outflow]",w,
"[total_inflow]",w,
"[time]");
449 s.str(std::string());
450 s << setw(w*c+wl) << setfill(
'-') <<
"-";
456 double flux = dh.
side_flux( *(bcd->side()) );
459 if (! r.
is_valid())
xprintf(
Msg,
"Invalid region, ele % d, edg: % d\n", bcd->bc_ele_idx_, bcd->edge_idx_);
461 bcd_balance[bc_region_idx] += flux;
463 if (flux > 0) bcd_plus_balance[bc_region_idx] += flux;
464 else bcd_minus_balance[bc_region_idx] += flux;
468 double total_balance = 0,
471 for( RegionSet::const_iterator reg = b_set.begin(); reg != b_set.end(); ++reg) {
472 total_balance += bcd_balance[reg->boundary_idx()];
473 total_outflow += bcd_plus_balance[reg->boundary_idx()];
474 total_inflow += bcd_minus_balance[reg->boundary_idx()];
476 w, bcd_balance[reg->boundary_idx()], w, bcd_plus_balance[reg->boundary_idx()],
482 w,total_balance, w, total_outflow, w, total_inflow);
485 string src_head_format =
"# %-*s%-*s%-*s%-*s%-*s\n",
486 src_format =
"%*s%-*d%-*s %-*g%-*s%-*g\n",
487 src_total_format =
"# %-*s%-*g\n\n\n";
491 w,
"[total_balance]",2*w,
"",w,
"[time]");
495 src_balance[elm->element_accessor().region().bulk_idx()] += elm->measure() *
503 for( RegionSet::const_iterator reg = bulk_set.begin(); reg != bulk_set.end(); ++reg)
505 total_balance += src_balance[reg->bulk_idx()];
508 reg->label().c_str(), w, src_balance[reg->bulk_idx()],2*w,
"", w,
darcy_flow->
time().
t());
526 char dbl_fmt[ 16 ]=
"%.8g ";
528 xfprintf(
raw_output_file,
"// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n]\n");
538 for (i = 0; i < 3; i++)
542 for (i = 0; i < ele->n_sides(); i++)
544 for (i = 0; i < ele->n_sides(); i++)
571 double pressure_error[2], velocity_error[2], div_error[2];
604 for (
unsigned int li = 0; li < ele->n_sides(); li++) {
605 fluxes[li] = result.
dh->
side_flux( *(ele->side( li ) ) );
606 pressure_traces[li] = result.
dh->
side_scalar( *(ele->side( li ) ) );
610 arma::vec analytical(5);
614 double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
618 double mean_x_squared=0;
619 for(
unsigned int i_node=0; i_node < ele->n_nodes(); i_node++ )
620 for(
unsigned int j_node=0; j_node < ele->n_nodes(); j_node++ )
622 mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim )
623 * arma::dot( ele->node[i_node]->point(), ele->node[j_node]->point());
626 for(
unsigned int i_point=0; i_point < fe_values.
n_points(); i_point++) {
630 analytical = anal_sol.
value(q_point, ele->element_accessor() );
631 for(
unsigned int i=0; i< 3; i++) anal_flux[i] = analytical[i+1];
635 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
636 unsigned int oposite_node = (i_shape + dim) % (dim + 1);
638 diff += fluxes[ i_shape ] *
639 ( arma::dot( q_point, q_point )/ 2
641 - arma::dot( q_point, ele->node[oposite_node]->point() )
642 + arma::dot( ele->centre(), ele->node[oposite_node]->point() )
646 diff = - (1.0 / conductivity) * diff / dim / ele->measure() / cross + pressure_mean ;
647 diff = ( diff - analytical[0]);
648 pressure_diff += diff * diff * fe_values.
JxW(i_point);
652 flux_in_q_point.zeros();
653 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
654 flux_in_q_point += fluxes[ i_shape ]
659 flux_in_q_point -= anal_flux;
660 velocity_diff += dot(flux_in_q_point, flux_in_q_point) * fe_values.
JxW(i_point);
664 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) diff += fluxes[ i_shape ];
665 diff = ( diff / ele->measure() / cross - analytical[4]);
666 divergence_diff += diff * diff * fe_values.
JxW(i_point);
681 result.
div_error[dim-1] += divergence_diff;
691 DBGMSG(
"l2 norm output\n");
694 const unsigned int order = 4;
711 ExactSolution anal_sol_1d(5);
714 ExactSolution anal_sol_2d(5);
749 unsigned int solution_size;
758 switch (ele->dim()) {
761 l2_diff_local<1>( ele, fe_values_1d, anal_sol_1d, result);
764 l2_diff_local<2>( ele, fe_values_2d, anal_sol_2d, result);
769 os <<
"l2 norm output\n\n"
770 <<
"pressure error 1d: " << sqrt(result.
pressure_error[0]) << endl
771 <<
"pressure error 2d: " << sqrt(result.
pressure_error[1]) << endl
772 <<
"velocity error 1d: " << sqrt(result.
velocity_error[0]) << endl
773 <<
"velocity error 2d: " << sqrt(result.
velocity_error[1]) << endl
774 <<
"masked velocity error 2d: " << sqrt(result.
mask_vel_error) <<endl
775 <<
"div error 1d: " << sqrt(result.
div_error[0]) << endl
776 <<
"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
void set_limit_side(LimitSide side)
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.
DarcyFlowMH_Steady * darcy_flow
#define FOR_ELEMENT_NODES(i, j)
virtual void get_solution_vector(double *&vec, unsigned int &vec_size)
const arma::vec::fixed< spacedim > point(const unsigned int point_no)
Return coordinates of the quadrature point in the actual cell system.
static Input::Type::Record input_type
The specification of output stream.
unsigned int bulk_size() const
static Input::Type::Record input_type
void add_admissible_field_names(const Input::Array &in_array)
Registers names of output fields that can be written using this stream.
Field< 3, FieldValue< 3 >::Scalar > field_node_pressure
#define FOR_ELEMENTS(_mesh_, __i)
VectorSeqDouble velocity_diff
int xfclose(FILE *stream)
FCLOSE WITH ERROR HANDLING.
DarcyFlowMHOutput(DarcyFlowMH_Steady *flow, Input::Record in_rec)
const double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point...
int xfprintf(FILE *out, const char *fmt,...)
FPRINTF WITH ERROR HANDLING.
void set_time(const TimeStep &time)
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
const MH_DofHandler & get_mh_dofhandler()
Field< 3, FieldValue< 3 >::Integer > subdomain
const TimeStep & step(int index=-1) const
Field< 3, FieldValue< 3 >::Scalar > storativity
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()
FiniteElement< dim, 3 > * fe() const
Symmetric Gauss-Legendre quadrature formulae on simplices.
const unsigned int n_points()
Returns the number of quadrature points.
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.
Data for Darcy flow equation.
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
static OutputTime * create_output_stream(const Input::Record &in_rec)
This method delete all object instances of class OutputTime stored in output_streams vector...
OutputFields output_fields
boost::shared_ptr< Balance > balance_
object for calculation and writing the water balance to file.
double element_scalar(ElementFullIter &ele) const
temporary replacement for DofHandler accessor, scalar (pressure) on element
void update(ElementFullIter ele, FieldType &cond_anisothropy, FieldType_Scalar &cross_section, FieldType_Scalar &conductivity)
VectorSeqDouble ele_piezo_head
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.
Field< 3, FieldValue< 3 >::TensorFixed > anisotropy
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.
void mark_output_times(const TimeGovernor &tg)
FieldSet fields_for_output
void output_internal_flow_data()
static Input::Type::Selection output_selection
Dedicated class for storing path to input and output files.
Field< 3, FieldValue< 3 >::Scalar > field_ele_piezo_head
Field< 3, FieldValue< 3 >::Scalar > conductivity
Field< 3, FieldValue< 3 >::Integer > region_id
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
arma::vec3 RT0_value(ElementFullIter ele, arma::vec3 point, unsigned int face)
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
const OutputFields & get_output_fields()
OutputTime * output_stream
void output(OutputTime *stream)
unsigned int boundary_size() const
void get_dof_indices(const CellIterator &cell, unsigned int indices[]) const override
Returns the global indices of dofs associated to the cell.
TimeGovernor const & time()
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 of steady Darcy flow with sources and variable density.
Input::Type::Selection make_output_field_selection(const string &name, const string &desc="")
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)
Calculates finite element data on the actual cell.
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)
Field< 3, FieldValue< 3 >::Scalar > cross_section
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.
UnitSI & md(int exp=-1)
Method sets value of exponent for m^{-d}, where d is dimension of region.
void l2_diff_local(ElementFullIter &ele, FEValues< dim, 3 > &fe_values, ExactSolution &anal_sol, DiffData &result)
static UnitSI & dimensionless()
Returns dimensionless unit.
#define FOR_SIDES(_mesh_, it)
void make_node_scalar_param()
Calculate nodes scalar, store it in double* node_scalars instead of node->scalar. ...
const unsigned int n_global_dofs() const
Getter for the number of all mesh dofs required by the given finite element.
Field< 3, FieldValue< 3 >::Scalar > water_source_density
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.