18 #ifndef ASSEMBLY_FLOW_OUTPUT_HH_
19 #define ASSEMBLY_FLOW_OUTPUT_HH_
51 template <
unsigned int dim,
class TEqData>
58 static constexpr
const char *
name() {
return "Output_L2Difference_Assembly"; }
86 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
91 for (
unsigned int li = 0; li < ele->
n_sides(); li++) {
98 double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
102 double mean_x_squared=0;
103 for(
unsigned int i_node=0; i_node < ele->
n_nodes(); i_node++ )
104 for(
unsigned int j_node=0; j_node < ele->
n_nodes(); j_node++ )
106 mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim )
107 * arma::dot( *ele.
node(i_node), *ele.
node(j_node));
110 unsigned int oposite_node;
123 for(
unsigned int i_shape=0; i_shape < ele->
n_sides(); i_shape++) {
130 + arma::dot( ele.
centre(), *ele.
node(oposite_node) )
136 pressure_diff += diff * diff *
JxW_(p);
140 for(
unsigned int i_shape=0; i_shape < ele->
n_sides(); i_shape++) {
151 for(
unsigned int i_shape=0; i_shape < ele->
n_sides(); i_shape++) diff +=
fluxes_[ i_shape ];
153 divergence_diff += diff * diff *
JxW_(p);
160 auto velocity_data =
eq_data_->vel_diff_ptr->vec();
161 velocity_data.set( idx, sqrt(velocity_diff) );
162 eq_data_->velocity_error[dim-1] += velocity_diff;
163 if (dim == 2 &&
eq_data_->velocity_mask.size() != 0 ) {
167 auto pressure_data =
eq_data_->pressure_diff_ptr->vec();
168 pressure_data.set( idx, sqrt(pressure_diff) );
169 eq_data_->pressure_error[dim-1] += pressure_diff;
171 auto div_data =
eq_data_->div_diff_ptr->vec();
172 div_data.set( idx, sqrt(divergence_diff) );
173 eq_data_->div_error[dim-1] += divergence_diff;
182 for(
unsigned int j=0; j<3; j++){
195 for(
unsigned int j=0; j<3; j++){
202 os <<
"l2 norm output\n\n"
203 <<
"pressure error 1d: " <<
eq_data_->pressure_error[0] << endl
204 <<
"pressure error 2d: " <<
eq_data_->pressure_error[1] << endl
205 <<
"pressure error 3d: " <<
eq_data_->pressure_error[2] << endl
206 <<
"velocity error 1d: " <<
eq_data_->velocity_error[0] << endl
207 <<
"velocity error 2d: " <<
eq_data_->velocity_error[1] << endl
208 <<
"velocity error 3d: " <<
eq_data_->velocity_error[2] << endl
209 <<
"masked velocity error 2d: " <<
eq_data_->mask_vel_error <<endl
210 <<
"div error 1d: " <<
eq_data_->div_error[0] << endl
211 <<
"div error 2d: " <<
eq_data_->div_error[1] << endl
212 <<
"div error 3d: " <<
eq_data_->div_error[2];
239 template <
template<
IntDim...>
class DimAssembly>
248 template <
unsigned int dim,
class TEqData>
255 static constexpr
const char *
name() {
return "Output_InternalFlow_Assembly"; }
274 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
279 std::stringstream ss;
286 for (
unsigned int i = 0; i < 3; i++)
295 for (
unsigned int i = 0; i < ele->
n_sides(); i++) {
298 uint old_opp_node = new_to_old_node[new_opp_node];
299 uint old_iside = ele->
n_sides() - old_opp_node - 1;
300 old_to_new_side[old_iside] = i;
305 for (
unsigned int i = 0; i < ele->
n_sides(); i++) {
306 uint new_lid = ele->
n_sides() + 1 + old_to_new_side[i];
307 ss <<
eq_data_->flow_data_->full_solution.get(indices[new_lid]) <<
" ";
310 for (
unsigned int i = 0; i < ele->
n_sides(); i++) {
311 uint new_iside = old_to_new_side[i];
312 ss <<
eq_data_->flow_data_->full_solution.get(indices[new_iside]) <<
" ";
316 string line = ss.str();
317 eq_data_->raw_output_strings_[cell.
elm_idx()] = line.substr(0, line.size()-1);
323 DebugOut() <<
"Internal flow data output\n";
325 eq_data_->raw_output_strings_.resize(
eq_data_->flow_data_->dh_->n_own_cells() );
333 eq_data_->raw_output_file <<
"// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n]\n";
337 auto permutation_vec =
eq_data_->flow_data_->dh_->mesh()->element_permutations();
338 for (
unsigned int i_elem=0; i_elem<
eq_data_->flow_data_->dh_->n_own_cells(); ++i_elem) {
339 eq_data_->raw_output_file <<
eq_data_->raw_output_strings_[ permutation_vec[i_elem] ] << endl;
342 eq_data_->raw_output_file <<
"$EndFlowField\n" << endl;
358 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Quadrature * quad_
Quadrature used in assembling methods.
std::shared_ptr< BulkIntegralAcc< dim > > create_bulk_integral(Quadrature *quad)
Cell accessor allow iterate over DOF handler cells.
unsigned int n_dofs() const
Return number of dofs on given cell.
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
DHCellAccessor cell_with_other_dh(const DOFHandlerMultiDim *dh) const
Create new accessor with same local idx and given DOF handler. Actual and given DOF handler must be c...
unsigned int dim() const
Return dimension of element appropriate to cell.
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
auto & orig_nodes_order() const
unsigned int input_id() const
Return the element ID in the input mesh. Should be only used for special output.
NodeAccessor< 3 > node(unsigned int ni) const
double measure() const
Computes the measure of the element.
unsigned int idx() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
unsigned int n_sides() const
unsigned int n_nodes() const
Container for various descendants of FieldCommonBase.
Dedicated class for storing path to input and output files.
Generic class of assemblation.
std::shared_ptr< BulkIntegralAcc< dim > > output_integral_
Integral accessor of assembly class.
static constexpr const char * name()
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
arma::vec3 flux_in_q_point_
Precomputed flux in quadrature point.
std::vector< double > fluxes_
Precomputed fluxes on element sides.
arma::vec3 q_point_
Local coords of quadrature point.
FieldSet used_fields_
Sub field set contains fields used in calculation.
FeQ< Scalar > JxW_
Following data members represent Element quantities and FE quantities.
void initialize()
Initialize auxiliary vectors and other data members.
EqFields * eq_fields_
Data objects shared with Flow equation.
double cross_
Field results.
virtual ~L2DifferenceAssembly()
Destructor.
void end() override
Implements AssemblyBase::end.
arma::vec3 ref_flux_
Field result.
L2DifferenceAssembly(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
TEqData::EqFields EqFields
FeQArray< Vector > vec_shape_rt_
void begin() override
Implements AssemblyBase::begin.
std::shared_ptr< BulkIntegralAcc< dim > > output_integral_
Integral accessor of assembly class.
virtual ~OutputInternalFlowAssembly()
Destructor.
EqFields * eq_fields_
Data objects shared with Flow equation.
void end() override
Implements AssemblyBase::end.
TEqData::EqFields EqFields
OutputInternalFlowAssembly(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
static constexpr const char * name()
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
void initialize()
Initialize auxiliary vectors and other data members.
arma::vec3 flux_in_center_
void begin() override
Implements AssemblyBase::begin.
FieldSet used_fields_
Sub field set contains fields used in calculation.
static unsigned int oposite_node(unsigned int sid)
Lumped mixed-hybrid model of linear Darcy flow, possibly unsteady.
Output class for darcy_flow_mh model.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
Definitions of Raviart-Thomas finite elements.
Class FESystem for compound finite elements.
arma::Col< IntIdx > LocDofVec
#define DebugOut()
Macro defining 'debug' record of log.
unsigned int IntDim
A dimension index type.
std::string format(CStringRef format_str, ArgList args)
Definitions of particular quadrature rules on simplices.
Holds common data shared between GenericAssemblz and Assembly<dim> classes.