11#ifndef PANZER_SCATTER_DIRICHLET_RESIDUAL_TPETRA_IMPL_HPP
12#define PANZER_SCATTER_DIRICHLET_RESIDUAL_TPETRA_IMPL_HPP
14#include "Teuchos_RCP.hpp"
15#include "Teuchos_Assert.hpp"
17#include "Phalanx_DataLayout.hpp"
26#include "Phalanx_DataLayout_MDALayout.hpp"
28#include "Teuchos_FancyOStream.hpp"
35template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
38 const Teuchos::ParameterList& p)
42 std::string scatterName = p.get<std::string>(
"Scatter Name");
44 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
47 const std::vector<std::string>& names =
48 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
51 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
54 scatterIC_ = p.isParameter(
"Scatter Initial Condition") ? p.get<
bool>(
"Scatter Initial Condition") :
false;
56 Teuchos::RCP<PHX::DataLayout> dl = (!
scatterIC_) ?
57 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional :
58 p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis")->functional ;
68 for (std::size_t eq = 0; eq < names.size(); ++eq) {
69 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
75 checkApplyBC_ = p.isParameter(
"Check Apply BC") ? p.get<
bool>(
"Check Apply BC") :
false;
78 for (std::size_t eq = 0; eq < names.size(); ++eq) {
79 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
80 this->addDependentField(
applyBC_[eq]);
87 if (p.isType<std::string>(
"Global Data Key"))
90 this->setName(scatterName+
" Scatter Residual");
94template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
100 const Workset & workset_0 = (*d.worksets_)[0];
101 std::string blockId = this->
wda(workset_0).block_id;
110 const std::pair<std::vector<int>,std::vector<int> > & indicePair
112 const std::vector<int> & offsets = indicePair.first;
113 const std::vector<int> & basisIdMap = indicePair.second;
116 Kokkos::deep_copy(
scratch_offsets_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(offsets.data(), offsets.size()));
119 Kokkos::deep_copy(
scratch_basisIds_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(basisIdMap.data(), basisIdMap.size()));
124 Kokkos::deep_copy(
scratch_offsets_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(offsets.data(), offsets.size()));
133template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
142 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(
globalDataKey_),
true)->getGhostedLOC();
149 Teuchos::RCP<LOC> tpetraContainer
150 = Teuchos::rcp_dynamic_cast<LOC>(d.gedc->getDataObject(
"Dirichlet Counter"),
true);
161template <
typename ScalarT,
typename LO,
typename GO,
typename NodeT>
162class ScatterDirichletResidual_Residual_Functor {
164 typedef typename PHX::ExecutionSpace execution_space;
165 typedef PHX::MDField<const ScalarT,Cell,NODE> ScalarFieldType;
166 typedef PHX::MDField<const bool,Cell,NODE> BoolFieldType;
168 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> r_data;
169 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> dirichlet_counter;
171 PHX::View<const LO**> lids;
172 PHX::View<const int*> offsets;
173 PHX::View<const int*> basisIds;
174 ScalarFieldType field;
175 BoolFieldType applyBC;
179 KOKKOS_INLINE_FUNCTION
180 void operator()(
const unsigned int cell)
const
184 for(std::size_t basis=0; basis < offsets.extent(0); basis++) {
185 int offset = offsets(basis);
186 LO lid = lids(cell,offset);
189 int basisId = basisIds(basis);
191 if(!applyBC(cell,basisId))
continue;
193 r_data(lid,0) = field(cell,basisId);
196 if (dirichlet_counter.extent(0) > 0)
197 dirichlet_counter(lid,0) = 1.0;
203template <
typename ScalarT,
typename LO,
typename GO,
typename NodeT>
204class ScatterDirichletResidualIC_Residual_Functor {
206 typedef typename PHX::ExecutionSpace execution_space;
207 typedef PHX::MDField<const ScalarT,Cell,NODE> FieldType;
209 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> r_data;
210 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> dirichlet_counter;
212 PHX::View<const LO**> lids;
213 PHX::View<const int*> offsets;
216 KOKKOS_INLINE_FUNCTION
217 void operator()(
const unsigned int cell)
const
221 for(std::size_t basis=0; basis < offsets.extent(0); basis++) {
222 int offset = offsets(basis);
223 LO lid = lids(cell,offset);
226 r_data(lid,0) = field(cell,basis);
229 if (dirichlet_counter.extent(0) > 0)
230 dirichlet_counter(lid,0) = 1.0;
239template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
243 std::vector<GO> GIDs;
244 std::vector<LO> LIDs;
247 std::string blockId = this->
wda(workset).block_id;
251 Teuchos::RCP<typename LOC::MultiVectorType> r = (!
scatterIC_) ?
256 ScatterDirichletResidualIC_Residual_Functor<ScalarT,LO,GO,NodeT> functor;
257 functor.r_data = r->getLocalViewDevice(Tpetra::Access::ReadWrite);
260 functor.dirichlet_counter =
dirichletCounter_->getLocalViewDevice(Tpetra::Access::ReadWrite);
263 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
267 Kokkos::parallel_for(workset.num_cells,functor);
270 ScatterDirichletResidual_Residual_Functor<ScalarT,LO,GO,NodeT> functor;
271 functor.r_data = r->getLocalViewDevice(Tpetra::Access::ReadWrite);
274 functor.dirichlet_counter =
dirichletCounter_->getLocalViewDevice(Tpetra::Access::ReadWrite);
277 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
284 Kokkos::parallel_for(workset.num_cells,functor);
295template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
298 const Teuchos::ParameterList& p)
302 std::string scatterName = p.get<std::string>(
"Scatter Name");
304 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
307 const std::vector<std::string>& names =
308 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
311 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
314 scatterIC_ = p.isParameter(
"Scatter Initial Condition") ? p.get<
bool>(
"Scatter Initial Condition") :
false;
316 Teuchos::RCP<PHX::DataLayout> dl = (!
scatterIC_) ?
317 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional :
318 p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis")->functional ;
328 for (std::size_t eq = 0; eq < names.size(); ++eq) {
329 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
335 checkApplyBC_ = p.isParameter(
"Check Apply BC") ? p.get<
bool>(
"Check Apply BC") :
false;
338 for (std::size_t eq = 0; eq < names.size(); ++eq) {
339 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
340 this->addDependentField(
applyBC_[eq]);
347 if (p.isType<std::string>(
"Global Data Key"))
350 this->setName(scatterName+
" Scatter Tangent");
354template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
360 const Workset & workset_0 = (*d.worksets_)[0];
361 std::string blockId = this->
wda(workset_0).block_id;
370 const std::pair<std::vector<int>,std::vector<int> > & indicePair
372 const std::vector<int> & offsets = indicePair.first;
373 const std::vector<int> & basisIdMap = indicePair.second;
376 Kokkos::deep_copy(
scratch_offsets_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(offsets.data(), offsets.size()));
379 Kokkos::deep_copy(
scratch_basisIds_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(basisIdMap.data(), basisIdMap.size()));
384 Kokkos::deep_copy(
scratch_offsets_[fd], Kokkos::View<const int*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(offsets.data(), offsets.size()));
394template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
403 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(
globalDataKey_),
true)->getGhostedLOC();
410 Teuchos::RCP<LOC> tpetraContainer
411 = Teuchos::rcp_dynamic_cast<LOC>(d.gedc->getDataObject(
"Dirichlet Counter"),
true);
418 using Teuchos::rcp_dynamic_cast;
421 std::vector<std::string> activeParameters =
422 rcp_dynamic_cast<ParameterList_GlobalEvaluationData>(d.gedc->getDataObject(
"PARAMETER_NAMES"))->getActiveParameters();
426 dfdpFieldsVoV_.initialize(
"ScatterResidual_Tpetra<Tangent>::dfdpFieldsVoV_",activeParameters.size());
429 for(std::size_t i=0;i<activeParameters.size();i++)
430 dfdpVectors_[i] = rcp_dynamic_cast<LOC>(d.gedc->getDataObject(activeParameters[i]),
true)->get_f_mv();
438template <
typename ScalarT,
typename LO,
typename GO,
typename NodeT>
439class ScatterDirichletResidual_Tangent_Functor {
441 typedef typename PHX::ExecutionSpace execution_space;
442 typedef PHX::MDField<const ScalarT,Cell,NODE> ScalarFieldType;
443 typedef PHX::MDField<const bool,Cell,NODE> BoolFieldType;
445 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> r_data;
446 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> dirichlet_counter;
448 Kokkos::View<Kokkos::View<double**,Kokkos::LayoutLeft,PHX::Device>*> dfdp_fields;
449 std::size_t num_params;
451 PHX::View<const LO**> lids;
452 PHX::View<const int*> offsets;
453 PHX::View<const int*> basisIds;
454 ScalarFieldType field;
455 BoolFieldType applyBC;
459 KOKKOS_INLINE_FUNCTION
460 void operator()(
const unsigned int cell)
const
464 for(std::size_t basis=0; basis < offsets.extent(0); basis++) {
465 int offset = offsets(basis);
466 LO lid = lids(cell,offset);
469 int basisId = basisIds(basis);
471 if(!applyBC(cell,basisId))
continue;
473 r_data(lid,0) = field(cell,basisId).val();
476 for(std::size_t i_param=0; i_param<num_params; i_param++)
477 dfdp_fields(i_param)(lid,0) = field(cell,basisId).fastAccessDx(i_param);
480 if (dirichlet_counter.extent(0) > 0)
481 dirichlet_counter(lid,0) = 1.0;
487template <
typename ScalarT,
typename LO,
typename GO,
typename NodeT>
488class ScatterDirichletResidualIC_Tangent_Functor {
490 typedef typename PHX::ExecutionSpace execution_space;
491 typedef PHX::MDField<const ScalarT,Cell,NODE> FieldType;
493 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> r_data;
494 Kokkos::View<double**, Kokkos::LayoutLeft,PHX::Device> dirichlet_counter;
496 Kokkos::View<Kokkos::View<double**,Kokkos::LayoutLeft,PHX::Device>*> dfdp_fields;
497 std::size_t num_params;
499 PHX::View<const LO**> lids;
500 PHX::View<const int*> offsets;
503 KOKKOS_INLINE_FUNCTION
504 void operator()(
const unsigned int cell)
const
508 for(std::size_t basis=0; basis < offsets.extent(0); basis++) {
509 int offset = offsets(basis);
510 LO lid = lids(cell,offset);
513 r_data(lid,0) = field(cell,basis).val();
516 for(std::size_t i_param=0; i_param<num_params; i_param++)
517 dfdp_fields(i_param)(lid,0) = field(cell,basis).fastAccessDx(i_param);
520 if (dirichlet_counter.extent(0) > 0)
521 dirichlet_counter(lid,0) = 1.0;
530template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
534 std::vector<GO> GIDs;
535 std::vector<LO> LIDs;
538 std::string blockId = this->
wda(workset).block_id;
542 Teuchos::RCP<typename LOC::MultiVectorType> r = (!
scatterIC_) ?
553 ScatterDirichletResidualIC_Tangent_Functor<ScalarT,LO,GO,NodeT> functor;
554 functor.r_data = r->getLocalViewDevice(Tpetra::Access::ReadWrite);
557 functor.dirichlet_counter =
dirichletCounter_->getLocalViewDevice(Tpetra::Access::ReadWrite);
561 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
564 functor.num_params = Sacado::dimension_scalar(
scatterFields_[fieldIndex].get_view())-1;
566 Kokkos::parallel_for(workset.num_cells,functor);
569 ScatterDirichletResidual_Tangent_Functor<ScalarT,LO,GO,NodeT> functor;
570 functor.r_data = r->getLocalViewDevice(Tpetra::Access::ReadWrite);
573 functor.dirichlet_counter =
dirichletCounter_->getLocalViewDevice(Tpetra::Access::ReadWrite);
577 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
583 functor.num_params = Sacado::dimension_scalar(
scatterFields_[fieldIndex].get_view())-1;
585 Kokkos::parallel_for(workset.num_cells,functor);
593 dfdpFieldsVoV_.addView(Kokkos::View<RealT**,Kokkos::LayoutLeft,PHX::Device>(),i);
600template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
603 const Teuchos::ParameterList& p)
607 std::string scatterName = p.get<std::string>(
"Scatter Name");
609 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
612 const std::vector<std::string>& names =
613 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
616 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
618 Teuchos::RCP<PHX::DataLayout> dl =
619 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional;
626 for (std::size_t eq = 0; eq < names.size(); ++eq) {
627 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
636 for (std::size_t eq = 0; eq < names.size(); ++eq) {
637 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
638 this->addDependentField(
applyBC_[eq]);
645 if (p.isType<std::string>(
"Global Data Key"))
648 this->setName(scatterName+
" Scatter Residual (Jacobian)");
652template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
671template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
680 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(
globalDataKey_),
true)->getGhostedLOC();
687 Teuchos::RCP<LOC> tpetraContainer
688 = Teuchos::rcp_dynamic_cast<LOC>(d.gedc->getDataObject(
"Dirichlet Counter"),
true);
696template<
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
700 std::vector<GO> GIDs;
703 std::string blockId = this->
wda(workset).block_id;
704 const std::vector<std::size_t> & localCellIds = this->
wda(workset).cell_local_ids;
706 Teuchos::RCP<typename LOC::MultiVectorType> r =
tpetraContainer_->get_f_mv();
709 using HostView =
typename LOC::MultiVectorType::host_view_type;
710 const bool haveResidual = Teuchos::nonnull(r);
715 r_view = r->getLocalViewHost(Tpetra::Access::ReadWrite);
717 if (haveDirichletCounter)
723 if (Jac != Teuchos::null) {
724 const std::size_t maxRowEntries = Jac->getLocalMaxNumRowEntries();
726 rowIndices_ =
typename LOC::CrsMatrixType::nonconst_local_inds_host_view_type(
"indices", maxRowEntries);
727 rowValues_ =
typename LOC::CrsMatrixType::nonconst_values_host_view_type(
"values", maxRowEntries);
742 lids_h_ = Kokkos::create_mirror_view(Kokkos::HostSpace(),LIDs);
745 if (
lids_h_.extent(0) != LIDs.extent(0) ||
lids_h_.extent(1) != LIDs.extent(1))
746 lids_h_ = Kokkos::create_mirror_view(Kokkos::HostSpace(),LIDs);
747 Kokkos::deep_copy(
lids_h_, LIDs);
754 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
756 const auto scatterFieldsDevice =
scatterFields_[fieldIndex].get_static_view();
757 if (
scatterFields_h_[fieldIndex].extent(0) != scatterFieldsDevice.extent(0) ||
759 scatterFields_h_[fieldIndex] = Kokkos::create_mirror_view(scatterFieldsDevice);
761 Kokkos::deep_copy(scatterFields_h, scatterFieldsDevice);
762 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
763 std::size_t cellLocalId = localCellIds[worksetCellIndex];
768 const std::pair<std::vector<int>,std::vector<int> > & indicePair
770 const std::vector<int> & elmtOffset = indicePair.first;
771 const std::vector<int> & basisIdMap = indicePair.second;
774 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
775 int offset = elmtOffset[basis];
776 int lid = LIDs_h(cellLocalId, offset);
780 int basisId = basisIdMap[basis];
783 if (!
applyBC_[fieldIndex](worksetCellIndex,basisId))
788 std::size_t numEntries = 0;
792 for(std::size_t i=0;i<numEntries;i++)
796 const auto rowRange = std::make_pair(std::size_t(0),numEntries);
797 Jac->replaceLocalValues(lid,
802 GO gid = GIDs[offset];
803 const ScalarT scatterField = scatterFields_h(worksetCellIndex,basisId);
806 r_view(lid,0) = scatterField.val();
807 if (haveDirichletCounter)
808 dc_view(lid,0) = 1.0;
811 jacRow_.resize(scatterField.size());
813 for(
int sensIndex=0;sensIndex<scatterField.size();++sensIndex)
814 jacRow_[sensIndex] = scatterField.fastAccessDx(sensIndex);
815 TEUCHOS_ASSERT(
jacRow_.size()==GIDs.size());
817 Jac->replaceGlobalValues(gid, GIDs,
jacRow_);
WorksetDetailsAccessor wda
Teuchos::RCP< const panzer::GlobalIndexer > globalIndexer_
Teuchos::RCP< PHX::FieldTag > scatterHolder_
std::string globalDataKey_
Teuchos::RCP< typename LOC::MultiVectorType > dirichletCounter_
std::vector< double > jacRow_
std::size_t side_subcell_dim_
LOC::CrsMatrixType::nonconst_local_inds_host_view_type rowIndices_
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
std::vector< int > fieldIds_
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
std::vector< PHX::MDField< const bool, Cell, NODE > > applyBC_
Teuchos::RCP< const std::map< std::string, std::string > > fieldMap_
static constexpr bool lidsAreHostResident_
panzer::Traits::Jacobian::ScalarT ScalarT
std::size_t local_side_id_
LOC::CrsMatrixType::nonconst_values_host_view_type rowValues_
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
std::vector< decltype(Kokkos::create_mirror_view(std::declval< ScatterFieldDeviceView >()))> scatterFields_h_
decltype(Kokkos::create_mirror_view(Kokkos::HostSpace(), std::declval< LIDsDeviceView >())) lids_h_
std::vector< PHX::MDField< const bool, Cell, NODE > > applyBC_
std::vector< PHX::View< int * > > scratch_basisIds_
std::size_t side_subcell_dim_
std::size_t local_side_id_
Teuchos::RCP< const panzer::GlobalIndexer > globalIndexer_
std::vector< int > fieldIds_
Teuchos::RCP< const std::map< std::string, std::string > > fieldMap_
Teuchos::RCP< typename LOC::MultiVectorType > dirichletCounter_
Teuchos::RCP< PHX::FieldTag > scatterHolder_
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Teuchos::RCP< const LOC > tpetraContainer_
std::string globalDataKey_
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
std::vector< PHX::View< int * > > scratch_offsets_
PHX::View< int ** > scratch_lids_
std::vector< PHX::View< int * > > scratch_offsets_
std::vector< Teuchos::RCP< typename LOC::MultiVectorType > > dfdpVectors_
Teuchos::RCP< const panzer::GlobalIndexer > globalIndexer_
Teuchos::RCP< const LOC > tpetraContainer_
std::size_t side_subcell_dim_
PHX::View< int ** > scratch_lids_
Teuchos::RCP< PHX::FieldTag > scatterHolder_
std::vector< int > fieldIds_
std::vector< PHX::View< int * > > scratch_basisIds_
std::size_t local_side_id_
PHX::ViewOfViews< 1, Kokkos::View< RealT **, Kokkos::LayoutLeft, PHX::Device > > dfdpFieldsVoV_
Storage for the tangent data.
Teuchos::RCP< const std::map< std::string, std::string > > fieldMap_
std::string globalDataKey_
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Teuchos::RCP< typename LOC::MultiVectorType > dirichletCounter_
std::vector< PHX::MDField< const bool, Cell, NODE > > applyBC_
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
Pushes residual values into the residual vector for a Newton-based solve.