tmp < GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh > > leastSquaresSolidInterfaceGrad<Type>::calcGrad ( const GeometricField<Type, fvPatchField, volMesh>& vsf, const word& name ) const { typedef typename outerProduct<vector, Type>::type GradType; const fvMesh& mesh = vsf.mesh(); tmp<GeometricField<GradType, fvPatchField, volMesh> > tlsGrad ( new GeometricField<GradType, fvPatchField, volMesh> ( IOobject ( name, vsf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<GradType> ( "zero", vsf.dimensions()/dimLength, pTraits<GradType>::zero ), zeroGradientFvPatchField<GradType>::typeName ) ); GeometricField<GradType, fvPatchField, volMesh>& lsGrad = tlsGrad(); // Get reference to least square vectors const leastSquaresSolidInterfaceVectors& lsv = leastSquaresSolidInterfaceVectors::New(mesh); const surfaceVectorField& ownLs = lsv.pVectors(); const surfaceVectorField& neiLs = lsv.nVectors(); const unallocLabelList& own = mesh.owner(); const unallocLabelList& nei = mesh.neighbour(); // interface fields const solidInterface& solInt = mesh.objectRegistry::lookupObject<IOReferencer<solidInterface> > ("solidInterface")(); const labelList& interfaceFacesMap = solInt.indicatorFieldMap(); const labelList& interfaceProcPatchMap = solInt.processorPatchMap(); const labelListList& interfaceProcPatchFacesMap = solInt.processorPatchFacesMap(); const vectorField& interfaceDispVec = solInt.interfaceDisplacement(); const List<vectorField>& procInterDispVec = solInt.processorInterfaceDisplacement(); // interface disp must be vector so // this is a quick hack Field<Type> interfaceDisp(interfaceDispVec.size(), pTraits<Type>::zero); if (pTraits<Type>::typeName != vector::typeName) { FatalError << "leastSquaresSolidInterface::grad() may only be used " "with a volVectorField" << exit(FatalError); } for (direction cmpt = 0; cmpt < pTraits<vector>::nComponents; cmpt++) { interfaceDisp.replace ( cmpt, interfaceDispVec.component(cmpt) ); } List<Field<Type> > procInterDisp (procInterDispVec.size(), Field<Type>(0, pTraits<Type>::zero)); forAll(procInterDisp, patchi) { procInterDisp[patchi].setSize (procInterDispVec[patchi].size(), pTraits<Type>::zero); for (direction cmpt = 0; cmpt < pTraits<vector>::nComponents; cmpt++) { procInterDisp[patchi].replace ( cmpt, procInterDispVec[patchi].component(cmpt) ); } }
tmp < GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh > > extendedLeastSquaresGrad<Type>::grad ( const GeometricField<Type, fvPatchField, volMesh>& vsf ) const { typedef typename outerProduct<vector, Type>::type GradType; const fvMesh& mesh = vsf.mesh(); tmp<GeometricField<GradType, fvPatchField, volMesh> > tlsGrad ( new GeometricField<GradType, fvPatchField, volMesh> ( IOobject ( "grad("+vsf.name()+')', vsf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<GradType> ( "zero", vsf.dimensions()/dimLength, pTraits<GradType>::zero ), zeroGradientFvPatchField<GradType>::typeName ) ); GeometricField<GradType, fvPatchField, volMesh>& lsGrad = tlsGrad(); // Get reference to least square vectors const extendedLeastSquaresVectors& lsv = extendedLeastSquaresVectors::New ( mesh, minDet_ ); const surfaceVectorField& ownLs = lsv.pVectors(); const surfaceVectorField& neiLs = lsv.nVectors(); const unallocLabelList& owner = mesh.owner(); const unallocLabelList& neighbour = mesh.neighbour(); forAll(owner, facei) { label own = owner[facei]; label nei = neighbour[facei]; Type deltaVsf = vsf[nei] - vsf[own]; lsGrad[own] += ownLs[facei]*deltaVsf; lsGrad[nei] -= neiLs[facei]*deltaVsf; }