00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "SimpleNonlinearEllipticAssembler.hpp"
00031
00032
00033 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00034 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::SimpleNonlinearEllipticAssembler(
00035 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>* pMesh,
00036 AbstractNonlinearEllipticPde<SPACE_DIM>* pPde,
00037 BoundaryConditionsContainer<ELEMENT_DIM, SPACE_DIM, 1>* pBoundaryConditions,
00038 unsigned numQuadPoints)
00039 : AbstractAssembler<ELEMENT_DIM,SPACE_DIM,1>(),
00040 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::BaseClassType(numQuadPoints)
00041 {
00042
00043
00044 assert(SPACE_DIM==ELEMENT_DIM);
00045
00046 assert(pMesh!=NULL);
00047 assert(pPde!=NULL);
00048 assert(pBoundaryConditions!=NULL);
00049
00050
00051 this->SetMesh(pMesh);
00052 mpNonlinearEllipticPde = pPde;
00053 this->SetBoundaryConditionsContainer(pBoundaryConditions);
00054 }
00055
00056 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00057 c_matrix<double,1*(ELEMENT_DIM+1),1*(ELEMENT_DIM+1)>
00058 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeMatrixTerm(
00059 c_vector<double, ELEMENT_DIM+1>& rPhi,
00060 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00061 ChastePoint<SPACE_DIM>& rX,
00062 c_vector<double,1>& rU,
00063 c_matrix<double,1,SPACE_DIM>& rGradU,
00064 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00065 {
00066 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> ret;
00067
00069 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> f_of_u = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX, rU(0));
00070 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> f_of_u_prime = mpNonlinearEllipticPde->ComputeDiffusionTermPrime(rX, rU(0));
00071
00072
00073 double forcing_term_prime = mpNonlinearEllipticPde->ComputeNonlinearSourceTermPrime(rX, rU(0));
00074
00075
00076
00077 matrix_row< c_matrix<double, 1, SPACE_DIM> > rGradU0(rGradU, 0);
00078 c_vector<double, SPACE_DIM> temp1 = prod(f_of_u_prime, rGradU0);
00079 c_vector<double, ELEMENT_DIM+1> temp1a = prod(temp1, rGradPhi);
00080
00081 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values1 = outer_prod(temp1a, rPhi);
00082 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1> temp2 = prod(f_of_u, rGradPhi);
00083 c_matrix<double, ELEMENT_DIM+1, ELEMENT_DIM+1> integrand_values2 = prod(trans(rGradPhi), temp2);
00084 c_vector<double, ELEMENT_DIM+1> integrand_values3 = forcing_term_prime * rPhi;
00085
00086 ret = integrand_values1 + integrand_values2 - outer_prod( scalar_vector<double>(ELEMENT_DIM+1), integrand_values3);
00087
00088 return ret;
00089 }
00090
00091 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00092 c_vector<double,1*(ELEMENT_DIM+1)>
00093 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeVectorTerm(
00094 c_vector<double, ELEMENT_DIM+1>& rPhi,
00095 c_matrix<double, SPACE_DIM, ELEMENT_DIM+1>& rGradPhi,
00096 ChastePoint<SPACE_DIM>& rX,
00097 c_vector<double,1>& rU,
00098 c_matrix<double,1,SPACE_DIM>& rGradU,
00099 Element<ELEMENT_DIM,SPACE_DIM>* pElement)
00100 {
00101 c_vector<double, 1*(ELEMENT_DIM+1)> ret;
00102
00103
00104
00105
00106
00107
00108
00109 double ForcingTerm = mpNonlinearEllipticPde->ComputeLinearSourceTerm(rX);
00110 ForcingTerm += mpNonlinearEllipticPde->ComputeNonlinearSourceTerm(rX, rU(0));
00111
00112
00113 c_matrix<double, ELEMENT_DIM, ELEMENT_DIM> FOfU = mpNonlinearEllipticPde->ComputeDiffusionTerm(rX, rU(0));
00114
00115
00116
00117 matrix_row< c_matrix<double, 1, SPACE_DIM> > rGradU0(rGradU, 0);
00118 c_vector<double, ELEMENT_DIM+1> integrand_values1 =
00119 prod(c_vector<double, ELEMENT_DIM>(prod(rGradU0, FOfU)), rGradPhi);
00120
00121 ret = integrand_values1 - (ForcingTerm * rPhi);
00122 return ret;
00123 }
00124
00125 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00126 c_vector<double, 1*ELEMENT_DIM>
00127 SimpleNonlinearEllipticAssembler<ELEMENT_DIM, SPACE_DIM>::ComputeVectorSurfaceTerm(
00128 const BoundaryElement<ELEMENT_DIM-1,SPACE_DIM>& rSurfaceElement,
00129 c_vector<double, ELEMENT_DIM>& rPhi,
00130 ChastePoint<SPACE_DIM>& rX)
00131 {
00132 double Dgradu_dot_n = this->mpBoundaryConditions->GetNeumannBCValue(&rSurfaceElement, rX);
00133
00134
00135 return (-Dgradu_dot_n)* rPhi;
00136 }
00137
00138
00139
00141
00143
00144 template class SimpleNonlinearEllipticAssembler<1,1>;
00145 template class SimpleNonlinearEllipticAssembler<2,2>;
00146 template class SimpleNonlinearEllipticAssembler<3,3>;