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";
152 }
INPUT_CATCH(FilePath::ExcFileOpen, FilePath::EI_Address_String, (*in_rec_specific))
232 START_TIMER(
"DarcyFlowMHOutput::make_element_scalar");
233 unsigned int sol_size;
238 for(
unsigned int i_ele : element_indices) {
252 START_TIMER(
"DarcyFlowMHOutput::make_element_vector");
256 auto multidim_assembler = AssemblyBase::create< AssemblyMH >(
darcy_flow->
data_);
258 for(
unsigned int i_ele : element_indices) {
261 flux_in_center = multidim_assembler[ele->dim() -1]->make_element_vector(ele);
264 for(
unsigned int j=0; j<3; j++)
ele_flux[3*i_ele + j]=flux_in_center[j];
271 START_TIMER(
"DarcyFlowMHOutput::make_corner_scalar");
272 unsigned int ndofs = max(
dh->
fe<1>()->n_dofs(), max(
dh->
fe<2>()->n_dofs(),
dh->
fe<3>()->n_dofs()));
273 unsigned int indices[ndofs];
301 START_TIMER(
"DarcyFlowMHOutput::make_node_scalar_param");
313 int* sum_elements =
new int [n_nodes];
314 int* sum_sides =
new int [n_nodes];
315 double* sum_ele_dist =
new double [n_nodes];
316 double* sum_side_dist =
new double [n_nodes];
320 bool count_elements =
true;
321 bool count_sides =
true;
327 for (
int i = 0; i < n_nodes; i++){
330 sum_ele_dist[i] = 0.0;
331 sum_side_dist[i] = 0.0;
338 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
339 node = ele->node[li];
343 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
344 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
345 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
347 sum_ele_dist[node_index] += dist;
348 sum_elements[node_index]++;
353 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
354 node = side->node(li);
357 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
358 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
359 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
362 sum_side_dist[node_index] += dist;
363 sum_sides[node_index]++;
371 for (
unsigned int li = 0; li < ele->n_nodes(); li++) {
372 node = ele->node[li];
377 ((node->
getX() - ele->centre()[ 0 ])*(node->
getX() - ele->centre()[ 0 ])) +
378 ((node->
getY() - ele->centre()[ 1 ])*(node->
getY() - ele->centre()[ 1 ])) +
379 ((node->
getZ() - ele->centre()[ 2 ])*(node->
getZ() - ele->centre()[ 2 ]))
382 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
383 (sum_elements[node_index] + sum_sides[node_index] - 1);
388 for (
unsigned int li = 0; li < side->n_nodes(); li++) {
389 node = side->node(li);
394 ((node->
getX() - side->centre()[ 0 ])*(node->
getX() - side->centre()[ 0 ])) +
395 ((node->
getY() - side->centre()[ 1 ])*(node->
getY() - side->centre()[ 1 ])) +
396 ((node->
getZ() - side->centre()[ 2 ])*(node->
getZ() - side->centre()[ 2 ]))
401 (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
402 (sum_sides[node_index] + sum_elements[node_index] - 1);
408 delete [] sum_elements;
410 delete [] sum_ele_dist;
411 delete [] sum_side_dist;
422 START_TIMER(
"DarcyFlowMHOutput::output_internal_flow_data");
429 raw_output_file <<
"// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n] ns_side_neighbors[n] neighbors[n*ns] n_vb_neighbors vb_neighbors[n_vb]\n";
437 unsigned int undefined_ele_id = -1;
440 if(ele->n_neighs_vb > 0){
441 for (
unsigned int i = 0; i < ele->n_neighs_vb; i++){
444 auto search = neigh_vb_map.find(higher_ele->
id());
445 if(search != neigh_vb_map.end()){
447 search->second[ele->neigh_vb[i]->side()->el_idx()] = ele->id();
452 higher_ele_side_ngh[ele->neigh_vb[i]->side()->el_idx()] = ele->id();
453 neigh_vb_map[higher_ele->
id()] = higher_ele_side_ngh;
461 for (
unsigned int i = 0; i < 3; i++)
466 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
469 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
473 auto search_neigh = neigh_vb_map.end();
474 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
475 unsigned int n_side_neighs = ele->side(i)->edge()->n_sides-1;
477 if(n_side_neighs == 0){
479 if(search_neigh == neigh_vb_map.end())
480 search_neigh = neigh_vb_map.find(ele->id());
482 if(search_neigh != neigh_vb_map.end())
483 if(search_neigh->second[i] != undefined_ele_id)
489 for (
unsigned int i = 0; i < ele->n_sides(); i++) {
491 if(ele->side(i)->edge()->n_sides > 1){
492 for (
unsigned int j = 0; j < edge->
n_sides; j++) {
493 if(edge->
side(j) != ele->side(i))
498 else if(search_neigh != neigh_vb_map.end()
499 && search_neigh->second[i] != undefined_ele_id){
506 for (
unsigned int i = 0; i < ele->n_neighs_vb; i++)
533 double pressure_error[2], velocity_error[2], div_error[2];
565 for (
unsigned int li = 0; li < ele->n_sides(); li++) {
566 fluxes[li] = result.
dh->
side_flux( *(ele->side( li ) ) );
571 arma::vec analytical(5);
575 double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
579 double mean_x_squared=0;
580 for(
unsigned int i_node=0; i_node < ele->n_nodes(); i_node++ )
581 for(
unsigned int j_node=0; j_node < ele->n_nodes(); j_node++ )
583 mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim )
584 * arma::dot( ele->node[i_node]->point(), ele->node[j_node]->point());
587 for(
unsigned int i_point=0; i_point < fe_values.
n_points(); i_point++) {
591 analytical = anal_sol.
value(q_point, ele->element_accessor() );
592 for(
unsigned int i=0; i< 3; i++) anal_flux[i] = analytical[i+1];
596 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
599 diff += fluxes[ i_shape ] *
600 ( arma::dot( q_point, q_point )/ 2
602 - arma::dot( q_point, ele->node[oposite_node]->point() )
603 + arma::dot( ele->centre(), ele->node[oposite_node]->point() )
607 diff = - (1.0 / conductivity) * diff / dim / ele->measure() / cross + pressure_mean ;
608 diff = ( diff - analytical[0]);
609 pressure_diff += diff * diff * fe_values.
JxW(i_point);
613 flux_in_q_point.zeros();
614 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
615 flux_in_q_point += fluxes[ i_shape ]
620 flux_in_q_point -= anal_flux;
621 velocity_diff += dot(flux_in_q_point, flux_in_q_point) * fe_values.
JxW(i_point);
625 for(
unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) diff += fluxes[ i_shape ];
626 diff = ( diff / ele->measure() / cross - analytical[4]);
627 divergence_diff += diff * diff * fe_values.
JxW(i_point);
642 result.
div_error[dim-1] += divergence_diff;
655 const unsigned int order = 4;
720 unsigned int solution_size;
729 switch (ele->dim()) {
732 l2_diff_local<1>( ele, fe_values_1d, fv_rt1d, anal_sol_1d, result);
735 l2_diff_local<2>( ele, fe_values_2d, fv_rt2d, anal_sol_2d, result);
740 os <<
"l2 norm output\n\n" 741 <<
"pressure error 1d: " << sqrt(result.
pressure_error[0]) << endl
742 <<
"pressure error 2d: " << sqrt(result.
pressure_error[1]) << endl
743 <<
"velocity error 1d: " << sqrt(result.
velocity_error[0]) << endl
744 <<
"velocity error 2d: " << sqrt(result.
velocity_error[1]) << endl
745 <<
"masked velocity error 2d: " << sqrt(result.
mask_vel_error) <<endl
746 <<
"div error 1d: " << sqrt(result.
div_error[0]) << endl
747 <<
"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.
#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 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.
int id()
Returns id of the iterator. See VectorId documentation.
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
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
void get_dof_indices(const CellIterator &cell, unsigned int indices[]) const override
Returns the global indices of dofs associated to the cell.
ElementFullIter element() const
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
bool set_time(const TimeStep &time, LimitSide limit_side)
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)
SideIter side(const unsigned int i) const
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.
const MH_DofHandler & get_mh_dofhandler() override
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.