Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_BlockedEpetraLinearObjContainer.cpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
12
13#include "Thyra_VectorBase.hpp"
14#include "Thyra_VectorStdOps.hpp"
15#include "Thyra_ProductVectorSpaceBase.hpp"
16#include "Thyra_get_Epetra_Operator.hpp"
17
18#include "Epetra_CrsMatrix.h"
19
20namespace panzer {
21
25{
27 using Teuchos::RCP;
28 using Teuchos::null;
29
30 bool x_matches=false, f_matches=false, dxdt_matches=false;
31
32 if(get_A()!=null) {
33 RCP<const VectorSpaceBase<double> > range = get_A()->range();
34 RCP<const VectorSpaceBase<double> > domain = get_A()->domain();
35
36 if(get_x()!=null)
37 x_matches = range->isCompatible(*get_x()->space());
38 else
39 x_matches = true; // nothing to compare
40
41 if(get_dxdt()!=null)
42 dxdt_matches = range->isCompatible(*get_dxdt()->space());
43 else
44 dxdt_matches = true; // nothing to compare
45
46 if(get_f()!=null)
47 f_matches = range->isCompatible(*get_f()->space());
48 else
49 f_matches = true; // nothing to compare
50 }
51 else if(get_x()!=null && get_dxdt()!=null) {
52 f_matches = true; // nothing to compare f to
53 x_matches = get_x()->space()->isCompatible(*get_dxdt()->space()); // dxdt and x are in the same space
54 dxdt_matches = x_matches;
55 }
56 else {
57 f_matches = x_matches = dxdt_matches = true; // nothing to compare to
58 }
59
60 return x_matches && dxdt_matches && f_matches;
61}
62
65{
67 using Thyra::PhysicallyBlockedLinearOpBase;
68 using Thyra::ProductVectorSpaceBase;
69 using Teuchos::RCP;
70 using Teuchos::rcp_dynamic_cast;
71
72 if(get_x()!=Teuchos::null) Thyra::assign<double>(x.ptr(),0.0);
73 if(get_dxdt()!=Teuchos::null) Thyra::assign<double>(get_dxdt().ptr(),0.0);
74 if(get_f()!=Teuchos::null) Thyra::assign<double>(get_f().ptr(),0.0);
75 if(get_A()!=Teuchos::null) {
76 RCP<PhysicallyBlockedLinearOpBase<double> > Amat
77 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(get_A(),true);
78 RCP<const ProductVectorSpaceBase<double> > range = Amat->productRange();
79 RCP<const ProductVectorSpaceBase<double> > domain = Amat->productDomain();
80
81 // loop over block entries
82 for(int i=0;i<range->numBlocks();i++) {
83 for(int j=0;j<domain->numBlocks();j++) {
84 RCP<LinearOpBase<double> > block = Amat->getNonconstBlock(i,j);
85 if(block!=Teuchos::null) {
86 RCP<Epetra_Operator> e_block = Thyra::get_Epetra_Operator(*block);
87 rcp_dynamic_cast<Epetra_CrsMatrix>(e_block,true)->PutScalar(0.0);
88 }
89 }
90 }
91 }
92}
93
95initializeMatrix(double value)
96{
98 using Thyra::PhysicallyBlockedLinearOpBase;
99 using Thyra::ProductVectorSpaceBase;
100 using Teuchos::RCP;
101 using Teuchos::rcp_dynamic_cast;
102
103 if(get_A()!=Teuchos::null) {
104 RCP<PhysicallyBlockedLinearOpBase<double> > Amat
105 = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(get_A(),true);
106 RCP<const ProductVectorSpaceBase<double> > range = Amat->productRange();
107 RCP<const ProductVectorSpaceBase<double> > domain = Amat->productDomain();
108
109 // loop over block entries
110 for(int i=0;i<range->numBlocks();i++) {
111 for(int j=0;j<domain->numBlocks();j++) {
112 RCP<LinearOpBase<double> > block = Amat->getNonconstBlock(i,j);
113 if(block!=Teuchos::null) {
114 RCP<Epetra_Operator> e_block = Thyra::get_Epetra_Operator(*block);
115 rcp_dynamic_cast<Epetra_CrsMatrix>(e_block,true)->PutScalar(value);
116 }
117 }
118 }
119 }
120}
121
123clear()
124{
125 set_x(Teuchos::null);
126 set_dxdt(Teuchos::null);
127 set_f(Teuchos::null);
128 set_A(Teuchos::null);
129}
130
131}
void set_A(const Teuchos::RCP< CrsMatrixType > &in)
bool checkCompatibility() const
Make sure row and column spaces match up.
void initializeMatrix(double value)
Put a particular scalar in the matrix.